/* hehe.css — mobile-first.
 * Palette pulls the ratfest vibe: black background, white text, ratfest red
 * (#700000 is the canonical deep red used behind every newsheading on the
 * legacy site; a brighter cousin is used for foreground text so it reads on
 * black). Layout is its own thing — single-column, large tap targets, designed
 * for thumbs on a phone first and grudgingly widens for desktop.
 */

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #888;
  --line: #222;
  --card: #0c0c0c;
  --accent: #e0252b;        /* bright readable ratfest red — foreground */
  --accent-dim: #700000;    /* canonical ratfest red (rf3.css) — backgrounds */
  --danger: #ff4040;

  /* level palette — green/blue/yellow/red per the design doc */
  --lvl-green:  #2ecc40;
  --lvl-blue:   #6fb1ff;
  --lvl-yellow: #ffd83d;
  --lvl-red:    #6b0f0f;

  /* tap targets ≥44px per Apple HIG */
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

a            { color: var(--accent); text-decoration: none; }
a:visited    { color: var(--accent-dim); }
a:hover      { text-decoration: underline; }

/* --- topbar / nav --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.topbar .brand {
  color: var(--accent);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1px;
  text-decoration: none;
}

/* "(beta)" tag next to the hehe brand — muted, lighter, smaller. Used in
 * both the topbar and the standalone login page. */
.beta {
  font-size: 0.55em;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 0.4em;
  vertical-align: middle;
  text-transform: lowercase;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.topbar nav a, .topbar nav .who {
  color: var(--fg);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}

.topbar nav .ext { color: var(--muted); }

.inline { display: inline; margin: 0; }

button.linkish {
  background: none;
  border: 0;
  color: var(--fg);
  font: inherit;
  padding: 0;
  cursor: pointer;
  min-height: var(--tap);
}
button.linkish:hover { color: var(--accent); }

/* --- main / cards --- */

main {
  padding: 14px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 8px 0;
  font-size: 28px;
  color: var(--accent);
}

.lede {
  font-size: 17px;
  margin: 0 0 12px 0;
}

.muted { color: var(--muted); font-size: 14px; }
.err   { color: var(--danger); margin: 8px 0; }

/* --- level legend (also used by future timeline rows) --- */

.level-legend {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
}
.level-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.lvl {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.15);
}
.lvl-green  { background: var(--lvl-green); }
.lvl-blue   { background: var(--lvl-blue); }
.lvl-yellow { background: var(--lvl-yellow); }
.lvl-red    { background: var(--lvl-red); }

/* --- login page --- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-main {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  text-align: center;
}

.login-brand {
  font-size: 48px;
  letter-spacing: 2px;
  margin: 0;
}

.login-tag {
  margin: 0 0 24px 0;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

.login-form input {
  background: #161616;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px;
  font-size: 16px;     /* >=16 so iOS doesn't zoom on focus */
  border-radius: 4px;
  min-height: var(--tap);
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.login-form button {
  background: var(--accent-dim);
  color: #fff;
  border: 0;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 4px;
  min-height: var(--tap);
  cursor: pointer;
  margin-top: 4px;
}

.login-form button:hover { background: var(--accent); }

.login-foot {
  margin-top: 24px;
  text-align: center;
}

/* --- home view: live-now + day buckets --- */

