/* Otto — design system. Warm neutral ground, white cards, ONE accent (uiConfig.theme.accent → --accent).
   Ink scale: --ink (primary) / --ink2 (secondary) / --ink3 (tertiary). 4pt spacing rhythm.
   All accent tints derive via color-mix so a theme change re-tints the whole app. */
:root {
  --accent: #5B5BD6;
  --bg: #F8F7F4;
  --card: #FFFFFF;
  --ink: #1C1B20;
  --ink2: #57565E;
  --ink3: #8C8B94;
  --line: #EAE8E2;
  --line2: #DCDAD3;
  --danger: #D64545;
  --ok: #2E8B4A;
  --amber: #A16207;
  --amber-bg: #FBF0D9;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--card));
  --accent-wash: color-mix(in srgb, var(--accent) 7%, var(--bg));
  --accent-line: color-mix(in srgb, var(--accent) 30%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 10%, var(--card));
  --ok-soft: color-mix(in srgb, var(--ok) 12%, var(--card));
  --radius: 16px;
  --shadow-1: 0 1px 2px rgba(25, 24, 29, .04), 0 6px 20px rgba(25, 24, 29, .05);
  --shadow-2: 0 2px 6px rgba(25, 24, 29, .07), 0 12px 32px rgba(25, 24, 29, .10);
  --sab: env(safe-area-inset-bottom, 0px);
}
[data-theme="dark"] {
  --bg: #121114;
  --card: #1D1C21;
  --ink: #F3F2F6;
  --ink2: #B6B5BE;
  --ink3: #82818B;
  --line: #2B2A31;
  --line2: #3B3A43;
  --danger: #E36A6A;
  --ok: #58B573;
  --amber: #E8C15C;
  --amber-bg: #33290F;
  --accent-soft: color-mix(in srgb, var(--accent) 20%, var(--card));
  --accent-wash: color-mix(in srgb, var(--accent) 12%, var(--bg));
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .30);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .45), 0 14px 36px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  font-synthesis-weight: none; text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.muted { color: var(--ink3); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; font-weight: 550; }
h1 { font-size: 28px; font-weight: 800; margin: 8px 0; letter-spacing: -.03em; line-height: 1.2; }
h2 { font-size: 20px; font-weight: 700; margin: 4px 0 12px; letter-spacing: -.02em; }

/* inline SVG icons (stroke set from render.js) */
.i { width: 1.25em; height: 1.25em; vertical-align: -0.27em; flex: 0 0 auto; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line2); border-radius: 12px; padding: 11px 13px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink3); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 13px 16px; border-radius: 14px; font-weight: 650; font-size: 15px;
  background: var(--card); border: 1px solid var(--line2); text-align: center; color: var(--ink);
  transition: transform .12s ease, box-shadow .2s, filter .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent); color: #fff; border: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line2)); }
.btn.slim { width: auto; padding: 9px 16px; display: inline-flex; font-size: 14px; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--ink2); font-size: 15px; font-weight: 550; padding: 8px; }

