:root {
  color-scheme: dark;
  --ink: #111019;
  --canvas: #14111d;
  --surface: #1d1928;
  --surface-raised: #272136;
  --line: #393247;
  --text: #f7f6fa;
  --muted: #aaa2bb;
  --violet: #7850f5;
  --violet-soft: #c6acff;
  --indigo: #38218c;
  --success: #a6e8c8;
  --danger: #ff879b;
  --ease: cubic-bezier(.23, 1, .32, 1);
  font-family: "Avenir Next", Inter, system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--canvas); }
button, textarea, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--violet-soft); outline-offset: 3px; }

.offline { position: fixed; z-index: 30; top: 10px; left: 50%; transform: translateX(-50%); padding: 9px 14px; border-radius: 12px; color: var(--ink); background: var(--violet-soft); font-size: 13px; }
.eyebrow { margin: 0 0 8px; color: var(--violet-soft); font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }

.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 32px 24px; overflow: hidden; position: relative; isolation: isolate; }
.auth-sphere { position: fixed; z-index: 0; top: max(-330px, -22vw); left: max(-300px, -15vw); width: min(62vw, 760px); height: min(62vw, 760px); pointer-events: none; contain: strict; will-change: transform; transform: translateZ(0); }
.auth-sphere canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.auth-card { position: relative; z-index: 1; width: min(100%, 448px); padding: 40px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: 0 26px 72px rgba(0,0,0,.36); animation: auth-card-in 280ms var(--ease) both; }
.auth-logo { width: 48px; height: 48px; margin-bottom: 26px; }
.auth-card h1 { max-width: 320px; margin: 0; font-size: clamp(40px, 5vw, 52px); line-height: .98; letter-spacing: -.05em; }
.auth-card > p:not(.eyebrow):not(.inline-error) { max-width: 360px; margin: 20px 0 28px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.telegram-login { min-height: 54px; display: grid; gap: 12px; }
.auth-button { width: 100%; min-height: 54px; padding-inline: 22px; border-radius: 15px; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.auth-progress { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.auth-card .inline-error { margin: 14px 0 0; color: var(--danger); font-size: 14px; line-height: 1.45; }
.inline-error { color: var(--danger); line-height: 1.4; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); background: var(--canvas); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 14px; border-right: 1px solid var(--line); background: var(--ink); display: flex; flex-direction: column; }
.brand { height: 48px; margin: 0 10px 30px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; letter-spacing: .16em; }
.brand img { width: 34px; height: 34px; }
.main-nav, .sidebar-bottom { display: grid; gap: 4px; }
.main-nav button, .sidebar-bottom button { min-height: 46px; padding: 0 13px; border: 0; border-radius: 14px; color: var(--muted); background: transparent; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; transition: color 150ms var(--ease), background 150ms var(--ease), transform 120ms var(--ease); }
.main-nav button:hover, .sidebar-bottom button:hover { color: var(--text); background: var(--surface); }
.main-nav button:active, .sidebar-bottom button:active { transform: scale(.98); }
.main-nav button.active { color: var(--text); background: var(--surface-raised); }
.main-nav img, .sidebar-bottom img { width: 22px; height: 22px; object-fit: contain; }
.nav-symbol { width: 22px; color: var(--violet-soft); text-align: center; }
.sidebar-bottom { margin-top: auto; }
.sidebar-bottom button { width: 100%; }
.plan-dot { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--muted); }
.plan-dot.active { background: var(--success); }
.avatar { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--violet-soft), var(--indigo)); font-size: 12px; font-weight: 700; }

.workspace { width: min(100%, 920px); min-width: 0; margin: 0 auto; padding: 42px clamp(24px, 5vw, 64px) 90px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 26px; }
.topbar h1 { margin: 0; font-size: clamp(34px, 5vw, 54px); line-height: 1; letter-spacing: -.045em; }
.icon-button, .detail-close { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: 24px; }

