/* J Dashboard — monochromatic black + gold
   Background #0E0E0E · Cards #1A1A1A · Wells #242424
   Text #F5F1E6 · Muted #8A8578 · Gold #D4AF37 / pressed #B8962E
*/

:root {
  --black: #0E0E0E;
  --card: #1A1A1A;
  --well: #242424;
  --gold: #D4AF37;
  --gold-deep: #B8962E;
  --gold-soft: #C4A032;
  --text: #F5F1E6;
  --muted: #8A8578;

  --pine: var(--black);
  --pine-soft: #161616;
  --bone: var(--black);
  --ivory: var(--card);
  --parchment: var(--well);
  --clay: var(--gold);
  --clay-deep: var(--gold-deep);
  --clay-soft: rgba(212, 175, 55, 0.22);
  --brass: var(--gold);
  --brass-soft: var(--gold-soft);
  --sage: var(--gold);
  --sage-soft: var(--gold-soft);
  --ink: var(--text);
  --ink-soft: var(--muted);
  --ink-faint: var(--muted);
  --on-pine: var(--text);
  --on-clay: var(--black);
  --line: rgba(212, 175, 55, 0.16);
  --line-strong: rgba(212, 175, 55, 0.28);
  --hairline: rgba(212, 175, 55, 0.22);

  --bg: var(--black);
  --bg-elevated: var(--card);
  --bg-sunken: var(--well);
  --bg-inverse: var(--black);

  --shadow-sm:
    0 1px 2px rgba(0, 0, 0, 0.45),
    0 8px 20px rgba(0, 0, 0, 0.28);
  --shadow-md:
    0 4px 12px rgba(0, 0, 0, 0.5),
    0 16px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg:
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 24px 48px rgba(0, 0, 0, 0.4);
  --shadow-sheet:
    0 -8px 32px rgba(0, 0, 0, 0.6);

  --serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;

  --display: 2rem;
  --title: 1.5rem;
  --title-sm: 1.25rem;
  --body: 1rem;
  --body-sm: 0.875rem;
  --caption: 0.75rem;
  --label: 0.6875rem;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --tabbar-h: 56px;
  --header-h: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap: 44px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--black);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color-scheme: dark;
  accent-color: var(--gold);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

img, svg { display: block; max-width: 100%; }

::placeholder { color: var(--muted); opacity: 1; }

a { color: var(--gold); }

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  opacity: 0.03;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

#app {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(900px 360px at 50% -40px, rgba(212, 175, 55, 0.06), transparent 70%),
    var(--bg);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  color: var(--ink);
}

/* ---------- Masthead (under status bar) ---------- */

.masthead {
  background:
    radial-gradient(700px 240px at 85% -30%, rgba(212, 175, 55, 0.08), transparent 65%),
    var(--black);
  color: var(--text);
  padding: calc(var(--safe-top) + 12px) 20px 14px;
  position: relative;
  border-bottom: 1px solid var(--hairline);
}

.masthead.compact {
  padding: calc(var(--safe-top) + 10px) 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(var(--safe-top) + var(--header-h));
}

.sticky-chrome {
  position: sticky;
  top: 0;
  z-index: 20;
}

.sticky-chrome .seg {
  margin-top: 0;
  padding: 10px 16px 8px;
  background: var(--bg);
}

