/* Cryptic Hub — surfaces and motion. Loaded after every screen's stylesheet,
   so it has the last word on how panels look and move.

   Surfaces are solid and a step apart: the page (--bg), panels and cards
   (--surface), and things inside them (--surface-2). One hairline border
   separates them; shadows are for things that float (menus, dialogs, toasts).

   Motion stays crisp. Things you do all day (switching views, opening a menu)
   finish within 200ms and barely move; nothing overshoots; entrances ease out
   and start from 97% scale, never from nothing. Hover effects only happen
   with a real pointer, and presses shrink to 97% at once. Less motion and
   more contrast are honoured at the bottom. */

/* ---- The page ------------------------------------------------------------------- */
.app { background: var(--bg); }
.app > .rail, .app > .tabbar, .app > .main { z-index: 1; }
.mesh { display: none; }

/* ---- Chrome ----------------------------------------------------------------------- */
.rail, .tabbar, .pane-side, .sheet-head {
  background: var(--surface); box-shadow: none;
}
.rail { background: var(--rail-bg); border-right: 1px solid var(--rail-brd); }
.tabbar { border-top: 1px solid var(--border); }
.pane-side { border-right: 1px solid var(--border); }
.pane-main > .pane-head, .pane-main > .thread > .pane-head, .view > .pane-head {
  background: var(--surface);
}
.pane-head { border-bottom: 1px solid var(--border); }
.pane-title { font-family: var(--font); font-size: 18px; font-weight: 650; letter-spacing: -.02em; }

/* The rail: navigation is used constantly, so it only changes colour; the
   press is the motion. The active item gets an accent bar, like a real app. */
.rail-item { transition: background-color .15s ease, color .15s ease, transform .16s var(--ease-out); border-radius: 10px; color: var(--rail-fg); }
.rail-item:hover { background: var(--rail-hover); color: var(--rail-fg-on); }
.rail-item:active { transform: scale(.97); }
.rail-item.active { background: var(--rail-on); color: var(--rail-fg-on); box-shadow: none; }
.rail-item.active svg { color: var(--rail-icon-on); filter: none; }
.rail-me:hover { box-shadow: 0 0 0 2px var(--rail-hover); }
@media (min-width: 761px) {
  .rail-item.active::after { content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--rail-bar); }
}
/* On phones the tab bar stays light and plain; the accent marks where you are. */
@media (max-width: 760px) {
  .tabbar .rail-item { color: var(--text-3); }
  .tabbar .rail-item:hover { background: none; color: var(--text); }
  .tabbar .rail-item.active { background: none; color: var(--accent); }
  .tabbar .rail-item.active svg { color: var(--accent); }
}
.rail-logo .brand-mark { box-shadow: var(--shadow-sm); }
.rail-logo:hover { transform: none; }