/* banner + toast */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--amber-bg); color: var(--amber); font-size: 13px; font-weight: 550;
  padding: 12px 44px 12px 16px; text-align: center;
}
.banner .x { position: absolute; right: 6px; top: 6px; padding: 6px 8px; }
.toast {
  position: fixed; bottom: calc(160px + var(--sab)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  background: color-mix(in srgb, var(--ink) 94%, var(--accent)); color: var(--bg);
  padding: 11px 18px; border-radius: 22px; font-size: 13.5px; font-weight: 600;
  z-index: 80; box-shadow: var(--shadow-2); max-width: 86vw;
  animation: toastUp .25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes toastUp { from { transform: translate(-50%, 14px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- auth ---------- */
.screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 340px; text-align: center; }
.auth-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow-2); margin-bottom: 6px; }
.auth-card p.muted { margin: 4px 0 20px; font-size: 15px; }
.auth-card input { margin-top: 10px; text-align: left; }
.auth-card .btn { margin-top: 16px; }
.auth-msg { color: var(--danger); font-size: 13px; min-height: 20px; margin: 10px 0 2px; }

/* ---------- onboarding ---------- */
.ob-wrap { width: 100%; max-width: 400px; min-height: 82dvh; display: flex; flex-direction: column; }
.ob-top { display: flex; justify-content: space-between; align-items: center; }
.ob-dots { display: flex; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 4px; background: var(--line2); transition: all .3s cubic-bezier(.4, 0, .2, 1); }
.dot.on { background: var(--accent); width: 24px; }
#obStep { flex: 1; padding: 20px 0; }
#obStep.ob-in { animation: fadeUp .32s cubic-bezier(.2, .8, .3, 1) both; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.persona {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: left; transition: border-color .15s, background .15s, transform .12s;
  box-shadow: var(--shadow-1);
}
.persona:active { transform: scale(.97); }
.persona .pe {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; font-size: 21px; background: var(--bg);
}
.persona b { display: block; margin-top: 10px; font-size: 15px; letter-spacing: -.01em; }
.persona span:not(.pe) { font-size: 12.5px; color: var(--ink3); line-height: 1.4; display: block; margin-top: 2px; }
.persona.sel { border-color: var(--accent); background: var(--accent-soft); }
.persona.sel .pe { background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.ob-next { margin-bottom: 12px; }
.ai-opt {
  display: block; width: 100%; text-align: left; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; margin-top: 12px; box-shadow: var(--shadow-1);
  transition: border-color .15s, background .15s;
}
.ai-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.ai-opt b { display: block; font-size: 15px; }
.ai-opt span { font-size: 13px; color: var(--ink3); }
.consent-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 20px; font-size: 13px; color: var(--ink2); cursor: pointer; line-height: 1.45; }
.consent-row input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--accent); }
.ntfy-link {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 650; border-radius: 14px; padding: 13px; margin-top: 12px;
}

/* ---------- app chrome ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 8px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#appTitle { font-size: 27px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
#topSub { font-size: 13px; color: var(--ink3); font-weight: 500; }
#main { padding: 4px 16px calc(150px + var(--sab)); }

/* floating tab bar */
#tabbar {
  position: fixed; bottom: calc(10px + var(--sab)); left: 50%; transform: translateX(-50%);
  z-index: 40; width: min(452px, calc(100% - 24px));
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px; border-radius: 30px;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
#tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; color: var(--ink3); padding: 2px 0; font-weight: 600; letter-spacing: .01em;
  transition: color .15s;
}
#tabbar button .ic {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 28px; border-radius: 14px; transition: background .2s;
}
#tabbar button .ic .i { width: 22px; height: 22px; }
#tabbar button.on { color: var(--accent); }
#tabbar button.on .ic { background: var(--accent-soft); }
#tabbar .chat-tab { flex: 0 0 62px; }
#tabbar .chat-tab .chat-bubble {
  display: flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 25px; color: #fff;
  background: var(--accent); margin: -18px 0 0;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .12s;
}
#tabbar .chat-tab:active .chat-bubble { transform: scale(.94); }
#tabbar .chat-tab .chat-bubble .i { width: 23px; height: 23px; }
#tabbar .chat-tab { overflow: visible; }

.due-strip, .kb, .seg { scrollbar-width: none; }
.due-strip::-webkit-scrollbar, .kb::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }

/* cards */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
  padding: 16px; margin: 12px 0;
  transition: box-shadow .3s, background .3s, transform .12s;
}
.card h3 {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 10px; font-size: 12px; color: var(--ink3); font-weight: 650;
  text-transform: uppercase; letter-spacing: .07em;
}
.card h3 .i { width: 15px; height: 15px; }
.card[data-open]:active, .task-row:active, .note-card:active { transform: scale(.98); }

