/* Susie: warm eggshell, pastel aurora, frosted glass, liquid motion.
   References Edward picked: ElevenLabs (eggshell + pills), Monad (pastel washes),
   monopo (liquid iridescence, patient easing), Air (glass, thin borders). */
@font-face { font-family: 'Manrope'; src: url('/fonts/manrope-latin.woff2') format('woff2'); font-weight: 200 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Manrope'; src: url('/fonts/manrope-latin-ext.woff2') format('woff2'); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #fbfaf7;
  --ink: #1b1b1b;
  --ink-2: #6f6a63;
  --ink-3: #a59f97;
  --line: rgba(40, 30, 20, 0.09);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.84);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.05), 0 2px 8px rgba(60, 40, 20, 0.04);
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.04), 0 10px 32px rgba(60, 40, 20, 0.08);
  --me: linear-gradient(135deg, #e3eaff 0%, #eee5fb 55%, #fbe9ec 100%);
  --me-ink: #1b1b1b;
  --button: #1f1f1f;
  --button-ink: #ffffff;
  --link: #2b59d1;
  --ok: #2f9e6a;
  --warn: #d4860f;
  --bad: #d4483f;
  --spot: rgba(255, 255, 255, 0.75);
  --aurora-1: #ff9473; --aurora-2: #a0b5eb; --aurora-3: #a7fccd; --aurora-4: #ecda98;
  --aurora-opacity: 0.42;
  --grain-opacity: 0.05;
  --iris: linear-gradient(255deg, #FACB0E, #F06BA8 30%, #78BAE6 65%, #FFFFFF);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --glide: cubic-bezier(0.19, 1, 0.22, 1);
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e11; --ink: #f1efea; --ink-2: #a8a39b; --ink-3: #6f6b65; --line: rgba(255, 255, 255, 0.08);
    --glass: rgba(30, 31, 37, 0.55); --glass-strong: rgba(38, 39, 46, 0.86); --glass-edge: rgba(255, 255, 255, 0.09); --glass-hi: rgba(255, 255, 255, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    --me: linear-gradient(135deg, #283458 0%, #33294d 60%, #45283a 100%); --me-ink: #f4f2ee;
    --button: #f1efea; --button-ink: #111214; --link: #8fa8ff; --spot: rgba(255, 255, 255, 0.12);
    --aurora-1: #b8542f; --aurora-2: #3c55c4; --aurora-3: #1f8f6d; --aurora-4: #8a6a1e; --aurora-opacity: 0.3; --grain-opacity: 0.07;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e11; --ink: #f1efea; --ink-2: #a8a39b; --ink-3: #6f6b65; --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(30, 31, 37, 0.55); --glass-strong: rgba(38, 39, 46, 0.86); --glass-edge: rgba(255, 255, 255, 0.09); --glass-hi: rgba(255, 255, 255, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --me: linear-gradient(135deg, #283458 0%, #33294d 60%, #45283a 100%); --me-ink: #f4f2ee;
  --button: #f1efea; --button-ink: #111214; --link: #8fa8ff; --spot: rgba(255, 255, 255, 0.12);
  --aurora-1: #b8542f; --aurora-2: #3c55c4; --aurora-3: #1f8f6d; --aurora-4: #8a6a1e; --aurora-opacity: 0.3; --grain-opacity: 0.07;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; overflow: hidden; gap: 12px; padding: 12px;
}
button, input, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
[hidden] { display: none !important; }

/* ---------- atmosphere: aurora + grain ---------- */
.aurora {
  position: fixed; inset: 0; z-index: -2; pointer-events: none; opacity: var(--aurora-opacity);
  background:
    radial-gradient(42vmax 42vmax at 82% 8%, var(--aurora-1), transparent 70%),
    radial-gradient(52vmax 52vmax at 12% 30%, var(--aurora-2), transparent 70%),
    radial-gradient(44vmax 44vmax at 55% 92%, var(--aurora-3), transparent 70%),
    radial-gradient(34vmax 34vmax at 95% 85%, var(--aurora-4), transparent 70%);
}
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow);
}

/* Liquid highlight that follows the pointer (JS sets --mx/--my on hover). */
.lg { position: relative; overflow: hidden; isolation: isolate; }
.lg::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 0.35s var(--glide);
  background: radial-gradient(140px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%);
}
.lg:hover::before { opacity: 1; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--glass-strong); border-radius: 999px;
  padding: 8px 18px; min-height: 40px; cursor: pointer; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-sm); transition: transform 0.45s var(--spring), box-shadow 0.3s var(--glide), background 0.3s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: scale(0.96); transition-duration: 0.12s; }
