:root {
  --bg: #0b0a08;
  --screen: #0a0908;
  --surface: #15130f;
  --surface-2: #1c1915;
  --line: #2a261d;
  --line-2: #3a352a;
  --text: #f4f0e8;
  --text-2: #b6ad9d;
  --text-3: #7d7565;
  --accent: #d8a23f;
  --accent-2: #b8862e;
  --green: #4eb86e;
  --orange: #e0913c;
  --blue: #5b8fe0;
  --purple: #9483d6;
  --red: #d9655a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(120% 65% at 50% -10%, #21180d 0%, #0b0a08 55%) fixed, var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.sprite { display: none; }
.ic {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.fill { fill: currentColor; stroke: none; }

#app { min-height: 100dvh; }
.shell {
  width: min(100%, 440px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--screen);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 40px 90px rgba(0,0,0,.45);
}
.scroll {
  flex: 1;
  overflow: auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 24px;
}
.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.screen-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.05;
}
.top-title { flex: 1; min-width: 0; }
.brand { text-align: center; line-height: 1.1; }
.brand b { display: block; font-size: 17px; }
.brand span { color: var(--accent); font-size: 11px; font-weight: 700; }
.gear, .icon-btn, .range-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .16s ease, border-color .16s ease, color .16s ease;
}
.gear:active, .icon-btn:active, .range-btn:active, .tab:active, .row:active { transform: scale(.97); }
.gear.active, .gear:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent), transparent 45%); }
.streak-top { display: flex; gap: 8px; align-items: center; color: var(--accent); }
.flame-emoji { font-size: 33px; line-height: .9; filter: drop-shadow(0 0 10px rgba(216,162,63,.25)); transform: translateY(-2px); }
.streak-top .n { color: var(--text); font-size: 22px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.streak-top .lab { color: var(--text-3); font-size: 11px; line-height: 1.1; }

.hero { margin: 18px 2px 18px; }
.hero .g { color: var(--text-2); font-weight: 500; font-size: 15px; }
.hero .h { font-size: 33px; font-weight: 800; line-height: 1.12; letter-spacing: 0; }
.hero em { color: var(--accent); font-style: italic; }
.card, .metric, .stat-card, .set-card, .empty, .capture-card, .item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.progress-card { padding: 14px 16px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; color: var(--text-3); }
.bar { height: 7px; background: #241f17; border-radius: 999px; overflow: hidden; margin-top: 11px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.metric { padding: 15px 15px; min-height: 118px; }
.metric .label, .stat-key { color: var(--text-2); font-size: 12.5px; font-weight: 700; display: flex; gap: 7px; align-items: center; }
.metric-icon { color: var(--accent); font-size: 18px; display: inline-grid; place-items: center; }
.metric-icon.green { color: var(--green); }
.metric .big, .stat-big {
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  margin: 9px 0 4px;
  font-variant-numeric: tabular-nums;
}
.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 2px 10px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .16em;
}
.link-action { color: var(--accent); background: transparent; min-height: 44px; font-weight: 800; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.plan-row, .item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid #1d1a14;
}
.plan-row:last-child { border-bottom: 0; }
.check {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 2px solid var(--line-2);
  border-radius: 8px;
  background: transparent;
  color: #06210f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.check svg { display: none; }
.plan-row.done .check { border-color: var(--green); background: var(--green); }
.plan-row.done .check svg { display: block; }
.check.is-done { border-color: var(--green); background: var(--green); }
.check.is-done svg { display: block; }
.tile {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--goal, var(--text-3)), transparent 84%);
  color: var(--goal, var(--text-3));
  font-size: 18px;
}
.plan-row .tile { background: color-mix(in srgb, var(--goal, var(--text-3)), transparent 88%); }
.item-card {
  padding: 14px 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  background: #14110d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.015);
}
.item-card .tile {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  font-size: 17px;
  background: color-mix(in srgb, var(--goal, var(--text-3)), transparent 84%);
}
.item-card .title-line { font-size: 15.5px; font-weight: 700; letter-spacing: 0; }
.item-card .tag-line { font-size: 10.5px; letter-spacing: .08em; }
.item-card .check {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  border: 2px solid var(--line-2);
}
.item-card .check.is-done { color: #06210f; border: 0; }
.item-card .check.is-done svg { width: 16px; height: 16px; stroke-width: 2.6; }
.item-card + .section-label { margin-top: 24px; }
.main { flex: 1; min-width: 0; }
.title-line { display: block; color: var(--text); font-size: 15px; font-weight: 700; white-space: normal; overflow-wrap: anywhere; }
.plan-row.done .title-line { color: var(--text-3); text-decoration: line-through; }
.tag-line { display: block; margin-top: 4px; color: var(--text-3); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.tag-line b { color: var(--goal, var(--text-3)); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--goal, var(--text-3)); }
.chev-action { color: var(--text-3); display: inline-flex; align-items: center; }
.form-icon { color: var(--accent); }
.addrow { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 16px 2px 6px; }
.outline-btn, .primary, .capture-btn, .danger-btn, .secondary {
  min-height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}
.outline-btn { border: 1.5px solid var(--accent-2); color: var(--accent); background: color-mix(in srgb, var(--accent), transparent 94%); }
.primary { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: #1a1305; width: 100%; }
.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); width: 100%; }
.capture-link-btn { min-height: 48px; border-radius: 8px; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; background: color-mix(in srgb, var(--accent), transparent 86%); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent), transparent 45%); }
.danger-btn { background: color-mix(in srgb, var(--red), transparent 86%); color: var(--red); border: 1px solid color-mix(in srgb, var(--red), transparent 45%); width: 100%; }
.inbox-card { width: 100%; padding: 14px 15px; margin-top: 14px; display: flex; gap: 13px; align-items: center; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: inherit; }
.inbox-card .tile { color: var(--accent); background: color-mix(in srgb, var(--accent), transparent 88%); }
.empty { padding: 18px; color: var(--text-2); line-height: 1.5; }

