:root {
  color-scheme: light;
  --bg: #f8f5fa;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-soft: #f1ebf6;
  --text: #28212f;
  --muted: #756d7d;
  --line: #e8e0ed;
  --primary: #8b68bd;
  --primary-dark: #6d4c9d;
  --primary-soft: #e9ddf5;
  --peach: #f3bea8;
  --peach-soft: #fceddf;
  --green: #4b9d7b;
  --danger: #b94d66;
  --shadow: 0 18px 60px rgba(62, 41, 80, 0.10);
  --radius: 26px;
  --font: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17141b;
  --surface: rgba(36, 31, 42, 0.90);
  --surface-solid: #24202a;
  --surface-soft: #302a39;
  --text: #f5f0f8;
  --muted: #b9afc1;
  --line: #3d3545;
  --primary: #b495df;
  --primary-dark: #d0b8ef;
  --primary-soft: #413452;
  --peach: #efb49a;
  --peach-soft: #44332d;
  --green: #72c09c;
  --danger: #e47a91;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.30);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #17141b;
    --surface: rgba(36, 31, 42, 0.90);
    --surface-solid: #24202a;
    --surface-soft: #302a39;
    --text: #f5f0f8;
    --muted: #b9afc1;
    --line: #3d3545;
    --primary: #b495df;
    --primary-dark: #d0b8ef;
    --primary-soft: #413452;
    --peach: #efb49a;
    --peach-soft: #44332d;
    --green: #72c09c;
    --danger: #e47a91;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.30);
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.05; letter-spacing: -.045em; }
h2 { margin-bottom: .35rem; font-size: 1.35rem; line-height: 1.2; letter-spacing: -.025em; }
small { color: var(--muted); }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: .5rem 0; }