.btn.primary { background: var(--button); color: var(--button-ink); border-color: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 999px;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: transform 0.45s var(--spring), background 0.25s, color 0.25s;
}
.icon-btn:hover { background: var(--glass-strong); color: var(--ink); transform: scale(1.06); }
.icon-btn:active { transform: scale(0.92); transition-duration: 0.12s; }
.link-btn { border: 0; background: none; padding: 0; text-decoration: underline; cursor: pointer; font-weight: 700; color: inherit; }

/* ---------- orb ---------- */
.orb {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-block; position: relative;
  background: var(--iris); background-size: 160% 160%; background-position: 30% 40%;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.08), inset 0 2px 4px rgba(255, 255, 255, 0.7), 0 2px 10px rgba(240, 107, 168, 0.25);
}
.orb::after { content: ''; position: absolute; left: 22%; top: 14%; width: 34%; height: 24%; border-radius: 50%; background: rgba(255, 255, 255, 0.65); filter: blur(1.5px); }
.orb.small { width: 22px; height: 22px; }
#brand-orb, .welcome .orb { animation: orb-shift 9s ease-in-out infinite alternate; }
.orb.thinking { animation: orb-shift 2.4s ease-in-out infinite alternate, breathe 1.6s ease-in-out infinite; }
@keyframes orb-shift { from { background-position: 0% 30%; } to { background-position: 100% 70%; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 10px 0 14px; border-radius: 22px; flex: none; position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; padding-right: 4px; }
.wordmark { font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.modes {
  position: relative; display: flex; gap: 2px; padding: 4px; border-radius: 999px; min-width: 0; flex: 0 1 auto;
  overflow-x: auto; scrollbar-width: none; background: rgba(127, 120, 110, 0.08);
}
.modes::-webkit-scrollbar { display: none; }
.mode-glider {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px; z-index: 0;
  background: var(--glass-strong); box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
  transition: left 0.6s var(--glide), width 0.6s var(--glide);
}
.mode-glider::after { content: ''; position: absolute; left: 30%; right: 30%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--iris); }
.mode-tab {
  position: relative; z-index: 1; border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: color 0.3s, transform 0.45s var(--spring);
}
.mode-tab:hover { color: var(--ink); }
.mode-tab:active { transform: scale(0.95); }
.mode-tab.active { color: var(--ink); }
.mode-tab.add { color: var(--ink-3); font-weight: 500; cursor: default; }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.usage {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--glass-strong);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: default; white-space: nowrap; color: var(--ink-2);
}
.usage .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); box-shadow: 0 0 0 3px rgba(127, 120, 110, 0.12); }
.usage.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.usage.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent); }
.usage.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent); }

