:root {
  color-scheme: light;
  --page: #f5f7f3;
  --surface: #ffffff;
  --surface-soft: #edf2eb;
  --text: #1d2b24;
  --muted: #52635a;
  --line: #d7dfd8;
  --accent: #315c4d;
  --accent-strong: #244b3d;
  --accent-soft: #dcebe1;
  --sun: #f3d982;
  --help: #8d3f32;
  --help-soft: #fff0e9;
  --danger: #8b302f;
  --focus: #a45b00;
  --shadow: 0 12px 32px rgb(26 49 38 / 7%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #151d19;
  --surface: #202b25;
  --surface-soft: #29372f;
  --text: #eef4ed;
  --muted: #c1cdc4;
  --line: #435149;
  --accent: #a6d0b6;
  --accent-strong: #c1e3cc;
  --accent-soft: #2f4939;
  --sun: #f0d47a;
  --help: #ffb39e;
  --help-soft: #4a2d29;
  --danger: #ffaaa1;
  --focus: #f4cb70;
  --shadow: 0 12px 32px rgb(0 0 0 / 18%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #151d19;
    --surface: #202b25;
    --surface-soft: #29372f;
    --text: #eef4ed;
    --muted: #c1cdc4;
    --line: #435149;
    --accent: #a6d0b6;
    --accent-strong: #c1e3cc;
    --accent-soft: #2f4939;
    --sun: #f0d47a;
    --help: #ffb39e;
    --help-soft: #4a2d29;
    --danger: #ffaaa1;
    --focus: #f4cb70;
    --shadow: 0 12px 32px rgb(0 0 0 / 18%);
  }
  :root:not([data-theme="light"]) .button-primary { color: #15231b; }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--text); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; z-index: 20; top: 8px; left: 8px; transform: translateY(-160%);
  padding: .6rem 1rem; border-radius: .5rem; background: var(--surface); color: var(--text);
}
.skip-link:focus { transform: translateY(0); }
.site-header {
  min-height: 76px; padding: 12px clamp(16px, 4vw, 56px); display: flex; align-items: center;
  justify-content: space-between; gap: 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-size: 1.25rem; font-weight: 750; letter-spacing: -.04em; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--accent); color: var(--sun); font-size: 1.55rem; font-weight: 800; font-family: Georgia, serif; }
.header-actions, .button-row { display: flex; align-items: center; gap: 10px; }
.button, .nav-link {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; cursor: pointer;
  font-weight: 650; text-decoration: none; transition: background-color .18s ease, transform .18s ease;
}
.button:hover:not(:disabled), .nav-link:hover { transform: translateY(-1px); }
.button:disabled { opacity: .65; cursor: not-allowed; }
.button-primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .button-primary { color: #15231b; }
.button-primary:hover { background: var(--accent-strong); }
.button-outline { border-color: var(--line); background: var(--surface); color: var(--text); }
.button-outline:hover { background: var(--surface-soft); }
.button-quiet { background: transparent; color: var(--text); }
.button-help { background: var(--help-soft); color: var(--help); border-color: color-mix(in srgb, var(--help) 25%, transparent); }
.button-danger { background: var(--danger); color: white; }
.text-button { display: inline-flex; gap: 6px; border: 0; padding: 6px 0; background: transparent; color: var(--accent-strong); font-weight: 700; text-decoration: none; cursor: pointer; }
.danger-text { color: var(--danger); }
.wrap { flex-wrap: wrap; }
.app-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.side-nav { position: sticky; top: 0; align-self: start; display: grid; gap: 6px; padding: 28px 16px; }
.nav-link { justify-content: flex-start; background: transparent; color: var(--muted); text-align: left; }
.nav-link span { width: 22px; color: var(--accent-strong); font-size: 1.15rem; text-align: center; }
.nav-link.is-active { color: var(--accent-strong); background: var(--accent-soft); }
main { width: min(100%, 1240px); margin: 0 auto; padding: clamp(24px, 4vw, 56px); }
.view { outline: none; }
.view > h1:focus { outline: none; }
.welcome-grid { min-height: 330px; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 30px; overflow: hidden; border-radius: 28px; padding: clamp(24px, 4vw, 52px); background: var(--accent-soft); }
.welcome-copy { max-width: 610px; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 800px; margin-bottom: 12px; font-size: clamp(2rem, 4.5vw, 3.35rem); line-height: 1.08; letter-spacing: -.055em; }
h1 em { color: var(--accent-strong); font-family: Georgia, serif; font-weight: 500; }
h2 { font-size: 1.28rem; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: 1rem; }
.welcome-copy > p:not(.eyebrow) { max-width: 580px; color: var(--muted); font-size: 1.08rem; margin-bottom: 24px; }
.eyebrow { margin-bottom: 8px; color: var(--accent-strong); font-size: .73rem; font-weight: 800; letter-spacing: .13em; }
.welcome-art { position: relative; min-height: 245px; align-self: stretch; overflow: hidden; }
.sun { position: absolute; top: 5%; right: 20%; width: 135px; aspect-ratio: 1; border-radius: 50%; background: var(--sun); }
.hill { position: absolute; bottom: -34%; width: 125%; height: 78%; border-radius: 50% 50% 0 0; }
.hill-one { right: -24%; background: var(--accent); transform: rotate(-12deg); }
.hill-two { left: -30%; bottom: -43%; background: color-mix(in srgb, var(--accent) 70%, var(--sun)); transform: rotate(12deg); }
.art-spark { position: absolute; color: var(--accent-strong); font-size: 1.6rem; }
.spark-one { top: 22%; left: 20%; }.spark-two { top: 5%; right: 7%; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 24px; }
.card { min-width: 0; padding: clamp(20px, 2.4vw, 28px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.card h2:last-child, .card p:last-child { margin-bottom: 0; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-heading h2 { margin-bottom: 8px; }
.card-icon { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-strong); font-size: 1.5rem; }
.quote-card { background: var(--surface-soft); }
.quote { margin: 20px 0 12px; font-family: Georgia, serif; font-size: 1.45rem; line-height: 1.35; }
.quick-card { background: var(--help-soft); border-color: color-mix(in srgb, var(--help) 20%, var(--line)); }
.quick-card .eyebrow { color: var(--help); }
.disclaimer, .site-footer { color: var(--muted); font-size: .85rem; }
.disclaimer { margin: 28px 0 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.page-heading { margin: 0 0 26px; }
.page-heading > p:last-child { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.two-column > .card { height: 100%; }
.field-label, legend { display: block; margin: 16px 0 7px; font-weight: 700; }
legend { padding: 0; }
fieldset { min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--surface); color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type="radio"], input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--accent); }
.short-field { margin-top: 14px; }
.mood-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.mood-options label { position: relative; display: grid; justify-items: center; gap: 4px; min-height: 94px; padding: 10px 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: center; }
.mood-options input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.mood-options label:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-soft); }
.mood-options label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.mood-options label > span { color: var(--accent-strong); font-size: 1.45rem; }
.mood-options b { font-size: .76rem; line-height: 1.15; }
.required-note { color: var(--muted); font-size: .82rem; font-weight: 400; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-option input { position: absolute; opacity: 0; }
.tag-option span { display: inline-flex; min-height: 38px; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: .9rem; }
.tag-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.tag-option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.form-message { min-height: 1.4em; margin: 8px 0 0; color: var(--accent-strong); font-weight: 650; }
.calendar-controls { display: flex; align-items: center; gap: 12px; margin-top: 26px; }
.calendar-controls label { font-weight: 700; }
.calendar-controls input { max-width: 175px; }
.chart-range-label { display: grid; gap: 2px; min-width: 92px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.chart-range-label select { min-height: 38px; padding: 6px 8px; }
.calendar-list, .saved-list { display: grid; gap: 10px; margin-top: 14px; }
.calendar-entry, .saved-item, .task-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.calendar-entry h3, .saved-item h3 { margin-bottom: 6px; }
.calendar-entry p, .saved-item p { margin-bottom: 6px; }
.calendar-entry p:last-child, .saved-item p:last-child { margin-bottom: 0; }
canvas { display: block; width: 100%; height: 220px; }
.breathing-card { min-height: 430px; }
.breathing-stage { display: grid; justify-items: center; gap: 10px; min-height: 210px; padding: 15px; text-align: center; }
.breathing-stage p { margin: 0; font-weight: 700; }
.breathing-orb { width: 100px; height: 100px; border: 3px solid var(--accent); border-radius: 50%; background: var(--accent-soft); transition: transform 1s ease-in-out; }
.breathing-stage[data-phase="Hinga sisse"] .breathing-orb { transform: scale(1.45); }
.breathing-stage[data-phase="Hoia õrnalt"] .breathing-orb { transform: scale(1.45); }
.breathing-stage[data-phase="Hinga välja"] .breathing-orb { transform: scale(.8); }
.breathing-stage[data-phase="Hinga aeglaselt välja"] .breathing-orb { transform: scale(.8); }
.breathing-count { color: var(--accent-strong); font-size: 1.3rem; font-weight: 750; }
.grounding-list, .instruction-list { padding-left: 1.4rem; }
.grounding-list li, .instruction-list li { margin: 10px 0; padding-left: 4px; }
.grounding-list b { color: var(--accent-strong); font-size: 1.1rem; }
.saved-list .text-button { margin-top: 8px; }
.notice { padding: 14px 16px; border-left: 4px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.notice-warm { border-left-color: var(--help); background: var(--help-soft); }
.task-list { display: grid; gap: 12px; margin-top: 12px; }
.task-item-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-done { flex: 1; }
.task-item.is-done .task-done span { color: var(--muted); text-decoration: line-through; }
.task-steps { margin-bottom: 0; padding-left: 1.2rem; color: var(--muted); }
.count-pill { padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: .85rem; font-weight: 700; }
.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0; cursor: pointer; }
.check-row input { flex: 0 0 19px; }
.timer-card { text-align: center; }
.timer-card .field-label { text-align: left; }
.timer-display { padding: 20px 0; color: var(--accent-strong); font-variant-numeric: tabular-nums; font-size: clamp(3rem, 8vw, 4.5rem); font-weight: 750; letter-spacing: -.05em; }
.timer-card .button-row { justify-content: center; }
.questionnaire-card { max-width: 900px; }
.who-question { padding: 18px 0; border-bottom: 1px solid var(--line); }
.who-question legend { margin: 0 0 12px; }
.support-question { margin-top: 20px; padding: 18px; border-radius: 12px; background: var(--surface-soft); }
.support-question > p { color: var(--muted); }
.who-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.who-options label { display: flex; align-items: flex-start; gap: 8px; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.who-options label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.result-box { margin-top: 20px; padding: 20px; border-radius: 14px; background: var(--accent-soft); }
.result-box h2 { margin-bottom: 8px; }
.challenge-card { background: var(--accent-soft); }
.challenge-card h2 { min-height: 3.3em; font-family: Georgia, serif; font-size: 1.65rem; }
.streak-note { margin-top: 18px; color: var(--muted); }
.message-template textarea { margin-bottom: 12px; }
.help-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.contact-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.contact-card h2, .contact-card p { margin: 0; }
.contact-card .button { margin-top: 4px; }
.contact-link { margin-top: auto; }
.urgent-contact { border-color: var(--help); background: var(--help-soft); }
.help-note { margin-top: 20px; }
.crisis-banner { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 20px 0; padding: 18px; border: 1px solid var(--help); border-radius: 16px; background: var(--help-soft); }
.crisis-banner p { margin: 5px 0 0; }
.crisis-response { align-items: flex-start; }
.privacy-list { padding-left: 1.25rem; }
.privacy-list li { margin: 12px 0; }
.file-button { position: relative; cursor: pointer; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
.danger-card h2 { color: var(--danger); }
.lock-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--page); }
.lock-card { width: min(100%, 420px); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.lock-card > .brand-mark { margin-bottom: 20px; }
.lock-card h1 { font-size: 2rem; }
.lock-card .button { width: 100%; margin-top: 16px; }
.lock-help { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px clamp(16px, 4vw, 56px); border-top: 1px solid var(--line); background: var(--surface); }
.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: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .side-nav { position: sticky; z-index: 5; top: 0; display: flex; gap: 5px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--page); scrollbar-width: thin; }
  .nav-link { flex: 0 0 auto; min-height: 42px; padding: 8px 12px; font-size: .88rem; }
  .nav-link span { display: none; }
  main { padding-top: 28px; }
}
@media (max-width: 700px) {
  .welcome-grid { grid-template-columns: 1fr; gap: 8px; }
  .welcome-art { min-height: 140px; }
  .sun { width: 95px; }
  .dashboard-grid, .two-column, .help-cards { grid-template-columns: 1fr; }
  .mood-options { gap: 4px; }
  .mood-options label { min-height: 86px; }
  .mood-options b { font-size: .68rem; }
  .who-options { grid-template-columns: repeat(2, 1fr); }
  .crisis-banner { align-items: flex-start; flex-direction: column; }
  .site-header { min-height: 66px; padding: 10px 14px; }
  .brand { font-size: 1.1rem; }
  .header-actions { gap: 6px; }
  .button { padding: 9px 12px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 390px) {
  .button-quiet { max-width: 88px; font-size: .82rem; }
  .button-help { padding: 8px 10px; font-size: .88rem; }
  .mood-options b { font-size: .62rem; }
  .calendar-controls { align-items: flex-start; flex-direction: column; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
