/* Drowsie member portal — v43 dark system (2026-07-23). Mobile-first. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --midnight: #120a24;
  --nebula: #060818;
  --cream: #F3EBE5;
  --dawn: #E8D5C8;
  --rose: #C4787A;
  --rose-deep: #A85F62;
  --gold: #D4A574;
  --lavender: #B8A0D0;
  --sage: #8FA89A;
  --card: rgba(46, 37, 57, 0.55);
  --line: rgba(184, 160, 208, 0.18);
}

/* No background-attachment:fixed — it breaks on iOS Safari and in long-page
   captures. Solid base colour + a viewport-height gradient overlay instead. */
html { -webkit-text-size-adjust: 100%; background: var(--nebula); }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  color: var(--dawn);
  background-color: var(--nebula);
  background-image: linear-gradient(180deg, var(--midnight) 0%, var(--nebula) 100vh);
  background-repeat: no-repeat;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- chrome ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.lockup { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.lockup img { width: 30px; height: 30px; }
.lockup span {
  font-family: 'Marcellus', serif;
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--cream);
  text-transform: lowercase;
}
.tabs { display: flex; gap: 4px; }
.tabs[hidden] { display: none; } /* display:flex would otherwise beat the hidden attribute */
.tab {
  background: none;
  border: none;
  color: rgba(232, 213, 200, 0.65);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: color .2s, background-color .2s;
}
.tab:hover { color: var(--cream); }
.tab.is-active { color: var(--cream); background: rgba(184, 160, 208, 0.14); }

main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 36px 20px 72px; }

.foot {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 22px 20px 34px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: rgba(232, 213, 200, 0.55);
}
.foot a { color: rgba(232, 213, 200, 0.55); text-decoration: none; }
.foot a:hover { color: var(--cream); }

/* ---------- type ---------- */
.eyebrow {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--lavender);
  margin-bottom: 10px;
}
h1 {
  font-family: 'Marcellus', serif;
  font-weight: 400;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.15;
  color: var(--cream);
  margin-bottom: 26px;
}
h2 {
  font-family: 'Marcellus', serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.25;
  color: var(--cream);
  margin-bottom: 10px;
}
.section-h { margin: 34px 0 14px; }
.lede { margin-bottom: 22px; }
.dim { color: rgba(232, 213, 200, 0.65); font-size: 14.5px; }
.small { font-size: 13px; }
.mono { color: var(--cream); letter-spacing: 0.02em; }
a { color: var(--rose); text-decoration: none; }
a:hover { color: var(--gold); }
strong { font-weight: 500; color: var(--cream); }