/* staggered entrance on tab switch */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeUp .4s cubic-bezier(.2, .8, .3, 1) backwards; }
.stagger > *:nth-child(2) { animation-delay: .04s; }
.stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .12s; }
.stagger > *:nth-child(5) { animation-delay: .16s; }
.stagger > *:nth-child(n+6) { animation-delay: .2s; }

/* skeleton shimmer (first load) */
.skel { border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); padding: 16px; margin: 12px 0; }
.skel i {
  display: block; height: 12px; border-radius: 6px; margin: 10px 0;
  background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 40%, var(--card)) 45%, var(--line) 65%);
  background-size: 220% 100%; animation: shimmer 1.3s linear infinite;
}
.skel i:first-child { width: 34%; height: 10px; }
.skel i:last-child { width: 72%; }
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -90% 0; } }

/* empty states */
.empty { text-align: center; color: var(--ink2); padding: 40px 24px; font-size: 15px; }
.empty-art {
  width: 76px; height: 76px; margin: 0 auto 4px; border-radius: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); position: relative;
}
.empty-art .i { width: 34px; height: 34px; }
.empty-art::before, .empty-art::after {
  content: ""; position: absolute; border-radius: 50%; background: var(--accent-line);
}
.empty-art::before { width: 8px; height: 8px; top: 2px; right: -8px; }
.empty-art::after { width: 5px; height: 5px; bottom: 6px; left: -10px; }
.empty p { margin: 12px 0 16px; line-height: 1.5; }
.empty .btn { margin: 0 auto; }

/* morph flash — signature moment when the agent rewrites uiConfig */
@keyframes morphPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 16px transparent; }
}
.morph .card, .morph .task-row, .morph .kb-col, .morph #viewTabs { animation: morphPulse 1.1s ease-out; }

/* ---------- home widgets ---------- */
#tab-home { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 8px; }
#tab-home > * { margin: 0; grid-column: 1 / -1; }
#tab-home > .stat { grid-column: auto; }

.needs-you { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.needs-you h3 { color: var(--amber); }

.brief-card { border-left: 3px solid var(--accent); }
.brief-date {
  font-family: "New York", ui-serif, Georgia, "Times New Roman", serif;
  font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: -2px 0 8px;
}
.brief-md { font-size: 15px; }
.brief-md h1, .brief-md h2, .brief-md h3 { font-size: 15.5px; margin: 12px 0 4px; }
.brief-md ul { margin: 4px 0; padding-left: 20px; }
.brief-md p { margin: 6px 0; }
.brief-md code { background: var(--bg); border-radius: 5px; padding: 1px 5px; font-size: 13px; }

.due-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.due-day {
  min-width: 47px; text-align: center; background: var(--bg); border-radius: 13px; padding: 9px 4px 7px;
  border: 1px solid transparent;
}
.due-day .dd-w { display: block; font-size: 10.5px; font-weight: 650; color: var(--ink3); text-transform: uppercase; letter-spacing: .05em; }
.due-day .dd-n { display: block; font-size: 17px; font-weight: 700; margin-top: 1px; }
.due-day .dd-dots { display: block; height: 6px; line-height: 6px; }
.due-day .dd-dots b { display: inline-block; width: 4px; height: 4px; border-radius: 2px; background: var(--accent); margin: 0 1px; }
.due-day.today { background: var(--accent-soft); border-color: var(--accent-line); }
.due-day.today .dd-w, .due-day.today .dd-n { color: var(--accent); }

.ck-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.ck-item[data-open] { justify-content: space-between; }

.stat { display: flex; flex-direction: column; justify-content: flex-end; min-height: 92px; }
.stat .counter-num { font-size: 36px; font-weight: 750; letter-spacing: -.04em; line-height: 1; margin-top: 4px; }
.stat h3 { margin-bottom: 0; }

.qc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--accent); border-radius: 18px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 600; transition: transform .12s;
}
.chip:active { transform: scale(.95); }