.banner {
  padding: 12px 18px; border-radius: 18px; font-size: 14px; flex: none;
  background: color-mix(in srgb, var(--warn) 12%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ---------- layout ---------- */
.layout { flex: 1; display: flex; gap: 12px; min-height: 0; }
.sidebar {
  width: 290px; flex: none; display: flex; flex-direction: column; padding: 16px 12px; gap: 20px;
  overflow-y: auto; border-radius: 24px; z-index: 4;
}
.side-section { display: flex; flex-direction: column; gap: 8px; }
.side-section.grow { flex: 1; min-height: 0; }
.side-section > .label { padding: 0 8px; }
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 10px; border-radius: 14px; cursor: pointer; font-weight: 600; min-height: 44px;
  transition: background 0.25s, transform 0.45s var(--spring);
}
.side-item:hover { background: var(--glass-strong); transform: translateX(2px); }
.side-item:active { transform: scale(0.98); }
.side-text { display: flex; flex-direction: column; line-height: 1.2; }
.side-name { font-size: 14px; font-weight: 600; }
.side-role { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.side-note { margin: 0; padding: 0 10px; }
.new-thread { flex: none; }
.side-mode { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.thread-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding: 2px; margin: -2px; }
.thread-item {
  display: block; width: 100%; text-align: left; border: 1px solid transparent; background: none; padding: 9px 12px;
  border-radius: 14px; cursor: pointer; min-height: 48px;
  transition: background 0.25s, transform 0.45s var(--spring), border-color 0.25s, box-shadow 0.25s;
}
.thread-item:hover { background: var(--glass-strong); transform: translateX(2px); }
.thread-item:active { transform: scale(0.98); }
.thread-item.active { background: var(--glass-strong); border-color: var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm); }
.thread-item .t-title { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.thread-item .t-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item .t-meta { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.busy-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--iris); flex: none; animation: breathe 1.4s ease-in-out infinite; }
.empty-note { color: var(--ink-3); font-size: 13px; padding: 8px 10px; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; }
/* Floating header pill. Messages slide under it and are cut off cleanly behind it (no fade). */
.thread-head {
  position: absolute; top: 4px; left: 16px; right: 16px; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 20px; border-radius: 22px;
  background: var(--bg); border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
}
/* The scroller is clipped at the middle of the pill: above that line nothing shows, below it the
   opaque pill covers what scrolls under it. Message content always sits inside the pill's width. */
.messages { clip-path: inset(var(--head-cut, 36px) 0 0 0); }
.thread-head .label { line-height: 1.3; }
.thread-title {
  margin: 1px 0 0; font-size: 21px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15;
}
.thread-file { text-align: right; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); }
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 96px 28px 24px; display: flex; flex-direction: column; gap: 6px;
  overflow-anchor: none;
}

.welcome { margin: auto; max-width: 560px; text-align: center; padding: 32px 16px; animation: rise 0.9s var(--glide) both; }
.welcome .orb { width: 72px; height: 72px; margin-bottom: 20px; }
.welcome h2 { margin: 0 0 10px; font-size: 40px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; }
.welcome p { margin: 0; font-size: 17px; }

/* messages: Susie on the left, Edward on the right */
.msg { display: flex; gap: 10px; max-width: 780px; width: 100%; align-items: flex-end; }
.msg.group-start { margin-top: 12px; }
.msg.edward { align-self: flex-end; justify-content: flex-end; }
.msg.susie, .msg.system, .msg.agent { align-self: flex-start; }
.msg .avatar-slot { width: 30px; flex: none; display: flex; align-items: flex-end; }
.msg .stack { display: flex; flex-direction: column; min-width: 0; max-width: min(640px, 86%); }
.msg.edward .stack { align-items: flex-end; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--ink-2); margin: 0 12px 4px; display: flex; gap: 8px; align-items: baseline; }
.msg .who time { font-weight: 500; color: var(--ink-3); }
.msg .bubble {
  padding: 11px 16px; border-radius: 22px; overflow-wrap: anywhere; min-width: 0;
  background: var(--glass-strong); border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
}
.msg.susie .bubble, .msg.agent .bubble { border-bottom-left-radius: 8px; }
.msg.edward .bubble { background: var(--me); color: var(--me-ink); border-color: transparent; border-bottom-right-radius: 8px; }
.msg.system .bubble { background: color-mix(in srgb, var(--warn) 10%, var(--glass-strong)); border-color: color-mix(in srgb, var(--warn) 28%, transparent); font-size: 14px; }
.msg.system .avatar-slot::before { content: '!'; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--warn); }
.msg .stamp { font-size: 11px; color: var(--ink-3); margin: 4px 12px 0; opacity: 0; transition: opacity 0.3s; }
.msg:hover .stamp, .msg.group-end .stamp { opacity: 1; }
.msg.enter { animation: rise 0.55s var(--glide) both; }
.msg.edward.enter { animation-name: rise-right; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes rise-right { from { opacity: 0; transform: translate(10px, 8px) scale(0.98); } to { opacity: 1; transform: none; } }

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble li + li { margin-top: 2px; }
.bubble a { color: var(--link); text-underline-offset: 3px; }
.bubble pre { background: rgba(127, 120, 110, 0.1); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 13px; }
.bubble code { background: rgba(127, 120, 110, 0.12); padding: 1px 5px; border-radius: 6px; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; margin: 0 0 10px; font-size: 14px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border-bottom: 1px solid var(--line); padding: 6px 12px 6px 0; text-align: left; }
.bubble blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-2); }
.bubble h1, .bubble h2, .bubble h3 { font-size: 16px; margin: 14px 0 6px; font-weight: 700; }
.cursor > :last-child::after, .cursor:empty::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--iris); animation: breathe 1s ease-in-out infinite; vertical-align: middle; }

