/* Dark by default — this thing lives on a phone at 6am and at 11pm. */
:root {
  --bg: #0a0b10;
  --bg-soft: #12141c;
  --card: #161925;
  --card-hi: #1d2130;
  --line: #262b3b;
  --text: #eef1f8;
  --muted: #8b93a7;
  --accent: #ff7a4d;
  --good: #4ade80;
  --warn: #fbbf24;
  --r: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; }

/* ---------------------------------------------------------------- ambient */

.ambient { background: var(--bg); overflow: hidden; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.ambient-body {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 28px) 26px calc(var(--safe-b) + 34px);
}

.ambient-top { display: flex; justify-content: space-between; align-items: baseline; }
.streak { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.streak .off { color: var(--muted); font-weight: 400; }
.weekcount { font-size: 13px; color: var(--muted); }

.ambient-mid { margin-top: auto; margin-bottom: auto; }
.clock {
  white-space: nowrap;
  font-size: clamp(64px, 22vw, 108px);
  font-weight: 200;
  letter-spacing: -.04em;
  line-height: .95;
  margin: 0 0 6px -4px;
}
.meridiem {
  font-size: .26em;
  font-weight: 500;
  letter-spacing: .04em;
  margin-left: .12em;
  vertical-align: .9em;
  color: var(--muted);
}

.today { font-size: 16px; color: var(--muted); letter-spacing: .01em; }

.ambient-bottom { display: flex; flex-direction: column; gap: 4px; }
.badge {
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 650;
  letter-spacing: -.025em;
  color: var(--accent);
  line-height: 1.1;
}
.badge-sub { font-size: 15px; color: var(--muted); margin-bottom: 18px; }

.hint {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 6px 0;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  .hint { animation: none; opacity: .7; }
}

/* -------------------------------------------------------------------- app */

.app { display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.icon-btn {
  width: 34px; height: 34px;
  flex: none;
  border: 0; border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.icon-btn:active { background: var(--card-hi); }

.tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 3px; border-radius: 12px; flex: 1; }
.tab {
  flex: 1;
  border: 0; border-radius: 9px;
  padding: 8px 4px;
  background: none;
  color: var(--muted);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--card-hi); color: var(--text); }

.view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px calc(var(--safe-b) + 90px);
}

/* ------------------------------------------------------------- components */

.head { margin: 2px 0 18px; }
.head h1 { font-size: 30px; font-weight: 680; letter-spacing: -.03em; margin: 0 0 4px; }
.head p { margin: 0; color: var(--muted); font-size: 15px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 10px;
}
.card.done { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 17px; font-weight: 640; letter-spacing: -.01em; }
.card-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tag {
  flex: none;
  font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 4px 8px; border-radius: 7px;
}

.note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 9px;
}

/* set checkboxes */
.sets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.set {
  width: 46px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 14px; font-weight: 640;
  cursor: pointer;
  transition: transform .1s ease, background .12s ease;
}
.set:active { transform: scale(.93); }
.set.on { background: var(--accent); border-color: var(--accent); color: #0a0b10; }

.weight { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.weight input {
  width: 92px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 15px;
}
.weight input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -1px; }
.weight .suggest { font-size: 13px; color: var(--muted); }
.weight .suggest.up { color: var(--good); }

/* macro ring + bars */
.macros { display: flex; gap: 12px; align-items: center; }
.ring { flex: none; }
.macro-list { flex: 1; display: grid; gap: 8px; }
.macro { display: grid; grid-template-columns: 22px 1fr auto; gap: 9px; align-items: center; font-size: 13px; }
.macro .bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.macro .bar i { display: block; height: 100%; border-radius: 3px; }
.macro .k { color: var(--muted); }
.macro .v { color: var(--muted); font-size: 12px; }

.items { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.items li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.items .portion { color: var(--muted); flex: none; }

.row-check {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.box {
  width: 24px; height: 24px; flex: none;
  border: 1.5px solid var(--line); border-radius: 8px;
  display: grid; place-items: center;
  color: transparent; font-size: 14px; font-weight: 800;
}
.box.on { background: var(--good); border-color: var(--good); color: #08130c; }

.list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: grid; gap: 5px; }

.banner {
  background: color-mix(in srgb, var(--warn) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  color: #f5e6c8;
  margin-bottom: 12px;
}

.section-label {
  font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 9px;
}

/* forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  width: 100%;
  border: 0; border-radius: 13px;
  padding: 14px;
  background: var(--accent);
  color: #0a0b10;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: #f87171; border: 1px solid color-mix(in srgb, #f87171 35%, var(--line)); }
.btn:active { filter: brightness(.92); }

.days { display: flex; gap: 6px; }
.day-btn {
  flex: 1;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); color: var(--muted);
  padding: 10px 0; font-size: 13px; font-weight: 640;
  cursor: pointer;
}
.day-btn.on { background: var(--accent); border-color: var(--accent); color: #0a0b10; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 660; letter-spacing: -.02em; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

.fine { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 16px; }

/* ------------------------------------------------------------ rest timer */

.rest {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-b) + 12px);
  z-index: 20;
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(110%); } to { transform: none; } }

.rest-inner {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 13px 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
.rest-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rest-time { font-size: 26px; font-weight: 640; letter-spacing: -.02em; margin-left: auto; }
.rest-skip {
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); padding: 7px 13px;
  font-size: 13px; font-weight: 640; cursor: pointer;
}