/* ---------- tasks ---------- */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px 12px; }
.seg button {
  white-space: nowrap; padding: 8px 15px; border-radius: 18px; font-size: 13.5px; font-weight: 650;
  background: var(--card); color: var(--ink2); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  transition: background .15s, color .15s, transform .12s;
}
.seg button:active { transform: scale(.95); }
.seg button.on { background: var(--ink); color: var(--bg); border-color: transparent; }
[data-theme="dark"] .seg button.on { background: var(--accent); color: #fff; }

.task-row {
  display: flex; align-items: flex-start; gap: 12px; background: var(--card);
  border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  padding: 13px 14px; margin: 10px 0; transition: transform .12s;
}
.tick {
  width: 24px; height: 24px; min-width: 24px; border-radius: 12px; border: 1.8px solid var(--line2);
  margin-top: 1px; display: flex; align-items: center; justify-content: center; color: #fff;
  transition: all .18s;
}
.tick .i { width: 14px; height: 14px; }
.tick.done { background: var(--accent); border-color: var(--accent); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 570; letter-spacing: -.01em; }
.task-title.done { text-decoration: line-through; color: var(--ink3); }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; padding: 2.5px 9px; border-radius: 10px;
  background: var(--bg); color: var(--ink2); font-weight: 550; font-variant-numeric: tabular-nums;
}
.pill .i { width: 12px; height: 12px; }
.pill.due { background: var(--accent-soft); color: var(--accent); }
.pill.overdue { background: var(--danger-soft); color: var(--danger); }
.pill.att { padding: 2.5px 7px; }

/* kanban */
.kb { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kb-col {
  min-width: 248px; width: 248px; background: color-mix(in srgb, var(--card) 45%, var(--bg));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
  transition: border-color .15s, background .15s;
}
.kb-col h4 {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 4px 8px; font-size: 12px; color: var(--ink2); text-transform: uppercase; letter-spacing: .06em;
}
.kb-col h4 .kb-n {
  font-size: 11px; font-weight: 700; min-width: 20px; text-align: center; padding: 1px 6px;
  border-radius: 9px; background: var(--card); border: 1px solid var(--line); color: var(--ink3);
  font-variant-numeric: tabular-nums;
}
.kb-col[data-col="doing"] h4 { color: var(--accent); }
.kb-col[data-col="doing"] h4 .kb-n { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.kb-col[data-col="done"] h4 { color: var(--ok); }
.kb-col[data-col="done"] h4 .kb-n { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.kb-col[data-col="blocked"] h4 { color: var(--danger); }
.kb-col[data-col="blocked"] h4 .kb-n { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.kb-col.dragover { border-color: var(--accent); background: var(--accent-wash); }
.kb-card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-1);
  padding: 11px 12px; margin: 8px 0; font-size: 14px; font-weight: 550; letter-spacing: -.01em;
  transition: transform .12s, opacity .12s;
}
.kb-card:active { transform: scale(.97); opacity: .8; }

/* table */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 480px; }
.tbl th { text-align: left; color: var(--ink3); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }

#fab {
  position: fixed; right: max(16px, calc(50% - 224px)); bottom: calc(92px + var(--sab)); z-index: 30;
  width: 56px; height: 56px; border-radius: 28px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px color-mix(in srgb, var(--accent) 30%, transparent),
              0 10px 28px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .12s;
}
#fab:active { transform: scale(.92); }
#fab .i { width: 26px; height: 26px; }

