/* Timedisk web timer. Tokens are the app's LoopPalette (lib/theme/app_theme.dart):
   clean (default), dark, kid. Alert red is one colour across every theme. */
:root {
  --bg: #F7F5F1; --surface: #FFFFFF; --fg: #171C28; --dim: #6C7385; --line: #E4DFD6;
  --accent: #EE5F26; --accent-soft: rgba(238,95,38,.10);
  --dial-face: #E8E3D9; --dial-bezel: #D6CFC2; --dial-tick: #C2BAAA; --dial-wedge: #EE5F26;
  --alert: #E23744; --midnight: #151D30;
  --radius: 16px; --control-h: 50px; --chip-weight: 600; --chip-font: 15px;
  --display: 'Fira Sans Condensed', 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ui: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Fira Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="clean"]):not([data-theme="kid"]) {
    --bg: #0F1522; --surface: #1A2338; --fg: #F1F4F9; --dim: #93A0B8; --line: #26304E;
    --accent: #F26A2E; --accent-soft: rgba(242,106,46,.16);
    --dial-face: #232D49; --dial-bezel: #3A4869; --dial-tick: #48587C; --dial-wedge: #F26A2E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1522; --surface: #1A2338; --fg: #F1F4F9; --dim: #93A0B8; --line: #26304E;
  --accent: #F26A2E; --accent-soft: rgba(242,106,46,.16);
  --dial-face: #232D49; --dial-bezel: #3A4869; --dial-tick: #48587C; --dial-wedge: #F26A2E;
  color-scheme: dark;
}
:root[data-theme="kid"] {
  --bg: #FFF6E9; --surface: #FFFFFF; --fg: #2C2145; --dim: #7C6E96; --line: #F0E4D2;
  --accent: #7A4DE0; --accent-soft: rgba(122,77,224,.12);
  --dial-face: #F1E8FF; --dial-bezel: #DCCBFA; --dial-tick: #C7B2F0; --dial-wedge: #FF5C8A;
  --radius: 24px; --control-h: 56px; --chip-weight: 700; --chip-font: 17px;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--ui); background: var(--bg); color: var(--fg); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .6rem max(16px, env(safe-area-inset-right, 0px)) .6rem max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); font-size: .9rem;
}
.bar .brand { display: flex; align-items: center; gap: .55rem; color: var(--fg); text-decoration: none; font-weight: 700; }
.bar .brand img { width: 28px; height: 28px; border-radius: 8px; }
.bar .brand small { color: var(--dim); font-weight: 500; }
.bar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.bar nav a { color: var(--dim); text-decoration: none; }
.bar nav a:hover { color: var(--fg); }
.adelyons-breadcrumb { font-size: .78rem; border-bottom: 1px solid var(--line); }
.adelyons-breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: .45rem max(16px, env(safe-area-inset-right, 0px)) .45rem max(16px, env(safe-area-inset-left, 0px)); color: var(--dim); }
.adelyons-breadcrumb a { color: inherit; text-decoration: none; }
.adelyons-breadcrumb a:hover { text-decoration: underline; }
.adelyons-breadcrumb .bc-sep { opacity: .5; }

/* ---- the stage: one screen, disk first ---- */
.stage {
  min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; gap: .5rem;
  padding: .75rem max(16px, env(safe-area-inset-right, 0px)) .75rem max(16px, env(safe-area-inset-left, 0px));
}
.stage-head { text-align: center; display: grid; gap: .15rem; }
.stage-head h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.25rem, 2.4vw, 1.7rem); letter-spacing: -.2px; line-height: 1.1; text-wrap: balance; }
.stage-head .step-label {
  font-family: var(--display); font-weight: 700; font-size: clamp(1.4rem, 4.5vmin, 3rem); line-height: 1.1; min-height: 1.1em; color: var(--fg);
}
.stage-head .step-label:empty::before { content: '\00a0'; }

.dial-wrap { position: relative; display: grid; place-items: center; min-height: 0; }
.dial {
  position: relative; width: min(100%, calc(100svh - 20rem)); max-width: 100%; aspect-ratio: 1; min-width: 240px;
  touch-action: none; cursor: grab; border-radius: 50%;
}
.dial[data-running="true"] { cursor: default; }
.dial canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.readout {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.035em;
  font-size: calc(var(--dial-size, 300px) * 0.18); line-height: 1; color: var(--fg);
}
.readout.hours { font-size: calc(var(--dial-size, 300px) * 0.13); }
.readout.warning { color: var(--alert); }
.readout.done { color: var(--alert); }
.readout[hidden] { display: none; }

.next-line { text-align: center; color: var(--dim); font-size: clamp(.95rem, 2.4vmin, 1.35rem); min-height: 1.5em; font-variant-numeric: tabular-nums; }
.next-line strong { color: var(--fg); font-weight: 600; }

