/* =============================================================================
   LifeOS — UI
   -----------------------------------------------------------------------------
   iPhone-first, no CSS framework, no build step. Everything reads from the
   tokens in section 1, so light and dark mode are one set of components.

     1. Tokens (light + dark)
     2. Base
     3. App shell (sidebar, tab bar, main column)
     4. Page furniture (headers, sections, back links)
     5. Grouped lists and rows
     6. Controls (buttons, chips, search, tick circles, avatars)
     7. Forms
     8. Feedback (notices, toasts, empty states)
     9. Sheets (dialogs)
    10. Calendar (FullCalendar theme)
    11. Review
    12. Ask (chat)
    13. Motion and accessibility
   ========================================================================== */

/* 1. Tokens ------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: #f2f2f6;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --fill: #ececf0;
  --fill-strong: #e0e0e6;
  --text: #111114;
  --text-2: #62626b;
  --text-3: #6e6e76;
  --sep: #e3e3e8;
  --ring: #8e8e96;

  --accent: #5847e6;
  --accent-fill: #5847e6;
  --accent-soft: rgb(88 71 230 / 0.1);
  --on-accent: #ffffff;
  --warn: #c2410c;
  --warn-soft: #fff1e8;
  --ok: #166534;
  --ok-soft: #e8f5ec;
  --teal: #0f766e;
  --teal-soft: #e6f4f2;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --danger-fill: #d92d20;
  --neutral-fill: #7c7c84;

  --shadow: 0 1px 2px rgb(17 17 20 / 0.04);
  --shadow-lg: 0 16px 48px rgb(17 17 20 / 0.2);
  --toast-bg: #1c1c1e;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 60px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);

  accent-color: var(--accent-fill);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #121214;
    --fill: #2c2c2e;
    --fill-strong: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #a1a1aa;
    --text-3: #8e8e96;
    --sep: #38383a;

    --accent: #b0a6ff;
    --accent-fill: #6d5ef8;
    --accent-soft: rgb(176 166 255 / 0.16);
    --warn: #fb923c;
    --warn-soft: rgb(251 146 60 / 0.16);
    --ok: #4ade80;
    --ok-soft: rgb(74 222 128 / 0.14);
    --teal: #2dd4bf;
    --teal-soft: rgb(45 212 191 / 0.14);
    --danger: #f87171;
    --danger-soft: rgb(248 113 113 / 0.14);

    --shadow: none;
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.6);
    --toast-bg: #3a3a3c;
  }
}

/* 2. Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { display: block; flex-shrink: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--accent-fill);
  color: var(--on-accent);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.muted { color: var(--text-2); }
.tabular { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hstack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 3. App shell ------------------------------------------------------------ */

.app-main {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 40px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar { display: none; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--sep);
  view-transition-name: tabbar;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 48px;
  padding: 4px 0 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

.tab-center { margin-top: -22px; }
.tab-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: 0 6px 16px rgb(88 71 230 / 0.35);
}

.tab-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--warn);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.tab-icon { position: relative; }

@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100dvh;
  }
  .tabbar { display: none; }
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100dvh;
    padding: 20px 12px;
    border-right: 1px solid var(--sep);
    background: var(--surface-2);
  }
  .app-main {
    max-width: 760px;
    padding: 36px 32px 72px;
  }
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: var(--text);
}
.side-brand img { width: 32px; height: 32px; }
.side-brand .wordmark { font-size: 22px; }

/* The LifeOS name, set the way the logo sets it */
.wordmark {
  margin: 0;
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.wordmark-lg { font-size: 44px; line-height: 48px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
}
.side-link:hover { background: var(--fill); }
.side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-link .count { margin-left: auto; }
.side-new { margin: 12px 0; }
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--sep);
}
.side-foot form { display: contents; }
.side-foot button.side-link { width: 100%; border: 0; background: none; text-align: left; }