.status-line { display: flex; align-items: center; gap: 10px; padding: 0 28px 8px; font-size: 13px; color: var(--ink-2); flex: none; animation: rise 0.4s var(--glide) both; }

/* composer: a floating glass capsule */
.composer {
  display: flex; gap: 8px; align-items: flex-end; margin: 0 16px calc(4px + env(safe-area-inset-bottom));
  padding: 8px 8px 8px 20px; border-radius: 28px; flex: none; transition: box-shadow 0.35s var(--glide), transform 0.45s var(--spring);
}
.composer:focus-within { box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 4px color-mix(in srgb, var(--link) 12%, transparent), var(--shadow); }
.composer textarea {
  flex: 1; resize: none; border: 0; background: transparent; padding: 10px 0; min-height: 44px; max-height: 40vh; line-height: 1.45; outline: none;
}
.composer textarea::placeholder { color: var(--ink-3); }
.send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; cursor: pointer; display: grid; place-items: center;
  background: var(--button); color: var(--button-ink); box-shadow: var(--shadow-sm);
  transition: transform 0.45s var(--spring), opacity 0.2s, box-shadow 0.3s;
}
.send:hover { transform: scale(1.07); box-shadow: var(--shadow); }
.send:active { transform: scale(0.9); transition-duration: 0.12s; }
.send:disabled { opacity: 0.35; transform: none; cursor: default; }
.send.stop { background: var(--glass-strong); color: var(--ink); border: 1px solid var(--line); }

