/* Themes: dark (default), light, vintage, gay. Picked with the switch at the top. */
:root, [data-theme="dark"] {
  --bg: #0f0f10; --fg: #ececec; --card: #18181b; --muted: #2a2a2e; --muted-fg: #9a9aa2;
  --btn: #232327; --border: #2c2c31; --progress: #facc15; --done: #4ade80; --time: #60a5fa; --radius: 10px;
  --switch-bg: #1f1f23; --switch-on: #3a3a40; --danger-bg: #3a1517; --danger-border: #7f1d1d; --danger-fg: #fecaca;
  --offline: #f87171;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f6f7; --fg: #18181b; --card: #ffffff; --muted: #e6e6ea; --muted-fg: #6b6b75;
  --btn: #f4f4f5; --border: #e4e4e7; --progress: #eab308; --done: #16a34a; --time: #3b82f6;
  --switch-bg: #ececef; --switch-on: #ffffff; --danger-bg: #fef2f2; --danger-border: #fca5a5; --danger-fg: #b91c1c;
  --offline: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f6f6f7; --fg: #18181b; --card: #ffffff; --muted: #e6e6ea; --muted-fg: #6b6b75;
    --btn: #f4f4f5; --border: #e4e4e7; --progress: #eab308; --done: #16a34a; --time: #3b82f6;
    --switch-bg: #ececef; --switch-on: #ffffff; --danger-bg: #fef2f2; --danger-border: #fca5a5; --danger-fg: #b91c1c;
    --offline: #dc2626;
    color-scheme: light;
  }
}
/* Vintage: cream #FFF4BF, pink #FFBEFB, lilac #DC95FF, purple #8C56D4 */
[data-theme="vintage"] {
  --bg: #FFF4BF; --fg: #3d2266; --card: #FFFAE0; --muted: #FFE0F6; --muted-fg: #8C56D4;
  --btn: #FFBEFB; --border: #F2C9E8; --progress: #DC95FF; --done: #8C56D4; --time: #FFBEFB;
  --switch-bg: #FFE9F4; --switch-on: #FFBEFB; --danger-bg: #FFBEFB; --danger-border: #8C56D4; --danger-fg: #5b2a9e;
  --offline: #c81e1e;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.4 -apple-system, system-ui, sans-serif; }
main { max-width: 880px; margin: 2rem auto; padding: 0 max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left)); }
@media (display-mode: standalone) { main { margin-top: max(1rem, env(safe-area-inset-top)); } }
button { touch-action: manipulation; } /* no double-tap zoom delay when tapping fast */
h1 { margin: 0; font-weight: 600; }
/* The title is a button (hold it 2 s to show the reset button), but it must look like plain text. */
h1 button.title-btn { all: unset; cursor: default; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 10px; }
.offline { margin: 0 0 .5rem; font-size: .8rem; color: var(--offline); }
.offline[hidden] { display: none; }

/* Theme switch: pill with icon buttons, the active one raised */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--switch-bg); }
.theme-switch button { display: grid; place-items: center; width: 36px; height: 30px; padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted-fg); }
.theme-switch button svg { width: 18px; height: 18px; }
.theme-switch button:hover { color: var(--fg); }
.theme-switch button[aria-pressed="true"] { background: var(--switch-on); color: var(--fg); box-shadow: 0 1px 3px #0003; }
.jess-btn { padding: 6px 12px; font-size: .9rem; }
.jess-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.people { display: inline-block; margin-left: .3rem; padding: 0 .4rem; border-radius: 999px; font-size: .72rem; line-height: 1.5;
  background: var(--muted); color: var(--fg); vertical-align: 1px; white-space: nowrap; }
.picker { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.picker .small { margin-right: 4px; }
.picker button { min-width: 2rem; }
.picker button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
h2 { margin: 1.4rem 0 .4rem; font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-fg); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.small { font-size: .8rem; }
.muted { color: var(--muted-fg); }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 2.2rem; font-weight: 500; line-height: 1.1; }

/* Top strip: clock | combined bar + time bar | done */
.strip { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; }
.done-box { text-align: right; }
.strip-bars { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.caption { display: flex; justify-content: space-between; gap: .5rem; }

/* Bars */
.bar { height: 6px; background: var(--muted); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--progress); border-radius: inherit; }
.bar.time > i { background: var(--time); }
.done .bar > i { background: var(--done); }

/* Combined bar: one segment per goal, width = difficulty weight */
.total-wrap { position: relative; }
.seg { display: flex; gap: 2px; height: 20px; }
.seg .segment { flex-basis: 0; background: var(--muted); border-radius: 3px; overflow: hidden; cursor: default; }
.seg .segment > i { display: block; height: 100%; background: var(--progress); }
.seg .segment.done > i { background: var(--done); }
.seg .segment.hover { outline: 2px solid var(--fg); outline-offset: -2px; }
.tip { position: absolute; top: calc(100% + 6px); left: 0; white-space: nowrap; background: var(--fg); color: var(--bg);
  font-size: .85rem; padding: .25rem .5rem; border-radius: 6px; pointer-events: none; z-index: 1; }

/* Goals, grouped by category */
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 24px; }
.goal { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); }
.goal .bar, .goal .actions { grid-column: 1 / -1; }
.goal .bar { margin: 2px 0 4px; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
button { font: inherit; font-size: .85rem; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border); background: var(--btn); color: var(--fg); cursor: pointer; }
button:hover { border-color: var(--muted-fg); }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; box-shadow: 0 4px 16px #0008; z-index: 1001; }
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  .strip { grid-template-columns: 1fr auto; }
  .strip-bars { grid-column: 1 / -1; grid-row: 2; }
  .caption { flex-wrap: wrap; }
  #time-label { order: 3; width: 100%; text-align: center; }
}
.reset-wrap { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; }
.reset-wrap[hidden] { display: none; }