/* ---- Cards and panels -------------------------------------------------------------- */
.card, .artifact, .event-card, .sources, .tour-card, .steps {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.card { border-radius: var(--r-xl); }
.card-head { border-bottom: 1px solid var(--border); }
.dialog {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.popover, .toast:not(.simple) {
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
}
.scrim { }
.list-item.active { background: var(--accent-soft); box-shadow: none; }
.segmented { background: var(--surface-2); border: 1px solid var(--border); box-shadow: none; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
[data-tone="dark"] .segmented button.on { background: var(--surface-3); }

/* Notes, the calendar and tables share the same material as cards. */
.nb-card, .nb-folder:not(.add), .table-wrap, .theme-card .tc-name, .nb-doc-sec, .nb-mode, .att-row, .nb-upload, .fc-row, .flash-face, .nb-text {
  background: var(--surface); border-color: var(--border); box-shadow: none;
}
.nb-thumb { background: color-mix(in srgb, var(--cls) 12%, var(--surface-2)); border-bottom-color: var(--border); }
.nb-paper, .nb-stack i, .nb-stack div, .nb-slide { background: var(--surface); border-color: var(--border); }
.month-grid { background: var(--surface); }
.month-cell { border-color: var(--border); transition: background-color .15s ease; }
.month-cell.out { background: var(--bg); }
.month-cell.out .ev-pill { opacity: .7; }
.month-dows, .week-head, .week-allday { background: var(--surface); }
.agenda-item, .task-row { border-radius: 10px; }
.study { background: var(--bg); }

/* ---- Tiles you can press ------------------------------------------------------------ */
.site, .suggest button, .quick button {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, background-color .15s ease, box-shadow .2s ease, transform .16s var(--ease-out);
}
.artifact, .event-card, .nb-card { transition: border-color .15s ease, box-shadow .2s ease, transform .16s var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .site:hover, .suggest button:hover, .quick button:hover, .nb-card:hover, .artifact:hover, .event-card:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow);
  }
}
.site:active, .suggest button:active, .quick button:active, .nb-card:active { transform: scale(.98); transition-duration: .1s; }
.site .s-icon { background: var(--surface-2); border-color: var(--border); box-shadow: none; }
.site .s-tools { background: var(--surface); border: 1px solid var(--border); }

/* ---- Buttons and controls -------------------------------------------------------- */
.btn, .icon-btn, .chip { transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .16s var(--ease-out); }
.btn:active:not(:disabled), .icon-btn:active, .chip:active { transform: scale(.97); transition-duration: .1s; }
.btn { font-weight: 550; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-text); }
  [data-tone="dark"] .btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); border-color: color-mix(in srgb, var(--accent) 86%, #fff); }
}
.chip { }
.chip.on { box-shadow: none; }
.segmented button { transition: background-color .15s ease, color .15s ease, box-shadow .15s ease; }
.input, .select, textarea.input { transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--focus); }

/* ---- The composer ----------------------------------------------------------------- */
.composer-box { background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, border-color .15s ease; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.send { transition: transform .16s var(--ease-out), background-color .15s ease, opacity .15s ease; }
.send:not(:disabled):active { transform: scale(.94); }

/* ---- ARIA ------------------------------------------------------------------------ */
.aria-turn { animation: turnIn .22s var(--ease-out) both; }
.aria-user .bubble { background: var(--accent); color: var(--accent-text); box-shadow: none; animation: bubbleIn .2s var(--ease-out) both; transform-origin: bottom right; }
@keyframes turnIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }
.aria-avatar { position: relative; background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.aria-status { color: var(--text-2); }
/* A caret at the end of an answer that is still being written. */
.aria-turn.live .md:last-of-type > :last-child::after {
  content: ""; display: inline-block; width: .5em; height: 1.05em; margin-left: 2px; vertical-align: -.15em;
  border-radius: 2px; background: var(--accent); animation: caret 1s steps(2, jump-none) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.aria-empty h1 { animation: turnIn .24s var(--ease-out) both; }
.suggest button { animation: cardIn .24s var(--ease-out) both; }
.suggest button:nth-child(2) { animation-delay: 30ms; } .suggest button:nth-child(3) { animation-delay: 60ms; }
.suggest button:nth-child(4) { animation-delay: 90ms; } .suggest button:nth-child(5) { animation-delay: 120ms; }
.suggest button:nth-child(n+6) { animation-delay: 150ms; }
.codeblock { box-shadow: none; border: 1px solid var(--border); }

/* What ARIA did before answering */
.steps { margin: 0 0 12px; border-radius: 12px; overflow: hidden; position: relative; box-shadow: none; animation: turnIn .2s var(--ease-out) both; }
.steps-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: none; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 500; text-align: left; }
.steps-head:hover { color: var(--text); }
.steps-chev { transition: transform .2s var(--ease-out); color: var(--text-3); }
.steps.open .steps-chev { transform: rotate(180deg); }
.steps-icons { display: inline-flex; }
.steps-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.steps-dot + .steps-dot { margin-left: -6px; }
.steps-dot.fail { background: var(--danger-soft); color: var(--danger); }
.steps-dot.run { animation: dotPulse 1.2s var(--ease) infinite; }
@keyframes dotPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.steps-list { list-style: none; margin: 0; padding: 2px 12px 10px; display: grid; gap: 6px; font-size: 12.5px; }
.steps-list li { display: flex; gap: 9px; align-items: flex-start; animation: stepIn .2s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); line-height: 1.45; }
.steps-list li b { font-weight: 600; color: var(--text); }
.steps-list .step-ic { width: 22px; height: 22px; flex-shrink: 0; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.steps-list .step-ic .spinner { width: 12px; height: 12px; }
.steps-list li.fail .step-ic { color: var(--danger); }
@keyframes stepIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.saved-card .saved-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.saved-card { animation: cardIn .24s var(--ease-out) both; }

/* ---- Views and lists ---------------------------------------------------------------- */
/* Switching views happens all day: a quick fade, no movement worth noticing. */
.main > * { animation: viewIn .16s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.dir-grid > .site { animation: cardIn .24s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 8) * 25ms); }
.dir-section-head h2 { font-family: var(--font); font-weight: 650; font-size: 18px; letter-spacing: -.02em; }
.dir-section { animation: cardIn .24s var(--ease-out) both; }
.dir-cats { scrollbar-width: none; }
.dir-cats::-webkit-scrollbar { display: none; }
.dir-bar .input-icon { position: relative; }
.dir-clear, .dir-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.dir-kbd { pointer-events: none; opacity: .7; }
.quick button { animation: cardIn .24s var(--ease-out) both; }
.quick button:nth-child(2) { animation-delay: 30ms; } .quick button:nth-child(3) { animation-delay: 60ms; } .quick button:nth-child(4) { animation-delay: 90ms; }