.ambient { position: fixed; z-index: 0; width: 420px; height: 420px; border-radius: 50%; filter: blur(12px); pointer-events: none; opacity: .55; }
.ambient-one { top: -230px; right: -130px; background: radial-gradient(circle, #e7d7f4 0, transparent 70%); }
.ambient-two { bottom: -260px; left: -160px; background: radial-gradient(circle, #f5ddcf 0, transparent 70%); }
.topbar { position: relative; z-index: 10; max-width: 1160px; margin: 0 auto; padding: 24px 28px 8px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.08rem; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 12px 12px 16px 16px; background: linear-gradient(145deg, #a983d2, #7953a9); color: white; transform: rotate(8deg); box-shadow: 0 8px 20px rgba(108, 74, 151, .24); }
.brand-mark.large { width: 62px; height: 62px; border-radius: 20px 20px 28px 28px; font-size: 1.6rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions form { margin: 0; }
.privacy-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.privacy-pill span { color: var(--green); font-size: .55rem; }
.app-shell { position: relative; z-index: 1; width: min(1100px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 120px; }
.auth-shell { width: min(470px, calc(100% - 32px)); min-height: 100vh; display: grid; place-items: center; padding: 40px 0; }

.eyebrow { margin-bottom: .45rem; color: var(--primary-dark); font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow.light { color: rgba(255, 255, 255, .76); }
.muted { color: var(--muted); }
.welcome-row, .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.welcome-row h1, .page-heading h1 { margin-bottom: 0; }
.page-heading { align-items: center; margin-bottom: 28px; }
.page-heading .muted { margin: 10px 0 0; max-width: 620px; }

.timer-card { position: relative; min-height: 305px; margin-bottom: 22px; padding: 42px clamp(28px, 6vw, 70px); overflow: hidden; border-radius: 36px; color: white; background: linear-gradient(130deg, #9d79c8 0%, #7550a4 64%, #684494 100%); box-shadow: 0 24px 70px rgba(99, 64, 137, .25); }
.timer-card::after { content: ""; position: absolute; width: 340px; height: 340px; right: -130px; top: -170px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 0 0 60px rgba(255,255,255,.035), 0 0 0 120px rgba(255,255,255,.025); }
.timer-card > *:not(.timer-orbit) { position: relative; z-index: 2; max-width: 610px; }
.timer-card h2 { margin: 0 0 9px; font-size: clamp(2.3rem, 6vw, 4rem); letter-spacing: -.055em; }
.timer-sub { margin-bottom: 26px; color: rgba(255, 255, 255, .78); }
.timer-display { font-variant-numeric: tabular-nums; margin: 2px 0 7px; font-size: clamp(3rem, 9vw, 5.7rem); font-weight: 750; letter-spacing: -.055em; line-height: 1; }
.timer-orbit { position: absolute; z-index: 1; right: 72px; top: 63px; width: 160px; height: 160px; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; }
.timer-orbit::before, .timer-orbit::after { content: ""; position: absolute; inset: 19px; border: 1px solid rgba(255,255,255,.1); border-radius: inherit; }
.timer-orbit::after { inset: 44px; background: rgba(255,255,255,.07); }
.timer-orbit span { position: absolute; width: 15px; height: 15px; top: 16px; right: 22px; border-radius: 50%; background: var(--peach); box-shadow: 0 0 24px rgba(255, 209, 186, .8); }
.start-button { display: inline-flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 26px; border: 0; border-radius: 18px; background: white; color: #6b4996; box-shadow: 0 14px 30px rgba(53, 28, 85, .22); font-weight: 850; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.start-button:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(53, 28, 85, .3); }
.start-button:disabled { opacity: .65; cursor: wait; }
.start-button span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); font-size: .72rem; }
.read-only-note { padding: 12px 15px; width: fit-content; border-radius: 13px; background: rgba(255,255,255,.12); }

.button { display: inline-flex; min-height: 45px; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border: 1px solid transparent; border-radius: 14px; font-weight: 750; color: var(--text); background: var(--surface-solid); cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: linear-gradient(135deg, #9771c5, #7852a8); box-shadow: 0 10px 22px rgba(111, 73, 153, .18); }
.button.subtle { border-color: var(--line); background: var(--surface); }
.button.text { color: var(--primary-dark); background: transparent; }
.button.stop { color: #7550a4; background: white; }
.button.danger { color: var(--danger); }
.button.compact { min-height: 38px; padding: 0 13px; border-radius: 12px; font-size: .84rem; }
.button.wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 39px; height: 39px; padding: 0; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: var(--surface); cursor: pointer; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat-card, .panel { border: 1px solid rgba(137, 106, 158, .12); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.stat-card { position: relative; min-height: 150px; padding: 24px; border-radius: var(--radius); }
.stat-card p { margin: 0 0 7px; color: var(--muted); font-size: .86rem; }
.stat-card strong { display: block; margin-bottom: 4px; font-size: clamp(1.8rem, 4vw, 2.35rem); line-height: 1; letter-spacing: -.045em; }
.stat-icon { position: absolute; top: 20px; right: 20px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; }
.stat-icon.lavender { color: var(--primary-dark); background: var(--primary-soft); }
.stat-icon.peach { color: #ad654d; background: var(--peach-soft); }
.panel { padding: 25px; border-radius: var(--radius); }
.content-grid { display: grid; grid-template-columns: .88fr 1.12fr; gap: 18px; margin-bottom: 18px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.panel-heading h2 { margin-bottom: 0; }
.panel-heading > a { color: var(--primary-dark); font-size: .84rem; font-weight: 750; }
.bell { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; background: var(--primary-soft); color: var(--primary-dark); font-size: 1.3rem; }
.countdown { margin: 18px 0 13px; color: var(--muted); font-size: 1.08rem; }
.countdown strong { color: var(--text); }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.inline-actions form { margin: 0; }
.soft-alert { margin: 14px 0; padding: 11px 13px; border-radius: 12px; color: var(--primary-dark); background: var(--primary-soft); font-size: .84rem; }

.mini-chart { height: 155px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 9px; padding-top: 24px; }
.bar-column { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.bar { width: min(27px, 78%); min-height: 3px; border-radius: 9px 9px 5px 5px; background: linear-gradient(#b896db, #7e59ae); }
.bar-value { position: absolute; top: -20px; font-size: .65rem; color: var(--muted); opacity: 0; transition: opacity .15s; }
.bar-column:hover .bar-value { opacity: 1; }
.bar-column small { font-size: .68rem; }

.recent-panel { margin-bottom: 10px; }
.session-list { margin-top: 18px; }
.session-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 13px; min-height: 69px; padding: 12px 4px; border-top: 1px solid var(--line); }
.session-row:first-child { border-top: 0; }
.session-row strong, .session-row small { display: block; }
.session-row strong { margin-bottom: 2px; font-size: .92rem; }
.session-row small { font-size: .78rem; }
.session-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.session-dot.interrupted { background: #d89a67; box-shadow: 0 0 0 5px var(--peach-soft); }
.session-dot.skipped { background: var(--muted); box-shadow: 0 0 0 5px var(--surface-soft); }
.session-volume { font-weight: 800; white-space: nowrap; }
.empty-state { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty-state > span { display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 13px; border-radius: 19px; background: var(--primary-soft); color: var(--primary-dark); font-size: 1.45rem; }
.empty-state h2 { color: var(--text); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin: -8px 0 16px; }
.toolbar select { min-width: 180px; }
.list-panel { padding: 12px 24px; }
.history-row { min-height: 78px; }
.narrow-page { width: min(680px, 100%); margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--primary-dark); font-weight: 750; }
.form-panel { padding: clamp(25px, 5vw, 38px); }
.form-panel h1 { margin-bottom: 28px; }
.stack-form { display: flex; flex-direction: column; gap: 17px; }
.stack-form label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; }
input, select, textarea { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; outline: none; color: var(--text); background: var(--surface-solid); transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type="checkbox"] { width: 22px; min-height: 22px; accent-color: var(--primary); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.errorlist { margin: 0; padding-left: 18px; color: var(--danger); font-size: .78rem; }
.form-error, .form-alert { color: var(--danger); }
.form-alert { margin: 18px 0; padding: 12px 14px; border-radius: 13px; background: rgba(185, 77, 102, .1); font-size: .85rem; }
.danger-zone { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.switch-row { flex-direction: row !important; justify-content: space-between; align-items: center; padding: 12px 0; color: var(--text) !important; font-size: .98rem !important; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(290px, .85fr); gap: 18px; align-items: start; }
.settings-side { display: grid; gap: 18px; }
details { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }
summary { cursor: pointer; color: var(--primary-dark); font-weight: 750; }
details li { margin: 7px 0; }
.status-line { margin: 10px 0 0; font-size: .82rem; color: var(--green); }
.audit-list { margin-top: 15px; }
.audit-list > div { display: flex; align-items: start; gap: 13px; padding: 11px 0; border-top: 1px solid var(--line); }
.audit-list > div:first-child { border-top: 0; }
.audit-list p, .audit-list strong, .audit-list small { display: block; margin: 0; }
.audit-list strong { font-size: .85rem; }
.audit-list small { margin-top: 2px; font-size: .73rem; }

.stash-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; padding: 12px 0; }
.stash-card { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-solid); }
.stash-card .inline-actions { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line); }
.stash-card h2 { margin-bottom: 4px; }
.stash-card strong, .stash-card small { display: block; }
.stash-card small { margin-top: 5px; }
.stash-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; color: var(--primary-dark); background: var(--primary-soft); }
.stash-icon.freezer { color: #507fa8; background: #e2eff7; }

.auth-card { width: 100%; padding: clamp(30px, 7vw, 46px); border: 1px solid var(--line); border-radius: 32px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.auth-logo { margin-bottom: 22px; }
.auth-card h1 { margin-bottom: 10px; }
.auth-card .muted { margin-bottom: 26px; }
.privacy-note { margin: 23px 0 0; text-align: center; color: var(--muted); font-size: .72rem; }

.modal { width: min(540px, calc(100% - 24px)); max-height: 92vh; overflow-y: auto; padding: 30px; border: 1px solid var(--line); border-radius: 27px; color: var(--text); background: var(--surface-solid); box-shadow: 0 40px 90px rgba(33, 21, 43, .3); }
.modal::backdrop { background: rgba(26, 17, 34, .55); backdrop-filter: blur(5px); }
.modal-close { position: absolute; top: 18px; right: 18px; width: 35px; height: 35px; border: 0; border-radius: 11px; color: var(--muted); background: var(--surface-soft); font-size: 1.35rem; cursor: pointer; }
.segment-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 14px; background: var(--surface-soft); }
.segment-control label { cursor: pointer; }
.segment-control input { position: absolute; opacity: 0; pointer-events: none; }
.segment-control span { display: grid; place-items: center; min-height: 39px; border-radius: 11px; color: var(--muted); }
.segment-control input:checked + span { color: var(--text); background: var(--surface-solid); box-shadow: 0 4px 12px rgba(40, 25, 50, .08); }
.toast-stack { position: fixed; z-index: 50; top: 78px; right: 20px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-solid); box-shadow: var(--shadow); font-size: .86rem; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--danger); }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 7px; border: 1px solid var(--line); border-radius: 22px; background: color-mix(in srgb, var(--surface-solid) 90%, transparent); box-shadow: 0 18px 46px rgba(46, 28, 59, .18); backdrop-filter: blur(22px); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 7px 12px 6px; border-radius: 15px; color: var(--muted); font-size: .67rem; font-weight: 700; }
.bottom-nav a span { margin-bottom: 1px; font-size: 1.05rem; }
.bottom-nav a.active { color: var(--primary-dark); background: var(--primary-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .topbar { padding: 16px 18px 0; }
  .privacy-pill { display: none; }
  .app-shell { width: min(100% - 24px, 600px); padding-top: 28px; padding-bottom: 112px; }
  .welcome-row, .page-heading { align-items: start; }
  .welcome-row { gap: 10px; }
  .welcome-row .button { font-size: 0; width: 43px; padding: 0; }
  .welcome-row .button::first-letter { font-size: 1rem; }
  .timer-card { min-height: 290px; padding: 34px 25px; border-radius: 29px; }
  .timer-orbit { right: -25px; top: 50px; opacity: .58; }
  .timer-display { font-size: clamp(2.7rem, 15vw, 4.4rem); }
  .stat-grid, .content-grid, .settings-grid { grid-template-columns: 1fr; }
  .stat-grid { gap: 12px; }
  .stat-card { min-height: 125px; }
  .panel { padding: 21px; }
  .list-panel { padding: 8px 16px; }
  .session-row { grid-template-columns: auto 1fr auto; }
  .session-row .icon-button { grid-column: 3; }
  .session-volume { font-size: .86rem; }
  .page-heading { flex-direction: column; }
  .page-heading .button { width: 100%; }
  .stash-grid { grid-template-columns: 1fr; }
  .bottom-nav { bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100% - 22px); justify-content: space-around; }
  .bottom-nav a { min-width: 0; flex: 1; padding-left: 6px; padding-right: 6px; }
}

@media (max-width: 430px) {
  h1 { font-size: 2rem; }
  .field-grid { grid-template-columns: 1fr; }
  .timer-card { min-height: 300px; }
  .timer-card h2 { font-size: 2.55rem; }
  .mini-chart { gap: 5px; }
  .bar { width: 20px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar form, .toolbar select, .toolbar .button { width: 100%; }
  .modal { padding: 25px 19px; }
  .segment-control + .field-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

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