/* ---------- settings ---------- */
.settings {
  border: 1px solid var(--glass-edge); background: color-mix(in srgb, var(--bg) 96%, transparent); color: var(--ink); padding: 0; border-radius: 28px;
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); overscroll-behavior: contain;
}
.settings[open] { animation: pop 0.3s var(--glide) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
.settings::backdrop { background: rgba(20, 16, 12, 0.28); }
.settings-inner { padding: 22px 26px 26px; display: flex; flex-direction: column; gap: 24px; }
.settings-head { display: flex; justify-content: space-between; align-items: center; }
.settings h2 { margin: 0; font-size: 24px; font-weight: 300; letter-spacing: -0.02em; }
.settings section { display: flex; flex-direction: column; gap: 8px; }
.settings textarea {
  width: 100%; border: 1px solid var(--line); background: var(--glass); border-radius: 18px; padding: 14px 16px;
  font-size: 14px; line-height: 1.5; resize: vertical; outline: none; transition: box-shadow 0.3s;
}
.settings textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--link) 12%, transparent); }
.settings p { margin: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- team ---------- */
.team { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding: 2px; margin: -2px; flex: 1; min-height: 0; }
.susie-item { margin-bottom: 6px; }
.unread-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--link); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 18%, transparent); }
.side-item .busy-dot { margin-left: auto; }
.orb.tiny { width: 16px; height: 16px; }
.day { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; color: var(--ink-3); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.load-earlier { display: flex; justify-content: center; padding: 4px 0 8px; }
.team-group { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 10px 2px; }
.side-item.active { background: var(--glass-strong); box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm); }
.agent-item.open { background: var(--glass-strong); }
.agent-item .busy-dot { margin-left: auto; }
.agent-threads { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 6px 18px; margin-left: 12px; border-left: 1px solid var(--line); }
.agent-threads .thread-item { min-height: 40px; padding: 7px 10px; }
.thread-item.new-with .t-title { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.new-agent { margin-top: 8px; flex: none; }
.agent-av {
  --h: 200; width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  font-size: 13px; font-weight: 700; color: hsl(var(--h) 45% 28%);
  background: linear-gradient(145deg, hsl(var(--h) 85% 90%), hsl(calc(var(--h) + 40) 70% 82%));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 3px rgba(0, 0, 0, 0.06);
}
:root[data-theme="dark"] .agent-av { color: hsl(var(--h) 80% 88%); background: linear-gradient(145deg, hsl(var(--h) 35% 32%), hsl(calc(var(--h) + 40) 30% 24%)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .agent-av { color: hsl(var(--h) 80% 88%); background: linear-gradient(145deg, hsl(var(--h) 35% 32%), hsl(calc(var(--h) + 40) 30% 24%)); } }
.agent-av.tiny { width: 20px; height: 20px; font-size: 10px; vertical-align: -5px; }
.agent-av.big { width: 72px; height: 72px; font-size: 30px; font-weight: 600; margin-bottom: 20px; }
.msg .avatar-slot .agent-av { width: 24px; height: 24px; font-size: 11px; }
#thread-mode { display: flex; align-items: center; gap: 6px; }

/* ---------- cards: hand-off, proposal ---------- */
.msg.cardrow { align-self: center; max-width: 640px; margin: 10px 0; }
.card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px 8px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
  font-size: 13px; color: var(--ink-2);
}
.card.proposal { border-radius: 20px; padding: 12px 14px; align-items: flex-start; flex-wrap: wrap; }
.card-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card, .msg .bubble, .ap-body, .ap-body li, .em-text, .em-row div { overflow-wrap: anywhere; word-break: break-word; }
.msg.cardrow { min-width: 0; max-width: min(640px, 100%); }
.em-note { margin-top: 10px; }
.card-text p { margin: 0; }
.card.guess .card-text { color: var(--ink); }
.card.is-moved { opacity: 0.6; }
.card-arrow { color: var(--ink-3); font-weight: 700; }
.card-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.card.proposal .card-actions { flex-basis: 100%; justify-content: flex-end; }
.chip-btn {
  border: 1px solid var(--line); background: var(--glass-strong); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: transform 0.45s var(--spring), box-shadow 0.25s;
}
.chip-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip-btn:active { transform: scale(0.95); }
.chip-btn.primary { background: var(--button); color: var(--button-ink); border-color: transparent; }
.chip-btn.inline { margin-top: 8px; }
.chip { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 4px 8px; }
.move-menu {
  position: fixed; z-index: 50; min-width: 240px; max-height: 60vh; overflow-y: auto; padding: 8px; border-radius: 18px;
  background: var(--glass-strong); animation: pop 0.35s var(--spring) both;
}
.move-menu .label { padding: 4px 8px 6px; }
.move-opt { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600; }
.move-opt:hover { background: var(--glass); }

/* ---------- approval cards ---------- */
.card.approval { display: block; border-radius: 22px; padding: 14px 16px; color: var(--ink); background: var(--glass-strong); border-color: color-mix(in srgb, var(--warn) 35%, var(--glass-edge)); }
.card.approval.high { border-color: color-mix(in srgb, var(--bad) 45%, var(--glass-edge)); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 3px color-mix(in srgb, var(--bad) 10%, transparent), var(--shadow-sm); }
.card.approval:not(.st-pending) { opacity: 0.75; border-color: var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi); }
.ap-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ap-head .chip { margin-left: auto; }
.ap-body { font-size: 14px; }
.ap-body p { margin: 0 0 8px; }
.ap-body ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.ap-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.ap-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ap-field textarea { border: 1px solid var(--line); background: var(--glass); border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.45; resize: vertical; outline: none; }
.approvals-pill { cursor: pointer; color: var(--ink); }
.approvals-pill .dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); animation: breathe 1.6s ease-in-out infinite; }