/* ---------- chat ---------- */
#tab-chat { padding-bottom: 8px; }
#chatLog { display: flex; flex-direction: column; gap: 3px; padding-top: 6px; }
.date-sep { align-self: center; margin: 14px 0 6px; }
.date-sep span {
  font-size: 11px; font-weight: 650; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px 12px;
}
.msg {
  max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 15px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.45;
  animation: fadeUp .25s ease-out backwards;
}
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.user + .msg.user { border-top-right-radius: 8px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.system { align-self: center; background: none; color: var(--ink3); font-size: 12.5px; }
.msg-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink3); padding: 2px 6px 8px; font-variant-numeric: tabular-nums; }
.msg-meta .i { width: 12px; height: 12px; }
.msg-meta.user { align-self: flex-end; }
.msg-meta.assistant { align-self: flex-start; }
.fx-row { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 86%; padding: 3px 0 10px; }
.fx {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  background: var(--card); color: var(--ink2); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px 12px; box-shadow: var(--shadow-1); transition: transform .12s;
}
.fx:active { transform: scale(.95); }
.fx .i { width: 14px; height: 14px; color: var(--accent); }
/* pending-action approval card (trust gates) */
.pa-card {
  align-self: flex-start; width: min(86%, 340px); margin: 3px 0 10px;
  background: var(--card); border: 1.5px solid var(--accent-line); border-radius: var(--radius);
  border-bottom-left-radius: 6px; box-shadow: var(--shadow-1); padding: 13px 14px;
  animation: fadeUp .25s ease-out backwards;
}
.pa-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .06em;
}
.pa-head .i { width: 14px; height: 14px; }
.pa-sum { font-size: 15px; font-weight: 570; letter-spacing: -.01em; margin-bottom: 12px; }
.pa-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pa-actions .btn { flex: 1; }
.pa-card.done { border-style: dashed; border-color: var(--line2); box-shadow: none; }
.pa-card.done .pa-sum { color: var(--ink3); margin-bottom: 6px; }
.pa-out { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--ink2); }
.pa-out .i { width: 14px; height: 14px; }
.pa-card.approved .pa-out { color: var(--ok); }
.pa-card.rejected .pa-out { color: var(--danger); }

.typing {
  display: flex; gap: 5px; align-self: flex-start; margin-top: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  border-bottom-left-radius: 6px; padding: 14px 16px;
}
.typing span { width: 7px; height: 7px; border-radius: 4px; background: var(--ink3); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes blink { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }
#chatBar {
  position: fixed; bottom: calc(84px + var(--sab)); left: 0; right: 0; z-index: 30;
  max-width: 480px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; padding: 8px 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
#chatInput { resize: none; max-height: 120px; border-radius: 21px; padding: 10px 16px; }
#micBtn { color: var(--ink2); padding: 9px 4px; }
#micBtn .i { width: 22px; height: 22px; }
#micBtn.rec { color: var(--danger); animation: blink 1s infinite; }
#sendBtn {
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; width: 42px; height: 42px; min-width: 42px;
  border-radius: 21px; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .12s;
}
#sendBtn:active { transform: scale(.9); }
#sendBtn .i { width: 20px; height: 20px; }

/* ---------- library (notes | files) ---------- */
.lib-seg {
  display: flex; gap: 0; background: color-mix(in srgb, var(--line) 55%, var(--bg));
  border-radius: 12px; padding: 3px; margin: 8px 0 4px;
}
.lib-seg button {
  flex: 1; padding: 8px; border-radius: 9px; font-size: 13.5px; font-weight: 650; color: var(--ink2);
  transition: background .15s, color .15s, box-shadow .15s;
}
.lib-seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }
.search { margin: 10px 0 4px; border-radius: 21px; }
.note-card .nt { font-weight: 620; letter-spacing: -.01em; }
.note-card .nb { font-size: 13px; color: var(--ink3); margin-top: 3px; max-height: 40px; overflow: hidden; }
#noteEdCard { background: var(--card); min-height: 100dvh; padding: 16px 16px calc(24px + var(--sab)); max-width: 480px; margin: 0 auto; }
#noteEdCard input { font-size: 19px; font-weight: 650; border: 0; padding-left: 0; background: none; box-shadow: none; }
#noteEdCard textarea { min-height: 46dvh; border: 0; padding-left: 0; background: none; font-size: 15px; box-shadow: none; }
.note-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