/* Signed-out pages (login) */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card { width: min(100%, 400px); display: flex; flex-direction: column; gap: 24px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.auth-brand img { width: 84px; height: 84px; border-radius: 19px; box-shadow: 0 12px 32px rgb(88 71 230 / 0.32); }
.auth-brand .page-sub { margin-top: 8px; }

/* 4. Page furniture --------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 0;
  margin-bottom: -12px;
}
.page-head > div { min-width: 0; }
/* Phones: the page's own button and the menu button share a top row on the
   right, with the large title below, the way iOS lays out a navigation bar.
   The sidebar replaces the menu button on wide screens. */
.menu-btn { color: var(--text); }
@media (max-width: 899px) {
  .page-head:has(> .menu-btn) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: ". action menu" "title title title";
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
    padding-top: 0;
  }
  .page-head:has(> .menu-btn) > div { grid-area: title; }
  .page-head:has(> .menu-btn) > :not(div):not(.menu-btn) { grid-area: action; }
  .page-head > .menu-btn { grid-area: menu; }
}
@media (min-width: 900px) { .page-head > .menu-btn { display: none; } }
.overline {
  font-size: 13px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}
.page-title {
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.page-sub { margin-top: 4px; font-size: 15px; color: var(--text-2); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  align-self: flex-start;
  min-height: 44px;
  margin: -6px 0 -24px -6px;
  padding-right: 8px;
  color: var(--accent);
  font-size: 17px;
}

.section { display: flex; flex-direction: column; gap: 8px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding: 0 4px;
}
.section-title { font-size: 20px; line-height: 25px; font-weight: 700; }
.section-title.day { font-size: 15px; line-height: 20px; font-weight: 600; color: var(--text-2); }
.section-title.day strong { color: var(--text); font-weight: 600; }
.section-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin: -8px -4px -8px 0;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.count.warn { background: var(--warn-soft); color: var(--warn); }

/* 5. Grouped lists and rows -------------------------------------------------- */

.group {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.group > * { position: relative; }
.group > * + *::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--inset, 16px);
  right: 0;
  border-top: 1px solid var(--sep);
}
.group.has-ticks { --inset: 56px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  color: inherit;
}
a.row:hover { background: var(--surface-2); }
a.row:active { background: var(--fill); }
.row > .icon:last-child { color: var(--ring); }

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
a.row-link { color: inherit; align-self: stretch; justify-content: center; margin: -10px 0; padding: 10px 0; }
a.row-link:hover .row-title { text-decoration: underline; text-decoration-color: var(--sep); text-underline-offset: 3px; }
.section.days { gap: 20px; }
.row-title { font-size: 17px; line-height: 22px; overflow-wrap: anywhere; }
.row-title.strong { font-weight: 600; }
.row-sub { font-size: 13px; line-height: 17px; color: var(--text-2); }
.row-sub.warn { color: var(--warn); font-weight: 600; }
.row-preview {
  font-size: 15px;
  line-height: 20px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row.is-done .row-title { color: var(--text-3); text-decoration: line-through; }
.row.is-done .row-sub { color: var(--text-3); font-weight: 400; }
.row.muted-row { color: var(--text-2); font-size: 15px; gap: 10px; }
.row.muted-row .icon { color: var(--ok); }

.row-time {
  width: 50px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
}
.row-time .t1 { font-size: 15px; line-height: 20px; font-weight: 600; }
.row-time .t2 { font-size: 13px; line-height: 17px; color: var(--text-2); }

.bar {
  width: 4px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--accent-fill);
}
.bar.work { background: var(--teal); }
.bar.task { background: var(--warn); }
.bar.reminder { background: var(--ok); }

.tile-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tile-icon.warn { background: var(--warn-soft); color: var(--warn); }
.tile-icon.teal { background: var(--teal-soft); color: var(--teal); }
.tile-icon.ok { background: var(--ok-soft); color: var(--ok); }

.pill {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }

details.row-details > summary {
  list-style: none;
  cursor: pointer;
}
details.row-details > summary::-webkit-details-marker { display: none; }
details.row-details[open] > summary .chev { transform: rotate(180deg); }
.chev { color: var(--ring); transition: transform 0.2s var(--ease); }
.row-details-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 14px 78px;
  font-size: 15px;
  color: var(--text-2);
}
.row-details-body a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; min-height: 36px; }

.is-highlighted { animation: highlight 2.4s var(--ease); }
@keyframes highlight {
  0%, 40% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* 6. Controls -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { filter: brightness(0.92); }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-tinted { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-plain { background: none; color: var(--accent); padding: 0 8px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; border-radius: var(--r); font-size: 17px; }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text);
}
.icon-btn.plain { background: none; }

.avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.avatar.w { background: var(--teal-soft); color: var(--teal); }
.avatar.b { background: var(--fill); color: var(--text-2); }
.avatar.lg { width: 44px; height: 44px; font-size: 17px; text-transform: uppercase; }
button.avatar { border: 0; padding: 0; }