/* ---- controls ---- */
.controls { display: grid; gap: .6rem; justify-items: center; }
.row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .5rem; }
.chip {
  min-height: calc(var(--control-h) - 10px); padding: 0 .95rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: var(--chip-weight); font-size: var(--chip-font); cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.custom { display: inline-flex; align-items: center; gap: .3rem; padding-right: .6rem; }
.chip.custom input {
  width: 3.2em; border: none; background: transparent; font: inherit; color: inherit; text-align: right;
  font-variant-numeric: tabular-nums;
}
.chip.custom input:focus { outline: none; }
.btn {
  min-height: var(--control-h); padding: 0 1.4rem; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 9rem; justify-content: center; font-size: 1.1rem; }
.btn.primary:hover { filter: brightness(1.05); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.small { min-height: 38px; padding: 0 .85rem; font-size: .88rem; font-weight: 500; border-radius: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { min-height: 38px; padding: 0 .8rem; border: none; background: transparent; font-size: .88rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.status { font-size: .85rem; color: var(--dim); min-height: 1.3em; text-align: center; }

/* ---- routine editor ---- */
.routine { width: 100%; max-width: 720px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.routine summary { cursor: pointer; padding: .8rem 1rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.routine summary::-webkit-details-marker { display: none; }
.routine summary .hint { color: var(--dim); font-weight: 400; font-size: .9rem; }
.routine .body { padding: 0 1rem 1rem; display: grid; gap: .6rem; }
.routine label { font-size: .85rem; color: var(--dim); }
.routine input[type="text"] {
  width: 100%; min-height: 44px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg);
  font-family: var(--mono); font-size: .95rem;
}
.steps { list-style: none; display: grid; gap: .35rem; }
.steps li { display: flex; align-items: center; gap: .6rem; font-size: .95rem; font-variant-numeric: tabular-nums; }
.steps .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.steps .dur { color: var(--dim); margin-left: auto; font-family: var(--mono); font-size: .88rem; }
.steps li.current { font-weight: 600; }
.routine .err { color: var(--alert); font-size: .85rem; }

/* ---- full screen ---- */
:fullscreen .bar, :fullscreen .adelyons-breadcrumb, :fullscreen .copy, :fullscreen footer, :fullscreen .routine, :fullscreen .stage-head h1 { display: none; }
:fullscreen .stage { min-height: 100vh; padding-top: max(16px, env(safe-area-inset-top, 0px)); }
:fullscreen .dial { width: min(100%, calc(100vh - 11rem)); }
:fullscreen .controls { opacity: .25; transition: opacity .3s; }
:fullscreen .controls:hover, :fullscreen .controls:focus-within, :fullscreen.show-controls .controls { opacity: 1; }
body.flash::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; background: var(--alert); z-index: 50;
  animation: flash 2.1s ease-out forwards;
}
@keyframes flash { 0%, 28.5%, 57% { opacity: .62; } 14%, 43%, 71%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { body.flash::after { animation: none; opacity: .4; } }

/* ---- copy below the fold ---- */
.copy { max-width: 760px; margin: 0 auto; padding: 2.5rem max(16px, env(safe-area-inset-right, 0px)) 3rem max(16px, env(safe-area-inset-left, 0px)); }
.copy h2 { font-family: var(--display); font-weight: 800; font-size: 1.6rem; letter-spacing: -.2px; margin: 2.2rem 0 .6rem; text-wrap: balance; }
.copy h3 { font-size: 1.1rem; margin: 1.5rem 0 .4rem; }
.copy p, .copy li { color: var(--fg); opacity: .88; }
.copy p { margin: .7rem 0; }
.copy ul, .copy ol { margin: .7rem 0 .7rem 1.4rem; }
.copy li { margin: .3rem 0; }
.copy code { font-family: var(--mono); font-size: .9em; background: var(--accent-soft); padding: .1em .35em; border-radius: 6px; }
.preset-links { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 !important; }
.preset-links li { margin: 0; }
.preset-links a { display: inline-block; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--fg); font-weight: 500; }
.preset-links a:hover { border-color: var(--accent); color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: .92rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }
.faq details { border-top: 1px solid var(--line); padding: .75rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: .5rem 0 0; }
.app-cta {
  margin: 2.5rem 0 0; padding: 1.5rem; border-radius: var(--radius); background: var(--midnight); color: #ffe6dc;
  display: grid; grid-template-columns: auto 1fr; gap: 1.1rem 1.25rem; align-items: center;
}
.app-cta img { width: 64px; height: 64px; border-radius: 16px; }
.app-cta h2 { color: #fff; margin: 0 0 .25rem; font-size: 1.35rem; }
.app-cta p { color: #ffe6dc; opacity: .85; margin: 0; }
.app-cta .cta-buttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .7rem; }
.app-cta .store { display: inline-block; padding: .7rem 1.3rem; border-radius: 10px; text-decoration: none; font-weight: 600; background: linear-gradient(135deg, #F0632B 0%, #D24B15 100%); color: #fff; }
.app-cta .store.ghost { background: transparent; border: 2px solid #f0a586; color: #ffe6dc; }
footer { text-align: center; padding: 2rem max(16px, env(safe-area-inset-right, 0px)) 2.5rem max(16px, env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); color: var(--dim); font-size: .9rem; }
footer a { color: var(--dim); text-decoration: none; }
footer a:hover { color: var(--fg); }

@media (max-width: 480px) {
  .dial { width: min(100%, calc(100svh - 21rem)); }
  .app-cta { grid-template-columns: 1fr; }
  .btn.primary { min-width: 0; flex: 1 1 100%; }
}
