:root {
  --bg: #0a0c11;
  --bg-glow: rgba(124, 108, 255, .18);
  --surface: #141823;
  --surface-2: #1e2430;
  --surface-3: #2a3242;
  --text: #eef1f7;
  --muted: #94a0b4;
  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, .14);
  --accent-2: #34d399;
  --danger: #fb7185;
  --amber: #fbbf24;
  --grad: linear-gradient(135deg, #7c6cff 0%, #5b8def 100%);
  --grad-warm: linear-gradient(135deg, #fb7185 0%, #fbbf24 100%);
  --grad-mint: linear-gradient(135deg, #34d399 0%, #5b8def 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-accent: 0 6px 18px rgba(124, 108, 255, .42);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5fb;
    --bg-glow: rgba(124, 108, 255, .16);
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --surface-3: #e2e7f2;
    --text: #161a23;
    --muted: #6b7488;
    --accent-soft: rgba(124, 108, 255, .12);
    --shadow: 0 8px 24px rgba(80, 90, 130, .14);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(130% 70% at 50% -15%, var(--bg-glow), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
::selection { background: var(--accent-soft); }

/* ---- Вход ---- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.gate-card {
  background: var(--surface); border-radius: 26px; padding: 34px 26px;
  width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .05);
}
.gate-logo {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 22px;
  background: var(--grad); display: grid; place-items: center; font-size: 38px;
  box-shadow: var(--shadow-accent);
}
.gate-card h1 { font-size: 22px; margin: 6px 0 6px; letter-spacing: -.3px; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.gate-card input, #token-input {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--surface-3); background: var(--surface-2);
  color: var(--text); font-size: 16px; margin-bottom: 12px; transition: border-color .2s;
}
#token-input:focus { outline: none; border-color: var(--accent); }
.gate-card button {
  width: 100%; padding: 14px; border: 0; border-radius: 14px; background: var(--grad);
  color: #fff; font-size: 16px; font-weight: 700; box-shadow: var(--shadow-accent);
}
.gate-card button:active { transform: scale(.98); }
.gate-err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---- Каркас ---- */
.app { display: flex; flex-direction: column; height: 100%; max-width: 660px; margin: 0 auto; }
.top {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px 8px;
}
.hello { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
#hello-name {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.chips { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05);
  padding: 5px 11px; border-radius: 20px;
}
.chip.warn { color: var(--danger); background: rgba(251, 113, 133, .12); border-color: transparent; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05);
  color: var(--muted); font-size: 18px; width: 40px; height: 40px; border-radius: 12px;
}
.icon-btn:active { transform: scale(.94); }

/* ---- Вкладки ---- */
.tabs { display: flex; gap: 8px; padding: 8px 14px 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05);
  padding: 9px 16px; border-radius: 22px; transition: all .18s;
}
.tab.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-accent); }

/* ---- Список ---- */
.list { flex: 1; overflow-y: auto; padding: 4px 14px 14px; -webkit-overflow-scrolling: touch; }
.list-head { font-size: 13px; color: var(--muted); margin: 14px 6px 10px; font-weight: 700; letter-spacing: .2px; }
.empty { text-align: center; color: var(--muted); padding: 56px 24px; font-size: 15px; line-height: 1.6; }

.card {
  display: flex; align-items: flex-start; gap: 12px; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05);
  border-radius: var(--radius); padding: 14px 14px 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .14s ease;
  animation: cardIn .22s ease both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } }
.card:active { transform: scale(.992); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: transparent; }
.card.prio-high::before { background: var(--grad-warm); }
.card.overdue::before { background: var(--danger); }
.card.st-doing::before { background: var(--accent); }
.card.st-done::before { background: var(--accent-2); }