.chips {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 2px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--sep);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.chip[aria-current="true"] { background: var(--text); color: var(--bg); box-shadow: none; }
.chip.toggle { color: var(--text-2); }
.chip.toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-fill); }
.chip .dot.work { background: var(--teal); }
.chip .dot.task { background: var(--warn); }
.chip .dot.reminder { background: var(--ok); }
.chip.toggle[aria-pressed="false"] .dot { opacity: 0.35; }

.search { position: relative; }
.search .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  translate: 0 -50%;
  color: var(--text-2);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 38px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--fill);
  font-size: 17px;
}
.search input::placeholder { color: var(--text-2); }

.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: -14px; }

/* Tick circle: a real button whose pressed state is the task's done state */
.tick-form { display: contents; }
.tick {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  margin: -8px -4px -8px -10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--on-accent);
}
.tick::before {
  content: "";
  grid-area: 1 / 1;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ring);
  border-radius: 50%;
  transition: background-color 0.15s, border-color 0.15s;
}
.tick .icon { grid-area: 1 / 1; width: 14px; height: 14px; opacity: 0; }
.tick[aria-pressed="true"]::before { background: var(--accent-fill); border-color: var(--accent-fill); }
.tick[aria-pressed="true"] .icon { opacity: 1; }
.tick:disabled { cursor: progress; }
.tick-placeholder {
  width: 24px;
  height: 24px;
  margin: 0 6px 0 0;
  flex-shrink: 0;
  border: 2px dashed var(--ring);
  border-radius: 50%;
}

/* 7. Forms ------------------------------------------------------------------ */

.form { display: flex; flex-direction: column; gap: 20px; }
.form-group {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.form-group > * { position: relative; }
.form-group > * + *::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 1px solid var(--sep);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-help { font-size: 13px; color: var(--text-2); }
.field-error { font-size: 13px; font-weight: 600; color: var(--danger); }
.field.is-check { flex-direction: row; align-items: center; justify-content: space-between; }

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--fill);
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
}
.input::placeholder { color: var(--text-2); }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 132px; resize: vertical; }
select.input {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e96' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.input.title-input { font-size: 20px; font-weight: 600; }
input[type="checkbox"].check { width: 22px; height: 22px; margin: 0; }

.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  border: 0;
  margin: 0;
  border-radius: var(--r-sm);
  background: var(--fill);
}
.segmented legend { padding: 0; }
.segmented label {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

.quick-add { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px 8px 6px 16px; }
.quick-add .icon { color: var(--accent); }
.quick-add input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-size: 17px;
}
.quick-add input:focus { outline: none; }
.quick-add input::placeholder { color: var(--accent); }
.quick-add input:focus::placeholder { color: var(--text-2); }
.quick-add:focus-within { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.quick-add input:placeholder-shown ~ .btn { visibility: hidden; }
.quick-add .btn { min-height: 36px; padding: 0 14px; font-size: 15px; }

/* 8. Feedback ------------------------------------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--warn-soft);
  font-size: 15px;
  line-height: 1.45;
}
.notice > .icon { margin-top: 1px; color: var(--warn); }
.notice.danger { background: var(--danger-soft); }
.notice.danger > .icon { color: var(--danger); }
.notice.info { background: var(--accent-soft); }
.notice.info > .icon { color: var(--accent); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 24px;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-2);
  text-align: center;
  font-size: 15px;
}
.empty > .icon { width: 32px; height: 32px; margin-bottom: 4px; color: var(--ring); }
.empty-title { color: var(--text); font-size: 17px; font-weight: 600; }
.empty .btn { margin-top: 10px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  z-index: 40;
  width: min(calc(100% - 32px), 440px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: 24px; left: calc(50% + 124px); } }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 6px 6px 16px;
  border-radius: var(--r);
  background: var(--toast-bg);
  color: #f5f5f7;
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  pointer-events: auto;
}
.toast > .icon { color: #4ade80; }
.toast.warning > .icon { color: #fb923c; }
.toast.error > .icon { color: #f87171; }
.toast.info > .icon { color: #b0a6ff; }
.toast-text { flex: 1; min-width: 0; }
.toast-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #c7c7cc;
}

/* 9. Sheets ----------------------------------------------------------------- */

dialog.sheet {
  width: min(100%, 520px);
  max-width: 100%;
  max-height: min(92dvh, 760px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); overflow: hidden; overscroll-behavior: contain; }
@media (min-width: 600px) {
  dialog.sheet { margin: auto; border-radius: 22px; }
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}
.sheet-head > :last-child { justify-self: end; }
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.sheet-links .row { min-height: 52px; }

dialog.drawer {
  width: min(88vw, 360px);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--sep);
  border-radius: 24px 0 0 24px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.drawer[open] { display: flex; flex-direction: column; }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 18px) 14px 14px 18px;
}
.drawer-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b6cf6, #5847e6);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 6px 16px rgb(88 71 230 / 0.3);
}
.drawer-who { flex: 1; min-width: 0; }
.drawer-name {
  font-size: 20px;
  line-height: 25px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 16px calc(env(safe-area-inset-bottom) + 20px);
  overflow-y: auto;
}
.drawer-body .row[aria-current="page"] .row-title { color: var(--accent); font-weight: 600; }
.drawer-foot { margin-top: auto; }

