:root {
  color-scheme: light;
  --green: #6f7d3c;
  --green-dark: #4e5a2b;
  --green-soft: #eef1e3;
  --surface: #f8f7f2;
  --card: #ffffff;
  --text: #343832;
  --muted: #666b61;
  --border: #e0e2d7;
  --danger: #b64c45;
  --shadow: 0 3px 14px rgba(52, 56, 50, .07);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--surface); }
body { margin: 0; color: var(--text); background: var(--surface); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page {
  display: none;
  width: min(100%, 780px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(36px + env(safe-area-inset-bottom));
}
.page.active { display: block; }
.hero { text-align: center; padding: 8px 16px 14px; }
.logo { display: block; width: 116px; height: 116px; object-fit: contain; margin: 0 auto; border-radius: 50%; }
.app-header { padding: 2px 0 8px; }
.title-block { text-align: center; }
.title-block p { margin: 4px 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.header-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 50%; }
.button.compact { width: auto; min-height: 42px; padding-inline: 14px; }
.home-secondary { margin-top: 10px; }
.access-status { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 4px 0 12px; padding: 10px 12px; background: var(--green-soft); border-radius: 14px; }
.access-status p { margin: 0; font-size: .86rem; }
.access-status .button { width: auto; min-height: 38px; padding: 7px 11px; font-size: .82rem; }
.locked-card { border-color: #c9cfad; }
.lock-badge { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 36px; height: 36px; color: white; background: var(--green-dark); border: 3px solid white; border-radius: 50%; box-shadow: 0 2px 8px rgba(52, 56, 50, .22); }
.lock-badge svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.locked-card .module-subtitle { color: var(--green-dark); font-weight: 750; }
.access-form { display: grid; gap: 12px; }
.access-form input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.checkbox-row { display: flex; gap: 9px; align-items: flex-start; color: var(--muted); font-size: .9rem; }
.checkbox-row input { width: auto; min-height: 0; margin-top: 4px; }
.admin-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.admin-table th, .admin-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.code-output { padding: 12px; word-break: break-all; font: 700 1.05rem ui-monospace, monospace; background: var(--green-soft); border-radius: 10px; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 6px 0 14px; }
.module-card { position: relative; min-width: 0; aspect-ratio: 1 / 1; padding: 13px 10px; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; text-decoration: none; }
.module-card:focus-visible { outline: 3px solid rgba(111, 125, 60, .35); outline-offset: 2px; }
.module-card.dragging { opacity: .55; transform: scale(.97); }
.module-grid.editing .module-card { touch-action: none; }
.module-icon { width: 52px; height: 52px; color: var(--green-dark); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.module-name { margin-top: 8px; font-weight: 750; line-height: 1.18; }
.module-subtitle { margin-top: 4px; color: var(--muted); font-size: .76rem; line-height: 1.2; }
.module-remove { position: absolute; top: 7px; right: 7px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #d9aaa7; color: #963e39; background: white; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.stack { display: grid; gap: 10px; }
.minimum-timer { margin: 9px 0 0; color: var(--green-dark); font-weight: 700; }
h1 { margin: 4px 0 0; font-size: clamp(1.8rem, 7vw, 2.2rem); line-height: 1.15; }
.hero p, .subpage-header p { margin: 4px 0 0; color: var(--muted); }
h2 { margin: 0; font-size: 1.3rem; }
h3 { margin: 0; font-size: 1rem; }
p { line-height: 1.5; }

.card, .stat-card, .difficulties {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 18px; }
.measurement-card { text-align: center; border-radius: 20px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.centered { text-align: center; }
.status, .phase-label { margin: 20px 0 0; color: var(--green-dark); font-weight: 750; font-size: 1.5rem; }
.hidden { display: none !important; }
.interpretation { margin-top: 14px; padding: 16px; text-align: left; background: var(--green-soft); border: 1px solid var(--border); border-radius: 16px; }
.interpretation-level { color: var(--green-dark); font-weight: 750; font-size: 1.12rem; }
.section-title { margin: 24px 0 12px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 11px 15px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
  transition: transform .12s ease, filter .12s ease;
}
.button:active { transform: scale(.985); }
.button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(111, 125, 60, .35); outline-offset: 2px; }
.button.primary { color: white; background: var(--green); }
.button.secondary { color: var(--text); background: white; border-color: var(--border); }
.button.soft-link { color: var(--green-dark); background: var(--green-soft); }
.button.danger, .button.measure-stop { color: white; background: var(--danger); }
.button.danger-outline { color: #963e39; background: white; border-color: #d9aaa7; }
.button.large { min-height: 58px; font-size: 1.08rem; margin-top: 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { min-height: 105px; padding: 16px 10px; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.stat-card strong { color: var(--green-dark); font-size: 1.65rem; }
.stat-card span { margin-top: 5px; color: var(--muted); font-size: .86rem; }
.wide-stat { grid-column: 1 / -1; }
.chart-card { margin-top: 16px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.range-button { min-height: 42px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; }
.range-button.selected { background: var(--green); border-color: var(--green); color: white; font-weight: 700; }
#progress-chart { width: 100%; height: 190px; margin-top: 14px; background: var(--surface); border-radius: 14px; }
.action-list { display: grid; gap: 10px; margin-top: 16px; }
.store-button { gap: 10px; color: var(--green-dark); }
.store-icon { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.training-card { margin-top: 14px; box-shadow: none; }
.disclaimer { margin: 18px 0 0; text-align: center; font-size: .82rem; }

.back-button { width: auto; min-width: 170px; }
.subpage-header { text-align: center; margin: 18px 0; }
.subpage-header h1 { margin: 0; }
.field-label { display: block; margin: 10px 0 6px; color: var(--muted); font-size: .9rem; }
input[type="number"], select { width: 100%; min-height: 48px; padding: 10px 12px; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 12px; }
input[type="date"], input[type="time"], input[type="text"] { width: 100%; min-height: 48px; padding: 10px 12px; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 12px; font: inherit; }
input[type="range"] { width: 100%; accent-color: var(--green); }
.large-timer { margin: 12px 0 0; color: var(--green-dark); font-size: 2.75rem; font-weight: 750; line-height: 1.1; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.summary-emphasis { margin: 0; color: var(--green-dark); font-weight: 700; }
.audio-card { margin-bottom: 18px; box-shadow: none; }
.audio-card h2 { font-size: 1.08rem; }

.guided-card { overflow: hidden; }
.guided-card .phase-label { margin-top: 0; }
.breathing-visual { height: 142px; display: grid; place-items: center; margin-top: 14px; }
.breathing-visual::before { content: ""; position: absolute; width: 118px; height: 118px; background: var(--green-soft); border-radius: 50%; }
.breathing-circle { position: relative; width: 82px; height: 82px; border-radius: 50%; background: var(--green); transform: scale(1); will-change: transform; }
.progress-track { height: 10px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: var(--green-soft); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--green); }
.difficulties { margin-top: 18px; overflow: hidden; box-shadow: none; }
.difficulties summary { padding: 15px 18px; cursor: pointer; font-weight: 700; }
.difficulties > div { padding: 0 18px 18px; color: var(--muted); line-height: 1.5; }

dialog { width: min(calc(100% - 28px), 560px); max-height: min(85dvh, 760px); padding: 0; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 16px 60px rgba(30, 35, 25, .25); }
dialog::backdrop { background: rgba(28, 31, 25, .45); }
.dialog-content { padding: 22px; overflow-y: auto; }
.dialog-content h2 { margin-bottom: 12px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.history-list { display: grid; gap: 8px; max-height: 50dvh; overflow-y: auto; }
.history-item { padding: 10px 12px; border-radius: 10px; background: var(--surface); line-height: 1.4; }
.instructions-list { padding-left: 1.4rem; }
.instructions-list li { margin-bottom: 12px; line-height: 1.5; }
.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; }
.module-shell { display: grid; gap: 14px; }
.subpage-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, auto)); justify-content: space-between; gap: 8px; }
.subpage-navigation .button { width: auto; min-width: 0; }
.choice-list { display: grid; gap: 12px; }
.choice-card { width: 100%; padding: 18px; text-align: left; color: var(--text); background: white; border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); cursor: pointer; }
.choice-card strong { display: block; font-size: 1.15rem; }
.choice-card .accent { display: block; margin-top: 4px; color: var(--green-dark); font-weight: 700; }
.choice-card small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.35; }
.info-card { padding: 18px; }
.info-card h2 { margin-bottom: 9px; }
.info-card p:first-of-type { margin-top: 0; }
.info-card p:last-child { margin-bottom: 0; }
.info-card ul { padding-left: 1.3rem; }
.info-card li { margin-bottom: 8px; line-height: 1.5; }
.counter { margin: 10px 0; color: var(--green-dark); font-size: 2.5rem; font-weight: 800; text-align: center; }
.stable-counter { min-height: 3.1rem; display: grid; place-items: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inline-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.inline-controls.three { grid-template-columns: repeat(3, 1fr); }
.form-grid { display: grid; gap: 10px; }
.form-grid label { color: var(--muted); font-size: .9rem; font-weight: 650; }
.entry-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.entry-row .button { width: auto; min-height: 40px; padding: 7px 9px; font-size: .82rem; }
.week-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.week-row:last-child { border-bottom: 0; }
.day-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.day-options label { display: flex; gap: 6px; align-items: center; }
.notice { padding: 13px; color: var(--muted); background: var(--green-soft); border-radius: 13px; line-height: 1.45; }
.book-card { text-align: left; }
.book-cover {
  display: block;
  width: auto;
  height: clamp(210px, 62vw, 280px);
  max-width: 100%;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 12px;
}
.journal-toolbar, #journal-table { min-width: 0; max-width: 100%; }
.journal-toolbar { display: grid; gap: 10px; }
.journal-toolbar .button-row { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.journal-toolbar .button { min-width: 0; padding-inline: 10px; white-space: nowrap; }
.journal-scroll { width: 100%; max-width: 100%; max-height: min(62dvh, 620px); overflow-x: auto; overflow-y: auto; border: 1px solid var(--border); border-radius: 16px; background: white; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.journal-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
.journal-table th, .journal-table td { min-width: 84px; height: 52px; padding: 7px; text-align: center; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: white; }
.journal-table th:first-child { position: sticky; left: 0; z-index: 2; min-width: 146px; max-width: 146px; text-align: left; background: var(--green-soft); }
.journal-table thead th { position: sticky; top: 0; z-index: 3; background: var(--green-soft); }
.journal-table thead th:first-child { z-index: 4; }
.journal-table tr:last-child > * { border-bottom: 0; }
.journal-table tr > *:last-child { border-right: 0; }
.journal-table button { width: 100%; min-height: 36px; padding: 4px; color: inherit; background: transparent; border: 0; border-radius: 8px; cursor: pointer; font: inherit; }
.journal-table button:hover, .journal-table button:focus-visible { background: rgba(111, 125, 60, .12); }

@media (min-width: 720px) {
  .page { padding-left: 28px; padding-right: 28px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .action-list { grid-template-columns: repeat(2, 1fr); }
  .action-list .button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .module-grid { gap: 16px; }
  .module-card { aspect-ratio: 1.18 / 1; }
  .book-card { display: grid; grid-template-columns: minmax(190px, 240px) 1fr; column-gap: 24px; align-items: start; }
  .book-card > :not(.book-cover) { grid-column: 2; }
  .book-card .book-cover { grid-column: 1; grid-row: 1 / span 20; height: 300px; align-self: center; justify-self: center; }
  .journal-table { font-size: .85rem; }
  .journal-table th, .journal-table td { min-width: 92px; padding: 8px; }
  .journal-table th:first-child { min-width: 190px; max-width: 190px; }
}

@media (max-width: 430px) {
  .back-button { min-width: 0; }
  .entry-row { grid-template-columns: 1fr 1fr; }
  .entry-row > span { grid-column: 1 / -1; }
  .entry-row .button { width: 100%; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .page { width: min(100%, 900px); }
  .module-card { aspect-ratio: 1.45 / 1; }
  .header-logo { width: 64px; height: 64px; }
}

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