:root {
  --bg: #F2F2F2;
  --card: #FFFFFF;
  --ink: #0A0A0A;
  --muted: #8A8A8A;
  --accent: #0A0A0A;
  --hair: #E5E5E5;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  letter-spacing: -0.01em;
}

.font-display { font-family: 'Space Grotesk', 'Inter', sans-serif; letter-spacing: -0.03em; }
.num { font-feature-settings: 'tnum'; font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.04em; }

.caps {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-size: 10px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: 28px;
  padding: 20px;
}
.card-dark {
  background: var(--ink);
  color: var(--bg);
  border-radius: 28px;
  padding: 20px;
}
.card-dark .dim-70 { opacity: 0.72 }
.card-dark .dim-60 { opacity: 0.62 }
.card-dark .dim-50 { opacity: 0.5 }
.card-dark .chip-soft {
  background-color: color-mix(in srgb, var(--bg) 12%, transparent);
  color: var(--bg);
}
.card-dark .divider-soft {
  border-color: color-mix(in srgb, var(--bg) 15%, transparent);
}
.card-dark .btn-inverted {
  background: var(--bg);
  color: var(--ink);
}
.accent-text { color: #FF8A7A }  /* overdue/alert text on any bg */

/* Overdue/warn text — adaptive per theme inside dark cards */
.text-overdue { color: #DC2626; }
.card-dark .text-overdue { color: #FCA5A5; }
body[data-theme="dark"] .card-dark .text-overdue { color: #DC2626; }

/* Lime accent tile: caps always dark with opacity on lime, regardless of theme */
.tile-accent .caps { color: rgba(10, 10, 10, 0.55) !important; opacity: 1 !important; }

/* Insight card — slight accent border-left to mark "AI voice" */
.insight-card {
  position: relative;
  overflow: hidden;
}
.insight-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: #C9FF3D;
}

.tile {
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.tile-dark { background: var(--ink); color: var(--bg); }
.tile-dark .dim-60 { opacity: 0.62 }
.tile-dark .dim-70 { opacity: 0.72 }
.tile-accent { background: #DFFF5F; color: var(--ink); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--hair);
  white-space: nowrap;
}
.chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.hair { border-color: var(--hair); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn-primary:active { opacity: 0.85; }

.btn-ghost {
  padding: 14px 20px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hair);
  font-weight: 500;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}

.arrow-btn {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.progress {
  height: 4px; background: var(--hair); border-radius: 2px; overflow: hidden;
}
.progress-bar { height: 100%; background: var(--ink); }

.ring {
  --p: 0;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--ink) calc(var(--p) * 1%), var(--hair) 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::after {
  content: '';
  position: absolute; inset: 8px;
  border-radius: 50%;
  background: var(--card);
}
.ring > span {
  position: relative; z-index: 1;
  font-size: 14px; font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

.spark {
  display: flex; align-items: end; gap: 3px; height: 40px;
}
.spark > span {
  flex: 1; background: var(--ink); border-radius: 2px;
}

.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; opacity: 0.55; font-weight: 500;
}
.tab.active { opacity: 1; }
.tab-dot {
  width: 5px; height: 5px; border-radius: 50%; background: white;
  opacity: 0; transition: opacity 0.2s;
}
.tab.active .tab-dot { opacity: 1; }

.safe-bottom { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

.screen { padding-bottom: 96px; }

.screen-enter {
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.divider {
  height: 1px; background: var(--hair); margin: 16px -4px;
}

/* ===== Sheet (bottom modal for quick add) ===== */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s;
}
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 50;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--hair);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.sheet-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px; font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.input {
  background: var(--bg);
  border: 1px solid var(--hair);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: 14px;
  width: 100%;
  height: 52px;
  min-height: 52px;
  box-sizing: border-box;
  font-size: 16px;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
/* iOS date input: prevent huge default size */
input[type="date"].input {
  min-width: 0;
  display: block;
  line-height: 1.2;
}
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
.input:focus { outline: none; border-color: var(--ink); }
.input::placeholder { color: var(--muted); }

.field-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 8px;
}

.checkbox-circle {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--hair);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.checkbox-circle.checked {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.checkbox-circle.checked::after {
  content: '✓';
  font-size: 12px;
  font-weight: 700;
}

/* --- Status bar (top): weather + USD rate --- */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: #0A0A0A;
  color: #FAFAFA;
  font-size: 12px;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.02em;
}
.status-bar .rate { font-weight: 600; }
.status-bar .rate .up   { color: #86EFAC; }
.status-bar .rate .down { color: #FCA5A5; }

/* --- Atlas hints --- */
.hint-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
}
.hint-row:last-child { border-bottom: none; }
.hint-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.hint-red    { background: #DC2626; }
.hint-orange { background: #F97316; }
.hint-lime   { background: #C9FF3D; }

/* --- Daily limit tile: flip to red when over-budget --- */
.limit-over { /* applied to .tile when spent > limit */ }
.limit-over .caps,
.limit-over .num,
.limit-over .limit-note { color: #DC2626 !important; }
.limit-bar { height: 6px; background: var(--hair); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.limit-bar > div { height: 100%; background: var(--ink); transition: width 0.3s; }
.limit-over .limit-bar > div { background: #DC2626; }

/* --- Ещё button (secondary header action, outlined) --- */
.ghost-btn {
  width: 40px; height: 40px; border-radius: 999px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--hair);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}

/* --- Task list rows --- */
.task-section { margin-bottom: 6px; }
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px 10px;
  cursor: pointer;
}
.sec-chev { font-size: 12px; opacity: 0.5; transition: transform 0.2s; }
.sec-collapsed .sec-chev { transform: rotate(-90deg); }
.sec-collapsed .sec-body { display: none; }

.t-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--card);
  border-radius: 14px;
  margin-bottom: 8px;
}
.t-row .prio-bar { width: 3px; align-self: stretch; border-radius: 2px; margin-right: -4px; }
.t-row .t-text { flex: 1; min-width: 0; cursor: pointer; }
.t-row .t-text .title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-row .t-text .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.t-row .t-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.t-row-done .title { text-decoration: line-through; opacity: 0.55; }
.t-row-done .sub { opacity: 0.5; }
.t-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(220, 38, 38, 0.18); color: #DC2626;
}
.t-badge-muted { background: var(--hair); color: var(--muted); }

/* Play button — 24px ▷ circle, fills lime when active */
.play-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: transparent;
  border: 1px solid var(--hair);
  display: grid; place-items: center;
  color: var(--ink);
  font-size: 9px;
  flex-shrink: 0;
}
.play-btn.active {
  background: #DFFF5F;
  border-color: #DFFF5F;
  color: #0A0A0A;
}
.play-btn-spacer { width: 26px; flex-shrink: 0; }

/* Focus stat tile */
.tile-focus {
  grid-column: span 2;
  background: var(--card);
  border-radius: 24px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.tile-focus .emoji { font-size: 28px; }
.tile-focus .meta { flex: 1; min-width: 0; }
.tile-focus .big { font-size: 22px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.02em; }
.tile-focus .small { font-size: 12px; color: var(--muted); margin-top: 1px; }

.focus-ring {
  --p: 0;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: conic-gradient(#DFFF5F calc(var(--p) * 1%), var(--hair) 0);
  display: grid; place-items: center;
  position: relative;
  flex-shrink: 0;
}
.focus-ring::after {
  content: ''; position: absolute; inset: 5px;
  border-radius: 50%; background: var(--card);
}
.focus-ring > span {
  position: relative; z-index: 1;
  font-size: 11px; font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

/* --- Sticky focus timer bar (top of viewport, above status bar) --- */
.focus-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 12px;
  background: linear-gradient(90deg, #DFFF5F 0%, #C9FF3D 100%);
  color: #0A0A0A;
  font-family: 'Space Grotesk', sans-serif;
  position: sticky; top: 0; z-index: 25;
}
.focus-bar .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #DC2626;
  animation: focus-blink 1s ease-in-out infinite;
  flex-shrink: 0;
}
.focus-bar .pulse.paused { animation: none; opacity: 0.5; background: #6E6E6E; }
@keyframes focus-blink { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }
.focus-bar .focus-task {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.focus-bar .focus-time {
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.focus-bar button {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(10,10,10,0.12);
  color: #0A0A0A;
  display: grid; place-items: center;
  font-size: 12px;
  border: none;
}

/* --- Voice FAB above bottom nav --- */
.voice-fab {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 60px;
  border-radius: 50%;
  background: #DFFF5F;
  color: #0A0A0A;
  display: grid; place-items: center;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.22),
    0 3px 8px rgba(0, 0, 0, 0.15),
    0 0 0 4px var(--bg);
  z-index: 30;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease-out;
}
.voice-fab:active { transform: translateX(-50%) scale(0.92); }
.voice-fab svg { width: 26px; height: 26px; }
.voice-fab::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid #DFFF5F;
  opacity: 0;
  animation: voice-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes voice-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Dark (Telegram dark theme) */
body[data-theme="dark"] {
  --bg: #0A0A0A;
  --card: #161616;
  --ink: #F2F2F2;
  --muted: #6E6E6E;
  --hair: #262626;
}
body[data-theme="dark"] .tile-accent { background: #C9FF3D; color: #0A0A0A; }
body[data-theme="dark"] .caps { color: var(--muted); }
/* In dark theme: hero card flips to near-white, text flips to dark */
body[data-theme="dark"] .card-dark { background: #FAFAFA; color: #0A0A0A; }
body[data-theme="dark"] .tile-dark { background: #FAFAFA; color: #0A0A0A; }
body[data-theme="dark"] .card-dark .chip-soft {
  background-color: rgba(10,10,10,0.08);
  color: #0A0A0A;
}
body[data-theme="dark"] .card-dark .divider-soft {
  border-color: rgba(10,10,10,0.1);
}
body[data-theme="dark"] .card-dark .btn-inverted { background: #0A0A0A; color: #FAFAFA; }
body[data-theme="dark"] .ring::after { background: #FAFAFA; }
body[data-theme="dark"] .ring > span { color: #0A0A0A; }
body[data-theme="dark"] #nav { background: #0A0A0A; border-top-color: #1a1a1a }
body[data-theme="dark"] .status-bar { background: #161616; }
body[data-theme="dark"] .voice-fab {
  box-shadow: 0 10px 24px rgba(0,0,0,0.6), 0 3px 8px rgba(0,0,0,0.4), 0 0 0 4px var(--bg);
}