.check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--surface-3); background: none; margin-top: 1px;
  display: grid; place-items: center; color: #fff; font-size: 14px; transition: all .18s;
}
.check.done { background: var(--grad-mint); border-color: transparent; box-shadow: 0 3px 10px rgba(52, 211, 153, .4); }
.body { flex: 1; min-width: 0; }
.title { font-size: 15.5px; font-weight: 650; letter-spacing: -.2px; }
.title.done { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.badge {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); padding: 3px 9px; border-radius: 9px;
}
.badge.date { color: #aab6ff; background: rgba(124, 108, 255, .12); }
.badge.over { color: #fff; background: var(--danger); }
.badge.high { color: #fff; background: var(--grad-warm); }
.badge.doing { color: #fff; background: var(--accent); }
.badge.tag { color: var(--accent-2); background: rgba(52, 211, 153, .12); }
.del { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 4px; opacity: .6; }
.del:active { opacity: 1; }

/* ---- Ассистент ---- */
.assistant {
  margin: 0 14px 10px; padding: 14px 16px; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(124, 108, 255, .12), rgba(91, 141, 239, .06));
  border: 1px solid rgba(124, 108, 255, .22);
}

/* ---- Композер ---- */
.composer {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.composer input {
  flex: 1; padding: 13px 16px; border-radius: 24px; border: 1px solid var(--surface-3);
  background: var(--surface); color: var(--text); font-size: 16px; transition: border-color .2s;
}
.composer input:focus { outline: none; border-color: var(--accent); }
.mic, .send {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: 0;
  font-size: 18px; color: #fff; transition: transform .12s;
}
.mic { background: var(--surface-2); color: var(--muted); }
.send { background: var(--grad); box-shadow: var(--shadow-accent); }
.mic:active, .send:active { transform: scale(.92); }
.mic.rec { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---- Доска (канбан) ---- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.col {
  flex: 0 0 84%; background: color-mix(in srgb, var(--surface) 60%, transparent);
  border: 1px solid rgba(255, 255, 255, .05); border-radius: var(--radius); padding: 10px;
}
.col-head { font-size: 13px; font-weight: 800; color: var(--text); margin: 4px 6px 12px; display: flex; align-items: center; }
.col-n { background: var(--accent-soft); color: var(--accent); border-radius: 20px; padding: 1px 9px; font-size: 11px; margin-left: 8px; }
.col .card { box-shadow: none; }
.col-empty { color: var(--muted); text-align: center; padding: 22px; font-size: 13px; }

/* ---- Карточка задачи (sheet) ---- */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; z-index: 60; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet-card {
  background: var(--surface); width: 100%; max-height: 88vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  max-width: 660px; margin: 0 auto; box-shadow: 0 -10px 40px rgba(0, 0, 0, .4);
  animation: slideUp .26s cubic-bezier(.22, 1, .36, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-grip { width: 42px; height: 4px; background: var(--surface-3); border-radius: 2px; margin: 4px auto 14px; }
.sheet-title { font-size: 20px; font-weight: 800; margin-bottom: 10px; letter-spacing: -.3px; }
.seg-row { display: flex; gap: 7px; margin: 16px 0; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg { flex: 1; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; transition: all .18s; }
.seg.on { background: var(--grad); color: #fff; box-shadow: var(--shadow-accent); }
.sub-head { font-size: 13px; color: var(--muted); font-weight: 800; margin: 14px 2px 8px; }
.sub { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--surface-2); }
.sub input { width: 22px; height: 22px; accent-color: var(--accent-2); flex: 0 0 auto; }
.sub .sdone { color: var(--muted); text-decoration: line-through; }
.sub-add { display: flex; gap: 9px; margin-top: 12px; }
.sub-add input { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--surface-3); background: var(--surface-2); color: var(--text); font-size: 15px; }
.sub-add input:focus { outline: none; border-color: var(--accent); }
.sub-add button { width: 48px; border: 0; border-radius: 12px; background: var(--grad); color: #fff; font-size: 22px; box-shadow: var(--shadow-accent); }
.sheet-del { width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 12px; background: rgba(251, 113, 133, .12); color: var(--danger); font-size: 14px; font-weight: 600; }

/* ---- Тост ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  background: rgba(20, 24, 35, .96); color: #fff; padding: 12px 18px; border-radius: 14px;
  font-size: 14px; max-width: 90%; text-align: center; z-index: 70; box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .08); animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.dots { animation: pulse 1.1s ease-in-out infinite; }
.card.pending { opacity: .72; }
.card.pending .check { border-style: dashed; border-color: var(--accent); }
.spinner { opacity: .6; }

/* ===== скин «Шалфей» — единый стиль с Life-дашбордом ===== */
:root {
  --bg: #10160f;
  --bg-glow: rgba(215, 181, 109, .10);
  --surface: #1a221a;
  --surface-2: #242e23;
  --surface-3: #3e4d3d;
  --text: #e9efe6;
  --muted: #8fa08b;
  --accent: #d7b56d;
  --accent-soft: rgba(215, 181, 109, .16);
  --accent-2: #7ecb8f;
  --danger: #e07a6d;
  --amber: #e0c25e;
  --grad: linear-gradient(135deg, #d7b56d 0%, #b99447 100%);
  --grad-warm: linear-gradient(135deg, #e07a6d 0%, #e0c25e 100%);
  --grad-mint: linear-gradient(135deg, #7ecb8f 0%, #9ccb7e 100%);
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-accent: 0 6px 18px rgba(215, 181, 109, .28);
}
@media (prefers-color-scheme: light) {
  /* единая тёмная тема на всех устройствах — как у Life */
  :root {
    --bg: #10160f; --bg-glow: rgba(215, 181, 109, .10);
    --surface: #1a221a; --surface-2: #242e23; --surface-3: #3e4d3d;
    --text: #e9efe6; --muted: #8fa08b;
    --accent-soft: rgba(215, 181, 109, .16);
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  }
}
body { font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif; }
/* тёмный текст на золотом */
.tab.active, .seg.on, .gate-card button, .send, .badge.doing { color: #1c1508; }
.badge.date { color: var(--accent); background: var(--accent-soft); }
.badge.tag { color: var(--accent-2); background: rgba(126, 203, 143, .14); }
.badge.high { color: #1c1508; }
.toast { background: rgba(26, 34, 26, .96); }

/* навигация между приложениями */
.hubnav { display: flex; gap: 8px; padding: 2px 14px 4px; flex-wrap: wrap; }
.hubnav a, .hubnav span {
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05); color: var(--muted);
  border-radius: 99px; padding: 6px 13px; font-size: 13px; font-weight: 700;
  text-decoration: none; white-space: nowrap;
}
.hubnav .on { color: var(--accent); border-color: var(--accent); }

/* доска на широких экранах */
@media (min-width: 900px) {
  .app { max-width: 1160px; }
  .sheet-card { max-width: 720px; border-radius: 26px; margin: auto; }
  .list { columns: 2; column-gap: 12px; }
  .list > * { break-inside: avoid; }
  .list-head { column-span: all; }
  .assistant, .board { column-span: all; }
  .board { display: flex; }
  .col { flex: 1 1 0; }
}