.card-h {
  margin: 0 0 10px 0;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.live-card.empty .card-h,
.day-card .card-h {
  color: var(--accent);
}

.day-card.today {
  border-color: var(--accent-dim);
}
.day-card.today .card-h {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Empty day cards (no windows) get a lighter footprint so populated days
 * dominate the scroll. `:has(> p.muted)` keys on the direct-child paragraph
 * the template emits in the empty branch — populated days emit a <ul> instead. */
.day-card:has(> p.muted) {
  padding: 10px 16px;
  opacity: 0.55;
}
.day-card:has(> p.muted) .card-h {
  margin-bottom: 0;
  border-bottom: 0;
  padding-bottom: 0;
  font-size: 13px;
}
.day-card:has(> p.muted) > p.muted {
  display: none;
}

/* The Coming-up-soon card uses the same body styling as Live now but a
 * subtler header treatment to signal it's a forecast, not "right now". */
.soon-card .card-h { color: var(--muted); }

.live-list, .window-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.live-row, .window-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  min-height: var(--tap);
}
.live-row:last-child, .window-row:last-child { border-bottom: 0; }

.live-row.own, .window-row.own {
  background: rgba(224, 37, 43, 0.06);
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 4px;
}

.live-name, .w-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-until, .w-time {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.w-note {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 13px;
}

/* goldmark wraps every note in <p>...</p>. For our single-line notes that
 * adds heavy vertical margin and looks awful. Flatten the first/only paragraph
 * to inline so notes sit on one line; multi-paragraph notes keep block flow. */
.w-note > p:only-child,
.rule-note > p:only-child {
  display: inline;
  margin: 0;
}
.w-note > p,
.rule-note > p {
  margin: 0 0 6px 0;
}

.you {
  color: var(--accent);
  font-size: 12px;
  font-weight: 400;
}

/* --- CTA bar above the day cards --- */

.cta-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* --- buttons --- */

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary, a.btn-primary:visited { background: var(--accent-dim); color: #fff; }
.btn-primary:hover { background: var(--accent); text-decoration: none; }
.btn-primary.small { padding: 0 12px; font-size: 13px; min-height: 32px; }

.btn-secondary, a.btn-secondary:visited { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-danger, a.btn-danger:visited { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* Same fix for the inline action chips (edit / del / skip / "edit rule").
 * Without it, once you've clicked "edit" once the chip text bleeds into the
 * background tint and effectively disappears. */
.chip, a.chip:visited { color: var(--fg); }
.chip-danger, a.chip-danger:visited { color: var(--danger); }

/* --- tag chips (pig / eye) --- */

.w-tags {
  grid-column: 2 / -1;
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* live-row uses a 3-col grid (lvl | name | until), so .w-tags wraps to a new
 * line under name+until. Same shape as day-cards' .w-tags. */
.live-row .w-tags { grid-column: 2 / -1; }

.chip-tag {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 30px;
  font-size: 14px;
  line-height: 1;
}
.chip-tag .tag-emoji { font-size: 16px; }
.chip-tag .tag-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.chip-tag:hover { background: rgba(255,255,255,0.1); border-color: var(--muted); }

/* Viewer's currently selected tag gets an accent outline + tint so it's
 * obvious which one you've picked from across the day card. */
.chip-tag.on {
  border-color: var(--accent);
  background: rgba(224, 37, 43, 0.12);
}
.chip-tag.on .tag-count { color: var(--accent); }

/* Read-only variant — shown on the owner's own window rows where you can
 * see who's committed/maybe but can't self-tag. No hover state, no pointer. */
.chip-tag-ro {
  cursor: default;
}
.chip-tag-ro:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--line);
}

/* --- own-row inline action chips --- */

.w-actions {
  grid-column: 2 / -1;
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  color: var(--fg);
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.chip:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.chip-danger { color: var(--danger); }
.chip-danger:hover { background: rgba(255,64,64,0.15); }

/* --- segmented mode toggle (once / every week) --- */

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}

.mode-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 0;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  min-height: var(--tap);
  text-transform: lowercase;
  letter-spacing: 1px;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--line);
}

.mode-btn.on {
  background: var(--accent-dim);
  color: #fff;
}

/* --- day-of-week chips (7 small toggles in a row) --- */

.day-picker {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.day-picker legend { padding: 0; }

.day-chips {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  min-height: var(--tap);
  padding: 0;
}

.day-chip.on {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
}

.day-chip:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- forms --- */

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

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.form-stack input[type="date"],
.form-stack input[type="time"],
.form-stack select,
.form-stack textarea {
  background: #161616;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px;
  font-size: 16px;          /* avoid iOS zoom on focus */
  border-radius: 4px;
  min-height: var(--tap);
  font-family: inherit;
  width: 100%;
}
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.form-stack textarea { resize: vertical; min-height: 70px; }

.hint { margin: -8px 0 0 0; font-size: 12px; }

/* --- level picker (radios styled as chips) --- */

.level-picker {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.level-picker legend { padding: 0; }

.lvl-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  min-height: var(--tap);
}
.lvl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.lvl-opt.on { border-color: var(--accent); background: rgba(224, 37, 43, 0.08); }
.lvl-opt-label { font-size: 14px; }

/* --- form bar (buttons row) --- */

.form-bar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.danger-form {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* --- recurring list rows --- */

.card-h-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-h.flush { margin: 0; border-bottom: 0; padding-bottom: 0; }

.rule-list { list-style: none; margin: 0; padding: 0; }

.rule-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rule-row:last-child { border-bottom: 0; }
.rule-when { font-size: 15px; }
.rule-note {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 13px;
}
.rule-actions { display: flex; gap: 6px; }
.small { font-size: 12px; }

.card-foot { margin-top: 16px; }

/* --- topbar notification toggle --- */

.notif-toggle {
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  min-height: var(--tap);
  min-width: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-toggle[disabled] { opacity: 0.5; }

/* --- iOS install coach banner --- */

.ios-coach {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--card);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 12px 40px 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg);
  box-shadow: 0 2px 12px rgba(0,0,0,0.6);
  z-index: 100;
}
.ios-coach strong { color: var(--accent); font-weight: 600; }
.ios-coach-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px 8px;
  font-family: inherit;
}
.ios-coach-dismiss:hover { color: var(--fg); }

/* --- desktop widening --- */

@media (min-width: 640px) {
  main { padding: 24px; }
  .topbar { padding: 12px 24px; }
}
