/* Trellis — calm, readable, one-thing-per-screen. No feeds, no badges, no red dots. */
:root {
  --bg: #f6f4ef; --card: #ffffff; --sunk: #eeebe4; --line: rgba(40,35,25,.10); --line-2: rgba(40,35,25,.18);
  --text: #23211d; --soft: #57534b; --muted: #8a857b;
  --accent: #3d7a4c; --accent-ink: #ffffff; --accent-bg: #e4efe5; --accent-text: #22502e;
  --warn-bg: #fbf0dc; --warn-line: #e7c98f; --warn-text: #6b4a12;
  --alert-bg: #fbe8e5; --alert-text: #8a2b20;
  --user: #e2ebf4; --user-text: #1d3a55;
  --chip: #f1eee7; --danger: #b2412f;
  --r-card: 18px; --r-chip: 999px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191917; --card: #242320; --sunk: #2d2c28; --line: rgba(255,250,240,.09); --line-2: rgba(255,250,240,.17);
    --text: #ece8e0; --soft: #c2bdb2; --muted: #8f8a80;
    --accent: #7fc08f; --accent-ink: #10230f; --accent-bg: #22362a; --accent-text: #bfe5c8;
    --warn-bg: #3a2f1c; --warn-line: #6e5426; --warn-text: #f1d39b;
    --alert-bg: #3b2320; --alert-text: #f3b0a5;
    --user: #233648; --user-text: #d4e5f6;
    --chip: #302e2a; --danger: #ec8e7f;
  }
}

/* Dynamic Type: iOS system text size drives everything below (rem units) */
html { font-size: 17px; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 1rem; line-height: 1.5; -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased; font-feature-settings: "kern", "liga", "tnum" 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary { background: var(--accent); color: var(--accent-ink); }
.error { color: var(--danger); }
.hint { color: var(--soft); font-size: .9rem; }

/* ---------- login */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-icon { width: 76px; height: 76px; border-radius: 18px; }
.login-card h1 { font-size: 1.6rem; font-weight: 650; margin: .4rem 0 1rem; letter-spacing: -.01em; }
.login-card label { display: block; text-align: left; font-size: .85rem; color: var(--soft); margin-bottom: 6px; }
.login-row { display: flex; gap: 8px; }
#code { flex: 1; min-width: 0; font-size: 1.5rem; letter-spacing: .35em; text-align: center; padding: 12px;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); }
.login-row button { flex: none; padding: 0 18px; border-radius: 14px; font-weight: 600; }

/* ---------- shell */
#app { height: 100dvh; display: flex; flex-direction: column; }
header.top { display: flex; align-items: center; gap: 8px; min-height: 52px;
  padding: calc(env(safe-area-inset-top) + 4px) 10px 4px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line); }
.brand { flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
header .title { font-weight: 650; font-size: 1.08rem; letter-spacing: -.01em; }
#status { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status.off { color: var(--danger); }
nav { display: flex; gap: 2px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--soft); }
.icon:active, .back:active { background: var(--sunk); }
.banner { margin: 8px 12px 0; padding: 12px 14px; border-radius: 14px; text-align: left;
  background: var(--accent-bg); color: var(--accent-text); font-size: .92rem; }

#chat { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 10px 12px 14px; }
#msgs { list-style: none; margin: 0 auto; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 680px; }
.empty { color: var(--muted); text-align: center; padding: 40px 24px; font-size: .95rem; }

/* ---------- «Сегодня» */
#today { margin: 8px 12px 0; background: var(--accent-bg); color: var(--accent-text);
  border-radius: var(--r-card); padding: 10px 14px; max-height: 40dvh; overflow-y: auto; }