button.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); padding: 8px 16px; }
button.danger:hover { border-color: var(--danger-fg); }
button.motivate-btn { padding: 8px 16px; }

/* Motivation dialog: a quote sent by one of us */
.quote-dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--fg); text-align: center; box-shadow: 0 10px 40px #0008; }
.quote-dialog::backdrop { background: #0008; }
.quote-dialog p { margin: 0; }
.quote-dialog .quote { margin: .6rem 0 1.4rem; font-size: 1.3rem; line-height: 1.35; font-weight: 500; }

/* ---------- Schedule page ---------- */
/* Links between the pages look like the buttons next to them, in every theme */
.nav-link { display: inline-block; padding: 6px 12px; font-size: .9rem; line-height: 1.4; border-radius: 6px; border: 1px solid var(--border); background: var(--btn);
  color: var(--fg); text-decoration: none; }
.nav-link:hover { border-color: var(--muted-fg); }
.now-card p { margin: 0; }
.now-card .acts { margin: .4rem 0; }
.now-card .act { font-size: 1rem; }
.now-card .next-label { margin-top: .9rem; }

/* Activities: one pill per goal, green with a check once the goal is done */
.acts { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.act { padding: 2px 8px; border-radius: 999px; background: var(--muted); font-size: .8rem; line-height: 1.35; overflow-wrap: anywhere; }
.act.done { background: var(--done); color: var(--bg); }
.act.done::before { content: "\2713  "; }
.act.plain { padding: 0; background: none; font-weight: 500; }
.act .small { display: block; font-weight: 400; }

/* Timeline: top to bottom, one slot per block, 28 px per hour of its real length (--h).
   Start time | bar | activities in a row. */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.slot { position: relative; height: calc(var(--h) * 28px); display: grid; grid-template-columns: 2.8rem 14px 1fr; gap: 0 10px; align-items: start; }
.slot-bar { height: 100%; background: var(--muted); overflow: hidden; }
.slot-bar > i { display: block; width: 100%; height: var(--pct); background: var(--time); }
.slot:first-child .slot-bar { border-radius: 7px 7px 0 0; }
.slot:last-child .slot-bar { border-radius: 0 0 7px 7px; }
.slot.filler .slot-bar { background: repeating-linear-gradient(45deg, var(--muted) 0 6px, transparent 6px 12px); }
.slot.past .acts, .slot.past .slot-time { opacity: .5; }
.slot.now .slot-time { color: var(--fg); font-weight: 600; }
.slot.now::after { content: ""; position: absolute; top: var(--pct); left: 0; right: 0; height: 2px; background: var(--fg); }

/* ---------- Vintage extras ---------- */
[data-theme="vintage"] body { font-family: Georgia, "Times New Roman", serif; }
[data-theme="vintage"] h1, [data-theme="vintage"] .big { font-family: Georgia, serif; font-style: italic; color: #8C56D4; }
[data-theme="vintage"] .card { box-shadow: 4px 4px 0 #FFBEFB; border-color: #DC95FF; }
[data-theme="vintage"] button, [data-theme="vintage"] .nav-link { border-color: #DC95FF; color: #3d2266; }
[data-theme="vintage"] .tip, [data-theme="vintage"] .toast { background: #8C56D4; color: #FFF4BF; }

/* ---------- Gay: rainbow everything ---------- */
[data-theme="gay"] {
  --r1: #e40303; --r2: #ff8c00; --r3: #ffed00; --r4: #008026; --r5: #24408e; --r6: #732982;
  --rainbow: linear-gradient(90deg, var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6));
  --bg: #fff; --fg: #2a0845; --card: rgba(255, 255, 255, .82); --muted: rgba(255, 255, 255, .55); --muted-fg: #5b1f7a;
  --btn: #fff; --border: rgba(115, 41, 130, .35); --progress: #ff8c00; --done: #e40303; --time: #24408e;
  --switch-bg: rgba(255, 255, 255, .6); --switch-on: #fff; --danger-bg: #fff; --danger-border: #e40303; --danger-fg: #e40303;
  --offline: #c00000;
  color-scheme: light;
}
@keyframes rainbow-drift { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
@keyframes hue-spin { to { filter: hue-rotate(360deg); } }
[data-theme="gay"] body {
  background: linear-gradient(120deg, #ff9a9e, #fecf6a, #fff59d, #a8e6a1, #8fd3fe, #c3a3ff, #ff9ad5, #ff9a9e);
  background-size: 300% 300%; background-attachment: fixed; animation: rainbow-drift 18s linear infinite;
}
[data-theme="gay"] h1 {
  background: var(--rainbow); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbow-drift 4s linear infinite; font-weight: 800; letter-spacing: -.01em;
}
[data-theme="gay"] .card {
  border: 3px solid transparent; background: linear-gradient(var(--card), var(--card)) padding-box, var(--rainbow) border-box;
  box-shadow: 0 6px 24px rgba(115, 41, 130, .25);
}
[data-theme="gay"] .big {
  background: var(--rainbow); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbow-drift 6s linear infinite; font-weight: 700;
}
[data-theme="gay"] .bar { height: 10px; background: rgba(255, 255, 255, .6); }
[data-theme="gay"] .bar > i, [data-theme="gay"] .done .bar > i, [data-theme="gay"] .bar.time > i {
  background: var(--rainbow); background-size: 200% 100%; animation: rainbow-drift 3s linear infinite;
}
[data-theme="gay"] .done .bar > i { box-shadow: 0 0 10px #ff8c00; }
[data-theme="gay"] .seg .segment { background: rgba(255, 255, 255, .55); }
[data-theme="gay"] .seg .segment:nth-child(6n+1) > i { background: var(--r1); }
[data-theme="gay"] .seg .segment:nth-child(6n+2) > i { background: var(--r2); }
[data-theme="gay"] .seg .segment:nth-child(6n+3) > i { background: var(--r3); }
[data-theme="gay"] .seg .segment:nth-child(6n+4) > i { background: var(--r4); }
[data-theme="gay"] .seg .segment:nth-child(6n+5) > i { background: var(--r5); }
[data-theme="gay"] .seg .segment:nth-child(6n+6) > i { background: var(--r6); }
[data-theme="gay"] .seg .segment.done > i { background: var(--rainbow); }
[data-theme="gay"] h2 { font-weight: 800; font-size: .9rem; }
[data-theme="gay"] h2:nth-of-type(3n+1) { color: var(--r1); }
[data-theme="gay"] h2:nth-of-type(3n+2) { color: var(--r4); }
[data-theme="gay"] h2:nth-of-type(3n+3) { color: var(--r5); }
[data-theme="gay"] .goal { border-bottom: 2px solid transparent; border-image: var(--rainbow) 1; }
[data-theme="gay"] .goal .name { font-weight: 700; }
[data-theme="gay"] .actions button, [data-theme="gay"] .picker button { color: #fff; border: 0; font-weight: 700; text-shadow: 0 1px 1px #0005; }
[data-theme="gay"] .actions button:nth-child(6n+1), [data-theme="gay"] .picker button:nth-of-type(6n+1) { background: var(--r1); }
[data-theme="gay"] .actions button:nth-child(6n+2), [data-theme="gay"] .picker button:nth-of-type(6n+2) { background: var(--r2); }
[data-theme="gay"] .actions button:nth-child(6n+3), [data-theme="gay"] .picker button:nth-of-type(6n+3) { background: #e0c400; }
[data-theme="gay"] .actions button:nth-child(6n+4), [data-theme="gay"] .picker button:nth-of-type(6n+4) { background: var(--r4); }
[data-theme="gay"] .actions button:nth-child(6n+5) { background: var(--r5); }
[data-theme="gay"] .actions button:nth-child(6n+6) { background: var(--r6); }
[data-theme="gay"] .picker button[aria-pressed="true"] { outline: 3px solid var(--r6); outline-offset: 1px; }
[data-theme="gay"] .people { background: var(--rainbow); color: #fff; font-weight: 700; text-shadow: 0 1px 1px #0006; }
[data-theme="gay"] .jess-btn, [data-theme="gay"] .nav-link { background: var(--rainbow); color: #fff; border: 0; font-weight: 700; text-shadow: 0 1px 1px #0006; }
[data-theme="gay"] .jess-btn[aria-pressed="true"] { outline: 3px solid var(--r6); outline-offset: 2px; }
[data-theme="gay"] .tip, [data-theme="gay"] .toast { background: var(--rainbow); color: #fff; font-weight: 700; text-shadow: 0 1px 2px #0007; }
[data-theme="gay"] .theme-switch { border: 2px solid transparent; background: linear-gradient(#fff9, #fff9) padding-box, var(--rainbow) border-box; }
@media (prefers-reduced-motion: reduce) {
  [data-theme="gay"] * , [data-theme="gay"] body { animation: none !important; }
}

/* Disabled step buttons: goal full (plus) or empty (minus) */
button:disabled, [data-theme] button:disabled { opacity: .35; cursor: not-allowed; }
button:disabled:hover { border-color: var(--border); }