/* App tiles in the menu panel, styled like home-screen icons */
.app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 12px 8px;
  list-style: none;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 4px 8px;
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.app-tile:hover { background: var(--surface-2); }
.app-tile:active .app-icon { transform: scale(0.92); }
.app-tile[aria-current="page"] { background: var(--accent-soft); }
.app-tile[aria-current="page"] .app-label { color: var(--accent); font-weight: 700; }
.app-icon {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(160deg, var(--tile-a), var(--tile-b));
  box-shadow: 0 6px 14px -4px var(--tile-shadow), inset 0 1px 0 rgb(255 255 255 / 0.22);
  transition: transform 0.15s var(--ease);
}
.app-icon .icon { stroke-width: 2; }
.app-today    { --tile-a: #4f8dfd; --tile-b: #2f5fe0; --tile-shadow: rgb(47 95 224 / 0.55); }
.app-calendar { --tile-a: #ff6b6b; --tile-b: #e5383b; --tile-shadow: rgb(229 56 59 / 0.5); }
.app-ask      { --tile-a: #8b7bff; --tile-b: #5847e6; --tile-shadow: rgb(88 71 230 / 0.55); }
.app-tasks    { --tile-a: #34d27b; --tile-b: #17a34a; --tile-shadow: rgb(23 163 74 / 0.5); }
.app-notes    { --tile-a: #ffc54d; --tile-b: #f59e0b; --tile-shadow: rgb(245 158 11 / 0.5); }
.app-review   { --tile-a: #2dd4bf; --tile-b: #0f9488; --tile-shadow: rgb(15 148 136 / 0.5); }
.app-label { font-size: 13px; line-height: 16px; font-weight: 500; }
.app-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--surface);
  border-radius: 11px;
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* Settings */
.settings-who { display: flex; align-items: center; gap: 12px; }
.settings-lede { padding: 0 4px; font-size: 15px; color: var(--text-2); }
.settings-logout { margin-top: 8px; }
.key-reveal { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--accent); }
.key-reveal .row-title { display: flex; align-items: center; gap: 6px; }
.copy-field { display: flex; gap: 8px; align-items: center; }
.copy-field .input { flex: 1; min-width: 0; }
.input.mono, code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.input.mono { font-size: 14px; }
code { padding: 1px 5px; border-radius: 6px; background: var(--fill); font-size: 0.9em; }
details.setup { padding: 0; }
.setup-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  list-style: none;
  cursor: pointer;
}
.setup-summary::-webkit-details-marker { display: none; }
details.setup[open] .chev { transform: rotate(180deg); }
.setup-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 16px;
  font-size: 15px;
  line-height: 1.5;
}
.steps { margin: 0; padding-left: 22px; }
.steps > li + li { margin-top: 10px; }
.steps ol, .steps ul { margin: 6px 0; padding-left: 20px; }
.steps ol > li + li, .steps ul > li + li { margin-top: 4px; }
.steps ul > li { list-style: disc; }

/* 10. Calendar ---------------------------------------------------------------- */

.calendar-card {
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.calendar-card.is-loading { opacity: 0.7; }

.fc {
  --fc-border-color: var(--sep);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  --fc-list-event-hover-bg-color: var(--fill);
  --fc-today-bg-color: var(--accent-soft);
  --fc-now-indicator-color: var(--warn);
  --fc-button-text-color: var(--text);
  --fc-button-bg-color: var(--fill);
  --fc-button-border-color: transparent;
  --fc-button-hover-bg-color: var(--fill-strong);
  --fc-button-hover-border-color: transparent;
  --fc-button-active-bg-color: var(--text);
  --fc-button-active-border-color: transparent;
  --fc-event-border-color: transparent;
  font-size: 15px;
}
.fc .fc-toolbar.fc-header-toolbar { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.fc .fc-toolbar-title { font-size: 20px; font-weight: 700; }
.fc .fc-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: none !important;
}
.fc .fc-button .fc-icon { font-size: 1.2em; }
.fc .fc-button-group > .fc-button { border-radius: 0; }
.fc .fc-button-group > .fc-button:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.fc .fc-button-group > .fc-button:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { color: var(--bg); }
.fc .fc-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fc a { color: inherit; }
.fc .fc-col-header-cell-cushion { padding: 6px 2px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.fc .fc-daygrid-day-number { padding: 4px 6px; font-size: 13px; }
.fc .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 700; }
.fc-theme-standard .fc-scrollgrid { border-radius: 12px; overflow: hidden; }
.fc .fc-daygrid-event { border-radius: 6px; padding: 1px 4px; font-size: 12px; }
.fc .fc-list { border: 0; }
.fc .fc-list-day-cushion { background: var(--surface-2); font-size: 14px; font-weight: 600; }
.fc .fc-list-day.is-today .fc-list-day-cushion { color: var(--accent); }
.fc .fc-list-event td { padding-top: 10px; padding-bottom: 10px; }
.fc .fc-list-event-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.fc .fc-list-empty { background: var(--surface); color: var(--text-2); }
.calendar-event-meta { display: block; margin-top: 2px; font-size: 13px; color: var(--text-2); }
.calendar-note { padding: 0 4px; font-size: 13px; color: var(--text-2); }

.kv { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); }
.kv > * { position: relative; }
.kv > * + *::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--sep); }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 15px; }
.kv-key { color: var(--text-2); flex-shrink: 0; }
.kv-val { text-align: right; font-weight: 500; overflow-wrap: anywhere; }

