:root {
  --paper: #fbf2dc;
  --paper-2: #f6e5be;
  --milk: #fff8e7;
  --ink: #1c2a3a;
  --ink-soft: #4a5970;
  --tomato: #e54a37;
  --tomato-soft: #f7cfc9;
  --sun: #f5b833;
  --sun-soft: #fbe6b3;
  --sage: #6f9a6b;
  --sage-soft: #cfe0c8;
  --sky: #5b9bc2;
  --sky-soft: #c8dfec;
  --plum: #7a4677;
  --plum-soft: #d8c6da;
  --cocoa: #8a4f2a;

  --border: 2.5px solid var(--ink);
  --border-thin: 2px solid var(--ink);
  --radius-card: 18px;
  --radius-chip: 999px;

  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-md: 5px 5px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);

  --font-display: "Caprasimo", "Georgia", serif;
  --font-body: "Quicksand", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% -10%, #ffe9c4 0, transparent 60%),
    radial-gradient(900px 500px at 95% 10%, #fce0b8 0, transparent 60%),
    var(--paper);
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

/* ---------- header ---------- */

.app-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 14px;
  padding: 8px 0 22px;
}

.app-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  text-align: center;
  transform: rotate(-1.5deg);
  text-shadow: 3px 3px 0 var(--sun);
}

.header-sticker {
  display: inline-grid;
  place-items: center;
  width: clamp(52px, 8vw, 78px);
  aspect-ratio: 1;
}

.header-sticker svg {
  width: 100%;
  height: 100%;
}

.header-sticker-left {
  transform: rotate(-12deg);
}

.header-sticker-right {
  transform: rotate(10deg);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(460px, 1.4fr);
  gap: 22px;
  align-items: start;
}

.clock-panel,
.day-panel {
  position: relative;
  background: var(--milk);
  border: var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
}

.clock-panel {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 22px 22px 24px;
  transform: rotate(-0.6deg);
}

.day-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 18px;
  min-width: 0;
  transform: rotate(0.4deg);
}

/* ---------- clock face ---------- */

.clock-face {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff 0%, var(--milk) 65%, #f0e3c4 100%);
  border: 10px solid var(--ink);
  box-shadow:
    inset 0 0 0 4px var(--milk),
    inset 0 0 0 6px var(--ink),
    var(--shadow-md);
}

.clock-number,
.clock-tick {
  position: absolute;
  left: var(--x);
  top: var(--y);
}

.clock-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  transform: translate(-50%, -50%);
}

.clock-tick {
  width: 3px;
  height: 8px;
  border-radius: 999px;
  background: var(--ink-soft);
  transform: translate(-50%, -50%) rotate(var(--angle));
}

.clock-minute-number {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--tomato);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.clock-face.show-minutes .clock-minute-number {
  display: grid;
}

.clock-tick.major {
  width: 5px;
  height: 14px;
  background: var(--ink);
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  border-radius: 999px;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.hour-hand {
  width: 12px;
  height: 28%;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--ink);
}

.minute-hand {
  width: 8px;
  height: 38%;
  background: var(--tomato);
  box-shadow: 0 0 0 2px var(--ink);
}

.clock-centre {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sun);
  border: 3px solid var(--ink);
  transform: translate(-50%, -50%);
}

/* ---------- clock legend ---------- */

.clock-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(100%, 340px);
}

.legend-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: var(--border-thin);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.legend-hand {
  display: inline-block;
  height: 6px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
}

.legend-hour {
  width: 18px;
  background: var(--ink);
}

.legend-minute {
  width: 30px;
  background: var(--tomato);
}

.legend-label {
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.legend-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
}

.legend-toggle {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: var(--border-thin);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

.legend-toggle:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.legend-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.legend-toggle.active {
  background: var(--sun);
  color: var(--ink);
}

.legend-toggle-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--milk);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

/* ---------- scene panel ---------- */

.scene-panel {
  display: grid;
  grid-template-columns: minmax(160px, 0.42fr) minmax(220px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.scene-art {
  position: relative;
  min-height: 200px;
  overflow: hidden;
  border-radius: 14px;
  border: var(--border);
  background: var(--sun-soft);
  box-shadow: var(--shadow-sm);
}

.scene-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.scene-school {
  background: var(--sky-soft);
}
.scene-home {
  background: var(--sage-soft);
}
.scene-swim {
  background: var(--sky-soft);
}
.scene-dinner {
  background: var(--tomato-soft);
}
.scene-bed {
  background: var(--plum-soft);
}
.scene-wake {
  background: var(--sun-soft);
}

.scene-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 0;
}

.scene-copy p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-weight: 500;
  line-height: 1.45;
}

.event-detail {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.loop-note {
  margin-top: 14px !important;
  padding-left: 14px;
  border-left: 3px solid var(--sun);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
  line-height: 1.4;
}

.digital-time {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 4.2rem;
  line-height: 0.95;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.spoken-time {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--tomato);
  font-size: 1.85rem;
  line-height: 1.05;
}

.scene-copy h2 {
  margin: 18px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--ink);
}

.time-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

/* ---------- mode tabs ---------- */

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 6px;
  border: var(--border);
  border-radius: var(--radius-chip);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.mode-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}

.mode-button.active {
  background: var(--ink);
  color: var(--milk);
  box-shadow: 0 0 0 2px var(--milk) inset;
}

.mode-view[hidden] {
  display: none;
}

.explorer-view {
  display: grid;
  gap: 18px;
}

/* ---------- timeline ---------- */

.timeline-wrap {
  position: relative;
  min-height: 140px;
  padding: 32px 0 54px;
}