/* ---------- email cards ---------- */
.card.approval.email { max-width: 640px; }
.em-reply { margin: 0 0 8px; }
.em-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; font-size: 14px; }
.em-row > span { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.em-row input { border: 0; background: transparent; padding: 6px 0; outline: none; font-size: 14px; width: 100%; }
.em-text { width: 100%; margin-top: 10px; border: 1px solid var(--line); background: var(--glass); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.55; resize: vertical; outline: none; }
.em-text:focus, .em-row input:focus { box-shadow: none; }
.em-text.read { background: transparent; }
.chip.ok { color: var(--ok); }
.chip.bad { color: var(--bad); }
.chip-btn.subtle { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-3); margin-right: auto; }
.chip-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.ap-details { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ap-raw { display: block; font-size: 11px; color: var(--ink-3); word-break: break-all; white-space: pre-wrap; }

/* ---------- tasks ---------- */
.tasks-btn { cursor: pointer; color: var(--ink); gap: 6px; }
.tasks-btn.has-due { border-color: color-mix(in srgb, var(--link) 35%, var(--line)); }
.tasks-panel {
  position: fixed; top: 80px; right: 16px; z-index: 40; width: min(420px, calc(100vw - 24px)); max-height: min(70vh, 640px);
  display: flex; flex-direction: column; border-radius: 22px; padding: 14px; background: var(--glass-strong); animation: pop 0.4s var(--spring) both;
}
.tp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px 10px; }
.tp-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.tp-head a { color: inherit; }
.tp-add { display: flex; gap: 6px; margin-bottom: 8px; }
.tp-add input { border: 1px solid var(--line); background: var(--glass); border-radius: 12px; padding: 8px 10px; font-size: 14px; outline: none; min-width: 0; }
.tp-add #tp-title { flex: 1; }
.tp-add #tp-due { width: 132px; color: var(--ink-2); }
.tp-add #tp-when { border: 1px solid var(--line); background: var(--glass); border-radius: 12px; padding: 8px 8px; font: inherit; font-size: 14px; color: var(--ink-2); outline: none; max-width: 120px; }
.tp-section.empty { display: none; }
.tp-list.drag-on .tp-section.empty { display: block; }
.tp-section { border-radius: 14px; transition: background 0.15s; }
.tp-list.drag-on .tp-section[data-group] { outline: 1px dashed transparent; }
.tp-section.over { background: color-mix(in srgb, var(--link) 10%, transparent); outline: 1px dashed color-mix(in srgb, var(--link) 45%, transparent) !important; }
.tp-drop-hint { font-size: 13px; color: var(--ink-3); padding: 8px 6px 10px 34px; }
.tp-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.tp-grip { flex: none; width: 22px; height: 30px; display: grid; place-items: center; color: var(--ink-3); opacity: 0.45; cursor: grab; touch-action: none; margin: 0 -4px 0 -6px; }
.tp-item:hover .tp-grip { opacity: 0.9; }
.tp-item.dragging { opacity: 0.3; }
.tp-ghost { position: fixed; z-index: 100; pointer-events: none; background: var(--glass-strong); border-radius: 12px; box-shadow: var(--shadow-sm), 0 12px 32px rgba(0,0,0,0.14); transform: rotate(-1deg) scale(1.02); }
@media (pointer: coarse) { .tp-grip { opacity: 0.7; width: 30px; } }
.tp-list { overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.tp-group { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 6px 4px; }
.tp-group.overdue { color: var(--bad); }
.tp-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; cursor: pointer; font-size: 14px; transition: background 0.2s, opacity 0.4s; }
.tp-item:hover { background: var(--glass); }
.tp-item input { width: 18px; height: 18px; accent-color: var(--ink); flex: none; }
.tp-item.done { opacity: 0.4; text-decoration: line-through; }
.tp-text { flex: 1; min-width: 0; }
.tp-text a { color: inherit; text-decoration: none; }
.tp-text a:hover { text-decoration: underline; }
.tp-due { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.tp-empty { padding: 16px 6px; color: var(--ink-3); font-size: 14px; }
.steps { margin: 6px 0 10px; padding-left: 20px; }
.steps li { margin-bottom: 4px; }
#notion-box p { margin: 0 0 8px; }
#notion-box input { flex: 1; border: 1px solid var(--line); background: var(--glass); border-radius: 12px; padding: 9px 12px; outline: none; }

/* ---------- phone settings ---------- */
.dev-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dev { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--glass); }
.code-big { font-size: 22px; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; margin: 0 4px; }