.wordmark {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.wordmark-j {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  font-weight: 400;
  color: var(--on-pine);
}

.wordmark-j span {
  color: var(--clay);
}

.icon-btn {
  appearance: none;
  border: 0;
  background: rgba(212, 175, 55, 0.08);
  color: var(--on-pine);
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:active { background: rgba(212, 175, 55, 0.16); }

.icon-btn.ink {
  background: transparent;
  color: var(--ink);
}

.icon-btn.ink:active { background: var(--parchment); }

.kicker {
  font-size: var(--label);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
}

.greet-line {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--muted);
  margin: 0;
  line-height: 1.15;
}

.greet-name {
  font-family: var(--serif);
  font-size: var(--display);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 2px 0 0;
  color: var(--on-pine);
}

.masthead-actions {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  right: 14px;
}

.masthead.compact .title {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.masthead.compact .icon-btn.back {
  background: rgba(212, 175, 55, 0.08);
}

.header-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* ---------- Page body ---------- */

.page {
  padding: 0 16px 8px;
}

.page.lift {
  margin-top: 0;
  position: relative;
  z-index: 1;
  padding: 8px 14px 8px;
}

.page.lift .card {
  padding: 12px 14px 11px;
  margin-bottom: 8px;
  border-radius: 16px;
}

.page.lift .card-kicker { margin-bottom: 3px; }
.page.lift .card-title { font-size: 1.4rem; }
.page.lift .card-title.sm { font-size: 1.22rem; }
.page.lift .card-sub { margin-top: 2px; }
.page.lift .card-peek { margin-top: 6px; }
.page.lift .card-peek li { padding: 3px 0; }
.page.lift .card-foot { margin-top: 6px; }
.page.lift .meters { margin-top: 8px; gap: 10px; }

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.home-grid .card { margin-bottom: 0; min-width: 0; }

.agenda-card {
  cursor: default;
}

.page.lift .agenda-card {
  padding: 12px 14px 12px;
}

.agenda-items {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.agenda-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.agenda-item:first-child {
  border-top: 0;
  padding-top: 4px;
}

.agenda-item .check {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 6px;
}

.agenda-item-body {
  flex: 1;
  min-width: 0;
}

.agenda-item-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: var(--ink);
}

.agenda-item-text.done {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: rgba(138, 133, 120, 0.7);
}

.agenda-when {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
}

.agenda-updated,
.agenda-empty {
  margin: 10px 0 0;
  color: var(--ink-faint);
  font-size: var(--caption);
}

.agenda-empty {
  font-size: var(--body-sm);
  margin-top: 8px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--hairline);
  width: 100%;
  text-align: left;
  appearance: none;
  display: block;
  color: inherit;
  margin: 0 0 12px;
  position: relative;
}

button.card { cursor: pointer; }
button.card:active { transform: translateY(1px); box-shadow: none; }

.card-kicker {
  font-size: var(--label);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-kicker .chev { margin-left: auto; color: var(--gold); }

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

.card-title {
  font-family: var(--serif);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
  font-weight: 400;
}

.card-title.sm { font-size: 1.35rem; }

.card-sub {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: var(--body-sm);
}

.card-peek {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.card-peek li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: var(--body-sm);
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

.card-peek li:first-child { border-top: 0; padding-top: 2px; }

.peek-mark {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--brass-soft);
  border-radius: 4px;
  flex-shrink: 0;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  color: var(--ink-faint);
  font-size: var(--caption);
}

.card-foot .chev { color: var(--brass); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clay-deep);
  background: rgba(212, 175, 55, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
}

.badge.sage {
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
}

.badge.muted {
  color: var(--ink-soft);
  background: var(--parchment);
}

/* Nutrition mini meters */

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

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--caption);
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.meter-label strong {
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.track {
  height: 6px;
  background: var(--parchment);
  border-radius: 999px;
  overflow: hidden;
}

.track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep) 0%, var(--gold) 100%);
  width: 0%;
}

.track.sage > span {
  background: linear-gradient(90deg, var(--sage) 0%, var(--sage-soft) 100%);
}

.track.brass > span {
  background: linear-gradient(90deg, var(--brass) 0%, var(--brass-soft) 100%);
}

/* Sleep quality dots */

.quality {
  display: flex;
  gap: 6px;
  align-items: center;
}

.quality i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--parchment);
  display: block;
}

.quality i.on { background: var(--brass); }

.quality-picker {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.quality-picker button {
  flex: 1;
  height: 48px;
  border: 1px solid var(--line-strong);
  background: var(--ivory);
  border-radius: 12px;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.quality-picker button.on {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--black) 88%, transparent);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-top: 1px solid var(--hairline);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  flex: 1;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 0;
}

.tab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.on {
  color: var(--clay-deep);
}

.tab.on svg { stroke-width: 1.9; }

