:root {
  --bg: #f4f2ee;
  --bg-2: #ebe8e2;
  --panel: #fbfaf8;
  --panel-2: #ffffff;
  --line: rgba(20, 20, 22, 0.09);
  --line-2: rgba(20, 20, 22, 0.16);
  --text: #18181a;
  --text-2: #5d5b57;
  --text-3: #8f8c86;
  --accent: #d9622f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(217, 98, 47, 0.11);
  --ok: #2f8f5b;
  --ok-soft: rgba(47, 143, 91, 0.12);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, 0.13);
  --bad: #c2413a;
  --bad-soft: rgba(194, 65, 58, 0.11);
  --info: #3d6fd1;
  --info-soft: rgba(61, 111, 209, 0.11);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --font: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0f1012;
  --bg-2: #16171a;
  --panel: #17181b;
  --panel-2: #1d1e22;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #eeece8;
  --text-2: #a9a6a0;
  --text-3: #76736e;
  --accent: #ec7a48;
  --accent-soft: rgba(236, 122, 72, 0.14);
  --ok: #4cbb7f;
  --ok-soft: rgba(76, 187, 127, 0.13);
  --warn: #e0a548;
  --warn-soft: rgba(224, 165, 72, 0.13);
  --bad: #ec6a62;
  --bad-soft: rgba(236, 106, 98, 0.13);
  --info: #7aa2f2;
  --info-soft: rgba(122, 162, 242, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 12px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; border-right: 1px solid var(--line); background: var(--bg-2);
}
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1180px; width: 100%; }
.topbar, .tabbar { display: none; }

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 6px 6px / 8px 8px no-repeat,
    linear-gradient(var(--text), var(--text)) 16px 6px / 8px 8px no-repeat,
    linear-gradient(var(--text), var(--text)) 6px 16px / 8px 8px no-repeat,
    linear-gradient(var(--text-3), var(--text-3)) 16px 16px / 8px 8px no-repeat,
    var(--panel-2);
  border: 1px solid var(--line-2);
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-3); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer; text-align: left;
}
.nav button:hover { background: var(--line); color: var(--text); }
.nav button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }

.side-status { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); padding: 0 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- common ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.raised { background: var(--panel-2); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover { border-color: var(--text-3); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--line); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-2); display: grid; place-items: center; cursor: pointer; }
.danger-soft { color: var(--bad); }