/* ---------- attachments ---------- */
.attach-btn { flex: none; align-self: flex-end; margin: 2px -4px 2px -8px; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 16px 6px; }
.att-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 240px; padding: 4px 6px 4px 4px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--glass-edge); font-size: 13px; box-shadow: var(--shadow-sm); }
.att-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 8px; }
.file-glyph { width: 32px; height: 32px; display: grid; place-items: center; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-x { border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-3); padding: 0 4px; }
.bubble img { display: block; max-width: 100%; max-height: 360px; border-radius: 12px; margin: 6px 0; }
.main.dropping::after { content: 'Drop files to attach'; position: absolute; inset: 8px; z-index: 6; display: grid; place-items: center; border: 2px dashed color-mix(in srgb, var(--link) 50%, transparent); border-radius: 24px; background: color-mix(in srgb, var(--bg) 80%, transparent); font-weight: 600; color: var(--ink-2); }

/* ---------- learning ---------- */
.card.learned { border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--ink-2); background: var(--glass); }
.card.learned .card-arrow { color: var(--ok); }
.card.learning .label { color: var(--ink-3); }
.card.approval.st-superseded { opacity: 0.5; }
@media (max-width: 767px) { .attachments { margin: 0 0 6px; } }

/* ---------- activity lines, teammates, questions ---------- */
.event-line { display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 6px; width: fit-content; max-width: 92%; margin: 4px auto; padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); text-align: center; }
.event-line b { font-weight: 600; color: var(--ink); }
.event-line .ev-icon { color: var(--ink-3); flex: none; }
.event-line .ev-text { min-width: 0; }
.event-line .ev-text p { margin: 0; }
.event-line > :not(.ev-text) { flex: none; }
.event-line .link-btn { font-size: 13px; padding: 2px 4px; }
.event-line .chip { font-size: 11px; padding: 1px 8px; }
.faces { display: inline-flex; }
.faces .agent-av { box-shadow: 0 0 0 2px var(--bg); }
.faces .agent-av + .agent-av { margin-left: -6px; }
.msg.cardrow:has(> .ev-more) { flex-direction: column; align-items: center; gap: 0; }
.ev-more { max-width: 560px; margin: -2px auto 4px; text-align: left; font-size: 13px; }
.ev-more summary { cursor: pointer; color: var(--ink-3); text-align: center; list-style: none; }
.ev-more summary::-webkit-details-marker { display: none; }
.ev-more > div { margin-top: 6px; padding: 10px 14px; border-radius: 14px; background: var(--glass); color: var(--ink-2); }
.who-tag { font-weight: 400; color: var(--ink-3); }
.sum-title { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.card.question { flex-direction: column; align-items: stretch; gap: 8px; max-width: 520px; }
.card.question .ap-head { display: flex; align-items: center; gap: 8px; }
.q-text p { margin: 0; font-size: 15px; font-weight: 600; }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q-other { display: flex; gap: 6px; }
.q-other input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--glass); border-radius: 12px; padding: 8px 10px; font: inherit; font-size: 14px; color: var(--ink); outline: none; }
.q-answer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass); font-size: 14px; }
.q-answer .ev-icon { color: var(--ok); width: 16px; height: 16px; }
.status-face { display: inline-grid; place-items: center; }
.status-face .agent-av { animation: breathe 1.6s ease-in-out infinite; }

