:root {
  --page: #151714;
  --card: #1E201C;
  --border: #30332D;
  --tile: #272A25;
  --verse: #2D2B22;
  --quote: #1E2E34;
  --image: #263438;
  --bars: #3A4540;
  --text: #ECE8DF;
  --muted: #A7ABA0;
  --input-border: #454A41;
  --accent: #8FB8CE;
  --radius: 24px;
  --gap: 20px;
  --tabbar: 84px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); color-scheme: dark; }
body {
  background: var(--page);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
.serif { font-family: "Fraunces", Georgia, serif; font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout: desktop ---------- */
.app { height: 100vh; display: flex; flex-direction: column; padding: 24px 32px 32px; gap: var(--gap); overflow: hidden; }
.top { display: flex; justify-content: space-between; align-items: center; flex: none; min-height: 64px; }
.top h1 { font-size: 36px; line-height: 1.1; }
.top-controls { display: flex; align-items: center; gap: 20px; }

.cols { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.col { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.col > .card { flex: 1 1 0; min-height: 0; }
.verse { flex-grow: 1.5 !important; }
.memories { flex-grow: 1.1 !important; }
.calendar { flex-grow: 1.7 !important; }
.reminders { flex-grow: 1.2 !important; }
.strava { flex-grow: 1 !important; }
/* Sleep card is short on purpose: scroll inside it to reach the Apple Watch tiles. */
.card.health { flex: 0 0 400px !important; overflow-y: auto; }
.reminders .plain-list { flex: 1; min-height: 0; overflow-y: auto; }
.health > *, .plain-list > li { flex-shrink: 0; } /* keep natural size so the card scrolls instead of squashing */
.health, .reminders .plain-list { scrollbar-width: thin; scrollbar-color: var(--input-border) transparent; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.card.verse { background: var(--verse); }
.card.quote { background: var(--quote); }

.label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.label svg { width: 18px; height: 18px; flex: none; stroke: var(--accent); }
.label.sub { margin-top: 8px; }

blockquote { overflow-wrap: break-word; }
.verse blockquote { font-size: 30px; line-height: 1.3; }
.verse-ref { color: var(--accent); font-weight: 600; }
.quote blockquote { font-size: 26px; line-height: 1.3; }
.verse .row { margin-top: auto; }

.row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  min-height: 44px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--input-border); font-weight: 500;
}
.btn:hover { border-color: var(--accent); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #151714; }
.btn-accent:hover { filter: brightness(1.08); }

.plain-list { display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.plain-list li { background: var(--tile); border-radius: 14px; padding: 12px 14px; overflow-wrap: anywhere; }

/* Calendar */
.ev { display: flex; gap: 14px; align-items: baseline; }
.ev-time { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }

/* Reminders */
.rem { padding: 0 !important; }
.rem label { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 14px; cursor: pointer; }
.rem input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.rem input:checked + span { text-decoration: line-through; color: var(--muted); }

/* Health */
.big { font-size: 48px; line-height: 1.1; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; margin: 4px 0 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar { width: 100%; background: var(--bars); border-radius: 8px; }
.bar.last { background: var(--accent); }
.bar-day { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--tile); border-radius: 16px; padding: 14px; min-width: 0; }
.tile-label { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tile-value { font-size: 30px; line-height: 1.2; margin-top: 4px; }
.tile-value small { font-size: 14px; color: var(--muted); font-family: "Inter", sans-serif; }

/* Strava */
.strava-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.strava-name { font-weight: 600; margin: 4px 0; overflow-wrap: anywhere; }
.strava .big { font-size: 34px; margin-top: 4px; }

/* Claude */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px; cursor: pointer; text-align: left;
  background: var(--tile); border: 1px solid var(--border);
}
.chip:hover { border-color: var(--accent); }
.ask { display: flex; gap: 10px; margin-top: auto; }
.ask input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: transparent; border: 1px solid var(--input-border);
}
.ask input::placeholder { color: var(--muted); }

/* Memories */
.memory-img {
  flex: 1; min-height: 0; border-radius: 16px; background: var(--image);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.memory-img { overflow: hidden; }
.memory-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory-img svg { width: 48px; height: 48px; stroke: var(--muted); }

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--input-border); border-radius: 999px; padding: 3px; }
.lang-switch button {
  min-width: 52px; min-height: 44px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-weight: 600;
}
.lang-switch button[aria-checked="true"] { background: var(--accent); color: #151714; }

.tabbar { display: none; }

/* Icons */
[data-icon] svg { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Tablet / small desktop: two columns, page scrolls ---------- */
@media (max-width: 1399px) and (min-width: 701px) {
  .app { height: auto; min-height: 100vh; overflow: visible; }
  .cols { grid-template-columns: repeat(2, 1fr); }
  .card { min-height: 220px; }
  .card.health { flex: none !important; overflow: visible; }
  .reminders .plain-list { overflow: visible; }
}

/* ---------- Phone: one column, tab bar ---------- */
@media (max-width: 700px) {
  :root { --radius: 20px; }
  .app { height: 100dvh; padding: 0; gap: 0; }
  .top {
    padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
    align-items: flex-start; gap: 12px;
  }
  .top h1 { font-size: 28px; }
  .top-controls { gap: 8px; }

  .cols {
    display: flex; flex-direction: column; gap: 14px;
    overflow-y: auto; padding: 4px 16px calc(var(--tabbar) + 16px);
    -webkit-overflow-scrolling: touch;
  }
  .col { display: contents; }
  .card.health { flex: none !important; overflow: visible; }
  .reminders .plain-list { overflow: visible; }
  .col > .card { flex: none; order: var(--m-order, 0); display: none; padding: 20px; }
  body[data-screen="home"] .card[data-screen="home"],
  body[data-screen="health"] .card[data-screen="health"],
  body[data-screen="more"] .card[data-screen="more"] { display: flex; }

  .verse blockquote { font-size: 24px; }
  .quote blockquote { font-size: 22px; }
  .big { font-size: 40px; }
  .memory-img { flex: none; aspect-ratio: 4 / 3; }
  .tile-value { font-size: 26px; }
  .strava-grid { grid-template-columns: 1fr; }

  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom);
    background: var(--card); border-top: 1px solid var(--border);
  }
  .tabbar button {
    background: transparent; border: 0; cursor: pointer; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500;
  }
  .tabbar svg { width: 24px; height: 24px; stroke: currentColor; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
}