/* 11. Review ------------------------------------------------------------------ */

.meter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter-track { width: 56px; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent-fill); }
.evidence { display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--text-2); }
.evidence li { margin-left: 18px; }

.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; line-height: 1.55; }
.card { padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }

/* 12. Ask (chat) -------------------------------------------------------------- */

body.is-ask {
  height: 100dvh;
  /* Ask moves as one sheet when it opens and closes (section 13). */
  view-transition-name: ask-sheet;
}
body.is-ask .toasts {
  left: 50%;
  bottom: calc(138px + env(safe-area-inset-bottom, 0px));
}

.ask-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}

.ask-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 88px;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}
.ask-header-title { text-align: center; min-width: 0; }
.ask-header-title h1 { font-size: 17px; line-height: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ask-header-title p { font-size: 12px; line-height: 16px; color: var(--text-2); }
.ask-header-actions { display: flex; justify-content: flex-end; }
.ask-new-form { display: contents; }
.ask-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 0 2px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ask-title-btn #askTitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ask-title-btn .icon { flex-shrink: 0; color: var(--text-2); }

/* A date line in a chat that spans more than one day */
.ask-day { display: flex; justify-content: center; }
.ask-day span {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
}

.ask-delete-form { display: flex; flex-direction: column; gap: 8px; }
.ask-delete-help { font-size: 13px; line-height: 1.4; color: var(--text-2); text-wrap: pretty; padding: 0 4px; }

/* Chat history: a drawer from the left on Ask, and a plain page without JS */
dialog.drawer.is-left {
  margin: 0 auto 0 0;
  border-left: 0;
  border-right: 1px solid var(--sep);
  border-radius: 0 24px 24px 0;
}
.ask-history-head { padding-left: 20px; gap: 4px; }
.ask-history-heading { flex: 1; min-width: 0; font-size: 26px; line-height: 32px; font-weight: 700; }
.ask-history-search { margin: 0 16px 6px; }
.ask-history-search input { height: 38px; font-size: 16px; }
.ask-history-body { gap: 0; padding-left: 8px; padding-right: 8px; }
.ask-history-list { display: flex; flex-direction: column; gap: 6px; }
.ask-history-group { display: flex; flex-direction: column; gap: 2px; }
.ask-history-label {
  padding: 10px 12px 4px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}
.ask-history-rows { display: flex; flex-direction: column; gap: 2px; }
.ask-history-item { position: relative; border-radius: var(--r-sm); overflow: hidden; }
.ask-history-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 2px 10px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  touch-action: pan-y;
  transition: transform 0.22s var(--ease);
}
.ask-history-row:hover { background: var(--fill); }
.ask-history-row.is-active { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
.ask-history-item.is-open .ask-history-row { transform: translateX(-192px); border-radius: var(--r-sm) 0 0 var(--r-sm); }
/* Behind the row on touch screens; revealed by a swipe. */
.ask-history-actions { position: absolute; inset: 0 0 0 auto; display: flex; }
.ask-history-act {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  color: #fff;
  font: 600 12px/1 var(--font);
  cursor: pointer;
}
/* Transparent until a swipe, so their colours don't show at the row's rounded edges. */
.ask-history-actions { opacity: 0; }
.ask-history-item.is-open .ask-history-actions,
.ask-history-item.is-dragging .ask-history-actions { opacity: 1; }
.ask-history-act.is-pin { background: var(--accent-fill); }
.ask-history-act.is-rename { background: var(--neutral-fill); }
.ask-history-act.is-delete { background: var(--danger-fill); }
/* With a mouse: small buttons over the row's end on hover or keyboard focus. */
@media (hover: hover) and (pointer: fine) {
  .ask-history-actions { inset: 8px 8px 8px auto; z-index: 2; gap: 4px; opacity: 0; pointer-events: none; }
  .ask-history-item:hover .ask-history-actions,
  .ask-history-item:focus-within .ask-history-actions { opacity: 1; pointer-events: auto; }
  .ask-history-act { width: 36px; border-radius: 8px; }
  .ask-history-act span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.ask-history-title { font-size: 16px; line-height: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ask-history-when { font-size: 13px; line-height: 17px; color: var(--text-3); }
.ask-history-preview {
  grid-column: 1 / -1;
  font-size: 14px;
  line-height: 19px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ask-history-row mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 1px; }
.ask-history-note { padding: 6px 12px; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.ask-history-empty { display: flex; flex-direction: column; gap: 4px; padding: 24px 12px; font-size: 15px; line-height: 1.45; color: var(--text-2); text-wrap: pretty; }
.ask-history-empty-title { font-size: 17px; font-weight: 600; color: var(--text); }
.ask-history-page { margin-top: 8px; }

/* Wide screens: the chat list stays open beside the conversation. A closed
   dialog is only hidden by the browser's own stylesheet, so showing it here
   needs no script and nothing jumps once the page loads. */
@media (min-width: 1024px) {
  dialog.ask-history:not([open]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: 320px;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .is-ask .ask-shell { margin-left: 320px; }
  body.is-ask .toasts { left: calc(50% + 160px); }
  .ask-header-actions [data-open-dialog="askHistory"],
  dialog.ask-history:not([open]) [data-close-dialog] { display: none; }
}

.ask-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column-reverse;
  scroll-padding-bottom: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
}
.ask-messages-inner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ask-messages-inner:has(.ask-empty) { margin: auto; }

.ask-turn { display: flex; flex-direction: column; gap: 10px; }
.ask-turn-user { align-items: flex-end; }
.ask-bubble {
  max-width: min(82%, 520px);
  padding: 10px 15px;
  border-radius: 20px 20px 6px 20px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: break-word;
}
.ask-bubble-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  opacity: 0.9;
}
.ask-bubble-text { text-wrap: pretty; }

.ask-reply {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: break-word;
}
.ask-reply p, .ask-reply li { text-wrap: pretty; }
.ask-list { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.ask-list li { list-style: disc; }

.ask-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
}
.ask-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ring);
  opacity: 0.45;
  animation: ask-dot 1.2s infinite ease-in-out;
}
.ask-typing span:nth-child(2) { animation-delay: 0.2s; }
.ask-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ask-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.ask-proposals { display: flex; flex-direction: column; gap: 10px; }
.ask-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ask-card-head { display: flex; align-items: flex-start; gap: 12px; }
.ask-card-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ask-card-label { font-size: 13px; line-height: 17px; font-weight: 600; color: var(--text-2); }
.ask-card-title { font-size: 17px; line-height: 22px; font-weight: 600; overflow-wrap: break-word; }
.ask-card-when { font-size: 15px; line-height: 20px; color: var(--text-2); }
.ask-card-cancel-form { display: contents; }
.ask-card-cancel { margin: -8px -8px 0 0; color: var(--text-2); }
.ask-card-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--sep);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-2);
  overflow-wrap: break-word;
}
.ask-card-actions form { display: contents; }
.ask-card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}
.ask-card-status.is-ok { color: var(--ok); }
.ask-card-status.is-failed { color: var(--danger); }