.capture-box { margin-bottom: 34px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 14px 38px rgba(0,0,0,.16); }
.capture-box label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.capture-row { display: flex; align-items: flex-end; gap: 12px; }
.capture-row textarea { flex: 1; min-width: 0; max-height: 160px; padding: 5px 0; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 16px; line-height: 1.5; }
.capture-row textarea::placeholder { color: #756d84; }
.primary-button, .secondary-button, .danger-button, .chip { min-height: 42px; padding: 0 17px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 650; transition: transform 120ms var(--ease), background 150ms var(--ease); }
.primary-button { color: white; background: var(--violet); }
.primary-button:hover { background: #8967f7; }
.primary-button:active, .secondary-button:active, .danger-button:active, .chip:active { transform: scale(.97); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--line); background: var(--surface-raised); }
.danger-button { color: var(--danger); border: 1px solid rgba(255,135,155,.26); background: transparent; }
.status-line { min-height: 0; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.status-line:empty { display: none; }

.screen { min-height: 280px; }
.screen-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 0 0 18px; }
.screen-head h2 { margin: 0; font-size: 18px; }
.segments { padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink); display: flex; }
.segments button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; }
.segments button.active { color: var(--text); background: var(--surface-raised); }
.group { margin-bottom: 28px; }
.group-title { margin: 0 0 9px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .04em; }
.entry-list { border-top: 1px solid var(--line); }
.entry-row { width: 100%; min-height: 70px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: transparent; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 12px; text-align: left; cursor: pointer; transition: padding 160ms var(--ease), background 160ms var(--ease); }
.entry-row:hover { padding-left: 10px; padding-right: 10px; background: rgba(39,33,54,.58); }
.entry-check { width: 22px; height: 22px; border: 1px solid #665b7b; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.entry-check.done { border-color: var(--success); color: var(--ink); background: var(--success); }
.entry-copy { min-width: 0; }
.entry-text { display: block; overflow-wrap: anywhere; font-size: 15px; line-height: 1.4; }
.entry-meta { display: flex; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.entry-when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.entry-when.overdue { color: var(--danger); }
.kind-badge { color: var(--violet-soft); }
.empty { min-height: 240px; padding: 46px 28px; border: 1px dashed var(--line); border-radius: 24px; display: grid; place-items: center; text-align: center; }
.empty-symbol { width: 84px; height: 84px; border-radius: 50%; background: linear-gradient(145deg, rgba(198,172,255,.24), rgba(56,33,140,.38)); display: grid; place-items: center; font-size: 30px; }
.empty h2 { margin: 18px 0 7px; font-size: 20px; }
.empty p { max-width: 360px; margin: 0; color: var(--muted); line-height: 1.5; }
.skeleton { height: 70px; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 18px 10%; border-radius: 8px; background: var(--surface-raised); opacity: .65; animation: breathe 1.1s ease-in-out infinite alternate; }

.search-form { display: flex; gap: 10px; margin-bottom: 22px; }
.search-form input { flex: 1; min-width: 0; min-height: 50px; padding: 0 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: var(--surface); font-size: 16px; }
.subscription-card { padding: 28px; border: 1px solid var(--line); border-radius: 26px; background: linear-gradient(145deg, var(--surface-raised), var(--surface)); }
.subscription-card h2 { margin: 0 0 8px; font-size: 28px; }
.subscription-card p { color: var(--muted); line-height: 1.5; }
.subscription-facts { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 24px 0; }
.fact { padding: 16px; border-radius: 16px; background: var(--ink); }
.fact strong { display: block; font-size: 20px; }
.fact span { color: var(--muted); font-size: 12px; }

.detail { position: fixed; z-index: 12; top: 0; right: 0; width: min(430px, 100%); height: 100vh; padding: 24px 28px; overflow: auto; border-left: 1px solid var(--line); background: rgba(20,17,29,.98); box-shadow: -30px 0 80px rgba(0,0,0,.28); animation: panel-in 260ms var(--ease) both; }
.detail-close { display: block; margin-left: auto; }
.detail .eyebrow { margin-top: 36px; }
.detail h2 { margin: 0; font-size: 30px; line-height: 1.16; letter-spacing: -.03em; overflow-wrap: anywhere; }
.detail-meta { margin: 16px 0 28px; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.toast { position: fixed; z-index: 40; right: 22px; bottom: 22px; max-width: 360px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); box-shadow: 0 16px 48px rgba(0,0,0,.3); animation: toast-in 180ms var(--ease) both; }
.mobile-nav { display: none; }

@keyframes panel-in { from { opacity: 0; transform: translateX(18px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes breathe { to { opacity: 1; } }
@keyframes auth-card-in { from { opacity: 0; transform: translateY(8px) scale(.975); } }

@media (max-width: 820px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { padding: 24px 18px calc(108px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 20px; }
  .topbar h1 { font-size: 36px; }
  .capture-box { margin-bottom: 26px; }
  .capture-row { align-items: stretch; }
  .capture-row textarea { min-height: 52px; }
  .capture-row .primary-button { padding: 0 14px; }
  .mobile-nav { position: fixed; z-index: 10; left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom)); min-height: 68px; padding: 6px; border: 1px solid var(--line); border-radius: 22px; background: rgba(29,25,40,.96); backdrop-filter: blur(18px); display: grid; grid-template-columns: repeat(5,1fr); align-items: center; }
  .mobile-nav button { min-width: 44px; min-height: 50px; padding: 4px; border: 0; border-radius: 15px; color: var(--muted); background: transparent; display: grid; place-items: center; gap: 1px; }
  .mobile-nav button.active { color: var(--text); background: var(--surface-raised); }
  .mobile-nav img { width: 21px; height: 21px; }
  .mobile-nav small { font-size: 10px; }
  .mobile-nav .capture-button { width: 48px; height: 48px; min-height: 48px; justify-self: center; border-radius: 17px; color: white; background: var(--violet); font-size: 25px; }
  .detail { padding: 18px 20px calc(92px + env(safe-area-inset-bottom)); }
  .detail h2 { font-size: 26px; }
  .entry-row { grid-template-columns: 30px minmax(0,1fr); }
  .entry-when { grid-column: 2; }
  .subscription-facts { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .auth-view { padding: 0; background: var(--surface); }
  .auth-sphere { top: -210px; left: -170px; width: 430px; height: 430px; opacity: .88; }
  .auth-card { min-height: 100vh; padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom)); border: 0; border-radius: 0; background: transparent; box-shadow: none; display: flex; flex-direction: column; justify-content: center; }
  .auth-logo { width: 44px; height: 44px; margin-bottom: 24px; }
  .auth-card h1 { font-size: clamp(40px, 13vw, 52px); }
  .auth-card > p:not(.eyebrow):not(.inline-error) { margin: 18px 0 26px; }
  .capture-box { padding: 15px; }
  .screen-head { align-items: flex-start; flex-direction: column; }
  .segments { width: 100%; }
  .segments button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