@media (min-width: 720px) { #today { width: 680px; margin: 8px auto 0; } }
#today.collapsed { padding-top: 8px; padding-bottom: 8px; }
#today.collapsed .body { display: none; }
#today .line { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; min-height: 32px; }
#today .line .t { flex: 1; min-width: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#today .body { margin-top: 4px; }
#today .head { display: flex; align-items: center; justify-content: space-between; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em; opacity: .75; margin-bottom: 4px; }
#today .head button { text-transform: none; letter-spacing: 0; font-size: .85rem; opacity: .9; padding: 4px 2px; }
#today .one-row { display: flex; gap: 10px; align-items: flex-start; }
#today .one { font-weight: 650; font-size: 1.12rem; line-height: 1.3; }
#today .step { font-size: .92rem; margin-top: 3px; }
#today .meta { font-size: .88rem; margin-top: 6px; display: grid; gap: 2px; }
#today ul { list-style: none; padding: 0; margin: 8px 0 0; border-top: 1px solid rgba(0,0,0,.07); }
@media (prefers-color-scheme: dark) { #today ul { border-top-color: rgba(255,255,255,.08); } }
#today li { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: .97rem; }
#today .focus-strip { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 10px;
  border-radius: 12px; background: rgba(255,255,255,.55); font-size: .92rem; width: 100%; text-align: left; }
@media (prefers-color-scheme: dark) { #today .focus-strip { background: rgba(0,0,0,.18); } }
.tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.8px solid currentColor;
  opacity: .7; display: grid; place-items: center; }
.tick::after { content: ""; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.tick.on { background: currentColor; opacity: 1; }
.tick.on::after { opacity: 1; border-color: var(--card); }
.closing .label { text-decoration: line-through; opacity: .55; }
.undo { margin-left: auto; font-size: .82rem; text-decoration: underline; padding: 8px 2px; }

/* ---------- messages */
.day { align-self: center; font-size: .75rem; color: var(--muted);
  background: var(--bg); padding: 4px 10px; border-radius: 99px; margin: 6px 0 2px; }
.msg { position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .time { display: block; font-size: .7rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.msg.bot { align-self: stretch; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px 14px 8px; box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.msg.bot.plan { border-color: transparent; box-shadow: 0 0 0 1.5px var(--accent-bg) inset; }
.msg.bot.reminder { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }
.msg.bot.alert { background: var(--alert-bg); border-color: transparent; color: var(--alert-text); }
.msg.bot .kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 4px; }
.msg.bot.reminder .kind { color: inherit; opacity: .75; }
.msg.bot img.photo { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-top: 10px; cursor: zoom-in; }
.msg.bot img.photo.solo { margin-top: 0; }
.msg.bot img.photo.full { max-height: none; object-fit: contain; cursor: zoom-out; }

.msg.user { align-self: flex-end; max-width: 84%; background: var(--user); color: var(--user-text);
  padding: 8px 12px 6px; border-radius: 18px 18px 6px 18px; }
.msg.user .time { color: inherit; opacity: .55; text-align: right; }
.msg.user img { display: block; max-width: 100%; border-radius: 12px; margin: 2px 0 4px; }
.msg.pill { align-self: flex-end; background: transparent; color: var(--soft); font-size: .88rem; padding: 0 4px; }
.msg.pill .time { display: none; }
.msg audio { width: 240px; max-width: 100%; height: 36px; }
.quote { font-size: .85rem; border-left: 2.5px solid currentColor; padding-left: 8px; opacity: .7; margin-bottom: 6px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.reply-btn { display: inline-block; font-size: .82rem; color: var(--muted); margin-top: 6px; padding: 6px 0; }

/* rich text */
.rt { font-size: 1rem; line-height: 1.5; }
.rt > * + * { margin-top: .5em; }
.rt p { margin: 0; }
.rt .row { display: grid; grid-template-columns: 1.55em 1fr; column-gap: .15em; align-items: baseline; }
.rt .row > .e { text-align: center; }
.rt h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .9em 0 0; font-weight: 600; }
.rt h4:first-child { margin-top: 0; }
.rt ul, .rt ol { margin: 0; padding-left: 1.3em; }
.rt li + li { margin-top: .2em; }
.rt li::marker { color: var(--muted); }
.rt blockquote { margin: 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--line-2); color: var(--soft); }
.rt hr { border: 0; border-top: 1px solid var(--line); margin: .7em 0; }
.rt b { font-weight: 650; }
.rt code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--sunk); padding: .05em .35em; border-radius: 5px; }
.rt a { color: var(--accent); text-underline-offset: 2px; }
.rt .small { font-size: .85rem; color: var(--soft); }
.task { display: inline-flex; align-items: center; gap: .35em; background: var(--chip); border-radius: 10px;
  padding: .05em .45em .05em .2em; margin: 0 .05em; }
.task .tick { width: 1.15em; height: 1.15em; border-width: 1.5px; }
.task .tick::after { width: .42em; height: .25em; border-width: 1.6px; }
.task.closing b { text-decoration: line-through; opacity: .55; }
.msg.reminder .task { background: rgba(255,255,255,.45); }
@media (prefers-color-scheme: dark) { .msg.reminder .task { background: rgba(0,0,0,.2); } }

/* buttons under bot messages */
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.buttons.stack { flex-direction: column; }
.buttons button { min-height: 42px; padding: 8px 14px; border-radius: 14px; background: var(--chip);
  font-size: .95rem; text-align: left; line-height: 1.25; }
.msg.reminder .buttons button { background: rgba(255,255,255,.55); }
@media (prefers-color-scheme: dark) { .msg.reminder .buttons button { background: rgba(0,0,0,.22); } }
.buttons button.chosen { background: var(--accent); color: var(--accent-ink); }
.buttons.done button:not(.chosen) { opacity: .45; }

/* typing / live status */
#typing { display: flex; align-items: center; gap: 10px; max-width: 680px; margin: 8px auto 0; color: var(--muted); font-size: .9rem; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- composer */
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px 2px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; min-height: 36px; padding: 6px 13px; border-radius: var(--r-chip); background: var(--card);
  border: 1px solid var(--line); font-size: .88rem; color: var(--soft); }
