@layer views {
  /* ── the tutor: a side panel over the page, full screen on phones ── */
  .tutor-fab {
    position: fixed; z-index: 40; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    display: inline-flex; align-items: center; gap: 9px; padding: 11px 18px; border-radius: var(--r-pill);
    border: 1px solid var(--line-2); background: var(--surface); color: var(--fg); font-weight: 700; font-size: 14px;
    box-shadow: var(--shadow-float); transition: transform var(--t-fast) var(--ease-spring);
    & .dot { background: var(--grad-b); }
    &:hover { transform: translateY(-1px); }
  }
  .tutor {
    position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
    display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
    background: var(--bg-raise); border-left: 1px solid var(--line); box-shadow: var(--shadow-float);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: tutor-in var(--t) var(--ease-liquid);
  }
  .tutor[hidden] { display: none; }
  @keyframes tutor-in { from { translate: 24px 0; opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .tutor { animation: none; } }
  .tutor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px; border-bottom: 1px solid var(--line); }
  .tutor-title { font-weight: 800; font-size: 17px; letter-spacing: -0.03em; color: var(--fg); }
  .tutor-about { font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
  .tutor-actions { display: flex; align-items: center; gap: 6px; }
  .tutor-log { overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; overscroll-behavior: contain; }
  .tutor-intro { display: grid; gap: 12px; font-size: 14px; color: var(--fg-2); }
  .tutor-msg { display: grid; gap: 6px; max-width: 92%; font-size: 14.5px; line-height: 1.55; }
  .tutor-msg.user { justify-self: end; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--surface-2); color: var(--fg); }
  .tutor-msg.assistant { justify-self: start; color: var(--fg-2); }
  .tutor-text { white-space: pre-wrap; overflow-wrap: anywhere; }
  .tutor-save { justify-self: start; font-size: 12.5px; color: var(--muted); font-weight: 500; }
  .tutor-note { padding: 0 16px 8px; font-size: 12.5px; color: var(--due); }
  .tutor-msg .tutor-note { padding: 0; color: var(--muted); }
  .tutor-compose { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
  .tutor-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 8px; }
  .tutor-input {
    min-height: 40px; max-height: 180px; resize: none; padding: 9px 12px; border-radius: var(--r-input);
    border: 1px solid var(--line-2); background: var(--surface); color: var(--fg); font: inherit; font-size: 14.5px; line-height: 1.45;
    &:focus-visible { outline: none; border-color: color-mix(in oklch, var(--fg) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in oklch, var(--grad-b) 20%, transparent); }
  }
  .tutor-attach .chip { gap: 4px; padding-right: 4px; }
  .tutor-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
  .tutor-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
  .tutor-typing i:nth-child(2) { animation-delay: .15s; }
  .tutor-typing i:nth-child(3) { animation-delay: .3s; }
  @keyframes typing { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
  @media (max-width: 560px) {
    .tutor { width: 100vw; border-left: 0; }
    .tutor-fab { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  }
}