.ask-docs .row > .icon:last-child { color: var(--accent); }

.ask-error-body { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.ask-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 8px;
  text-align: center;
}
.ask-empty-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: 0 6px 16px rgb(88 71 230 / 0.3);
}
.ask-empty-title { font-size: 26px; line-height: 32px; font-weight: 700; text-wrap: balance; color: var(--text); }
.ask-empty-sub { max-width: 34ch; font-size: 15px; line-height: 1.45; color: var(--text-2); text-wrap: pretty; }
.ask-starters {
  width: 100%;
  max-width: 460px;
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}
.ask-starters form { display: contents; }
.ask-starter {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--sep);
  font-size: 15px;
  font-weight: 500;
}

.ask-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--sep);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.ask-composer-inner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-chips { margin: 0 -12px; padding: 2px 12px; }
.ask-chips .chip { min-height: 44px; }

.ask-file-pill {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  max-width: 100%;
  padding: 0 4px 0 12px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}
.ask-file-pill-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ask-file-clear {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
}

.ask-form { display: flex; align-items: flex-end; gap: 8px; }
.ask-attach-wrap { position: relative; flex-shrink: 0; }
.ask-attach { cursor: pointer; }
.ask-attach-wrap:focus-within .ask-attach { outline: 2px solid var(--accent); outline-offset: 2px; }

