:root {
  --bg: #efe4d1;
  --card: rgba(255, 248, 238, 0.9);
  --card-strong: rgba(255, 252, 247, 0.96);
  --panel: rgba(19, 33, 29, 0.06);
  --ink: #18140f;
  --muted: #665b4f;
  --accent: #173c33;
  --accent-strong: #0f2922;
  --accent-soft: rgba(23, 60, 51, 0.1);
  --signal: #c3733e;
  --signal-soft: rgba(195, 115, 62, 0.14);
  --line: rgba(24, 20, 15, 0.1);
  --shadow: 0 30px 90px rgba(43, 31, 20, 0.14);
  --green: #2f6f4f;
  --yellow: #a37d22;
  --orange: #bd6a32;
  --grey: #b4a99b;
  --danger: #8b4334;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(195, 115, 62, 0.2), transparent 34%),
    radial-gradient(circle at top right, rgba(23, 60, 51, 0.18), transparent 28%),
    linear-gradient(180deg, #f6ebdb 0%, #ecdcc6 54%, #e7ddcf 100%);
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom));
}

.topbar,
.hero-card,
.screen-card,
.stat-card,
.summary-card,
.day-card,
.modal-card,
.screen-card,
.debug-clock,
.planner-sidebar,
.period-tile,
.history-summary-card {
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.brand-block {
  display: grid;
  gap: 8px;
}

.eyebrow,
.kicker,
.status-badge,
.period-pill,
.tag,
.small-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.kicker,
.small-pill {
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 0.96;
}

h3 {
  font-size: 1.38rem;
  line-height: 1.04;
}

.topbar-actions,
.debug-actions,
.welcome-links,
.planner-actions,
.report-actions,
.suggestion-actions,
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.debug-clock {
  display: grid;
  gap: 7px;
  min-width: min(100%, 220px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 248, 238, 0.72);
}

.debug-clock strong {
  color: var(--accent-strong);
  font-size: 0.95rem;
  line-height: 1.35;
}

.debug-clock[hidden] {
  display: none;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font-weight: 800;
}

.inline-link {
  color: var(--accent);
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.text-button-danger {
  color: var(--danger);
}

.screen {
  display: block;
}

.screen-hidden {
  display: none;
}

.hero-card,
.screen-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero-card {
  border-radius: 30px;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.screen-card {
  border-radius: 30px;
  padding: 24px;
}

.screen-card-narrow {
  max-width: 640px;
  margin: 0 auto;
}

.status-badge {
  padding: 9px 14px;
  background: rgba(195, 115, 62, 0.14);
  color: #935726;
}

.status-badge[data-tone="green"] {
  background: rgba(47, 111, 79, 0.14);
  color: var(--green);
}

.status-badge[data-tone="yellow"] {
  background: rgba(163, 125, 34, 0.16);
  color: var(--yellow);
}

.status-badge[data-tone="orange"] {
  background: rgba(189, 106, 50, 0.16);
  color: var(--orange);
}

.hero-grid {
  display: grid;
  gap: 18px;
}

.hero-main {
  display: grid;
  gap: 12px;
}

.lead,
.subtle,
.field-label,
.period-copy,
.suggestion-copy,
.history-note,
.history-meta,
.day-card p,
.stat-label,
.screen-head,
.small-label {
  color: var(--muted);
  line-height: 1.65;
}

.lead {
  font-size: 1.1rem;
}

.hero-stats,
.report-summary,
.history-summary {
  display: grid;
  gap: 12px;
}

.stat-card,
.summary-card,
.history-summary-card {
  padding: 16px;
  border-radius: 22px;
  background: var(--card-strong);
  border: 1px solid rgba(23, 60, 51, 0.08);
}

.stat-label,
.small-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-card strong,
.summary-card strong,
.history-summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.36rem;
  color: var(--accent-strong);
}

.welcome-footer {
  display: grid;
  gap: 14px;
}

.action-button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 800;
  color: #fff9f2;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 16px 32px rgba(15, 41, 34, 0.18);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.action-button-large {
  width: 100%;
  min-height: 58px;
  font-size: 1.02rem;
}

.action-button-secondary {
  background: rgba(23, 60, 51, 0.08);
  color: var(--accent);
  box-shadow: none;
}

.action-button-hidden {
  display: none;
}

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}

.planner-overview {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.overview-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.78);
  border: 1px solid rgba(24, 20, 15, 0.06);
}

.planner-layout {
  display: grid;
  gap: 18px;
}

.planner-sidebar {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 26px;
  background: rgba(255, 252, 247, 0.68);
  border: 1px solid rgba(24, 20, 15, 0.06);
}

.period-tile {
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 14px;
  text-align: left;
  background: rgba(23, 60, 51, 0.05);
  cursor: pointer;
}

.period-tile strong {
  display: block;
  margin-top: 6px;
  color: var(--accent-strong);
}

.period-tile[data-state="locked"] {
  cursor: not-allowed;
  opacity: 0.48;
}

.period-tile[data-state="active"] {
  border-color: rgba(23, 60, 51, 0.34);
  box-shadow: 0 0 0 3px rgba(23, 60, 51, 0.1);
}

.planner-detail {
  display: grid;
  gap: 18px;
}