.input, select.input, textarea.input {
  width: 100%; min-height: 36px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--panel-2); outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.input { resize: vertical; min-height: 70px; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 500; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--line); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.info { background: var(--info-soft); color: var(--info); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .em-title { color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.empty .em-icon { width: 44px; height: 44px; border-radius: 12px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-3); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid; }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner b { display: block; margin-bottom: 2px; }

/* ---------- inbox ---------- */
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 600; font-size: 14px; background: var(--accent-soft); color: var(--accent); }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-name { font-weight: 600; }
.msg-text { margin: 6px 0 10px; white-space: pre-wrap; word-wrap: break-word; }
/* Long texts fold; a tap unfolds them. */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines, 6); overflow: hidden; cursor: pointer; }
.clamp.open { display: block; -webkit-line-clamp: unset; cursor: auto; }
.msg-summary { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--bg-2); font-size: 13px; color: var(--text-2); }
.msg-summary .sum-text { --lines: 3; }
.msg-summary .sum-text b { color: var(--text); font-weight: 600; margin-right: 4px; }
.msg-summary .sum-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg-summary.bad { background: var(--bad-soft); color: var(--bad); }
.draft { border-left: 2px solid var(--accent); padding-left: 10px; margin: 0 0 12px; }
.draft .faint { margin-bottom: 4px; display: block; }
.msg-actions select.input { width: auto; min-width: 160px; }
/* Handled messages: one short row each, so the open ones stand out. */
.msg.compact { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 10px 14px; background: transparent; box-shadow: none; }
.msg.compact .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; background: var(--line); color: var(--text-2); }
.msg.compact .msg-text { --lines: 2; margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.msg.compact .msg-name { font-weight: 500; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 2px 8px; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.top-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.top-stop { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--bad); font-size: 12px; font-weight: 600; cursor: pointer; }
.top-stop.paused { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.top-stop svg.i { width: 14px; height: 14px; }

/* ---------- sessions ---------- */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pitem { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; width: 100%; }
.pitem:hover { background: var(--panel); border-color: var(--line); }
.pitem.active { background: var(--panel-2); border-color: var(--line-2); box-shadow: var(--shadow); }
.pitem .dot { margin-top: 7px; }
.pitem-name { font-weight: 600; }
.pitem-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat { display: flex; flex-direction: column; height: calc(100dvh - 140px); min-height: 420px; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat-foot textarea { min-height: 40px; max-height: 180px; resize: none; }

.bubble { max-width: min(680px, 92%); padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.bubble.ai { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.err { align-self: flex-start; background: var(--bad-soft); color: var(--bad); }
.bubble .origin { display: block; font-size: 11px; opacity: 0.75; margin-bottom: 3px; }
.tool { align-self: flex-start; display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--text-2); padding: 4px 10px; border-radius: 99px; background: var(--bg-2); max-width: 92%; }
.tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys { align-self: center; font-size: 12px; color: var(--text-3); text-align: center; }
.run-sep { align-self: center; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ---------- tasks, contacts, log ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 12px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 99px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.switch { position: relative; width: 36px; height: 21px; border-radius: 99px; background: var(--line-2); border: 0; cursor: pointer; flex: none; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(15px); }

.log-li { display: grid; grid-template-columns: 54px 84px minmax(0, 1fr); gap: 10px; padding: 7px 4px; border-top: 1px solid var(--line); font-size: 13px; }
.log-li .t { color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.log-li .m { word-wrap: break-word; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.stat-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); word-break: break-all; }
.copy-line { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.copy-line .kbd { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 12, 0.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade 0.12s ease-out; }
.modal { width: min(560px, 100%); max-height: 86vh; overflow: auto; background: var(--panel-2); border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
@keyframes fade { from { opacity: 0; } }
#toast-root { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: fade 0.15s; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }

@media (min-width: 861px) { .mobile-only { display: none !important; } }

/* ---------- mobile / Mini App: dense, more on one screen ---------- */
@media (max-width: 860px) {
  :root { --top-h: 44px; --tab-h: calc(50px + var(--safe-b)); --radius: 10px; }
  body { font-size: 13px; line-height: 1.42; }
  code, .mono, .kbd { font-size: 11px; }
  svg.i { width: 16px; height: 16px; }
  #app { grid-template-columns: 1fr; align-content: start; }
  .sidebar { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; height: var(--top-h); align-items: center; justify-content: space-between; padding: 0 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .topbar .brand { gap: 8px; padding: 0; }
  .topbar .brand-mark { width: 24px; height: 24px; border-radius: 7px; background-size: 6px 6px, 6px 6px, 6px 6px, 6px 6px, auto;
    background-position: 5px 5px, 13px 5px, 5px 13px, 13px 13px, 0 0; }
  .topbar .brand-name { font-size: 15px; }
  .main { padding: 10px 10px calc(var(--tab-h) + 14px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tab-h);
    padding: 3px 4px var(--safe-b); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--text-3); font-size: 10px; font-weight: 500; cursor: pointer; }
  .tabbar button svg.i { width: 20px; height: 20px; }
  .tabbar button.active { color: var(--accent); }
  .tabbar .count { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 15px; height: 15px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 9.5px; line-height: 15px; }

  /* The title is already in the top bar: keep only the page's controls. */
  .page-head { margin-bottom: 8px; gap: 8px; }
  .page-head > div:first-child { display: none; }
  .page-head:has(> :only-child) { display: none; }

  .stack { gap: 8px; }
  .card { padding: 11px 12px; }
  .card h3 { font-size: 13px; }
  .btn { height: 32px; padding: 0 11px; font-size: 13px; }
  .btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
  .icon-btn { width: 32px; height: 32px; }
  .badge { height: 20px; padding: 0 7px; font-size: 11px; }
  .seg { padding: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
  .empty { padding: 26px 14px; }
  .empty .em-icon { width: 36px; height: 36px; margin-bottom: 10px; }
  .banner { padding: 9px 11px; gap: 9px; margin-bottom: 10px; font-size: 12.5px; }

  .msg { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
  .msg-head { gap: 6px; row-gap: 0; }
  .msg-text { margin: 4px 0 8px; }
  .msg-summary { padding: 7px 9px; margin-bottom: 8px; font-size: 12.5px; }
  .msg-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .msg-actions select.input { grid-column: 1 / -1; width: 100%; min-width: 0; min-height: 32px; padding: 4px 9px; }
  .msg-actions .btn { width: 100%; }
  .msg-actions .grow { display: none; }
  .msg.compact { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 8px 10px; }
  .msg.compact .avatar { width: 24px; height: 24px; font-size: 10px; border-radius: 7px; }
  .msg.compact .msg-text { font-size: 12.5px; }
  .section-label { margin: 12px 2px 6px; font-size: 11px; }

  .split { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .split.detail .plist-wrap { display: none; }
  .split:not(.detail) .chat-wrap { display: none; }
  .plist { gap: 2px; }
  .pitem { padding: 8px 10px; gap: 8px; }
  .pitem-sub { font-size: 11.5px; }
  /* The chat fills the screen between the bars; Telegram reports its real viewport. */
  .chat { height: calc(var(--tg-viewport-stable-height, 100dvh) - var(--top-h) - var(--tab-h) - 20px); min-height: 300px; }
  .chat-head { padding: 7px 8px; gap: 6px; flex-wrap: nowrap; }
  .chat-head .grow > div:first-child { font-size: 13.5px; }
  .chat-head .faint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-body { padding: 10px 8px; gap: 6px; }
  .chat-foot { padding: 6px; gap: 6px; }
  .chat-foot textarea { min-height: 36px; padding: 6px 10px; }
  .bubble { padding: 7px 10px; border-radius: 12px; line-height: 1.45; max-width: 94%; }
  .bubble .origin { font-size: 10px; }
  .tool { font-size: 11px; padding: 3px 8px; }
  .run-sep, .sys { font-size: 11px; }

  .li { padding: 8px 2px; gap: 8px; flex-wrap: wrap; }
  .li-main { flex: 1 1 calc(100% - 60px); }
  .li-title { font-size: 13px; }
  .li-sub { font-size: 11.5px; white-space: normal; }
  .li .btn.small { height: 26px; }
  .li > select.input { flex: 1; min-height: 30px; padding: 4px 8px; }

  .log-li { grid-template-columns: 38px minmax(0, 1fr); gap: 8px; padding: 5px 2px; font-size: 12px; }
  .log-li .t { font-size: 11px; }
  .log-li .k { display: none; }

  .grid2 { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stat-title { margin-bottom: 3px; }
  .modal { padding: 16px; border-radius: 14px; }
}

/* iOS zooms into inputs under 16px on focus (Safari and Telegram). */
@media (max-width: 860px) {
  .input, select.input, textarea.input, .chat-foot textarea { font-size: 16px; }
}
.msg.compact.li { align-items: start; }
.msg.compact .btn.small.ghost { height: 22px; padding: 0 4px; }

/* ---------- inbox work ---------- */
.msg-body { min-width: 0; }
.msg-tabs { display: flex; align-items: center; gap: 4px; margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tabbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.tabbtn:hover { background: var(--line); color: var(--text); }
.tabbtn.on { background: var(--accent-soft); color: var(--accent); }
.tabbtn svg.i { width: 15px; height: 15px; }
.panel { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.panel .row { gap: 8px; }
.panel select.input { width: auto; flex: 1; min-width: 0; }
.panel .faint { font-size: 12px; }
.history { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; padding: 8px; max-height: 320px; overflow-y: auto; border-radius: var(--radius-sm); background: var(--bg-2); }
.hmsg { align-self: flex-start; max-width: 88%; padding: 5px 9px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; white-space: pre-wrap; word-wrap: break-word; }
.hmsg.out { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.hmsg .htime { display: block; font-size: 10px; color: var(--text-3); margin-top: 2px; text-align: right; }
.kbd-hint { display: inline-flex; gap: 4px; align-items: center; margin-left: 6px; color: var(--text-3); font-size: 12px; }
kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); }
@media (hover: hover) and (min-width: 861px) { .msg.focused { box-shadow: 0 0 0 2px var(--accent), var(--shadow); } }
@media (hover: none), (max-width: 860px) { .kbd-hint { display: none; } }
.toast { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }
@media (max-width: 860px) {
  .msg-tabs { gap: 2px; padding-top: 6px; }
  .tabbtn { height: 30px; padding: 0 8px; font-size: 12.5px; }
  .panel { padding: 8px; margin-top: 6px; }
  .panel .row .faint { display: none; }
  .history { max-height: 260px; }
}
@media (max-width: 380px) { .hide-xs { display: none; } }
.msg > .full { grid-column: 1 / -1; }
.msg-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.msg-tabs::-webkit-scrollbar { display: none; }
.tabbtn { white-space: nowrap; flex: none; }
@media (max-width: 860px) { .tabbtn { padding: 0 7px; gap: 5px; } }
.src-mail { display: inline-flex; color: var(--info); align-self: center; }
.src-mail svg.i { width: 14px; height: 14px; }
.msg-subject { font-weight: 600; margin-top: 4px; }
.msg.compact .avatar svg.i { width: 13px; height: 13px; }
.past { display: flex; flex-direction: column; gap: 8px; opacity: 0.82; }
.past > .btn { align-self: center; }
.past .bubble.me { background: color-mix(in srgb, var(--accent) 70%, var(--panel-2)); }
@media (max-width: 860px) { .past { gap: 6px; } }

/* ---------- today ---------- */
.today-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; align-items: start; }
.sec-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.sec-title svg.i { color: var(--text-3); }
.day + .day { margin-top: 12px; }
.day-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 0 0 4px; }
.day-label::first-letter { text-transform: uppercase; }
.ev { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: var(--radius-sm); }
.ev + .ev { border-top: 1px solid var(--line); }
.ev-time { font-family: var(--mono); font-size: 12px; color: var(--text-2); min-width: 92px; }
.ev-title { flex: 1; min-width: 0; font-weight: 500; }
.ev.now { background: var(--accent-soft); }
.ev.now .ev-time { color: var(--accent); }
.ev.past { opacity: 0.5; }
.rem { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-top: 1px solid var(--line); }
.rem:first-of-type { border-top: 0; }
.rem.overdue .grow { color: var(--bad); }
.check { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); background: transparent; cursor: pointer; flex: none; }
.check:hover { border-color: var(--ok); }
.check.done { background: var(--ok); border-color: var(--ok); }
.quick-add { display: flex; gap: 6px; margin-top: 10px; }
.quick-add .input { min-height: 32px; padding: 5px 9px; }
.quick-add input.input { flex: 1; min-width: 0; }
.quick-add select.input { width: auto; flex: none; }

/* ---------- notes ---------- */
.search-box { position: relative; margin-bottom: 10px; }
.search-box svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box .input { padding-left: 34px; }
.note + .note { border-top: 1px solid var(--line); }
.note-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.note-head:hover { background: var(--line); }
.note-head svg.i { color: var(--text-3); }
.note.open .note-head svg.i { transform: rotate(-90deg); }
.note-body { padding: 0 14px 12px; white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; }

/* ---------- more (phone) ---------- */
.more-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.more-item + .more-item { border-top: 1px solid var(--line); }
.more-item > svg.i:last-child { transform: rotate(180deg); color: var(--text-3); }

@media (max-width: 860px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ev { padding: 6px 4px; gap: 10px; }
  .ev-time { min-width: 80px; font-size: 11px; }
  .note-head { padding: 9px 12px; }
  .note-body { padding: 0 12px 10px; font-size: 13px; }
  .more-item { padding: 11px 12px; }
  .search-box { margin-bottom: 8px; }
}

/* ---------- social ---------- */
.social-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.sec-title a { font-weight: 400; font-size: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: var(--radius-sm); background: var(--bg-2); }
.kpi-v { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; }
.kpi-l { font-size: 11px; color: var(--text-3); line-height: 1.25; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.post { padding: 8px 2px; border-top: 1px solid var(--line); }
.post-text { font-size: 13px; }
.post-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--text-2); }
.post-meta span { display: inline-flex; align-items: center; gap: 3px; }
.post-meta svg.i { width: 13px; height: 13px; color: var(--text-3); }
.nets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.net { padding: 10px; border-radius: var(--radius-sm); background: var(--bg-2); display: flex; flex-direction: column; gap: 3px; }
.net-name { font-size: 12px; font-weight: 600; color: var(--text-2); }
.net-big { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; }
.net-row { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.advice { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 1100px) { .social-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .social-grid { gap: 8px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .kpi { padding: 7px 9px; }
  .kpi-v { font-size: 17px; }
  .nets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .net { padding: 8px; }
  .net-big { font-size: 17px; }
}

.top-stop[hidden] { display: none; }

/* ---------- chat like Claude Code: folded steps ---------- */
.steps { align-self: flex-start; max-width: 92%; font-size: 12.5px; color: var(--text-2); }
.steps > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); user-select: none; }
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary::after { content: '▸'; font-size: 10px; color: var(--text-3); transition: transform 0.15s; }
.steps[open] > summary::after { transform: rotate(90deg); }
.steps > summary .dot { width: 6px; height: 6px; }
.steps-body { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 2px 10px; padding-left: 10px; border-left: 2px solid var(--line); }
.steps-body .tool { max-width: 100%; }
.steps-body .sys { align-self: flex-start; text-align: left; }
.thought { color: var(--text-2); font-size: 12.5px; white-space: pre-wrap; word-wrap: break-word; }

/* ---------- attachments ---------- */
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.attach-row:empty { display: none; }
.attach-row:not(:empty) { padding-top: 8px; border-top: 1px solid var(--line); }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 3px 4px 3px 3px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12px; }
.attach-chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }
.attach-chip > span:not(.faint) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 15px; padding: 0 4px; }
.attach-btn { flex: none; cursor: pointer; color: var(--text-2); }
.chat-foot { align-items: flex-end; }

/* ---------- finance ---------- */
.fin-hero { position: relative; overflow: hidden; padding: 18px 20px; margin-bottom: 12px; border-radius: 16px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #2b2f6b 0%, #191b33 45%, #101118 100%); box-shadow: var(--shadow); }
.fin-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(236,122,72,.35), transparent 70%); }
.fin-hero-top { display: flex; justify-content: space-between; align-items: baseline; position: relative; }
.fin-hero-top .faint { color: rgba(255,255,255,.55); }
.fin-hero-l { font-size: 13px; color: rgba(255,255,255,.75); }
.fin-hero-v { position: relative; font-size: 34px; font-weight: 600; letter-spacing: -0.03em; margin: 2px 0 14px; font-variant-numeric: tabular-nums; }
.fin-accounts { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.fin-acc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.08); backdrop-filter: blur(6px); }
.fin-acc-dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.fin-acc-n { display: block; font-weight: 600; font-size: 13px; }
.fin-acc-t { display: block; font-size: 11px; color: rgba(255,255,255,.55); }
.fin-acc-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-acc-v small { display: block; font-weight: 400; font-size: 11px; color: rgba(255,255,255,.6); }
.fin-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.fin-kpis .kpi { background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 12px 14px; gap: 3px; }
.fin-kpis .kpi-l { font-size: 12px; color: var(--text-2); }
.fin-kpis .kpi-v { font-size: 20px; }
.fin-kpis .kpi-s { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-kpis .kpi.in .kpi-v { color: var(--ok); }
.fin-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.fin-day + .fin-day { margin-top: 10px; }
.fin-day-h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 4px 4px; }
.fin-day-h span:first-child::first-letter { text-transform: uppercase; }
.fin-op { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: var(--radius-sm); }
.fin-op:hover { background: var(--bg-2); }
.fin-op-e { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); font-size: 15px; flex: none; }
.fin-op-n { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-op-s { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-op-v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-op.in .fin-op-v { color: var(--ok); }
.fin-del { width: 26px; height: 26px; border: 0; background: transparent; opacity: 0; color: var(--text-3); }
.fin-op:hover .fin-del { opacity: 1; }
.fin-cat { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.fin-cat-e { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-2); flex: none; }
.fin-cat-n { display: block; font-size: 13px; margin-bottom: 4px; }
.fin-bar { display: block; height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.fin-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #f5a06f); }
.fin-cat b { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.fin-form { display: flex; gap: 8px; margin-bottom: 12px; padding: 10px; }
.fin-form input[name=amount] { max-width: 140px; }
.fin-form select.input { width: auto; }
@media (max-width: 1100px) { .fin-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .fin-hero { padding: 14px; border-radius: 14px; }
  .fin-hero-v { font-size: 28px; margin-bottom: 10px; }
  .fin-accounts { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .fin-acc { padding: 8px 10px; }
  .fin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .fin-kpis .kpi { padding: 9px 10px; }
  .fin-kpis .kpi-v { font-size: 16px; }
  .fin-del { opacity: .5; }
  .fin-form { flex-wrap: wrap; }
  .fin-form input[name=merchant] { flex: 1 1 100%; }
}
.fin-more { display: block; margin: 10px auto 0; }
@media (max-width: 1100px) { .fin-cats { order: -1; } }

/* ---------- hero (shared with Finance look) ---------- */
.hero { --h1: #2b2f6b; --h2: #191b33; --glow: rgba(236,122,72,.35);
  position: relative; overflow: hidden; padding: 18px 20px; margin-bottom: 14px; border-radius: 18px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, var(--h1) 0%, var(--h2) 48%, #101118 100%); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.hero::after { content: ''; position: absolute; right: -70px; top: -70px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, var(--glow), transparent 70%); pointer-events: none; }
.hero.warm { --h1: #6b2f1f; --h2: #2a1712; --glow: rgba(255,170,90,.45); }
.hero.teal { --h1: #0f5a57; --h2: #0e2a2b; --glow: rgba(90,220,200,.35); }
.hero.violet { --h1: #4b2a7a; --h2: #1f1533; --glow: rgba(190,140,255,.35); }
.hero.blue { --h1: #1d4f8f; --h2: #111f36; --glow: rgba(110,180,255,.38); }
.hero.green { --h1: #1f6b44; --h2: #10261b; --glow: rgba(120,230,160,.35); }
.hero-top { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hero-l { font-size: 13px; color: rgba(255,255,255,.78); }
.hero-note { font-size: 12px; color: rgba(255,255,255,.6); text-align: right; }
.hero-v { position: relative; font-size: 30px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; margin: 4px 0 14px; }
.hero-tiles { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.hero-tile { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,.09); backdrop-filter: blur(6px); }
.hero-tile.tap { cursor: pointer; } .hero-tile.tap:hover { background: rgba(255,255,255,.16); }
.hero-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.14); flex: none; font-size: 15px; }
.hero-tn { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-ts { display: block; font-size: 11px; color: rgba(255,255,255,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-tv { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 15px; }

/* ---------- global polish ---------- */
.card { border-radius: 16px; }
.card.raised { box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06); }
:root[data-theme='dark'] .card.raised { box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 28px rgba(0,0,0,.28); }
.page-head h1 { font-size: 24px; letter-spacing: -0.025em; }
.page-head p { font-size: 13px; color: var(--text-3); max-width: 640px; }
.sec-title { font-size: 14px; letter-spacing: -0.01em; }
.li { border-radius: 10px; padding-left: 8px; padding-right: 8px; transition: background .12s; }
.li:hover { background: var(--bg-2); }
.list .li + .li { border-top-color: transparent; }
.avatar { border-radius: 12px; font-weight: 650; }
.msg.card.raised { border-radius: 16px; }
.msg-summary { border-radius: 12px; }
.badge { font-weight: 600; }
.pitem { border-radius: 12px; }
.pitem.active { box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.ev { border-radius: 10px; }
.ev .ev-time { background: var(--bg-2); border-radius: 8px; padding: 3px 7px; min-width: auto; }
.ev.now .ev-time { background: var(--accent); color: var(--accent-ink); }
.rem { border-radius: 10px; padding-left: 6px; padding-right: 6px; }
.rem:hover { background: var(--bg-2); }
.more-item { border-radius: 12px; }
.more-item > svg.i:first-child { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--bg-2); color: var(--accent); }
.note-head { border-radius: 12px; }
.sidebar .nav button.active { box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px var(--line); }
.tabbar button.active svg.i { filter: drop-shadow(0 0 8px var(--accent-soft)); }
@media (max-width: 860px) {
  .hero { padding: 14px; border-radius: 16px; margin-bottom: 10px; }
  .hero-v { font-size: 24px; margin-bottom: 10px; }
  .hero-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .hero-tile { padding: 8px 8px; gap: 6px; }
  .hero-tile .grow { min-width: 0; }
  .hero-tv { font-size: 14px; flex: none; }
  .hero-ico { width: 26px; height: 26px; font-size: 13px; }
  .hero-tn { font-size: 12px; }
  .page-head h1 { font-size: 20px; }
}
.hero-tv small { font-size: 11px; font-weight: 600; margin-left: 3px; }
.hero-tv small.up { color: #6be3a0; } .hero-tv small.down { color: #ff8a7a; }

.li-badge{display:inline-grid;place-items:center;width:18px;height:18px;border-radius:4px;background:#0a66c2;color:#fff;font:700 11px/1 -apple-system,sans-serif;margin-right:6px}

/* ---------- social: tabs, studio, calendar ---------- */
.soc-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: -4px 0 12px; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.soc-tabs::-webkit-scrollbar { display: none; }
.soc-tabs button { flex: 1 0 auto; border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.soc-tabs button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.soc-tabs small { display: inline-block; min-width: 16px; padding: 0 5px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.net-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: #fff; background: #666; white-space: nowrap; }
.n-telegram { background: #2aabee; } .n-linkedin { background: #0a66c2; } .n-instagram { background: linear-gradient(135deg,#f58529,#dd2a7b,#8134af); }
.n-threads { background: #333; } .n-tiktok { background: #111; } .n-youtube { background: #ff0000; } .n-facebook { background: #1877f2; }
.studio textarea { margin-top: 4px; }
.net-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.net-chk { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; cursor: pointer; }
.net-chk input { accent-color: var(--accent); margin: 0; }
.dpost textarea { margin: 8px 0 4px; min-height: 140px; }
.dpost .pre { white-space: pre-wrap; margin-top: 6px; font-size: 13px; }
.dpost-actions { flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.dpost-actions input[type=datetime-local] { width: auto; max-width: 210px; padding: 5px 8px; }
.cal { display: flex; flex-direction: column; gap: 6px; }
.cal-day { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft) inset; }
.cal-day.empty-day { padding: 7px 12px; }
.cal-date { display: flex; flex-direction: column; line-height: 1.15; }
.cal-date b { font-size: 20px; font-weight: 650; }
.cal-date span { font-size: 12px; color: var(--text-2); }
.cal-day.today .cal-date span { color: var(--accent); font-weight: 600; }
.cal-day.empty-day .cal-date { flex-direction: row; align-items: baseline; gap: 6px; }
.cal-day.empty-day .cal-date b { font-size: 15px; }
.cal-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; justify-content: center; min-height: 22px; }
.cal-post { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.cal-text { font-size: 13.5px; }
.pre-line.open { white-space: pre-line; }
.cal-text a { font-weight: 600; }
.cal-slots { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-2); }
.cal-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 0; border-top: 1px solid var(--line); }
.cal-item:first-of-type { border-top: 0; }
.cal-time { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
@media (max-width: 600px) {
  .cal-day { grid-template-columns: 44px minmax(0, 1fr); gap: 8px; padding: 8px 10px; }
  .cal-post { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 4px; }
  .cal-post .cal-time { grid-row: 1; }
  .cal-post .cal-text { grid-column: 1 / -1; grid-row: 2; --lines: 2 !important; }
}
.goal-bar { height: 8px; border-radius: 6px; background: var(--bg-2); overflow: hidden; margin: 4px 0 10px; }
.goal-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); border-radius: 6px; }
.goal-form { flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.goal-form .input { flex: 1 1 140px; }
.factors { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.factor-row { display: grid; grid-template-columns: 110px 1fr auto auto; align-items: center; gap: 6px; font-size: 12.5px; margin-top: 4px; }
.factor-bar { height: 6px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.factor-bar span { display: block; height: 100%; background: var(--accent); }
.idea b { font-size: 14.5px; }
.post-meta { flex-wrap: wrap; row-gap: 4px; }

/* ---------- memory ---------- */
.chip-btn { border: 1px solid var(--line); background: var(--bg-2); color: var(--text-2); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; }
.chip-btn.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.recall-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.recall-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.recall-snip { font-size: 13.5px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }
.recall-snip mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; padding: 0 2px; }
.recall-full { white-space: pre-wrap; font-size: 13px; margin-top: 8px; max-height: 420px; overflow: auto; padding: 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.mem-note { padding: 10px 0; border-top: 1px solid var(--line); }
.mem-note:first-of-type { border-top: 0; }
.mem-note .row { gap: 6px; }
.mem-body { font-size: 13.5px; margin-top: 6px; white-space: pre-line; }
.mem-pending { border-color: var(--accent); }
.mem-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.mem-hist { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--line); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: right; font-weight: 500; color: var(--text-3); padding: 4px 6px; white-space: nowrap; }
.tbl td { text-align: right; padding: 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl .pos { color: #2fa866; }
.tbl .neg { color: #e0544b; }
.pill { display: inline-block; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }

/* one rule for spacing between blocks on every page (cards, heroes, forms, grids) */
#view > :is(section, .card, form, div, details, .hero) + :is(section, .card, form, div, details, .hero) { margin-top: 14px; }
:is(.today-grid, .fin-grid) > * > :is(section, .card, form, details) + :is(section, .card, form, details) { margin-top: 12px; }
@media (max-width: 760px) {
  #view > :is(section, .card, form, div, details, .hero) + :is(section, .card, form, div, details, .hero) { margin-top: 10px; }
}

/* Taps answer at once: no double-tap zoom wait, a visible press. */
button, a, [data-nav], [data-action], [data-project], [data-open-project], [data-panel], [data-inbox-filter], .tap, .hero-tile, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:active, [data-nav]:active, [data-action]:active, [data-project]:active, [data-open-project]:active, .tap:active, .hero-tile.tap:active { transform: scale(.97); opacity: .75; transition: transform .06s, opacity .06s; }
.loading-ph { display: grid; gap: 12px; padding: 4px 0; }
.loading-ph span { display: block; height: 84px; border-radius: 16px; background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04)); background-size: 200% 100%; animation: ph 1.1s linear infinite; }
@keyframes ph { to { background-position: -200% 0; } }

/* sections: segments, home blocks, folded details, the system light */
.seg-main { display: flex; width: 100%; margin-bottom: 12px; }
.seg-main button { flex: 1; padding: 7px 8px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-item, .wait-item { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.run-item:first-of-type, .wait-item:first-of-type { border-top: 0; padding-top: 2px; }
.run-item .row, .wait-item .row { gap: 8px; align-items: center; min-width: 0; }
.run-bar { height: 6px; border-radius: 4px; background: var(--bg-2); overflow: hidden; margin-top: 2px; }
.run-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .6s; }
.run-sub { font-size: 13px; color: var(--text-2); }
.wait-item.tap { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; font: inherit; cursor: pointer; }
.wait-item.tap svg.i { transform: rotate(180deg); opacity: .5; }
.wait-item .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
details.fold > summary { cursor: pointer; list-style: none; margin: 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { margin-bottom: 10px; }
details.fold .hero { margin-top: 0; }
.sys-lamp { display: flex; align-items: center; gap: 12px; }
.lamp { width: 14px; height: 14px; border-radius: 50%; flex: none; background: #2fa866; box-shadow: 0 0 0 4px rgba(47,168,102,.18); }
.lamp.warn { background: #e0a53a; box-shadow: 0 0 0 4px rgba(224,165,58,.2); }
.lamp.bad { background: #e0544b; box-shadow: 0 0 0 4px rgba(224,84,75,.2); }
details.fold .page-head h1 { display: none; }
details.fold .page-head { margin-bottom: 8px; }
details.fold .seg { display: flex; flex-wrap: wrap; max-width: 100%; }
/* home: one summary tile per optional module */
.mod-sums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mod-sum { display: grid; gap: 2px; text-align: left; padding: 12px; border-radius: var(--radius, 14px); background: var(--panel); border: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer; min-width: 0; }
.mod-sum .ms-t { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-sum .ms-v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-sum .ms-n { font-size: 12px; color: var(--text-3); line-height: 1.3; }
.mod-sums:only-child, .mod-sums > .mod-sum:only-child { grid-column: 1 / -1; }

/* the assistant's face (public/spark.js) */
.brand mf-spark { margin-right: 2px; }
.em-face { display: flex; justify-content: center; margin-bottom: 6px; }
.sec-title mf-spark { margin: -4px 2px -4px -2px; }
.steps summary mf-spark { margin: -4px 4px -4px 0; }
.run-item .row mf-spark { margin: -4px 0; }
.model-form { display: grid; gap: 8px; }
.model-form .field { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-3); }
.ok-line { color: var(--ok); font-size: 13.5px; }
.bad-line { color: var(--bad); font-size: 13.5px; }
/* «Где работает»: mail, Google, the computer bridge */
.sec-sub { font-weight: 600; font-size: 13px; margin: 14px 0 6px; color: var(--text-2); }
pre.cmd { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: 12px/1.4 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; user-select: all; margin: 4px 0 8px; }
/* the owner's tasks on the home screen */
.td-card { padding-bottom: 8px; }
.td-add { display: flex; gap: 6px; margin: 2px 0 6px; }
.td-add .input { padding: 8px 10px; }
.td-group { margin-top: 6px; }
.td-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 6px 2px 2px; }
.td-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-top: 1px solid var(--line); min-height: 40px; transition: opacity .25s; }
.td-group .td-row:first-of-type { border-top: 0; }
.td-row.gone { opacity: .35; text-decoration: line-through; }
.td-row .check { width: 22px; height: 22px; }
.td-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.td-due { font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.td-due.late { color: var(--bad); font-weight: 600; }
.td-who { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.td-today { border: 0; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; padding: 5px 8px; border-radius: 99px; cursor: pointer; white-space: nowrap; }
.td-more { border: 0; background: none; color: var(--accent); font-size: 12.5px; padding: 6px 2px; cursor: pointer; }
