:root {
  --bg: #eee9df;
  --surface: #f8f5ee;
  --surface-strong: #ffffff;
  --ink: #23332e;
  --muted: #66736d;
  --border: #d5d2c8;
  --accent: #356456;
  --accent-strong: #284f44;
  --accent-soft: #dbe7e0;
  --danger: #8a443f;
  --shadow: 0 20px 60px rgba(37, 50, 44, 0.10);
  --radius-lg: 28px;
  --radius-md: 18px;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.72), transparent 34%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(53, 100, 86, 0.35);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--safe-top) 20px var(--safe-bottom);
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 5px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--bg);
}

.icon-button, .text-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  cursor: pointer;
}

main { min-height: 0; }
.screen { min-height: calc(100dvh - 96px); }

.home-screen {
  display: grid;
  align-content: center;
  gap: clamp(34px, 7vh, 76px);
  padding: 34px 0;
}

.home-copy { max-width: 610px; }
.eyebrow, .step-kind {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4rem, 18vw, 7.4rem);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.07em;
}

.lead {
  max-width: 480px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 3.8vw, 1.3rem);
  line-height: 1.52;
}

.mode-list { display: grid; gap: 12px; }

.mode-button {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(248, 245, 238, 0.78);
  padding: 18px 20px;
  text-align: left;
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.mode-button:active { transform: scale(0.985); }
.mode-button:hover { border-color: #a9b5ae; background: var(--surface); }
.mode-button-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.mode-button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.mode-name { font-size: 1.22rem; font-weight: 760; }
.mode-description { opacity: 0.74; font-size: 0.92rem; line-height: 1.35; }

.resume-button, .quiet-action, .primary-action, .secondary-actions button {
  min-height: 54px;
  border-radius: 15px;
  cursor: pointer;
}

.resume-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 720;
}

.offline-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #b28a55; }
.status-dot.ready { background: #56836f; }

.exercise-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 16px 0 4px;
}

.exercise-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.mode-label { color: var(--muted); font-size: 0.86rem; }
.step-wrap { display: grid; align-content: center; padding: 28px 0; }
.step-text {
  margin: 0;
  max-width: 680px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 9vw, 4.8rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
  text-wrap: pretty;
}

.answer-field { display: grid; gap: 8px; margin-top: clamp(36px, 7vh, 72px); color: var(--muted); font-size: 0.84rem; }
.answer-field input {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.2rem;
  padding: 8px 2px;
}
.answer-field input:focus { border-bottom-color: var(--accent); outline-offset: 5px; }

.action-panel, .finish-panel { display: grid; gap: 12px; padding-bottom: var(--safe-bottom); }
.primary-action {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 14px 20px;
  font-size: 1.08rem;
  font-weight: 760;
}
.primary-action:hover { background: var(--accent-strong); }
.secondary-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.secondary-actions button, .quiet-action {
  border: 1px solid var(--border);
  background: rgba(248, 245, 238, 0.74);
  padding: 10px 12px;
}
.secondary-actions button:hover, .quiet-action:hover { background: var(--surface-strong); }
.full-width { width: 100%; }

body[data-mode="night"] {
  --bg: #18211f;
  --surface: #202b28;
  --surface-strong: #293632;
  --ink: #edf1ed;
  --muted: #aab6b0;
  --border: #3a4843;
  --accent: #8eb5a5;
  --accent-strong: #779e8e;
  --accent-soft: #2c3e38;
  background: var(--bg);
}
body[data-mode="night"] .mode-button,
body[data-mode="night"] .secondary-actions button,
body[data-mode="night"] .quiet-action { background: rgba(32, 43, 40, 0.86); }

body.large-text .step-text { font-size: clamp(2.8rem, 11vw, 5.4rem); }
body.large-text button { font-size: 1.08rem; }
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }

dialog {
  width: min(calc(100% - 24px), 560px);
  max-height: calc(100dvh - 28px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 29, 26, 0.46); backdrop-filter: blur(3px); }
.dialog-card { padding: 22px; display: grid; gap: 18px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.dialog-header h2 { margin: 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 500; }
.setting-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.setting-row span { display: grid; gap: 4px; }
.setting-row small { color: var(--muted); line-height: 1.35; }
.setting-row input { width: 26px; height: 26px; accent-color: var(--accent); }
.danger-link { min-height: 44px; border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.install-steps { margin: 0; padding-left: 24px; display: grid; gap: 12px; line-height: 1.45; }
.dialog-note { color: var(--muted); line-height: 1.45; }

noscript { display: block; padding: 24px; text-align: center; }

@media (min-width: 620px) {
  .app-shell { padding-left: 34px; padding-right: 34px; }
  .mode-list { grid-template-columns: 1.1fr 1fr; }
  .resume-button { grid-column: 1 / -1; }
  .secondary-actions { grid-template-columns: repeat(4, 1fr); }
}

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