/* Efficiency Made Easy palette: brown & cream, matched from the booklet (swap for exact brand codes). */
:root {
  /* Efficiency Made Easy brand colours */
  --brand: #493423;        /* primary brown */
  --cream: #FFF4E2;        /* primary cream */
  --gold: #C1A37F;         /* primary gold */
  --green: #46890C;        /* primary green */
  --orange: #D26B15;       /* primary orange */
  --mint: #D8F4C0;         /* secondary */
  --rust: #922B09;         /* secondary */
  --peach: #EDCEAC;        /* secondary */

  --brand-ink: var(--cream);
  --bg: var(--cream);
  --card: #FFFFFF;
  --text: #2b1f15;
  --muted: #7a6552;
  --line: #eadbc6;
  --soft: #fbecd6;
  --good: var(--green);
  --bad: var(--rust);
  --bleed: #f1c7b8;
  --ovu: var(--mint);
  --radius: 16px;
  --head-font: "Sora", "Poppins", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b140e;
    --card: #261c14;
    --text: #FFF4E2;
    --muted: #c3ab90;
    --line: #3d2e21;
    --soft: #33261a;
    --good: #7fbf45;
    --bad: #e0764f;
    --bleed: #6b2a14;
    --ovu: #2f4a1b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Poppins", system-ui, -apple-system, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { font-family: var(--head-font); margin: 0 0 6px; letter-spacing: -.01em; }
h4 { font-family: "Poppins", sans-serif; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; margin-top: 18px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: var(--brand-ink);
  padding: 10px 16px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand .mark { width: 54px; height: 54px; display: block; margin: -6px -4px; }
.brand b { font-family: var(--head-font); font-size: 18px; display: block; line-height: 1.1; }
.brand small { color: var(--gold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
#tabs { display: flex; gap: 2px; background: rgba(255,255,255,.08); border-radius: 999px; padding: 3px; }
#tabs button { border: 0; background: none; color: var(--brand-ink); padding: 6px 14px; border-radius: 999px; cursor: pointer; opacity: .8; }
#tabs button.active { background: var(--brand-ink); color: var(--brand); opacity: 1; font-weight: 700; }
body.in-setup #tabs { display: none; }

main { max-width: 820px; margin: 0 auto; padding: 16px; }

/* ---------- Generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 700; margin: 0 0 2px; }
.num { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700; margin-right: 4px; vertical-align: 2px; font-family: "Poppins", sans-serif; }

button, .btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 14px; cursor: pointer; display: inline-block;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--gold); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
button.danger { color: var(--bad); }
button.icon { padding: 6px 11px; }
button.small { padding: 4px 10px; font-size: 13px; }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; font-weight: 700; }
@media (prefers-color-scheme: dark) { button.link { color: var(--gold); } }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.field { display: block; margin-top: 14px; font-weight: 500; }
.field input, .field select { display: block; margin-top: 6px; max-width: 100%; }
.field .row input { margin-top: 0; }
.field small { font-weight: 400; }

/* ---------- Setup ---------- */
.setup { max-width: 620px; margin: 8px auto; }
.setup h2 { font-size: 28px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps span.on { background: var(--gold); }
.var-fixed { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--soft); border-radius: 12px; }
.var-fixed small { color: var(--muted); }
.picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pick { border-radius: 999px; }
.pick.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.options { display: grid; gap: 8px; margin-top: 8px; }
.options.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.option.on { border-color: var(--gold); background: var(--soft); }
.option input { margin-top: 4px; accent-color: var(--brand); }
.option small, .toggle-row small { display: block; color: var(--muted); font-size: 13px; }
.toggle-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; padding: 12px; background: var(--soft); border-radius: 12px; cursor: pointer; }
.toggle-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--brand); }

.key-editor { display: grid; gap: 6px; margin-top: 8px; }
.key-row { display: grid; grid-template-columns: 56px 52px 1fr 44px; gap: 8px; align-items: center; }
.key-row .rank { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.key-row .icon-in { text-align: center; font-size: 18px; padding: 6px 4px; }
.key-row input[type=color] { width: 44px; height: 38px; padding: 2px; }

/* ---------- Tonight ---------- */
.hero { background: linear-gradient(160deg, var(--soft), var(--card)); }
.hero h2 { font-size: 24px; }
.hero input[type=date] { padding: 6px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 13px; padding: 4px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.chip.strong { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.chip.moon { border-color: var(--gold); }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.level {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 4px; border-radius: 14px; border: 2px solid var(--line);
}
.level .ico { font-size: 26px; line-height: 1.1; color: var(--c); }
.level .lbl { font-size: 13px; font-weight: 500; text-align: center; }
.level.on { background: var(--c); border-color: var(--c); color: #fff; }
.level.on .ico { color: #fff; }
.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.tog { text-align: left; border-radius: 14px; border-width: 2px; }
.tog small { display: block; color: var(--muted); font-size: 12px; }
.tog.on.bleed { background: var(--bleed); border-color: var(--bad); }
.tog.on.ovu { background: var(--ovu); border-color: var(--good); }
.tog.on.start { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tog.on.start small { color: var(--brand-ink); opacity: .8; }
.status { text-align: center; color: var(--muted); margin: 6px 0 20px; }
.status.done { color: var(--good); font-weight: 700; }

/* ---------- Tracker grid ---------- */
.grid-wrap { overflow-x: auto; margin: 14px -4px 0; padding: 0 4px; }
.grid { border-collapse: collapse; width: 100%; min-width: 460px; font-size: 13px; }
.grid th, .grid td { border: 1px solid var(--line); text-align: center; padding: 0; height: 28px; min-width: 32px; }
.grid .rowhead { position: sticky; left: 0; background: var(--soft); font-weight: 700; width: 36px; z-index: 1; }
.grid .ghead { background: var(--brand); color: var(--brand-ink); padding: 6px 4px; font-weight: 400; border-color: var(--brand); }
.grid .ghead b { font-family: var(--head-font); font-size: 15px; display: block; }
.grid .ghead small { display: block; font-size: 11px; opacity: .85; }
.grid .ghead .season { color: var(--gold); opacity: 1; }
.grid .sub { background: var(--soft); font-size: 11px; font-weight: 700; padding: 3px 2px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .gstart { border-left: 2px solid var(--brand); }
.grid td[data-open] { cursor: pointer; }
.grid td[data-open]:hover { background: var(--soft); }
.grid td b { font-size: 16px; }
.grid .c-date { font-size: 11px; color: var(--muted); }
.grid .c-moon { font-size: 14px; }
.grid td.bleed { background: var(--bleed); color: var(--text); }
.grid td.ovu { background: var(--ovu); color: var(--text); }
.grid td.void { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--soft) 4px 5px); }
.grid td.future { opacity: .35; }
.grid td.today { box-shadow: inset 0 0 0 2px var(--gold); }

.legend { display: grid; gap: 6px; margin: 14px 0 6px; font-size: 13px; }
.legend > div { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.lg-title { font-weight: 700; margin-right: 4px; }
.lg b { margin-right: 4px; font-size: 15px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; }
.sw.bleed { background: var(--bleed); } .sw.ovu { background: var(--ovu); }
.empty-note { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: 12px; font-size: 14px; }

/* ---------- Patterns ---------- */
.prompts { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.prompts li { margin: 3px 0; }
.locked p { margin: 0 0 10px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--gold); }
.pattern { display: flex; gap: 12px; padding: 14px 0; }
.pattern + .pattern { border-top: 1px solid var(--line); }
.pattern .mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-weight: 700; }
.pattern.positive .mark { color: var(--good); }
.pattern.negative .mark { color: var(--bad); }
.pattern p { margin: 3px 0 8px; color: var(--muted); font-size: 14px; }
.pattern .action { color: var(--text); font-weight: 500; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 14px; }
.reflection { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.add-row { display: flex; gap: 6px; margin-top: 10px; }
.add-row input { flex: 1; }
.note { font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: var(--brand); color: var(--brand-ink); padding: 8px 16px; border-radius: 99px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .top { padding: 10px 12px; }
  #tabs { width: 100%; justify-content: space-between; }
  #tabs button { padding: 6px 10px; flex: 1; }
  .card { padding: 14px; }
  .level .ico { font-size: 22px; }
  .level .lbl { font-size: 12px; }
  .key-row { grid-template-columns: 44px 46px 1fr 40px; gap: 6px; }
}

/* ---------- Round 3 additions ---------- */
.setup-logo { display: block; text-align: center; margin: -4px 0 8px; }
.setup-logo img { width: 190px; height: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chip small { opacity: .7; }
.chip.gold { border-color: var(--gold); }
.chip.pred { border-style: dashed; border-color: var(--gold); color: var(--muted); }
.chip.marker { background: var(--soft); border-color: var(--gold); display: inline-flex; align-items: center; gap: 4px; }
.chip .x { border: 0; background: none; padding: 0 2px; font-size: 12px; color: var(--muted); }
.marker-card summary { list-style: none; cursor: pointer; }
.marker-card summary::-webkit-details-marker { display: none; }
.marker-card summary h3 { display: inline; }
.marker-card summary::after { content: '+'; float: right; font-size: 20px; line-height: 1; color: var(--muted); }
.marker-card[open] summary::after { content: '–'; }
.marker-card p { margin-top: 6px; }
.picks.small { margin-top: 10px; }
.picks.small .pick { font-size: 13px; padding: 4px 10px; }

.grid td.phased { box-shadow: inset 4px 0 0 var(--ph); }
.grid td.phased.est { box-shadow: inset 4px 0 0 color-mix(in srgb, var(--ph) 40%, transparent); }
.grid td.today.phased { box-shadow: inset 4px 0 0 var(--ph), inset 0 0 0 2px var(--gold); }
.grid td.pred-bleed { outline: 2px dashed var(--rust); outline-offset: -3px; opacity: .8; }
.grid td.pred-ovu { outline: 2px dashed var(--green); outline-offset: -3px; opacity: .8; }
.grid .ghead.upcoming { background: color-mix(in srgb, var(--brand) 75%, var(--bg)); }
.mk { font-style: normal; color: var(--orange); font-size: 12px; }
.sw.pred { background: none; outline: 2px dashed var(--gold); outline-offset: -2px; }

.switcher { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.switcher select { flex: 1; max-width: 420px; }
.tracker-list { margin-top: 8px; }
.tracker-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tracker-row small { display: block; color: var(--muted); font-size: 12px; }
.new-tracker { margin-top: 12px; padding: 14px; border: 1px dashed var(--gold); border-radius: 12px; }
.new-tracker h4 { margin-top: 0; }
.soon { font-family: "Poppins", sans-serif; font-size: 11px; font-weight: 600; background: var(--soft); color: var(--muted); padding: 2px 8px; border-radius: 99px; vertical-align: 2px; margin-left: 6px; }
.ok { color: var(--good); font-weight: 600; margin: 0; }

/* ---------- Sign-in & membership ---------- */
.gate { text-align: center; }
.gate .card { text-align: left; }
.gate .lead { max-width: 480px; margin-left: auto; margin-right: auto; }
button.google { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; font-weight: 600; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; border-radius: 12px; }
button.google:hover { border-color: var(--gold); }
.error { color: var(--bad); font-weight: 500; margin: 12px 0 0; }

/* ---------- Cycles of Success ---------- */
.phase-card { border-left: 5px solid var(--ph, var(--gold)); }
.phase-card h3 small { font-family: "Poppins", sans-serif; font-weight: 500; font-size: 13px; color: var(--muted); margin-left: 4px; }
.phase-card p { margin: 6px 0 0; }
.phase-card .tip { font-weight: 500; }
.conf { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-bottom: 3px; background: var(--soft); color: var(--muted); }
.conf.conf-pattern { background: var(--mint); color: #2c5208; }
.conf.conf-strong { background: var(--green); color: #fff; }
.pattern .conf + b { display: block; }
.note-line { color: var(--text) !important; font-style: italic; }
.reflect { color: var(--orange) !important; font-weight: 500; }
.progress-block { margin-top: 14px; }
.progress-block .progress { margin: 6px 0; }
.action-row small { display: block; margin-top: 2px; }
.action-row.helped span { color: var(--good); }
.action-row.not span { color: var(--muted); text-decoration: line-through; }
.cta { background: linear-gradient(160deg, var(--soft), var(--card)); }
a.btn { text-decoration: none; color: inherit; }
a.primary-link { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.note a, .card a { color: var(--brand); font-weight: 600; }
@media (prefers-color-scheme: dark) { .note a, .card a { color: var(--gold); } }

.load-more { width: 100%; margin: 4px 0 8px; font-weight: 600; }

/* ---------- Log my cycle ---------- */
.cycle-log summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cycle-log summary::-webkit-details-marker { display: none; }
.cycle-log summary h3 { margin: 0; }
.cycle-log summary::after { content: '+'; margin-left: auto; font-size: 20px; line-height: 1; color: var(--muted); }
.cycle-log[open] summary::after { content: '–'; }
.cycle-log p { margin: 8px 0 0; }

/* ---------- Red light filter ---------- */
.red-toggle { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); }
.red-toggle span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #e2554a; }
.red-toggle.on span { background: #e2554a; box-shadow: 0 0 8px #e2554a; }
html.rl-amber body::after, html.rl-red body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 9999; mix-blend-mode: multiply;
}
/* Warm amber: multiply by amber cuts most blue, and dims a little */
html.rl-amber body::after { background: #ffa04d; opacity: .7; }
html.rl-amber body { filter: brightness(.9); }
/* Deep red: a dark palette, then multiply by pure red so only red light is left */
html.rl-red body::after { background: #ff0000; }
html.rl-red {
  --bg: #000; --card: #0d0d0d; --text: #fff; --muted: #a8a8a8; --line: #2a2a2a; --soft: #161616;
  --brand: #1a1a1a; --brand-ink: #fff; --gold: #d0d0d0; --bleed: #3a3a3a; --ovu: #2a2a2a; --mint: #333;
}
html.rl-red img { filter: brightness(.7); }

/* ---------- Consent, footer, admin ---------- */
.consent-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 14px; cursor: pointer; text-align: left; }
.consent-row input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.footer { max-width: 820px; margin: 0 auto; padding: 4px 16px 28px; font-size: 12px; color: var(--muted); text-align: center; }
.footer p { margin: 6px 0; }
.footer a { color: inherit; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--head-font); font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; margin-top: 8px; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--gold); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; }

.demo-signin label { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.demo-signin input { width: 100%; }
.demo-signin small { display: block; margin-top: 6px; }

/* ---------- Streak ---------- */
.streak-chip { font-weight: 700; }
.streak-chip:not(.lit) { opacity: .75; }
.streak-chip.lit { border-color: var(--orange); color: var(--orange); }

/* ---------- Celebration ---------- */
.celebrate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(43, 31, 21, .25); animation: fadeIn .2s; }
.celebrate.out { opacity: 0; transition: opacity .3s; }
.celebrate canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.celebrate-card { position: relative; background: var(--card); border-radius: 20px; padding: 22px 30px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.2); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.celebrate-card .big { font-size: 44px; line-height: 1; }
.celebrate-card b { display: block; font-family: var(--head-font); font-size: 22px; margin-top: 6px; }
.celebrate-card small { color: var(--muted); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .celebrate, .celebrate-card { animation: none; } }

.google-slot { display: flex; justify-content: center; min-height: 44px; }

/* ---------- iPhone / Android home-screen app: keep clear of the notch, status bar and home bar ---------- */
.top {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (max-width: 560px) {
  .top { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
}
main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.footer { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
#toast { bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
.red-toggle { width: 40px; height: 40px; flex: none; } /* comfortable tap target */
@media (max-width: 560px) {
  #tabs { overflow-x: auto; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button { padding: 6px 8px; font-size: 14px; flex: 1 0 auto; }
}