/* ---------- Lists & rows ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 2px 10px;
}

.section-head h2 {
  font-family: var(--serif);
  font-size: var(--title);
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 0;
}

.section-head .meta {
  color: var(--ink-faint);
  font-size: var(--caption);
}

.row, .list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: var(--ivory);
  padding: 14px 14px;
  min-height: var(--tap);
  color: inherit;
}

.list-card {
  background: var(--ivory);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--hairline);
  overflow: hidden;
  margin-bottom: 12px;
}

.list-card .row + .row,
.list-card .item-row + .item-row {
  border-top: 1px solid var(--line);
}

.row-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--parchment);
  color: var(--pine);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.row-icon svg { width: 18px; height: 18px; }

.row-body { flex: 1; min-width: 0; }

.row-title {
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  margin: 2px 0 0;
  font-size: var(--caption);
  color: var(--ink-faint);
}

.row-count {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--pine);
  letter-spacing: -0.02em;
}

.chev {
  color: var(--ink-faint);
  flex-shrink: 0;
}

/* Checklist items */

.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 4px 10px;
  min-height: 52px;
  background: var(--ivory);
  width: 100%;
}

.check {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1.5px solid var(--brass-soft);
  background: transparent;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: transparent;
}

.check:active { transform: scale(0.94); }

.check.on {
  background: var(--clay);
  border-color: var(--clay);
  color: var(--on-clay);
}

.item-text {
  flex: 1;
  text-align: left;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 0;
  min-height: var(--tap);
  font-size: 1rem;
  color: var(--ink);
}

.item-text.done {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: rgba(138, 133, 120, 0.7);
}

.qty {
  font-size: var(--caption);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-width: 2.2em;
  text-align: right;
}

.ghost-btn, .text-btn, .btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--clay-deep);
  font-weight: 600;
  font-size: var(--body-sm);
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
}

.text-btn.danger, .btn.danger { color: var(--muted); }

.btn {
  padding: 0 18px;
  min-height: var(--tap);
  border-radius: 14px;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #DCC056 0%, var(--gold) 55%, var(--gold-soft) 100%);
  color: var(--black);
  box-shadow: 0 1px 0 rgba(245, 241, 230, 0.22) inset, 0 6px 18px rgba(212, 175, 55, 0.18);
}
.btn:active {
  background: var(--gold-deep);
  color: var(--black);
  transform: translateY(1px);
  box-shadow: none;
}

.btn.block { display: block; width: 100%; text-align: center; }

.btn.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--hairline);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  border: 1px solid var(--line-strong);
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: var(--body-sm);
  box-shadow: none;
}

/* Add bar */

.add-bar {
  display: flex;
  gap: 8px;
  margin: 14px 0 8px;
  align-items: center;
}

.add-bar input, .field input, .field select, .field textarea, .input {
  flex: 1;
  min-height: var(--tap);
  border: 1px solid var(--line-strong);
  background: var(--ivory);
  border-radius: 14px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
  color: var(--ink);
  box-shadow: none;
  color: var(--text);
}

.add-bar input:focus, .field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.22);
}

.add-bar .btn { flex-shrink: 0; min-width: 72px; }

.field { margin: 0 0 14px; }

.field label {
  display: block;
  font-size: var(--label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 6px;
}

.field textarea { min-height: 88px; resize: vertical; }

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

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

.hint {
  font-size: var(--caption);
  color: var(--ink-faint);
  margin: 6px 0 0;
}

.banner {
  background: rgba(212, 175, 55, 0.1);
  color: var(--ink-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: var(--body-sm);
  margin: 0 0 14px;
  border: 1px solid var(--hairline);
}

.banner strong { color: var(--ink); font-weight: 600; }

/* Segmented control */

.seg {
  display: flex;
  background: var(--parchment);
  border-radius: 12px;
  padding: 3px;
  margin: 14px 16px 0;
}

.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  min-height: 40px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: var(--body-sm);
}

.seg button.on {
  background: var(--ivory);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Workout history */

.workout-card {
  background: var(--ivory);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--hairline);
  padding: 16px;
  margin-bottom: 12px;
  width: 100%;
  text-align: left;
  appearance: none;
  color: inherit;
}

.workout-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.workout-card h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 400;
}