.planner-period-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.planner-target {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.selection-summary {
  display: grid;
  gap: 10px;
}

.planner-support {
  margin: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  border: 1px solid rgba(23, 60, 51, 0.08);
  text-transform: none;
  letter-spacing: 0;
}

.tag-empty {
  background: rgba(24, 20, 15, 0.06);
  color: var(--muted);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.option-button {
  border: 1px solid rgba(24, 20, 15, 0.08);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 252, 247, 0.88);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.45;
}

.option-button[data-selected="true"] {
  border-color: rgba(23, 60, 51, 0.34);
  background: rgba(23, 60, 51, 0.1);
  color: var(--accent-strong);
}

.field-row {
  display: grid;
  gap: 8px;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.94);
  color: var(--ink);
  padding: 14px 16px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.text-input:focus,
.text-area:focus {
  outline: none;
  border-color: rgba(23, 60, 51, 0.4);
  box-shadow: 0 0 0 4px rgba(23, 60, 51, 0.12);
}

.suggestion-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(195, 115, 62, 0.1);
  border: 1px solid rgba(195, 115, 62, 0.14);
}

.suggestion-hidden {
  display: none;
}

.report-list,
.history-list {
  display: grid;
  gap: 12px;
}

.habit-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.8);
  border: 1px solid rgba(24, 20, 15, 0.06);
}

.habit-row input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.field-hidden {
  display: none;
}

.history-list {
  margin-top: 18px;
}

.day-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 24px;
  background: var(--card-strong);
  border: 1px solid rgba(23, 60, 51, 0.08);
}

.day-card-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  flex-wrap: wrap;
}

.period-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.period-box {
  padding: 12px;
  border-radius: 16px;
  background: rgba(23, 60, 51, 0.05);
}

.period-box strong {
  display: block;
  margin-top: 6px;
  color: var(--accent-strong);
}

.period-box[data-tone="green"],
.history-summary-card[data-tone="green"],
.stat-card[data-tone="green"] {
  background: rgba(47, 111, 79, 0.14);
}

.period-box[data-tone="yellow"],
.history-summary-card[data-tone="yellow"],
.stat-card[data-tone="yellow"] {
  background: rgba(163, 125, 34, 0.16);
}

.period-box[data-tone="orange"],
.history-summary-card[data-tone="orange"],
.stat-card[data-tone="orange"] {
  background: rgba(189, 106, 50, 0.16);
}

.period-box[data-tone="grey"],
.history-summary-card[data-tone="grey"],
.stat-card[data-tone="grey"] {
  background: rgba(180, 169, 155, 0.22);
}

.day-card[data-blank="true"] {
  background: rgba(180, 169, 155, 0.18);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 27, 24, 0.46);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-hidden {
  display: none;
}

.modal-card {
  width: min(640px, 100%);
  padding: 24px;
  border-radius: 28px;
  background: var(--card-strong);
  border: 1px solid rgba(23, 60, 51, 0.08);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.quote-counter {
  margin: 0;
  font-weight: 800;
}

.sync-grid {
  display: grid;
  gap: 12px;
}

.sync-status {
  min-height: 1.5em;
  margin: 0;
  font-weight: 800;
}

.sync-note {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(23, 60, 51, 0.08);
  color: var(--accent-strong);
  line-height: 1.55;
  font-weight: 700;
}

.privacy-card {
  display: grid;
  gap: 18px;
}

.privacy-card h1 {
  font-size: clamp(2.2rem, 8vw, 4rem);
}

.privacy-section {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.76);
  border: 1px solid rgba(24, 20, 15, 0.06);
}

.privacy-section h2 {
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.privacy-section p {
  margin: 0;
}

.privacy-return {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.sync-status[data-tone="good"] {
  color: var(--green);
}

.sync-status[data-tone="bad"] {
  color: var(--danger);
}

.sync-status[data-tone="warn"] {
  color: var(--orange);
}

@media (min-width: 760px) {
  .hero-grid,
  .report-summary,
  .history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .planner-layout {
    grid-template-columns: 280px 1fr;
  }

  .history-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 759px) {
  .app-shell {
    width: min(100% - 18px, 1120px);
  }

  .topbar {
    display: grid;
  }

  .brand-block h1 {
    font-size: clamp(2.1rem, 14vw, 3.2rem);
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .topbar-actions .text-button {
    min-height: 40px;
    padding: 8px;
    border-radius: 14px;
    background: rgba(23, 60, 51, 0.08);
  }

  .hero-card,
  .screen-card {
    border-radius: 24px;
    padding: 18px;
  }

  .inline-field,
  .planner-actions,
  .report-actions,
  .suggestion-actions,
  .period-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .option-grid {
    grid-template-columns: 1fr;
  }

  .planner-target {
    justify-items: start;
  }

  .modal {
    align-items: end;
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
    overflow: auto;
    border-radius: 24px;
  }

  .sync-actions {
    display: grid;
  }

  .sync-actions .action-button,
  .sync-actions .text-button {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar-actions,
  .welcome-links,
  .planner-actions,
  .report-actions,
  .suggestion-actions,
  .modal {
    display: none !important;
  }

  .hero-card,
  .screen-card,
  .day-card {
    box-shadow: none;
    background: #fff;
  }
}
