/* SpinePop: Playful Pastel Bento. Mobile-first, iPhone safe areas respected. */

:root {
  --bg: #F8F7FA;
  --card: #FFFFFF;
  --lavender: #C4B5FD;
  --ink: #1E1B4B;
  --muted: #5B5878;
  --pink: #F7B2D9;
  --coral: #F8B4B4;
  --accent: #E85D88;
  --butter: #FCE786;
  --mint: #B7E4C7;
  --sky: #BFDBFE;
  --cta: #141414;
  --line: rgba(30, 27, 75, 0.1);

  --radius-card: 24px;
  --radius-pill: 999px;
  --shadow: 0 8px 24px rgba(30, 27, 75, 0.08);
  --shadow-lift: 0 14px 34px rgba(30, 27, 75, 0.14);
  --tabbar-height: 68px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

body.is-sheet-open {
  overflow: hidden;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 22px) calc(16px + var(--safe-right))
    calc(var(--tabbar-height) + var(--safe-bottom) + 48px) calc(16px + var(--safe-left));
}

.view {
  animation: fade-up 0.4s var(--ease-out) both;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.center {
  text-align: center;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

/* ---------- Typography ---------- */

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-title,
.page-title {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.hero-sub,
.page-sub {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
}

.big-number {
  margin: 8px 0 4px;
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.tile-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.tile-time {
  margin: 8px 0 4px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tile-note {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.notice {
  min-height: 1.2em;
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--accent);
}

.notice-title {
  margin: 0 0 4px;
  font-weight: 800;
}

.note-quote {
  margin: 12px 0 0;
  padding-left: 12px;
  border-left: 3px solid var(--pink);
  font-style: italic;
  color: var(--muted);
}

/* ---------- Hero and bento ---------- */

.hero {
  display: grid;
  grid-template-columns: 1fr 112px;
  align-items: center;
  gap: 8px;
}

.mascot {
  width: 112px;
  height: 112px;
  filter: drop-shadow(0 10px 18px rgba(30, 27, 75, 0.12));
  animation: float 5s ease-in-out infinite;
}

.bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.tile {
  min-width: 0;
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.tile:hover {
  box-shadow: var(--shadow-lift);
}

.tile--wide {
  grid-column: 1 / -1;
}

.tile-lavender { background: var(--lavender); }
.tile-butter { background: var(--butter); }
.tile-pink { background: var(--pink); }
.tile-mint { background: var(--mint); }
.tile-sky { background: var(--sky); }

.break-cta {
  margin-top: 18px;
}

/* ---------- Buttons ---------- */

.btn-primary,
.btn-pill {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-pill);
  transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  min-height: 56px;
  padding: 14px 24px;
  background: var(--cta);
  color: #FFFFFF;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(20, 20, 20, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 10px 22px rgba(20, 20, 20, 0.28);
}

.btn-pill {
  min-height: 44px;
  padding: 10px 18px;
  background: #FFFFFF;
  color: var(--ink);
  font-size: 14px;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-pill:hover {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.btn-primary:active,
.btn-pill:active {
  transform: scale(0.97);
}

.btn-primary:disabled,
.btn-pill:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn-wide {
  width: 100%;
  margin-top: 14px;
}

.btn-ghost {
  min-height: 44px;
  padding: 8px 4px;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.select,
.textarea {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #FFFFFF;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
}

.window-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.window-controls label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
}

.window-controls span {
  color: var(--muted);
}

.notice-card {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--butter);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* ---------- Routine ---------- */

.exercise-card {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 14px;
  align-items: center;
}

.exercise-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: var(--bg);
  border-radius: 18px;
  overflow: hidden;
}

.exercise-thumb svg {
  width: 100%;
  height: auto;
}

.exercise-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.exercise-info .btn-primary {
  margin-top: 12px;
  min-height: 48px;
  padding: 10px 20px;
}

/* ---------- Check-in ---------- */

.mood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.mood-chip {
  min-height: 60px;
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mood-chip:hover {
  transform: translateY(-1px);
}

.mood-chip[aria-pressed='true'] {
  box-shadow: inset 0 0 0 3px var(--ink);
}

.textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
}

.history {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.mood-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
}

/* ---------- Calendar ---------- */

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.month-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.weekday-row,
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekday-row {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}

.day-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 14px;
  background: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.day-cell.is-active { background: var(--mint); }
.day-cell.is-heavy { background: #8ED1A6; }
.day-cell.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.day-cell.is-selected { outline: 3px solid var(--pink); outline-offset: 1px; }

.day-blank {
  display: block;
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 5px;
}

.swatch.is-active { background: var(--mint); }
.swatch.is-heavy { background: #8ED1A6; }

/* ---------- Tab bar (floating pill) ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 488px);
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: var(--radius-pill);
  box-shadow: 0 12px 32px rgba(30, 27, 75, 0.16);
  z-index: 10;
}

.tab {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

.tab svg {
  width: 22px;
  height: 22px;
}

.tab:active {
  transform: scale(0.96);
}

.tab[aria-current='page'] {
  background: var(--lavender);
  color: var(--ink);
  font-weight: 800;
}

/* ---------- Workout sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  padding: calc(var(--safe-top) + 16px) calc(16px + var(--safe-right))
    calc(var(--safe-bottom) + 28px) calc(16px + var(--safe-left));
}

.sheet-body {
  max-width: 520px;
  margin: 0 auto;
}

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

.workout-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.workout-meta {
  margin: 6px 0 0;
  font-weight: 600;
  color: var(--muted);
}

.diagram-wrap {
  margin-top: 14px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.diagram {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
}

.timer-card {
  margin-top: 14px;
  padding: 22px 18px 18px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
}

.ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(30, 27, 75, 0.08);
  stroke-width: 10;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}

.ring-readout {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-seconds {
  margin: 0;
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.phase {
  margin: 14px 0 0;
  font-size: 20px;
  font-weight: 800;
}

.phase-sub {
  margin: 4px 0 0;
  font-weight: 600;
  color: var(--muted);
}

.timer-card .row {
  justify-content: center;
}

.done-card {
  margin-top: 14px;
  padding: 24px 18px;
  text-align: center;
  background: var(--mint);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.done-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.how {
  margin-top: 12px;
  padding: 14px 18px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.how summary {
  font-weight: 800;
  cursor: pointer;
}

.how ol,
.how ul {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.55;
}

.how li + li {
  margin-top: 6px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 14px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  background: var(--ink);
  color: #FFFFFF;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lift);
  z-index: 30;
  animation: fade-up 0.25s var(--ease-out) both;
}

/* ---------- Motion ---------- */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
