/* ============================================================================
   FATHM — "My day" dashboard
   Home & Lake design system: navy-first (deep navy ink / white / warm paper),
   with ONE restrained accent — Coast Guard orange, FS 595 #12250 (#CF4E38) —
   reserved for STATE that matters: deadlines due & overdue, touchpoints
   pending. Everything else stays neutral. (Britton ruling 2026-07-12.)
   Register: high-end listing brochure — editorial serif display, letterspaced
   small-cap labels, warm paper surfaces, layered depth. Theme-aware, WCAG-AA.
   ========================================================================== */

/* ---- brand fonts: Instrument Serif (display) + Gerstner Programm (UI) ---- */
@font-face { font-family: "Instrument Serif"; src: url("assets/fonts/InstrumentSerif-Normal-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("assets/fonts/InstrumentSerif-Italic-latin.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Gerstner Programm"; src: url("assets/fonts/GerstnerProgramm-Light.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Gerstner Programm"; src: url("assets/fonts/GerstnerProgramm-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Gerstner Programm"; src: url("assets/fonts/GerstnerProgramm-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ---------------------------------------------------------------- tokens --- */
:root {
  /* type */
  --font-ui: "Gerstner Programm", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", Palatino, Georgia, serif;

  /* type scale (body = 15px) */
  --fs-2xs: .6875rem;   /* 11 */
  --fs-xs:  .75rem;     /* 12 */
  --fs-sm:  .8125rem;   /* 13 */
  --fs-base:.9375rem;   /* 15 */
  --fs-md:  1rem;       /* 16 */
  --fs-lg:  1.125rem;   /* 18 */
  --fs-h1:  2.1rem;     /* ~34, display serif */

  /* spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* radii */
  --r-xs: 7px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 26px; --r-pill: 999px;

  /* motion */
  --t-fast: 130ms ease;
  --t: 200ms cubic-bezier(.2, .6, .2, 1);

  /* ---- light palette (default): warm paper ---- */
  --bg: #f3f1ec;
  --bg-glow: #faf9f6;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f0eee8;
  --ink: #142138;
  --ink-2: #4e5a73;
  --ink-3: #8591a6;
  --line: #e8e5de;
  --line-2: #d9d5cc;
  --hairline: rgb(20 33 56 / .08);
  --on-accent: #ffffff;

  --sidebar-bg: linear-gradient(180deg, #17243e 0%, #0c1526 100%);
  --sidebar-edge: rgb(255 255 255 / .06);
  --sidebar-ink: #f0f0ef;
  --sidebar-muted: #989ca5;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(255, 255, 255, .10);

  /* the single STATE accent — Coast Guard orange (FS 595 #12250) */
  --accent: #cf4e38;
  --accent-strong: #b03e28;      /* accessible CG-orange text on white */
  --accent-ink: #7e2b1a;         /* text on --accent-soft */
  --accent-soft: #e9eff8;
  --accent-line: #c9d7ea;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / .04), 0 2px 6px rgb(16 24 40 / .05);
  --shadow-md: 0 2px 4px rgb(16 24 40 / .05), 0 12px 28px rgb(16 24 40 / .09);
  --shadow-lg: 0 10px 24px rgb(16 24 40 / .13), 0 32px 64px rgb(16 24 40 / .22);
  --shadow-pop: 0 1px 0 rgb(255 255 255 / .8) inset, var(--shadow-sm);

  --glow: 0 0 0 rgb(0 0 0 / 0);
  --focus: 0 0 0 3px rgb(207 78 56 / .32);
  color-scheme: light;
}

/* system dark, unless the user forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101e;
    --bg-glow: #16223a;
    --surface: #121b2e;
    --surface-2: #172236;
    --surface-3: #1f2c47;
    --ink: #e9edf5;
    --ink-2: #a6b0c3;
    --ink-3: #74809a;
    --line: #263450;
    --line-2: #384a6e;
    --hairline: rgb(255 255 255 / .07);
    --on-accent: #1a0c07;

    --sidebar-bg: linear-gradient(180deg, #0b1322 0%, #070c16 100%);
    --sidebar-edge: rgb(255 255 255 / .07);
    --sidebar-ink: #eceded;
    --sidebar-muted: #8b8f98;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(255, 255, 255, .10);

    --accent: #ed6e52;
    --accent-strong: #f08268;
    --accent-ink: #f5a38f;
    --accent-soft: rgb(124 158 220 / .16);
    --accent-line: rgb(124 158 220 / .38);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / .40), 0 2px 8px rgb(0 0 0 / .30);
    --shadow-md: 0 6px 18px rgb(0 0 0 / .50);
    --shadow-lg: 0 22px 46px rgb(0 0 0 / .62);
    --shadow-pop: 0 1px 0 rgb(255 255 255 / .05) inset, var(--shadow-sm);

    --glow: 0 0 14px rgb(237 110 82 / .20);
    --focus: 0 0 0 3px rgb(237 110 82 / .38);
    color-scheme: dark;
  }
}

/* manual dark (wins over system in both directions) */
:root[data-theme="dark"] {
  --bg: #0a101e;
  --bg-glow: #16223a;
  --surface: #121b2e;
  --surface-2: #172236;
  --surface-3: #1f2c47;
  --ink: #e9edf5;
  --ink-2: #a6b0c3;
  --ink-3: #74809a;
  --line: #263450;
  --line-2: #384a6e;
  --hairline: rgb(255 255 255 / .07);
  --on-accent: #1a0c07;

  --sidebar-bg: linear-gradient(180deg, #0b1322 0%, #070c16 100%);
  --sidebar-edge: rgb(255 255 255 / .07);
  --sidebar-ink: #eceded;
  --sidebar-muted: #8b8f98;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(255, 255, 255, .10);

  --accent: #ed6e52;
  --accent-strong: #f08268;
  --accent-ink: #f5a38f;
  --accent-soft: rgb(124 158 220 / .16);
  --accent-line: rgb(124 158 220 / .38);

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .40), 0 2px 8px rgb(0 0 0 / .30);
  --shadow-md: 0 6px 18px rgb(0 0 0 / .50);
  --shadow-lg: 0 22px 46px rgb(0 0 0 / .62);
  --shadow-pop: 0 1px 0 rgb(255 255 255 / .05) inset, var(--shadow-sm);

  --glow: 0 0 14px rgb(237 110 82 / .20);
  --focus: 0 0 0 3px rgb(237 110 82 / .38);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base --- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: var(--fs-base)/1.5 var(--font-ui);
  background:
    radial-gradient(1200px 500px at 78% -8%, var(--bg-glow) 0%, transparent 62%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); font-size: .9em; }
.empty { color: var(--ink-2); font-size: var(--fs-sm); padding: .35rem .15rem; }
.empty.error-text { color: var(--accent-strong); }
.spacer { flex: 1; }

/* shared inline-icon styling */
.ic { width: 1.25em; height: 1.25em; display: block; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* keyboard focus, everywhere */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
a:focus-visible, button:focus-visible, textarea:focus-visible, summary:focus-visible,
.conv-item:focus-visible, .item.clickable:focus-visible { box-shadow: var(--focus); }

.layout { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------- sidebar ----- */
.sidebar {
  width: 228px; min-width: 228px;
  background: var(--sidebar-bg); color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-edge);
  display: flex; flex-direction: column;
  padding: var(--sp-6) var(--sp-3) var(--sp-5);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .1rem .4rem var(--sp-8); }
.logo-mark {
  width: 46px; height: auto; display: block;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / .35));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--font-display); font-weight: 600; letter-spacing: .2em; font-size: 1.04rem; }
.brand-sub { font-size: .56rem; letter-spacing: .32em; text-transform: uppercase; color: var(--sidebar-muted); font-weight: 600; margin-top: .32rem; }

.sidebar nav { display: flex; flex-direction: column; gap: .14rem; }
.sidebar nav a {
  color: var(--sidebar-muted); text-decoration: none;
  padding: .58rem .65rem; border-radius: 10px;
  font-weight: 500; font-size: .9rem; letter-spacing: .01em;
  display: flex; gap: .68rem; align-items: center;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar nav a .icon { display: grid; place-items: center; width: 1.15rem; opacity: .95; }
.sidebar nav a:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar nav a.active { color: #fff; background: var(--sidebar-active); box-shadow: var(--glow); }
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -2px; top: 22%; bottom: 22%;
  width: 2.5px; border-radius: 2px; background: var(--accent);
}
.sidebar nav a.active .icon { color: var(--accent); opacity: 1; }

.sidebar-foot {
  margin-top: auto; display: flex; gap: .6rem; align-items: center;
  padding: var(--sp-4) .3rem 0; border-top: 1px solid rgb(255 255 255 / .09);
}
.avatar {
  width: 32px; height: 32px; min-width: 32px; border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #383c44, #23262c 70%);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .82rem;
  box-shadow: 0 0 0 1px rgb(255 255 255 / .09);
}
.user-meta { min-width: 0; }
.user-email { font-size: .72rem; color: var(--sidebar-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linklike { background: none; border: none; color: #c4c8ce; font-size: .76rem; padding: 0; cursor: pointer; }
.linklike:hover { color: #fff; text-decoration: underline; }

/* -------------------------------------------------------- content area ----- */
.content { flex: 1; padding: var(--sp-8) var(--sp-8) var(--sp-8); min-width: 0; }
.page-head { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-title h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1); font-weight: 600; letter-spacing: -.005em; line-height: 1.06;
}
.today-date {
  margin: .4rem 0 0; color: var(--ink-3); font-size: var(--fs-2xs);
  text-transform: uppercase; letter-spacing: .18em; font-weight: 600;
}
.stats { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; }
.head-actions { display: flex; align-items: center; gap: .5rem; }

.chip {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: .44rem 1.05rem; font-size: var(--fs-sm); color: var(--ink-2);
  box-shadow: var(--shadow-pop); white-space: nowrap; font-weight: 500;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
/* the two "act on this" stat chips light up amber when they carry a count */
.chip.chip-state {
  background: var(--accent-soft); color: var(--accent-ink);
  border-color: var(--accent-line); font-weight: 600;
  box-shadow: var(--shadow-pop), var(--glow);
}
.chip.chip-state::before {
  content: ""; display: inline-block; width: .42em; height: .42em;
  border-radius: 50%; background: var(--accent); margin: 0 .5em .12em 0;
  vertical-align: middle;
}

/* -------------------------------------------------------------- buttons ---- */
button { font: inherit; cursor: pointer; }
.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 88%, #ffffff), var(--ink));
  border: 1px solid var(--ink); color: var(--surface);
  border-radius: var(--r-sm); padding: .5rem .95rem; font-weight: 600; letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: .45rem;
  box-shadow: var(--shadow-sm);
  transition: filter var(--t-fast), transform var(--t-fast), opacity var(--t-fast), box-shadow var(--t-fast);
}
.primary .ic { width: 1.05em; height: 1.05em; }
.primary:hover { filter: brightness(1.16); box-shadow: var(--shadow-md); }
.primary:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.primary:disabled { opacity: .5; cursor: default; filter: none; transform: none; }

.ghost {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: var(--r-sm); padding: .46rem .9rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: .45rem;
  box-shadow: var(--shadow-pop);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.ghost .ic { width: 1em; height: 1em; }
.ghost:hover { border-color: var(--ink-3); background: var(--surface-2); box-shadow: var(--shadow-sm); }
.sm { padding: .22rem .6rem; font-size: var(--fs-sm); border-radius: var(--r-xs); }

.iconbtn {
  background: none; border: none; color: var(--ink-3);
  padding: .3rem; border-radius: var(--r-xs); line-height: 0;
  display: inline-grid; place-items: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.iconbtn .ic { width: 1.05rem; height: 1.05rem; }
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.ghost-icon { border: 1px solid var(--line-2); color: var(--ink-2); padding: .42rem; border-radius: var(--r-sm); box-shadow: var(--shadow-pop); }
.ghost-icon:hover { border-color: var(--ink-3); background: var(--surface-2); }

/* ---------------------------------------------------------------- tiles ---- */
.grid-stack > .grid-stack-item > .tile {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; overflow: hidden;
  transition: box-shadow var(--t), border-color var(--t), transform var(--t);
}
.grid-stack > .grid-stack-item > .tile:hover {
  box-shadow: var(--shadow-md); border-color: var(--line-2);
  transform: translateY(-1px);
}
.tile-head {
  display: flex; align-items: center; gap: .55rem;
  padding: .85rem 1rem .8rem;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.tile-head:active { cursor: grabbing; }
.tile-glyph { color: var(--ink-3); display: grid; place-items: center; }
.tile-glyph .ic { width: 1rem; height: 1rem; }
.tile-head h2 {
  font-size: .72rem; font-weight: 700; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .14em; color: var(--ink-2);
  transform: translateY(.5px);
}
.count {
  background: var(--surface-3); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: var(--r-pill); padding: 0 .5rem; font-size: var(--fs-2xs);
  font-weight: 700; min-width: 1.55em; height: 1.55em; display: inline-grid; place-items: center;
}
.count:empty { display: none; }
.count.state { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.tile-head .iconbtn { cursor: pointer; }
.tile-body { flex: 1; overflow-y: auto; padding: .95rem 1rem; min-height: 0; }

/* drag feedback + gridstack placeholder */
.grid-stack-item.ui-draggable-dragging .tile,
.grid-stack-item.ui-resizable-resizing .tile { box-shadow: var(--shadow-lg); border-color: var(--accent-line); transform: none; }
.grid-stack-placeholder > .placeholder-content {
  background: var(--accent-soft) !important;
  border: 1.5px dashed var(--accent) !important; border-radius: var(--r-lg) !important;
}
/* subtle resize grip */
.grid-stack-item > .ui-resizable-se { width: 16px; height: 16px; right: 4px; bottom: 4px; }
.grid-stack-item > .ui-resizable-se::after {
  content: ""; position: absolute; right: 2px; bottom: 2px; width: 7px; height: 7px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  border-bottom-right-radius: 3px; opacity: .5;
}

/* ------------------------------------------------- list items (shared) ----- */
.item {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .65rem .75rem; margin-bottom: .55rem; background: var(--surface);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.item:last-child { margin-bottom: 0; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.item.overdue { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.item-main { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.item-main strong { font-weight: 650; font-size: var(--fs-base); letter-spacing: -.005em; }
.item .muted { margin-top: .2rem; }
.pill {
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  border-radius: var(--r-pill); padding: .05rem .55rem; font-size: var(--fs-2xs);
  font-weight: 650; white-space: nowrap; text-transform: capitalize; letter-spacing: .02em;
}
.pill.overdue-pill, .pill.pending {
  background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line);
}
.item.done { opacity: .5; }
.item.done .tp-action, .item.done strong { text-decoration: line-through; }

/* --------------------------------------------------------- touchpoints ----- */
.tp-action { margin: .3rem 0 .4rem; color: var(--ink); }
.tp-foot { display: flex; align-items: center; gap: .4rem; }
details.snooze { position: relative; }
details.snooze summary {
  list-style: none; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-xs); padding: .22rem .6rem; font-size: var(--fs-sm);
  color: var(--ink); cursor: pointer; white-space: nowrap;
}
details.snooze summary::-webkit-details-marker { display: none; }
details.snooze summary:hover { border-color: var(--ink-3); }
details.snooze[open] summary { border-color: var(--accent); color: var(--accent-ink); }
.snooze-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; z-index: 30;
  min-width: 96px; overflow: hidden; padding: .2rem;
}
.snooze-menu button {
  background: none; border: none; text-align: left; padding: .4rem .6rem;
  font-size: var(--fs-sm); color: var(--ink); border-radius: var(--r-xs);
}
.snooze-menu button:hover { background: var(--accent-soft); color: var(--accent-ink); }

/* --------------------------------------------------------------- chat ------ */
.tile-body.chat-body { display: flex; padding: 0; overflow: hidden; }
.chat-history {
  width: 212px; min-width: 212px; border-right: 1px solid var(--hairline);
  background: var(--surface-2); display: flex; flex-direction: column;
  padding: .65rem; overflow-y: auto;
}
.chat-history.collapsed { display: none; }
.new-chat {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: .48rem .6rem; margin-bottom: .65rem; font-size: var(--fs-sm); font-weight: 600;
  color: var(--ink); display: flex; align-items: center; justify-content: center; gap: .4rem;
  box-shadow: var(--shadow-pop);
  transition: border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.new-chat .ic { width: 1rem; height: 1rem; }
.new-chat:hover { border-color: var(--ink-3); box-shadow: var(--shadow-sm); }
.conv-list { display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  padding: .5rem .6rem; border-radius: var(--r-sm); font-size: var(--fs-sm);
  cursor: pointer; color: var(--ink-2); transition: background var(--t-fast), color var(--t-fast);
}
.conv-item:hover { background: var(--surface-3); color: var(--ink); }
.conv-dock { display: flex; align-items: center; gap: 4px; font-size: var(--fs-2xs); margin-top: 2px; }
.conv-dock .ic { width: 12px; height: 12px; flex: none; }

.conv-item.active {
  background: var(--ink); color: var(--surface); font-weight: 650;
  box-shadow: var(--shadow-sm), var(--glow);
}
.conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .75rem; }
.chat-empty { margin: auto; text-align: center; max-width: 420px; padding: 1rem; color: var(--ink-2); }
.chat-empty .es-mark {
  width: 52px; height: 52px; margin: 0 auto .85rem; border-radius: 14px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  color: var(--ink-3); display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
}
.chat-empty .es-mark .ic { width: 1.5rem; height: 1.5rem; }
.chat-empty h3 { font-family: var(--font-display); font-size: 1.35rem; color: var(--ink); margin-bottom: .4rem; font-weight: 600; }
.chat-empty .chat-hint { margin: .1rem 0 0; font-size: var(--fs-xs); color: var(--ink-3); }

/* dock context chip in the chat tile head: neutral - context, not state */
.dock-chip {
  display: inline-flex; align-items: center; gap: .32rem; min-width: 0;
  max-width: 13rem; padding: .1rem .6rem .1rem .45rem;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .02em;
}
.dock-chip .ic { width: .8rem; height: .8rem; flex: none; }
.dock-chip .dock-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg {
  padding: .7rem .95rem; border-radius: 16px; max-width: 86%;
  white-space: pre-wrap; overflow-wrap: break-word; line-height: 1.55;
  animation: msg-in var(--t) both;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.user {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink) 88%, #ffffff), var(--ink));
  color: var(--surface); align-self: flex-end; border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.msg.assistant { background: var(--surface-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg .citations { margin-top: .6rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.citation-chip {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2);
  border-radius: var(--r-xs); padding: .12rem .5rem .12rem .42rem; font-size: var(--fs-xs);
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .28rem;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.citation-chip::before {
  content: ""; width: .62rem; height: .62rem; flex: none;
  background: currentColor;
  -webkit-mask: no-repeat center / contain; mask: no-repeat center / contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5V6a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5V6a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z'/%3E%3C/svg%3E");
  opacity: .8;
}
.citation-chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.msg .flag { margin-top: .45rem; }
/* thinking indicator: three pulsing dots while FATHM works */
.msg.typing {
  display: inline-flex; align-items: center; gap: .32rem;
  padding: .9rem 1.05rem; min-height: 0;
}
.msg.typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3); opacity: .45;
  animation: typing-pulse 1.2s infinite ease-in-out;
}
.msg.typing .dot:nth-child(2) { animation-delay: .18s; }
.msg.typing .dot:nth-child(3) { animation-delay: .36s; }
@keyframes typing-pulse {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.msg .flag button {
  background: none; border: none; color: var(--ink-3); font-size: var(--fs-xs);
  padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem;
}
.msg .flag button .ic { width: .85rem; height: .85rem; }
.msg .flag button:hover { color: var(--ink); }
.msg .flag button:disabled { cursor: default; color: var(--accent-ink); }

.chat-composer { display: flex; gap: .55rem; padding: .75rem; border-top: 1px solid var(--hairline); background: var(--surface); }
.chat-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: .6rem .75rem; font: inherit; background: var(--surface-2); color: var(--ink); min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.chat-composer textarea::placeholder { color: var(--ink-3); }
.chat-composer textarea:focus { outline: none; border-color: var(--ink); background: var(--surface); box-shadow: var(--focus); }
.chat-composer .primary { align-self: stretch; }

/* ------------------------------------------------------------ calendar ----- */
.cal-body { display: flex; flex-direction: column; }
.cal-label { font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; min-width: 4.6em; text-align: center; font-weight: 600; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { margin-bottom: 4px; }
.cal-dow span { font-size: var(--fs-2xs); color: var(--ink-3); text-align: center; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.cal-cell {
  background: var(--surface-2); border-radius: var(--r-xs); min-height: 46px;
  padding: 2px 3px; font-size: var(--fs-xs); overflow: hidden;
  border: 1px solid transparent; transition: border-color var(--t-fast), background var(--t-fast);
}
.cal-cell.blank { background: transparent; }
.cal-cell.today { border-color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm), var(--glow); }
.cal-cell.has-items { cursor: pointer; }
.cal-cell.has-items:hover { border-color: var(--line-2); background: var(--surface); }
.cal-daynum { font-weight: 600; color: var(--ink-3); font-size: var(--fs-2xs); }
.cal-cell.today .cal-daynum { color: var(--ink); }
.cal-chip {
  background: var(--accent-soft); color: var(--accent-ink); border-radius: 4px;
  padding: 0 3px; margin-top: 1px; font-size: 10px; line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-chip.satisfied { background: var(--surface-3); color: var(--ink-3); text-decoration: line-through; }
.cal-chip.missed, .cal-chip.waived { background: var(--surface-3); color: var(--ink-3); }
.cal-more { font-size: var(--fs-2xs); color: var(--ink-3); padding: 0 3px; }
.cal-detail { margin-top: .7rem; }
.cal-detail h3 { margin-bottom: .45rem; font-size: var(--fs-sm); color: var(--ink); }

/* -------------------------------------------------------- empty states ----- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .45rem; padding: 1.5rem 1rem; }
.empty-state .es-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  color: var(--ink-3); display: grid; place-items: center; margin-bottom: .1rem;
  box-shadow: var(--shadow-pop);
}
.empty-state .es-icon .ic { width: 1.35rem; height: 1.35rem; }
.empty-state.state .es-icon { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.empty-state .es-title { font-weight: 650; color: var(--ink); font-size: var(--fs-sm); }
.empty-state .es-sub { font-size: var(--fs-xs); color: var(--ink-2); max-width: 32ch; line-height: 1.5; }

/* ---------------------------------------------------------- skeletons ------ */
.skel {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: var(--r-xs);
}
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-row { border: 1px solid var(--line); border-radius: var(--r-md); padding: .6rem .7rem; margin-bottom: .5rem; display: flex; flex-direction: column; gap: .45rem; }
.skel-line { height: .72rem; }
.skel-line.sm { height: .58rem; }
.skel-conv { height: 1.9rem; margin-bottom: 4px; border-radius: var(--r-sm); }
.w40 { width: 40%; } .w55 { width: 55%; } .w70 { width: 70%; } .w90 { width: 90%; }

/* --------------------------------------------------- citation modal -------- */
.modal { position: fixed; inset: 0; background: rgb(10 11 13 / .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; animation: fade var(--t) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 1.5rem 1.6rem; width: min(640px, 94vw); max-height: 82vh; overflow: auto;
  position: relative; box-shadow: var(--shadow-lg);
  animation: modal-in var(--t) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-body .close { position: absolute; top: .8rem; right: .8rem; }
.modal-body h3 { margin: .1rem 0 .4rem; font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; padding-right: 1.5rem; letter-spacing: -.005em; }
.modal-body pre {
  white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line);
  padding: .9rem; border-radius: var(--r-md); font-size: .85em; line-height: 1.5;
  margin: .7rem 0; color: var(--ink);
}
.modal-status { display: flex; align-items: center; gap: .35rem; font-weight: 500; }

/* ---------------------------------------------------------------- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--surface); border-radius: var(--r-pill);
  padding: .6rem 1.25rem; font-size: var(--fs-sm); font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity var(--t), transform var(--t);
  z-index: 120; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------- scrollbars ------ */
.tile-body, .chat-messages, .chat-history, .modal-body { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tile-body::-webkit-scrollbar, .chat-messages::-webkit-scrollbar, .chat-history::-webkit-scrollbar { width: 9px; height: 9px; }
.tile-body::-webkit-scrollbar-thumb, .chat-messages::-webkit-scrollbar-thumb, .chat-history::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.tile-body::-webkit-scrollbar-thumb:hover, .chat-messages::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: padding-box; }

/* --------------------------------------------------------- responsive ------ */
@media (max-width: 1100px) {
  .sidebar { width: 72px; min-width: 72px; padding: var(--sp-4) .6rem; }
  .sidebar .brand-text, .sidebar nav a .label, .sidebar .user-meta { display: none; }
  .brand { justify-content: center; padding: .1rem 0 var(--sp-5); }
  .sidebar nav a { justify-content: center; padding: .6rem; }
  .sidebar-foot { justify-content: center; }
}
@media (max-width: 720px) {
  .content { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .page-head { gap: .7rem; }
  .head-actions { margin-left: auto; }
}

/* --------------------------------------- static fallback (no GridStack) ---- */
.grid-stack.no-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.grid-stack.no-grid > .grid-stack-item { position: static; }
.grid-stack.no-grid > .grid-stack-item > .grid-stack-item-content { position: relative; inset: auto; height: 520px; }
.grid-stack.no-grid > [gs-id="deadlines"], .grid-stack.no-grid > [gs-id="touchpoints"], .grid-stack.no-grid > [gs-id="calendar"], .grid-stack.no-grid > [gs-id="docks"] { grid-column: span 3; }
.grid-stack.no-grid > [gs-id="chat"] { grid-column: span 6; }
@media (max-width: 900px) { .grid-stack.no-grid > .grid-stack-item { grid-column: span 12 !important; } }

/* --------------------------------------------------- reduced motion -------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .skel { animation: none; background: var(--surface-3); }
  .msg.typing .dot { animation: none; opacity: .55; }
}

/* ------------------------------------------------ notifications bell ------- */
.bell-wrap { position: relative; }
.bell-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: var(--r-pill);
  background: var(--accent); color: var(--on-accent);
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center;
  pointer-events: none; box-shadow: 0 0 0 2px var(--bg);
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120;
  width: min(360px, 88vw); max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: fade var(--t) both;
}
.bell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .85rem; border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-2);
  position: sticky; top: 0; background: var(--surface);
}
.bell-head .linklike { color: var(--accent-strong); font-size: var(--fs-xs); }
.bell-head .linklike:hover { color: var(--accent-ink); }
.bell-item { padding: .6rem .85rem; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: var(--accent-soft); }
.bell-item.unread:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--surface)); }
.bell-item-head { display: flex; justify-content: space-between; gap: .6rem; margin-bottom: .15rem; }
.bell-item-title { font-size: var(--fs-sm); font-weight: 600; }
.bell-item.unread .bell-item-title::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); margin-right: .4rem;
}
.bell-item-time { font-size: var(--fs-2xs); color: var(--ink-3); flex: none; }
.bell-item-body {
  font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bell-empty { padding: .9rem .85rem; font-size: var(--fs-sm); }

/* --------------------------------------------------- docks + upload -------- */
.dock-head { display: flex; align-items: center; gap: .1rem; }
.dock-head .dock-row { flex: 1 1 auto; min-width: 0; width: auto; }
.dock-chat { flex: none; }
.dock-row {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .55rem .55rem; border-radius: var(--r-md);
  border: 1px solid transparent; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.dock-row:hover {
  background: var(--surface-2); border-color: var(--line);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.dock-kind {
  flex: none; width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  color: var(--ink-2); display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
}
.dock-kind .ic { width: 1rem; height: 1rem; }
.dock-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .06rem; }
.dock-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); letter-spacing: -.005em; }
.dock-meta { font-size: var(--fs-2xs); color: var(--ink-3); }

.dock-caret {
  flex: none; width: .85rem; height: .85rem; color: var(--ink-3);
  transition: transform var(--t-fast);
}
.dock-entry.open .dock-caret { transform: rotate(90deg); }
.dock-docs {
  margin: .1rem .55rem .45rem calc(.55rem + 32px + .7rem);
  padding-left: .7rem; border-left: 2px solid var(--line);
  display: flex; flex-direction: column; gap: .1rem;
}
.dock-doc { display: flex; align-items: center; gap: .55rem; padding: .3rem .3rem; border-radius: var(--r-sm); }
.dock-doc:hover { background: var(--surface-2); }
.dock-doc > .ic { flex: none; width: .95rem; height: .95rem; color: var(--ink-3); }
.dock-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); font-weight: 500; }
.dock-doc-note { margin: .2rem 0 .3rem; font-size: var(--fs-sm); }
.dock-review { flex: none; margin-left: auto; white-space: nowrap; font-size: var(--fs-2xs); }
.dock-review:disabled { opacity: .55; cursor: default; pointer-events: none; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgb(10 11 13 / .48);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  pointer-events: none; animation: fade var(--t) both;
}
.drop-overlay.hidden { display: none; }
.drop-inner {
  text-align: center; color: #fff; font-size: 1.05rem; font-weight: 500;
  border: 2px dashed rgb(255 255 255 / .65); border-radius: var(--r-xl);
  padding: 2.6rem 3.4rem; background: rgb(255 255 255 / .06);
}
.drop-inner .ic.big { width: 42px; height: 42px; margin: 0 auto .7rem; }
.drop-inner p { margin: 0; }

#upload-detail { margin: .7rem 0; line-height: 1.6; }
.upload-candidates { display: flex; flex-wrap: wrap; gap: .5rem; margin: .7rem 0; }
.upload-candidates .dock-pick { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); }
.upload-candidates .dock-pick .ic { width: .9rem; height: .9rem; color: var(--ink-3); }
.upload-newdock { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.upload-newdock input[type="text"] {
  flex: 1 1 200px; min-width: 0; padding: .5rem .7rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: inherit; font: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.upload-newdock input[type="text"]:focus { outline: none; border-color: var(--ink); background: var(--surface); box-shadow: var(--focus); }
.upload-newdock select {
  padding: .5rem .5rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: inherit; font: inherit;
}