/* ---------- schedules ---------- */
.sp-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 6px; border-radius: 14px; transition: background 0.2s, opacity 0.3s; }
.sp-item:hover { background: var(--glass); }
.sp-item.off .sp-main { opacity: 0.55; }
.sp-main { flex: 1; min-width: 0; }
.sp-name { font-size: 14px; font-weight: 600; }
.sp-when { margin-top: 1px; }
.sp-more summary { cursor: pointer; list-style: none; margin-top: 2px; }
.sp-more summary::-webkit-details-marker { display: none; }
.sp-more[open] summary { margin-bottom: 4px; }
.sp-more div { white-space: pre-wrap; color: var(--ink-2); }
.sp-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.small-x { width: 30px; height: 30px; font-size: 18px; color: var(--ink-3); }
.sp-foot { border-top: 1px solid var(--line); margin-top: 8px; padding: 10px 4px 0; }
.sp-idea { display: flex; align-items: flex-start; gap: 10px; padding: 10px 8px; margin: 4px 0; border-radius: 14px; border: 1px dashed var(--line); }
.sp-about { color: var(--ink-2); margin-top: 3px; }
.sp-needs { color: var(--ink-3); margin-top: 4px; font-style: italic; }
.chip.tiny { font-size: 10px; padding: 1px 6px; vertical-align: 2px; }
.switch { position: relative; flex: none; width: 34px; height: 20px; margin-top: 2px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.25s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.3s var(--spring); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.head-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head-sched { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.schedule-card .card-arrow { display: grid; place-items: center; color: var(--ink-3); }

/* ---------- effort ---------- */
.effort-btn { flex: none; align-self: flex-end; margin: 2px 0; width: auto; min-width: 36px; height: 36px; padding: 0 8px; gap: 3px; display: inline-flex; flex-direction: row; align-items: center; white-space: nowrap; border-radius: 999px; color: var(--ink-3); transition: background 0.25s, color 0.25s; }
.effort-btn .effort-label { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.effort-btn .effort-label:empty { display: none; }
.effort-btn[data-level="extra"] { color: #a35f00; background: color-mix(in srgb, #ffb340 30%, transparent); }
.effort-btn[data-level="max"] { color: #fff; background: linear-gradient(135deg, #ff8a3d, #e0457b); }
.effort-btn[data-level="extra"] svg, .effort-btn[data-level="max"] svg { fill: currentColor; }
@media (max-width: 767px) {
  .sched-btn-label, #sched-label { display: none; }
  .head-sched span { display: none; }
  .effort-btn { min-width: 32px; padding: 0 6px; }
}

/* ---------- form fields (new agent) ---------- */
.fields { gap: 14px !important; }
.fields label { display: flex; flex-direction: column; gap: 6px; }
.fields input, .fields select {
  border: 1px solid var(--line); background: var(--glass); border-radius: 14px; padding: 10px 14px; outline: none; font-size: 15px;
}
.fields input:focus, .fields select:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--link) 12%, transparent); }

.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(20, 16, 12, 0.25); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); z-index: 20; }

/* ---------- phone ---------- */
@media (max-width: 767px) {
  body { padding: 8px; gap: 8px; }
  .only-mobile { display: inline-grid; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 8px 8px 10px; row-gap: 8px; border-radius: 20px; }
  .modes { order: 3; flex: 1 1 100%; }
  .usage { padding: 6px 10px; }
  .usage #usage-label { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
  .sidebar {
    position: fixed; top: 8px; bottom: 8px; left: 8px; z-index: 30; width: min(320px, 84vw);
    transform: translateX(calc(-100% - 16px)); transition: transform 0.5s var(--glide); padding-top: 20px;
    background: var(--glass-strong);
  }
  .sidebar.open { transform: none; }
  .thread-head { left: 4px; right: 4px; top: 2px; padding: 8px 14px; border-radius: 18px; }
  .thread-title { font-size: 18px; }
  .thread-title { font-size: 22px; }
  .thread-file { display: none; }
  .messages { padding: 82px 8px 16px; --head-cut: 30px; }
  .tasks-panel { top: 120px; right: 8px; }
  .tasks-btn #tasks-label { display: none; }
  .msg .stack { max-width: 88%; }
  .msg .avatar-slot { width: 24px; }
  .status-line { padding: 0 12px 6px; }
  .composer { margin: 0 0 calc(2px + env(safe-area-inset-bottom)); padding: 6px 6px 6px 16px; }
  .composer textarea { font-size: 16px; }
  .welcome h2 { font-size: 32px; }
}

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