.timeline-bands {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 56px;
  overflow: hidden;
  border-radius: 12px;
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.timeline-band {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: flex-start;
  padding: 8px 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  overflow: hidden;
}

.band-morning {
  background: var(--sun-soft);
}
.band-school {
  background: var(--sky-soft);
}
.band-afternoon {
  background: var(--sage-soft);
}
.band-evening {
  background: var(--plum-soft);
}
.band-night {
  background: #c8cfdb;
  color: var(--ink);
}

/* ---------- slider ---------- */

.time-slider {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 56px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

.time-slider::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
}

.time-slider::-moz-range-track {
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
}

.time-slider::-webkit-slider-thumb {
  width: 40px;
  height: 40px;
  margin-top: -13px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--tomato);
  box-shadow: 3px 3px 0 var(--ink);
  appearance: none;
  transition: transform 120ms ease;
}

.time-slider::-webkit-slider-thumb:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.time-slider::-moz-range-thumb {
  width: 36px;
  height: 36px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--tomato);
  box-shadow: 3px 3px 0 var(--ink);
}

/* ---------- event pins ---------- */

.event-pins {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
}

.event-pin {
  position: absolute;
  bottom: 0;
  width: 88px;
  min-height: 46px;
  padding: 5px 6px;
  border: var(--border-thin);
  border-radius: 10px;
  background: var(--milk);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transform: translateX(-50%);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.event-pin:hover {
  transform: translate(-50%, -1px);
}

.event-pin span {
  display: block;
}

.event-emoji {
  margin-bottom: 2px;
  font-size: 1rem;
  line-height: 1;
}

.event-pin::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -14px;
  width: 3px;
  height: 12px;
  background: var(--ink);
  transform: translateX(-50%);
}

.event-pin.active {
  background: var(--sun);
  transform: translate(-50%, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.event-pin.edge-end {
  transform: translateX(-100%);
}

.event-pin.edge-end::before {
  left: 100%;
}

.event-pin.edge-end.active {
  transform: translate(-100%, 1px);
}

/* ---------- anchors ---------- */

.anchor-panel {
  margin-top: 22px;
}

.anchor-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.anchor-button {
  display: grid;
  min-height: 60px;
  padding: 9px 10px;
  border: var(--border-thin);
  border-radius: 12px;
  background: var(--milk);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.anchor-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.anchor-button:active,
.anchor-button.active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.anchor-button.active {
  background: var(--sun);
}

.anchor-time {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.anchor-name {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.15;
}

.anchor-name span[aria-hidden="true"] {
  margin-right: 4px;
}

/* ---------- practice card ---------- */

.practice-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.challenge-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.challenge-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: var(--border);
  background: var(--sun);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-8deg);
}

.challenge {
  flex: 1 1 auto;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.25;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  min-height: 68px;
  padding: 12px 16px;
  border: var(--border-thin);
  border-radius: 14px;
  background: var(--milk);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.choice-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.choice-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.choice-button.selected {
  background: var(--sun);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.ch-main {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.05;
  color: var(--ink);
}

.ch-period {
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.choice-button.selected .ch-period {
  color: var(--ink);
}

/* ---------- action buttons ---------- */

.practice-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 9px 16px;
  border: var(--border-thin);
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  background: var(--ink);
  color: var(--milk);
}

.secondary-button {
  background: var(--milk);
  color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-button:active,
.secondary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: var(--border-thin);
  border-radius: 14px;
  background: var(--milk);
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.icon-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.icon-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.panel-speak {
  width: 48px;
  height: 48px;
}

/* ---------- feedback ---------- */

.feedback {
  grid-column: 1 / -1;
  min-height: 28px;
  margin: 4px 0 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.feedback.success {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 46px;
  padding: 9px 14px;
  border: var(--border-thin);
  border-radius: 12px;
  background: var(--sage-soft);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.08rem;
  box-shadow: var(--shadow-sm);
  animation: celebrate 460ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes celebrate {
  0% {
    transform: scale(0.85) rotate(-3deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.06) rotate(2deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ---------- focus ---------- */

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--tomato);
  outline-offset: 3px;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .clock-panel,
  .day-panel {
    transform: none;
  }

  .clock-panel {
    padding-bottom: 18px;
  }

  .digital-time {
    font-size: 3.3rem;
  }

  .app-title {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
  }
}

@media (min-width: 560px) and (max-width: 900px) {
  .workspace {
    grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1fr);
    gap: 14px;
  }

  .clock-panel {
    padding: 16px;
  }

  .clock-face {
    width: min(100%, 260px);
  }

  .clock-legend {
    font-size: 0.86rem;
  }

  .day-panel {
    padding: 16px;
  }

  .scene-panel {
    display: block;
  }

  .scene-art {
    display: none;
  }

  .timeline-band {
    padding: 6px 6px;
    font-size: 0.78rem;
  }

  .practice-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .clock-panel,
  .scene-panel {
    grid-template-columns: 1fr;
  }

  .clock-face {
    width: min(100%, 300px);
  }

  .scene-art {
    min-height: 160px;
  }

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

  .event-pin {
    width: 72px;
    font-size: 0.7rem;
  }

  .practice-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .header-sticker {
    width: 48px;
  }
}

@media (min-width: 560px) and (max-width: 680px) {
  .clock-face {
    width: min(100%, 260px);
  }

  .scene-art {
    min-height: 140px;
  }

  .practice-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .anchor-panel .anchor-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .digital-time {
    font-size: 2.85rem;
  }

  .spoken-time {
    font-size: 1.45rem;
  }

  .challenge {
    font-size: 1.15rem;
  }

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

  .choice-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .anchor-list {
    grid-template-columns: 1fr;
  }
}