/* ---------- cards + fields ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 16px;
}
.card-kicker {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
  margin-bottom: 10px;
}
.empty-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 28px;
  text-align: center;
}
.empty-card p { max-width: 420px; margin: 0 auto 10px; }
.loading { color: rgba(232, 213, 200, 0.6); padding: 26px 0; }

input[type="email"], input[type="text"], input[type="tel"] {
  width: 100%;
  background: rgba(6, 8, 24, 0.6);
  border: 1px solid rgba(184, 160, 208, 0.3);
  border-radius: 14px;
  color: var(--cream);
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color .2s;
}
input:focus { border-color: var(--rose); }
input::placeholder { color: rgba(232, 213, 200, 0.35); }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--lavender);
  margin-bottom: 8px;
}

.btn {
  display: inline-block;
  background-color: var(--rose);
  color: var(--cream);
  border: none;
  border-radius: 100px;
  padding: 13px 30px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .2s;
}
.btn:hover { background-color: var(--rose-deep); color: var(--cream); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--ghost {
  background: none;
  border: 1px solid rgba(196, 120, 122, 0.5);
  color: var(--rose);
}
.btn--ghost:hover { background: rgba(196, 120, 122, 0.12); color: var(--rose); }
.btn-row { margin: 16px 0 14px; }
.linkish {
  background: none; border: none; cursor: pointer;
  color: var(--rose); font-family: 'Inter', sans-serif; font-size: 14px;
  margin-top: 14px; padding: 0;
}
.linkish:hover { color: var(--gold); }

/* ---------- auth ---------- */
.auth-card {
  max-width: 440px;
  margin: 6vh auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px 30px;
}
.auth-card h1 { font-size: 30px; margin-bottom: 14px; }
.auth-err {
  margin-top: 16px;
  background: rgba(200, 89, 91, 0.12);
  border: 1px solid rgba(200, 89, 91, 0.4);
  border-radius: 12px;
  padding: 12px 14px;
  color: #d98a8c;
  font-size: 14px;
}
.ok { color: var(--sage); }
.save-err { color: #d98a8c; }

/* ---------- overview ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 14px;
  text-align: center;
}
.stat-num {
  font-family: 'Marcellus', serif;
  font-size: 27px;
  color: var(--cream);
  line-height: 1.2;
}
.stat-label { font-size: 12px; color: rgba(232, 213, 200, 0.6); margin-top: 4px; }

.bar {
  height: 8px;
  background: rgba(6, 8, 24, 0.6);
  border-radius: 100px;
  overflow: hidden;
  margin: 12px 0;
}
.bar-fill {
  height: 100%;
  width: 0;
  background-color: var(--rose);
  border-radius: 100px;
  transition: width .6s ease;
}
.bar-fill--sage { background-color: var(--sage); }

.insight {
  display: flex;
  gap: 16px;
  align-items: baseline;
  background: var(--card);
  border: 1px solid rgba(212, 165, 116, 0.35);
  border-radius: 18px;
  padding: 18px 22px;
  margin-bottom: 12px;
}
.insight-metric {
  font-family: 'Marcellus', serif;
  font-size: 26px;
  color: var(--gold);
  flex: 0 0 auto;
}
.insight h3 { font-weight: 500; font-size: 15px; color: var(--cream); margin-bottom: 2px; }
.insight p { font-size: 13.5px; color: rgba(232, 213, 200, 0.7); }

.night {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.night:last-child { border-bottom: none; }
.night-date { color: var(--cream); }
.night-cell { text-align: right; color: rgba(232, 213, 200, 0.75); }
.night-cell b {
  font-weight: 500;
  color: var(--cream);
}
.night-score {
  font-family: 'Marcellus', serif;
  font-size: 19px;
  color: var(--gold);
  text-align: right;
  min-width: 34px;
}

/* ---------- membership ---------- */
.kv { margin: 14px 0; }
.kv div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.kv div:last-child { border-bottom: none; }
.kv dt { color: rgba(232, 213, 200, 0.65); }
.kv dd { color: var(--cream); text-align: right; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 100px;
  padding: 4px 12px;
  margin-left: 10px;
  vertical-align: middle;
}
.pill--active { background: rgba(143, 168, 154, 0.15); color: var(--sage); }
.pill--off { background: rgba(232, 213, 200, 0.1); color: rgba(232, 213, 200, 0.7); }

/* ---------- profile ---------- */
#form-name { display: flex; gap: 10px; flex-wrap: wrap; }
#form-name input { flex: 1 1 220px; margin-bottom: 0; }
#form-name .btn { flex: 0 0 auto; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 14px 16px; }
  .tabs { width: 100%; justify-content: space-between; order: 3; }
  .tab { flex: 1; text-align: center; padding: 8px 6px; }
  main { padding: 26px 16px 56px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-card { margin-top: 2vh; padding: 28px 22px; }
  .night { grid-template-columns: 1fr auto auto; }
  .night-cell--wakes { display: none; }
  .card { padding: 20px 18px; }
}

/* Delivery-address form (Profile tab). Inputs inherit the existing card input
   styling; these two rules cover the pieces that card didn't have before. */
#form-shipping input,
#form-shipping select { width: 100%; margin-bottom: 10px; }
#form-shipping .ship-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#form-shipping select {
  background: rgba(0,0,0,.35); color: #F3EBE5;
  border: 1px solid rgba(184,160,208,.22); border-radius: 12px;
  padding: 13px 14px; font-family: inherit; font-size: 15px; appearance: none;
}
#form-shipping select:focus { outline: none; border-color: #C4787A; }
#shipping-locked { margin-top: 12px; color: rgba(212,165,116,.85); }
/* 390px: two-up row would squeeze State/Postcode below usability */
@media (max-width: 420px) {
  #form-shipping .ship-row { grid-template-columns: 1fr; }
}
