@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-cyrillic.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Scene: a warm, dim room behind frosted glass. Inner cards are light paper on top of the glass. */
:root {
  --scene-1: #1a120c;
  --scene-2: #4a2e18;
  --scene-3: #2b1c12;
  --glass: rgb(30 26 24 / 58%);
  --glass-2: rgb(255 255 255 / 7%);
  --glass-line: rgb(255 255 255 / 10%);
  --on-glass: #f4efe9;
  --on-glass-muted: #b5aca3;
  --card: #f7f5f2;
  --card-2: #ece8e3;
  --ink: #1d1916;
  --ink-muted: #857b72;
  --line: #e2ddd7;
  --accent: #f26b21;
  --accent-ink: #ffffff;
  --accent-soft: #fde4d4;
  --ok: #22a755;
  --ok-soft: #dcf3e4;
  --bad: #e0393e;
  --bad-soft: #fbe0e0;
  --info: #2f6fe4;
  --info-soft: #e1eafc;
  --r-panel: 28px;
  --r-card: 18px;
  --r-pill: 999px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --scene-1: #e9dccd;
    --scene-2: #f6c79a;
    --scene-3: #d9c2a8;
    --glass: rgb(255 255 255 / 45%);
    --glass-2: rgb(255 255 255 / 55%);
    --glass-line: rgb(255 255 255 / 70%);
    --on-glass: #241c16;
    --on-glass-muted: #6f6359;
    --card: #ffffff;
    --card-2: #f3efea;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 500 14px/1.45 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--on-glass);
  background:
    radial-gradient(60% 55% at 18% 12%, var(--scene-2) 0%, transparent 70%),
    radial-gradient(45% 50% at 88% 85%, rgb(242 107 33 / 28%) 0%, transparent 70%),
    radial-gradient(70% 60% at 70% 10%, var(--scene-3) 0%, transparent 75%),
    var(--scene-1);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

/* ---------- frame ---------- */
.shell {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 340px;
  gap: 16px;
  height: 100vh;
  padding: 18px;
}
.shell.wide { grid-template-columns: 76px minmax(0, 1fr); }
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-panel);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 6%), 0 20px 50px rgb(0 0 0 / 25%);
}
.main, .side { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 15%) transparent; }
.main { padding: 22px 24px 28px; }
.side { padding: 18px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- rail ---------- */
.rail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0; }
.logo { width: 40px; height: 40px; border-radius: 13px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 19px; margin-bottom: 18px; }
.rail-btn {
  position: relative; width: 44px; height: 44px; border-radius: 14px; border: 0; background: none;
  color: var(--on-glass-muted); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s;
}
.rail-btn:hover { color: var(--on-glass); background: var(--glass-2); }
.rail-btn[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn .tip {
  position: absolute; left: 54px; top: 50%; transform: translateY(-50%); white-space: nowrap;
  background: var(--ink); color: #fff; font-size: 12px; padding: 4px 9px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.rail-btn:hover .tip, .rail-btn:focus-visible .tip { opacity: 1; }
.rail .spacer { flex: 1; }

/* ---------- header ---------- */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.head .sub { color: var(--on-glass-muted); font-size: 13px; margin-top: 2px; }
.head-tools { display: flex; gap: 10px; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; width: 280px; max-width: 100%;
  background: var(--glass-2); border: 1px solid var(--glass-line); border-radius: var(--r-pill); padding: 0 14px;
}
.search svg { width: 16px; height: 16px; color: var(--on-glass-muted); flex: none; }
.search input { border: 0; background: none; outline: none; padding: 9px 0; width: 100%; color: var(--on-glass); }
.search input::placeholder { color: var(--on-glass-muted); }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--glass-line); background: var(--glass-2);
  color: var(--on-glass); display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .pip { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--scene-1); }
.popover {
  position: absolute; right: 0; top: 48px; z-index: 30; width: 300px; padding: 12px; border-radius: 16px;
  background: var(--card); color: var(--ink); box-shadow: 0 16px 40px rgb(0 0 0 / 30%); font-size: 13px;
}
.popover > * + * { margin-top: 8px; }
.rel { position: relative; }