.workout-card time {
  font-size: var(--caption);
  color: var(--ink-faint);
}

.ex-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--body-sm);
  padding: 5px 0;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

.ex-line:first-of-type { border-top: 0; }

.ex-line .meta { font-variant-numeric: tabular-nums; color: var(--ink-faint); }

/* Exercise editor rows */

.ex-edit {
  background: var(--bg-sunken);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
}

.ex-edit .name { margin-bottom: 8px; }

.ex-edit .nums {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}

.ex-edit .nums input { min-height: 40px; padding: 8px; border-radius: 10px; text-align: center; }

.ex-edit .nums .lab {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
  margin-bottom: 2px;
}

.icon-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Split editor */

.split-list { overflow: hidden; }

.split-day {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  min-height: 56px;
}

.split-day:first-child { border-top: 0; }

.split-day.is-today { background: rgba(212, 175, 55, 0.08); }

.split-dow {
  width: 3.2rem;
  font-size: var(--label);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.split-day.is-today .split-dow { color: var(--clay-deep); }

.split-day input {
  flex: 1;
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--serif);
  font-size: 1.1rem;
}

.split-day input:focus {
  background: var(--ivory);
  border-color: var(--brass);
  outline: none;
}

/* Sleep chart */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding: 8px 4px 0;
  margin: 8px 0 4px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.chart-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: 70%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--brass-soft), var(--brass));
  border-radius: 6px 6px 3px 3px;
  min-height: 4px;
}

.chart-bar.empty {
  background: var(--parchment);
  height: 8px !important;
}

.chart-bar.tonight {
  background: linear-gradient(180deg, #E0C04A, var(--gold-deep));
}

.chart-lab {
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.chart-val {
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* Empty states */

.empty {
  text-align: center;
  padding: 36px 20px 24px;
  color: var(--ink-soft);
}

.empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  stroke: var(--brass);
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}

.empty h3 {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-weight: 400;
  margin: 0 0 6px;
}

.empty p { margin: 0 0 16px; font-size: var(--body-sm); }

/* Nutrition totals */

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.total-tile {
  background: var(--ivory);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--hairline);
}

.total-tile .lab {
  font-size: var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 4px;
}

.total-tile .num {
  font-family: var(--serif);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.total-tile .goal {
  font-size: var(--caption);
  color: var(--ink-faint);
  margin-top: 4px;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 14px;
}

.date-nav h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 400;
  text-align: center;
  flex: 1;
}

/* Sheets / modal */

#sheet-root:empty { display: none; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  background: var(--bone);
  width: 100%;
  max-height: min(92vh, 100%);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 10px 18px calc(18px + var(--safe-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  animation: rise 0.28s ease;
  position: relative;
}

@keyframes rise {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--brass-soft);
  opacity: 0.6;
  margin: 4px auto 12px;
}

.sheet h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 0 0 16px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.sheet-actions .btn { flex: 1; }

.confirm-box {
  background: var(--bone);
  width: calc(100% - 32px);
  max-width: 340px;
  margin: auto;
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.22s ease;
}

.confirm-box h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 0 0 8px;
}

.confirm-box p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: var(--body-sm);
}

/* Toast */

#toast-root:empty { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--hairline);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: var(--body-sm);
  box-shadow: var(--shadow-md);
  z-index: 300;
  max-width: calc(100% - 32px);
  animation: rise 0.25s ease;
}

/* Settings */

.settings-block {
  background: var(--ivory);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--hairline);
  overflow: hidden;
  margin-bottom: 16px;
}

.settings-block h3 {
  font-size: var(--label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0;
  padding: 14px 16px 6px;
}

.settings-block p {
  margin: 0;
  padding: 0 16px 12px;
  font-size: var(--body-sm);
  color: var(--ink-soft);
}

.settings-block .row { background: transparent; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.footnote {
  text-align: center;
  color: var(--ink-faint);
  font-size: var(--caption);
  padding: 8px 16px 24px;
}

/* Utility */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden { display: none !important; }

.stack { display: flex; flex-direction: column; gap: 12px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--ivory);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: var(--body-sm);
  font-weight: 600;
}

.chip.on {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