.ask-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 132px;
  padding: 10px 16px;
  border: 1px solid var(--sep);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
}
.ask-input::placeholder { color: var(--text-2); }
.ask-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-send { background: var(--accent-fill); color: var(--on-accent); }

/* 13. Motion and accessibility ----------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  dialog.sheet[open] { animation: sheet-in 0.28s var(--ease); }
  dialog.drawer[open] { animation: drawer-in 0.32s var(--ease); }
  dialog.drawer.is-left[open] { animation-name: drawer-in-left; }
  dialog.drawer[open] .app-grid > li { animation: tile-in 0.36s var(--ease) both; animation-delay: calc(80ms + var(--i, 0) * 30ms); }
  .toast { animation: toast-in 0.24s var(--ease); }

  /* Ask is a sheet: it slides up over the page you opened it from, and the
     down chevron (or Back) slides it away again. The sheet existing on only
     one side of a navigation is what makes it an opening or a closing. */
  ::view-transition-group(ask-sheet) { z-index: 2; }
  ::view-transition-new(ask-sheet):only-child { animation: ask-sheet-in 0.44s var(--sheet-ease) both; }
  ::view-transition-old(ask-sheet):only-child { animation: ask-sheet-out 0.34s var(--sheet-ease) both; }
  /* Hold the page underneath still instead of cross-fading it. These types
     come from the pagereveal script in base.html; browsers without the
     Navigation API keep the cross-fade and still get the slide. */
  html:active-view-transition-type(ask-open)::view-transition-old(root),
  html:active-view-transition-type(ask-open)::view-transition-old(tabbar) { animation: none; }
  html:active-view-transition-type(ask-open)::view-transition-new(root) { animation: none; opacity: 0; }
  html:active-view-transition-type(ask-close)::view-transition-old(root),
  html:active-view-transition-type(ask-close)::view-transition-new(root),
  html:active-view-transition-type(ask-close)::view-transition-new(tabbar) { animation: none; }
}
@keyframes ask-sheet-in { from { transform: translateY(100%); } }
@keyframes ask-sheet-out { to { transform: translateY(100%); } }
@keyframes sheet-in { from { transform: translateY(32px); opacity: 0; } }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-in-left { from { transform: translateX(-100%); } }
@keyframes tile-in { from { transform: translateY(10px) scale(0.94); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .tick::before { border-color: CanvasText; }
  .tick[aria-pressed="true"]::before { background: Highlight; border-color: Highlight; }
  .chip[aria-current="true"], .chip.toggle[aria-pressed="true"] { outline: 2px solid Highlight; }
}