/* ---------- light cards on glass ---------- */
.card { background: var(--card); color: var(--ink); border-radius: var(--r-card); padding: 16px; min-width: 0; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.card-title .hint { font-weight: 600; color: var(--ink-muted); font-size: 12px; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat { display: flex; flex-direction: column; gap: 6px; min-height: 132px; }
.stat-label { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; }
.stat-label .chip-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat-label .chip-ico svg { width: 13px; height: 13px; }
.stat-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; }
.value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); line-height: 1; }
.value small { font-size: 12px; font-weight: 600; color: var(--ink-muted); margin-left: 3px; letter-spacing: 0; }
.row2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 10px; }
.section-head h2 { font-size: 14px; font-weight: 700; padding-left: 10px; border-left: 3px solid var(--accent); line-height: 1.1; }
.link-btn { border: 0; background: none; color: var(--on-glass-muted); font-size: 12px; cursor: pointer; padding: 4px; }
.link-btn:hover { color: var(--on-glass); }
.ideas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.idea { display: flex; flex-direction: column; gap: 6px; min-height: 104px; }
.idea .t { font-weight: 700; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.idea.hot { background: var(--accent); color: var(--accent-ink); }
.idea.hot .muted { color: rgb(255 255 255 / 80%); }
.idea .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }

/* next-up card */
.next { display: flex; flex-direction: column; gap: 8px; background: var(--ink); color: #fff; position: relative; overflow: hidden; }
.next::after { content: ""; position: absolute; right: -40px; bottom: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgb(242 107 33 / 55%), transparent 70%); }
.next .muted { color: #b9b0a8; }
.next .big { font-size: 17px; font-weight: 700; line-height: 1.3; position: relative; z-index: 1; }
.next .when { font-size: 28px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; position: relative; z-index: 1; }

/* ---------- pills, badges, buttons ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; background: var(--card-2); color: var(--ink-muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer; white-space: nowrap;
  padding: 9px 16px; border-radius: var(--r-pill); font-weight: 700; font-size: 13px; background: var(--glass-2); color: var(--on-glass); border: 1px solid var(--glass-line);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { filter: brightness(1.1); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.card .btn:not(.primary) { background: var(--card-2); color: var(--ink); border-color: transparent; }
.ghost { border: 0; background: none; color: var(--ink-muted); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.ghost:hover { background: var(--card-2); color: var(--ink); }
.ghost.danger:hover { color: var(--bad); }
.ghost svg { width: 16px; height: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--glass-line); background: var(--glass-2); color: var(--on-glass-muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- lists (task rows like the reference's drill list) ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.task .body { flex: 1; min-width: 0; }
.task .day { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }
.task .t { font-weight: 700; font-size: 13.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.task.done .t { color: var(--ink-muted); text-decoration: line-through; }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.task .right { display: flex; align-items: center; gap: 4px; flex: none; }
.check {
  appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); flex: none; cursor: pointer; margin: 0;
}
.check:checked { background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; border-color: var(--ok); }
.lead-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; margin-top: 6px; color: var(--ink); }
.empty { color: var(--ink-muted); padding: 16px 0; text-align: center; font-size: 13px; }
.glass-empty { color: var(--on-glass-muted); padding: 24px 0; text-align: center; }

/* ---------- forms ---------- */
.field { display: block; font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 500; min-width: 0;
}
.field textarea { resize: vertical; min-height: 70px; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.form .full { grid-column: 1 / -1; }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; margin-bottom: 12px; }
.toolbar .search { width: auto; }
.toolbar select { border-radius: var(--r-pill); padding: 9px 14px; background: var(--glass-2); border: 1px solid var(--glass-line); color: var(--on-glass); }
.toolbar option { color: #1d1916; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search input:focus-visible { outline: none; }

/* ---------- side panel ---------- */
.profile { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #ffb37a); color: #fff; display: grid; place-items: center; font-weight: 800; }
.profile .name { font-weight: 700; }
.profile .role { color: var(--on-glass-muted); font-size: 12px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--glass-2); border: 1px solid var(--glass-line); border-radius: 16px; padding: 12px 6px; text-align: center; }
.trio b { display: block; font-size: 17px; font-weight: 800; }
.trio span { color: var(--on-glass-muted); font-size: 11.5px; }
.trio > div + div { border-left: 1px solid var(--glass-line); }
.cal { background: var(--glass-2); border: 1px solid var(--glass-line); border-radius: 18px; padding: 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--glass-line); background: none; color: var(--on-glass); cursor: pointer; display: grid; place-items: center; }
.cal-nav svg { width: 14px; height: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px 2px; text-align: center; font-size: 12px; }
.cal-grid .dow { color: var(--on-glass-muted); font-size: 11px; padding-bottom: 4px; }
.cal-grid .d { height: 30px; display: grid; place-items: center; border-radius: 50%; width: 30px; margin: 0 auto; font-weight: 600; }
.cal-grid .d.today { box-shadow: inset 0 0 0 1.5px var(--on-glass); }
.cal-grid .d.done { background: var(--ok); color: #fff; }
.cal-grid .d.due { background: var(--accent); color: #fff; }
.cal-grid .d.overdue { background: var(--bad); color: #fff; }
.cal-legend { display: flex; gap: 12px; margin-top: 10px; font-size: 11px; color: var(--on-glass-muted); flex-wrap: wrap; }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.side .section-head { margin: 0; }
.sched { display: flex; align-items: center; gap: 10px; padding: 10px; }
.sched .tile { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 18px; flex: none; }
.sched .body { min-width: 0; flex: 1; }
.sched .t { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* spend */
.spend-today { font-size: 12px; color: var(--on-glass-muted); font-weight: 600; }
.spend-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.spend-row b { font-size: 22px; font-weight: 800; color: var(--accent); }
.spend-row span { color: var(--on-glass-muted); font-size: 12px; }
.spend .meter { background: rgb(255 255 255 / 10%); }
.spend-kinds { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 11.5px; color: var(--on-glass-muted); }

/* chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 380px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; scrollbar-width: thin; }
.bubble { max-width: min(78%, 640px); padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.bubble.assistant { align-self: flex-start; background: var(--card); color: var(--ink); border-bottom-left-radius: 6px; }
.bubble.thinking { color: var(--ink-muted); font-style: italic; }
.bubble.error { background: var(--bad-soft); color: var(--bad); }
.chat-input { display: flex; gap: 10px; align-items: flex-end; padding-top: 12px; border-top: 1px solid var(--glass-line); }
.chat-input textarea {
  flex: 1; resize: none; border-radius: 20px; padding: 11px 16px; border: 1px solid var(--glass-line); background: var(--glass-2); color: var(--on-glass); line-height: 1.4; max-height: 160px;
}
.chat-input textarea::placeholder { color: var(--on-glass-muted); }
.chat-input .btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; }
a.btn { text-decoration: none; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 190px; }
.chart text { font-size: 10px; fill: var(--ink-muted); font-family: inherit; font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; font-weight: 600; color: var(--ink-muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.seg { display: inline-flex; background: var(--card-2); border-radius: var(--r-pill); padding: 3px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; color: var(--ink-muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }
.meter { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.hot > i { background: var(--bad); }
.dotline { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); flex: none; }
.dot.up { background: var(--ok); }
.dot.down { background: var(--bad); }
.alert { background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; margin-bottom: 14px; }
.alert.soft { background: var(--glass-2); color: var(--on-glass); border: 1px solid var(--glass-line); font-weight: 600; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .glass { width: 100%; max-width: 380px; padding: 30px; }
.login .logo { margin-bottom: 18px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login p { color: var(--on-glass-muted); margin-bottom: 18px; }
.login form > * + * { margin-top: 12px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--glass-line); background: var(--glass-2); color: var(--on-glass); }
.login .btn { width: 100%; padding: 12px; }
.error { color: #ff8a80; font-size: 13px; min-height: 1.2em; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100vw - 32px); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); height: auto; min-height: 100vh; }
  .side { grid-column: 2; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
  .main, .side { overflow: visible; }
  .rail { position: sticky; top: 18px; height: calc(100vh - 36px); }
}
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; padding: 12px 12px calc(92px + env(safe-area-inset-bottom)); gap: 12px; }
  .side { grid-column: 1; }
  .main { padding: 18px 16px 20px; }
  .rail {
    position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); top: auto; height: auto;
    flex-direction: row; justify-content: space-around; padding: 8px; border-radius: 24px;
  }
  .logo, .rail .spacer { display: none; }
  .rail-btn .tip { display: none; }
  .search { width: 100%; }
  .head-tools { width: 100%; }
  .ideas { grid-template-columns: 1fr; }
  .task { flex-wrap: wrap; align-items: flex-start; }
  .task .body { flex: 1 1 calc(100% - 40px); }
  .task .right { width: 100%; justify-content: flex-end; margin-top: -4px; }
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .chat { height: calc(100vh - 260px); }
  .bubble { max-width: 88%; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { min-height: 118px; padding: 13px; }
  .stat-foot { flex-direction: column; align-items: flex-start; gap: 8px; }
  .value { font-size: 20px; }
  .value small { display: block; margin: 4px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