/* Menus grow out of what opened them (data-place from the Popover component);
   dialogs aren't anchored, so they stay centred. Nothing overshoots. */
.popover { animation: menuIn .15s var(--ease-out); transform-origin: top left; }
.popover[data-place^="bottom"][data-place$="end"] { transform-origin: top right; }
.popover[data-place^="top"] { transform-origin: bottom left; }
.popover[data-place^="top"][data-place$="end"] { transform-origin: bottom right; }
.popover[data-place="right-end"] { transform-origin: bottom left; }
@keyframes menuIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.dialog { animation: dialogIn .2s var(--ease-out); }
@keyframes dialogIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.toast { animation: toastIn .22s var(--ease-out) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.badge { animation: badgePop .2s var(--ease-out); }
@keyframes badgePop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.spinner { border-top-color: var(--accent) !important; }

/* Less motion, when asked: no movement, no cascade. */
@media (prefers-reduced-motion: reduce) {
  .main > *, .aria-turn, .aria-user .bubble, .dir-grid > .site, .dir-section, .suggest button, .quick button, .steps, .steps-list li, .saved-card { animation: none !important; }
  .site:active, .suggest button:active, .quick button:active, .nb-card:active { transform: none !important; }
}
/* More contrast: firmer borders. */
@media (prefers-contrast: more) {
  :root, [data-theme] { --border: var(--border-strong); }
}

/* ---- Colour beyond the accent ----------------------------------------------------------
   Each kind of thing has its own hue (tokens in base.css, tuned per tone):
   quick actions, card headings on Home, ARIA's starting points. */
.quick button:nth-child(1) .q-icon { background: var(--hue-blue-bg); color: var(--hue-blue); }
.quick button:nth-child(2) .q-icon { background: var(--hue-purple-bg); color: var(--hue-purple); }
.quick button:nth-child(3) .q-icon { background: var(--hue-orange-bg); color: var(--hue-orange); }
.quick button:nth-child(4) .q-icon { background: var(--hue-green-bg); color: var(--hue-green); }
.card-head > svg:first-child { color: var(--text-2); }
.weather-card .card-head > svg:first-child, .winter-card .hc-count b { color: var(--hue-sky); }
.week-card .card-head > svg:first-child { color: var(--hue-purple); }
.msgs-card .card-head > svg:first-child { color: var(--hue-green); }
.news-card .card-head > svg:first-child { color: var(--hue-orange); }
.study-card .card-head > svg:first-child { color: var(--hue-orange); }
.quote-card .card-head > svg:first-child { color: var(--hue-pink); }
.aria-card .card-head > svg:first-child { color: var(--accent); }
.notes-card .card-head > svg:first-child { color: var(--hue-teal); }
.weather-ic { background: var(--hue-sky-bg); color: var(--hue-sky); }
.suggest button:nth-child(6n+1) svg:first-child { color: var(--hue-blue); }
.suggest button:nth-child(6n+2) svg:first-child { color: var(--hue-purple); }
.suggest button:nth-child(6n+3) svg:first-child { color: var(--hue-teal); }
.suggest button:nth-child(6n+4) svg:first-child { color: var(--hue-orange); }
.suggest button:nth-child(6n+5) svg:first-child { color: var(--hue-green); }
.suggest button:nth-child(6n+6) svg:first-child { color: var(--hue-pink); }

/* The account menu's theme picker: every theme visible at once, two rows of three. */
.menu-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.menu-themes button { display: flex; align-items: center; gap: 7px; min-width: 0; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 550; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: border-color .15s ease, background-color .15s ease, transform .16s var(--ease-out); }
.menu-themes button:hover { background: var(--hover); color: var(--text); }
.menu-themes button:active { transform: scale(.97); }
.menu-themes button.on { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.mt-swatch { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--border-strong); }

/* ---- Putting the side bar away ----------------------------------------------------------
   The ≡ at the top of the rail slides it out to the left; a ≡ in the top-left
   corner brings it back. On a phone the tab bar folds down to a thin strip
   with the ≡ in the middle. Used now and then, so a short drawer ease. */
.rail-hide { width: 38px; height: 30px; margin: -6px 0 8px; border: none; background: none; border-radius: 8px; color: var(--rail-fg); display: grid; place-items: center; flex-shrink: 0; transition: background-color .15s ease, color .15s ease; }
.rail-hide:hover { background: var(--rail-hover); color: var(--rail-fg-on); }
.rail { transition: margin-left .26s var(--ease-drawer), opacity .2s ease; }
.app.rail-hidden .rail { margin-left: calc(-1 * var(--rail) - 1px); opacity: 0; visibility: hidden; pointer-events: none; transition: margin-left .26s var(--ease-drawer), opacity .18s ease, visibility 0s linear .26s; }
.rail-handle { position: fixed; top: 11px; left: 11px; z-index: 25; }
.rail-open { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); color: var(--text-2); display: grid; place-items: center; animation: handleIn .22s var(--ease-out) .12s both; transition: color .15s ease, border-color .15s ease, transform .16s var(--ease-out); }
.rail-open:hover { color: var(--text); border-color: var(--border-strong); }
.rail-open:active { transform: scale(.94); }
@keyframes handleIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
html[data-bg] .rail-open { backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); }
@media (max-width: 760px) {
  .app.rail-hidden .tabbar { display: none; }
  .rail-handle { position: static; order: -1; flex-shrink: 0; display: flex; justify-content: center; align-items: center; height: calc(30px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
  .rail-open { width: 64px; height: 24px; border-radius: 999px; box-shadow: var(--shadow-sm); }
  .rail-open svg { width: 17px; height: 17px; }
}
@media (prefers-reduced-motion: reduce) { .rail, .app.rail-hidden .rail { transition: none; } .rail-open { animation: none; } }
/* Room for the ≡ wherever a page's first column starts in the top-left corner. */
@media (min-width: 761px) {
  .app.rail-hidden .view > .pane:first-child > .pane-head:first-child,
  .app.rail-hidden .view > .pane-head:first-child { padding-left: 62px; }
  .app.rail-hidden :is(.cal-side, .notes-side, .settings-nav) { padding-top: 60px; }
}
@media (min-width: 761px) and (max-width: 1260px) {
  .app.rail-hidden :is(.dash-inner, .dir-inner) { padding-left: 68px; }
}

/* The account menu's backgrounds: Plain, a thumbnail per picture, Slideshow */
.menu-bgs { display: flex; flex-wrap: wrap; gap: 6px; }
.menu-bgs button { height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: border-color .15s ease, background-color .15s ease, transform .16s var(--ease-out); }
.menu-bgs button:hover { background: var(--hover); color: var(--text); }
.menu-bgs button:active { transform: scale(.97); }
.menu-bgs .mb-chip { display: inline-flex; align-items: center; gap: 5px; padding: 0 9px; font-size: 12.5px; font-weight: 550; }
.menu-bgs .mb-thumb { width: 44px; padding: 0; overflow: hidden; background: var(--surface-2); }
.menu-bgs .mb-thumb img, .menu-bgs .mb-thumb .skeleton { display: block; width: 100%; height: 100%; object-fit: cover; }
.menu-bgs .on { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