#replybar { display: flex; align-items: center; gap: 8px; margin: 6px 12px 0; padding: 7px 10px; font-size: .85rem;
  border-left: 3px solid var(--accent); background: var(--sunk); border-radius: 0 10px 10px 0; }
#reply-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#reply-cancel { padding: 4px 8px; }
#composer, #recording { display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); background: var(--bg); }
#input { flex: 1; resize: none; max-height: 9rem; min-height: 44px; font-size: max(16px, 1rem); line-height: 1.35;
  padding: 10px 14px; border-radius: 22px; border: 1px solid var(--line-2); background: var(--card); outline: none; }
#input:focus { border-color: var(--accent); }
.round { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.4rem; color: var(--soft); background: var(--card); border: 1px solid var(--line); }
.round.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
#recording { align-items: center; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
#rec-time { flex: 1; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
#recording button { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line-2); }
#recording button.primary { border-color: transparent; }

/* ---------- panels (Фокус / Неделя / Настройки) */
.panel { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.panel header .back { min-height: 44px; padding: 0 10px 0 2px; color: var(--accent); font-size: 1rem; border-radius: 10px; }
.panel header .title { flex: 1; text-align: center; }
.panel header .spacer { width: 64px; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); }
.panel-body > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.section { margin-bottom: 22px; }
.section > h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 0 0 8px 4px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 10px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .sub { font-size: .82rem; color: var(--muted); }
.item .when { flex: none; width: 3.4em; font-variant-numeric: tabular-nums; color: var(--soft); font-size: .92rem; }
.item button.x { flex: none; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 1.05rem; }
.item.pick { width: 100%; text-align: left; }
.item.pick.sel { background: var(--accent-bg); color: var(--accent-text); }
.btn { display: block; width: 100%; min-height: 50px; border-radius: 14px; font-weight: 600; font-size: 1rem; margin-top: 10px; }
.btn.ghost { background: var(--card); border: 1px solid var(--line-2); font-weight: 500; }
.field { width: 100%; min-height: 48px; padding: 12px 14px; font-size: max(16px, 1rem); border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--card); outline: none; }
.field:focus { border-color: var(--accent); }
textarea.field { resize: vertical; min-height: 64px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 42px; padding: 0 16px; border-radius: var(--r-chip); background: var(--card); border: 1px solid var(--line-2); }
.chips button.sel { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.timer { text-align: center; padding: 18px 0 8px; }
.timer .big { font-size: 3.6rem; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.timer .what { font-size: 1.15rem; font-weight: 600; margin-top: 10px; }
.timer .sub { color: var(--soft); margin-top: 4px; }
.crumb { background: var(--sunk); border-radius: 14px; padding: 12px 14px; font-size: .95rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem; word-break: break-all;
  background: var(--sunk); border-radius: 10px; padding: 10px 12px; user-select: all; -webkit-user-select: all; }
ol.steps { padding-left: 1.3em; margin: 6px 0 0; } ol.steps li + li { margin-top: 6px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  z-index: 20; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: .9rem;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18); }

/* ---------- line icons (placeholder set; swap the ICON table in app.js for a pack) */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.ic.accent { color: var(--accent); }
.ic.warn { color: #b7791f; }
.ic.danger { color: var(--danger); }
@media (prefers-color-scheme: dark) { .ic.warn { color: #e3b35e; } }
.rt .row > .e { display: flex; justify-content: center; padding-top: .14em; color: var(--soft); }
.rt .row > .e .ic { width: 1.12em; height: 1.12em; }
.msg.bot .kind { display: flex; align-items: center; gap: 6px; }
.msg.bot .kind .ic { width: 1.05em; height: 1.05em; }
.msg.pill { display: inline-flex; align-items: center; gap: 6px; }
.msg.pill .ic { width: 1em; height: 1em; opacity: .8; }
.msg .att { display: flex; align-items: center; gap: 6px; }
.buttons button { display: inline-flex; align-items: center; gap: 8px; }
.buttons button .ic { width: 1.05em; height: 1.05em; opacity: .85; }
.reply-btn { display: inline-flex; align-items: center; gap: 5px; }
#today .line { gap: 10px; }
#today .line .ic { width: 1.25em; height: 1.25em; }
#today .line .t { font-size: 1.05rem; }
#today .line .chev { width: 1.05em; height: 1.05em; opacity: .7; transition: transform .15s; }
#today.collapsed .line .chev { transform: rotate(-90deg); }
#today .step { margin: 2px 0 0 calc(1.25em + 10px); }
#today .meta { margin-left: calc(1.25em + 10px); }
#today .mrow { display: flex; align-items: baseline; gap: 6px; }
#today .mrow .ic { width: 1em; height: 1em; opacity: .8; }
.banner { display: flex; align-items: center; gap: 10px; }
.item > .ic { width: 1.1em; height: 1.1em; color: var(--muted); }
.item > .ic.warn { color: #b7791f; }
.item button.x { display: grid; place-items: center; }
#reply-cancel svg, .round svg { width: 1.3rem; height: 1.3rem; }