.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: #0c0b09;
  padding: 5px 0 calc(7px + var(--safe-bottom));
}
.tab {
  min-height: 58px;
  background: transparent;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
}
.tab svg { font-size: 21px; }
.tab.on { color: var(--accent); }

.month-row, .range-row { margin: 12px 2px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.month-title { min-height: 44px; background: transparent; color: var(--text); font-size: 20px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.month-nav { display: inline-flex; align-items: center; gap: 8px; }
.chev-down { display: inline-flex; transition: transform .18s ease; color: var(--text-2); }
.chev-down.open { transform: rotate(180deg); }
.week, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.month-grid.expanded { padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.wd, .daynum { text-align: center; color: var(--text-3); font-size: 10px; font-weight: 800; padding: 4px 0; }
.day {
  min-height: 44px;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.day.sel { outline: 1px solid var(--accent); }
.mark { width: 24px; height: 20px; display: grid; place-items: center; color: var(--text-3); }
.mark.win { color: var(--accent); }
.mark.partial { color: var(--green); }
.mark.miss { color: var(--red); }
.mark.pending { border: 2px solid var(--accent); border-radius: 999px; color: var(--accent); font-size: 10px; }
.fab-wrap { position: absolute; right: 18px; bottom: calc(88px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 12px; z-index: 20; }
.fab-menu { display: none; flex-direction: column; gap: 10px; }
.fab-wrap.open .fab-menu { display: flex; }
.fab-opt { display: flex; align-items: center; gap: 10px; background: transparent; color: var(--text); }
.fab-label { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 12px; font-weight: 800; }
.fab-mini, .fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
}
.fab { width: 60px; height: 60px; color: #1a1305; background: linear-gradient(150deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 26px color-mix(in srgb, var(--accent), transparent 70%); font-size: 26px; }
.fab-wrap.open .fab { transform: rotate(45deg); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin: 14px 2px; }
.seg button { min-height: 42px; background: transparent; color: var(--text-2); border-radius: 7px; font-weight: 800; }
.seg button.on { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: #1a1305; }
.stat-card { padding: 17px 16px; margin-bottom: 13px; }
.stat-grid { display: grid; grid-template-columns: .82fr 1.18fr; gap: 14px; align-items: center; }
.stat-big { font-size: 46px; letter-spacing: 0; }
.amal-total { font-size: 38px; }
.delta { color: var(--green); font-size: 12px; font-weight: 800; }
.chart-wrap { display: grid; grid-template-columns: 28px 1fr; gap: 7px; align-items: stretch; }
.y-axis { height: 110px; display: flex; flex-direction: column; justify-content: space-between; color: var(--text-3); font-size: 9px; font-weight: 700; text-align: right; padding-bottom: 18px; }
.bars { height: 110px; display: flex; align-items: flex-end; gap: 6px; }
.bcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; background: transparent; color: inherit; padding: 0; }
.bb { width: 74%; min-height: 3px; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); opacity: .45; }
.bcol.current .bb { opacity: 1; }
.bcol.future .bb { width: 5px; height: 5px !important; border-radius: 50%; background: #2e2a21; opacity: 1; }
.bl { font-size: 9px; color: var(--text-3); font-weight: 800; }
.bar-tip { margin-top: 10px; color: var(--accent); font-size: 12px; font-weight: 800; text-align: right; }
.align-right { text-align: right; justify-content: flex-end; display: flex; }
.spark { width: 100%; height: 66px; display: block; margin-top: 6px; }
.cat-row { display: grid; grid-template-columns: 34px minmax(64px, .7fr) 1fr 45px; gap: 10px; align-items: center; margin-top: 14px; }
.track { height: 8px; border-radius: 999px; background: #241f17; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: inherit; background: var(--goal); }

.capture-btn { width: 100%; margin: 8px 0 16px; background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: #1a1305; }
.capture-card { padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.capture-card .text { flex: 1; min-width: 0; font-weight: 700; }
.actions { display: flex; gap: 8px; }
.actions .icon-btn { border-radius: 8px; }
.actions [data-schedule] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent), transparent 88%);
  border-color: color-mix(in srgb, var(--accent), transparent 55%);
}
.actions [data-delete-capture] {
  color: var(--red);
  background: color-mix(in srgb, var(--red), transparent 88%);
  border-color: color-mix(in srgb, var(--red), transparent 55%);
}
.capture-btn .ic { font-size: 18px; color: #1a1305; }

.set-card { padding: 16px; margin-bottom: 13px; }
.set-head { font-weight: 800; font-size: 16px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.swatch {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.13);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.swatch.sel { outline: 2px solid var(--text); outline-offset: 3px; }
.field { margin: 14px 0; }
.label { color: var(--text-2); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.input, .select, textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  outline: none;
}
textarea { resize: vertical; min-height: 90px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-width: 44px; min-height: 44px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); color: var(--text-2); font-weight: 800; }
.chip.on { background: var(--accent); color: #1a1305; border-color: var(--accent); }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; align-items: end; z-index: 50; }
.sheet {
  width: min(100%, 440px);
  max-height: min(90dvh, 760px);
  overflow: auto;
  margin: 0 auto;
  background: #0d0c0a;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + var(--safe-bottom));
  box-shadow: 0 -20px 50px rgba(0,0,0,.5);
}
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; margin: 3px auto 14px; background: var(--line-2); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-title { font-size: 24px; font-weight: 800; }
.sheet-actions { display: flex; align-items: center; gap: 8px; }
.delete-mini { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--red); border: 1px solid color-mix(in srgb, var(--red), transparent 45%); background: color-mix(in srgb, var(--red), transparent 88%); }
.date-field { width: 100%; min-height: 48px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 12px; text-align: left; font-weight: 700; }
.picker-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 10px 0 14px; }
.picker-tabs button { min-height: 42px; border-radius: 8px; background: transparent; color: var(--text-2); font-weight: 800; }
.picker-tabs button.on { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: #1a1305; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 12px 0; }
.icon-choice { aspect-ratio: 1; border-radius: 8px; background: var(--surface); color: var(--text-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 20px; }
.icon-choice.sel { color: var(--accent); border-color: var(--accent); }
.date-picker-grid .day { border: 1px solid transparent; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  max-width: min(92vw, 420px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 80;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: 0; }
.auth-card h1 span { color: var(--accent); }

@media (min-width: 760px) {
  body { padding: 24px; }
  .shell { min-height: calc(100dvh - 48px); max-height: 920px; border-radius: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