/* files */
.file-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 4px; }
.file-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.file-tile {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; box-shadow: var(--shadow-1); transition: transform .12s; min-width: 0;
}
.file-tile:active { transform: scale(.96); }
.ft-thumb {
  height: 84px; border-radius: 9px; overflow: hidden; background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: var(--ink3);
}
.ft-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-thumb .i { width: 28px; height: 28px; }
.ft-name { font-size: 12px; font-weight: 600; margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-meta { display: flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--ink3); margin-top: 1px; }
.ft-meta .i { width: 11px; height: 11px; }

/* file viewer */
#viewerCard { background: var(--bg); min-height: 100dvh; width: 100%; padding: 12px 16px calc(24px + var(--sab)); max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.viewer-top .v-name { flex: 1; font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  overflow: hidden; min-height: 42dvh; margin-bottom: 12px;
}
.viewer-body img { max-width: 100%; max-height: 62dvh; object-fit: contain; display: block; }
.viewer-body .v-icon { color: var(--ink3); }
.viewer-body .v-icon .i { width: 56px; height: 56px; }
.viewer-body .v-meta { font-size: 13px; color: var(--ink3); margin-top: 10px; }
.viewer-actions { display: flex; gap: 8px; }
.viewer-actions .btn { font-size: 13.5px; padding: 11px 8px; }
.v-attached { margin-top: 12px; }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.set-row label { font-size: 13.5px; color: var(--ink2); font-weight: 550; min-width: 86px; }
.mem-item { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mem-item:last-child { border-bottom: 0; }
.mem-item .i { color: var(--accent); margin-right: 2px; }
.mem-item button { color: var(--danger); font-size: 13px; font-weight: 550; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
textarea.mono { min-height: 220px; }
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist-item:last-child { border-bottom: 0; }
.howto { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; color: var(--ink2); margin-top: 10px; line-height: 1.5; }
.howto ol { margin: 4px 0 0; padding-left: 18px; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 70; background: rgba(20, 19, 24, .45);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.overlay.full { background: var(--bg); align-items: stretch; backdrop-filter: none; -webkit-backdrop-filter: none; }
.sheet-card {
  background: var(--card); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(20px + var(--sab)); max-height: 88dvh; overflow-y: auto;
  animation: rise .28s cubic-bezier(.2, .8, .3, 1);
}
.sheet-card.slim { padding-bottom: calc(12px + var(--sab)); }
@keyframes rise { from { transform: translateY(48px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-card .frow { margin-top: 14px; }
.sheet-card label.fl { display: block; font-size: 11.5px; color: var(--ink3); font-weight: 650; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
.tagbox { display: flex; flex-wrap: wrap; gap: 7px; }
.tagbox .chip.off { background: var(--bg); color: var(--ink3); }
.att-row { display: flex; flex-wrap: wrap; gap: 7px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 14px 6px; font-size: 15.5px; font-weight: 500; border-bottom: 1px solid var(--line);
}
.sheet-item .i { color: var(--ink3); }
.sheet-item:last-child { border-bottom: 0; }
.sheet-item.danger, .sheet-item.danger .i { color: var(--danger); }

/* ---------- live browser view (P-3 prototype) ---------- */
#liveBar {
  position: fixed; bottom: calc(146px + var(--sab)); left: 14px; right: 14px; z-index: 29;
  max-width: 452px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 38%, transparent);
  animation: livepulse 2.4s ease-in-out infinite;
}
#liveBar .i { width: 18px; height: 18px; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .82; } }
#liveCard { background: var(--bg); min-height: 100dvh; width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; }
#liveHead {
  display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  border-bottom: 1px solid var(--line2); background: var(--card);
}
#liveHead .i { width: 20px; height: 20px; }
#liveUrl {
  flex: 1; font-size: 12.5px; color: var(--ink2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; background: var(--bg); border-radius: 9px; padding: 6px 10px;
}
#liveTgl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink2); }
#liveTgl input { accent-color: var(--accent); width: 18px; height: 18px; }
#liveTgl:has(input:checked) { color: var(--accent); }
#liveWrap { flex: 1; overflow: hidden; background: #101014; display: flex; align-items: flex-start; justify-content: center; }
#liveCanvas { width: 100%; height: auto; display: block; }
#liveFoot {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px calc(12px + var(--sab));
  border-top: 1px solid var(--line2); background: var(--card);
}
#liveFoot input { flex: 1; border-radius: 12px; padding: 9px 12px; font-size: 14px; }
#liveFoot .btn { white-space: nowrap; }
#liveFoot .btn .i { width: 18px; height: 18px; }
/* system messages (e.g. "user finished the manual step") — quiet, centered */
.msg.system { align-self: center; background: none; border: 0; color: var(--ink3); font-size: 12.5px; box-shadow: none; padding: 2px 8px; }
.msg-meta.system { display: none; }

/* ---------- notification center (bell + sheet) ---------- */
#bellBtn {
  position: relative; flex: none; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; color: var(--ink2);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
#bellBtn:active { transform: scale(.94); }
#bellBtn .i { width: 20px; height: 20px; }
#bellBadge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
  border: 2px solid var(--bg); box-sizing: border-box;
}
.ntf-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ntf-head h2 { margin: 0; }
.ntf-row {
  display: flex; gap: 12px; width: 100%; text-align: left; align-items: flex-start;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
}
.ntf-row:last-child { border-bottom: 0; }
.ntf-row:active { background: var(--bg); }
.ntf-ic {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.ntf-ic .i { width: 17px; height: 17px; }
.ntf-main { flex: 1; min-width: 0; }
.ntf-main b { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.ntf-row:not(.unread) .ntf-main b { font-weight: 500; color: var(--ink2); }
.ntf-body {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; color: var(--ink3); line-height: 1.4; margin-top: 1px;
}
.ntf-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding-top: 2px; }
.ntf-time { font-size: 11.5px; color: var(--ink3); }
.ntf-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- N-9 style presets (uiConfig.theme.preset: default | glass | material) ----------
   Token-level overrides only — every component re-skins from the same variables. */
[data-preset="glass"] {
  --card: rgba(255, 255, 255, .58);
  --line: rgba(255, 255, 255, .60);
  --line2: rgba(28, 27, 32, .10);
  --shadow-1: 0 2px 14px rgba(25, 24, 29, .07), inset 0 1px 0 rgba(255, 255, 255, .65);
  --shadow-2: 0 8px 32px rgba(25, 24, 29, .12), inset 0 1px 0 rgba(255, 255, 255, .65);
}
[data-preset="glass"] body { background: linear-gradient(160deg, var(--accent-wash), var(--bg) 40%, color-mix(in srgb, var(--accent) 4%, var(--bg))); background-attachment: fixed; }
[data-preset="glass"] .card, [data-preset="glass"] #topbar, [data-preset="glass"] #tabbar,
[data-preset="glass"] #chatBar, [data-preset="glass"] .sheet-card {
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
[data-theme="dark"][data-preset="glass"] {
  --card: rgba(29, 28, 33, .55);
  --line: rgba(255, 255, 255, .10);
  --line2: rgba(255, 255, 255, .14);
  --shadow-1: 0 2px 14px rgba(0, 0, 0, .40), inset 0 1px 0 rgba(255, 255, 255, .06);
  --shadow-2: 0 8px 32px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
}
[data-preset="material"] {
  --radius: 24px;
  --card: color-mix(in srgb, var(--accent) 5%, #FFFFFF);
  --bg: color-mix(in srgb, var(--accent) 2%, #FAF9F6);
  --line: transparent;
  --line2: color-mix(in srgb, var(--accent) 18%, transparent);
  --shadow-1: none;
  --shadow-2: 0 1px 3px rgba(25, 24, 29, .10);
}
[data-theme="dark"][data-preset="material"] {
  --card: color-mix(in srgb, var(--accent) 9%, #17161B);
  --bg: #121114;
  --line: transparent;
  --line2: color-mix(in srgb, var(--accent) 24%, transparent);
  --shadow-1: none;
  --shadow-2: 0 1px 3px rgba(0, 0, 0, .45);
}
