/* DH Prayer Watch — all colours are tokens below; change them here to restyle. */

:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --ink: #1e2533;
  --muted: #687082;
  --line: #e4dccb;
  --accent: #a87a22;
  --accent-strong: #8a6316;
  --accent-ink: #ffffff;
  --danger: #b4412f;
  --ok: #2e7d4f;

  /* roster coverage: gap, 1, 2, 3+ people */
  --c0: #fbf1ec;
  --c0-line: #e7c2b3;
  --c1: #efe2bd;
  --c2: #ddbb6a;
  --c3: #b98a2c;
  --c3-ink: #fff;

  /* globe (always a night-sky panel) */
  --sky: #0d1626;
  --sky-2: #16233a;
  --ocean: #1b3150;
  --land: #3d5a4a;
  --land-line: #5b7a66;
  --grat: rgba(255, 255, 255, 0.07);
  --night: rgba(4, 8, 20, 0.45);
  --pin: #f2c25b;
  --pin-now: #ffffff;
  --pin-ring: #f2c25b;
  --sky-ink: #e9e4d6;
  --sky-muted: #9aa6bb;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 37, 51, 0.06), 0 6px 20px rgba(30, 37, 51, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f;
    --surface: #1a202b;
    --surface-2: #212836;
    --ink: #ebe7dc;
    --muted: #9aa3b4;
    --line: #2d3545;
    --accent: #d9a648;
    --accent-strong: #e8b95e;
    --accent-ink: #1a1306;
    --danger: #e0715f;
    --c0: #2a2224;
    --c0-line: #5c3c35;
    --c1: #4a4128;
    --c2: #7d6530;
    --c3: #c49537;
    --c3-ink: #1a1306;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 0.4em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.6em; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

input, select, button, textarea { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5em 0.7em;
  min-height: 40px;
  max-width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, .pin:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  border: 1px solid transparent; border-radius: 999px;
  padding: 0.5em 1.05em; min-height: 40px;
  cursor: pointer; background: var(--surface-2); color: var(--ink);
  font-weight: 600; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-icon { width: 40px; padding: 0; background: transparent; border-color: var(--line); font-size: 1.2rem; }
.btn-small { min-height: 32px; padding: 0.25em 0.8em; font-size: 0.88rem; }
.btn-wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--accent-strong); text-decoration: underline; cursor: pointer; font-size: 0.86rem; }

.badge { display: inline-block; border-radius: 999px; padding: 0.05em 0.6em; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; vertical-align: middle; }
.badge-dev { background: var(--danger); color: #fff; }
.badge-now { background: var(--accent); color: var(--accent-ink); margin-left: 0.5em; }

.chip {
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  padding: 0.35em 0.85em; min-height: 40px; cursor: pointer; font-weight: 600;
}
.chip-label { color: var(--muted); font-weight: 500; }

/* ── Login ───────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 20%, var(--sky-2), var(--sky) 70%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 18px;
  padding: 28px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center;
  display: grid; gap: 12px;
}
.login-card input { text-align: center; font-size: 1.1rem; letter-spacing: 0.12em; }
.login-card .plain-input { letter-spacing: normal; font-size: 1rem; width: 100%; }
#register-ask { display: grid; gap: 12px; }
#register-ask p, .login-register p { margin: 0; }
.login-register { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.form-ok { color: var(--ok); margin: 0; font-weight: 600; text-align: left; }
.code-show {
  font-size: 1.6rem; font-weight: 700; letter-spacing: 0.12em; margin: 0;
  padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--accent);
  word-break: break-all; user-select: all;
}
#verify-ok { display: grid; gap: 10px; }
#verify-ok p { margin: 0; }
/* Honeypot field for bots: kept off screen, never shown to people */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.people-table .row-actions { white-space: nowrap; }
.people-table .row-actions .btn + .btn { margin-left: 6px; }
.badge-verified { background: rgba(46, 125, 79, 0.15); color: var(--ok); }
.badge-pending { background: var(--surface-2); color: var(--muted); }
.badge-blocked { background: rgba(180, 65, 47, 0.15); color: var(--danger); }
.person-blocked td { color: var(--muted); }
/* Show/hide eye inside the code field (padding on both sides keeps the text centred) */
.code-field { position: relative; }
.code-field input { width: 100%; padding-left: 48px; padding-right: 48px; }
.eye-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 8px; padding: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.eye-btn:hover { color: var(--ink); }
.eye-btn svg { width: 22px; height: 22px; }
.login-mark, .brand-mark {
  width: 44px; height: 44px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6d690, var(--accent) 55%, #6b4b10);
  box-shadow: 0 0 0 4px rgba(168, 122, 34, 0.18);
}
.app-title { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; margin: 0; box-shadow: none; }
.brand .app-title { font-size: 1.2rem; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 0.45em 0.9em; border-radius: 999px;
  cursor: pointer; color: var(--muted); font-weight: 600; min-height: 38px;
}
.tab[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

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

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ── Board: globe next to roster ─────────────────────────────────────── */
.board { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 960px) {
  .board { grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); align-items: start; }
  .globe-card { position: sticky; top: 76px; }
}

.globe-card { background: linear-gradient(180deg, var(--sky-2), var(--sky)); color: var(--sky-ink); border-color: transparent; }
.globe-card .muted { color: var(--sky-muted); }
.globe-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.globe { width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 1 / 1; touch-action: none; }
.globe-svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
.globe-svg.is-dragging { cursor: grabbing; }
.globe-svg .halo { fill: none; stroke: rgba(242, 194, 91, 0.12); stroke-width: 10; }
.globe-svg .ocean { fill: var(--ocean); }
.globe-svg .graticule { fill: none; stroke: var(--grat); stroke-width: 0.6; }
.globe-svg .land { fill: var(--land); stroke: var(--land-line); stroke-width: 0.4; }
.globe-svg .night { fill: var(--night); pointer-events: none; }
.globe-svg .shine { pointer-events: none; }
.globe-svg .shade-hi { stop-color: #ffffff; stop-opacity: 0.12; }
.globe-svg .shade-lo { stop-color: #000000; stop-opacity: 0.25; }
.pin { cursor: pointer; }
.pin-dot { fill: var(--pin); stroke: var(--sky); stroke-width: 1.5; }
.pin-pulse { fill: none; stroke: var(--pin-ring); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.pin.is-now .pin-dot { fill: var(--pin-now); stroke: var(--pin); stroke-width: 2.5; }
.pin.is-now .pin-pulse { animation: pulse 2s ease-out infinite; }
.pin.is-selected .pin-dot { stroke: #fff; stroke-width: 3; }
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(3); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .pin.is-now .pin-pulse { animation: none; opacity: 0.6; transform: scale(1.8); } }

.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 8px 0; color: var(--sky-muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; }
.dot-now { background: var(--pin-now); box-shadow: 0 0 0 2px var(--pin); }
.dot-on { background: var(--pin); }
.dot-night { background: #2a3448; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.globe-info { min-height: 2.6em; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 8px; }
.is-now-name { color: #fff; font-weight: 700; }

/* ── Roster ──────────────────────────────────────────────────────────── */
.roster-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.date-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.date-nav input { min-height: 40px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 0.45em 1em; min-height: 38px; cursor: pointer; font-weight: 600; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.focus-filter { margin-left: auto; }
.focus-filter select { max-width: 240px; }
.roster-heading { font-size: 1.15rem; }

.coverage { margin-bottom: 10px; }
.coverage-bar progress { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--c0); appearance: none; }
.coverage-bar progress::-webkit-progress-bar { background: var(--c0); border-radius: 999px; }
.coverage-bar progress::-webkit-progress-value { background: var(--c3); border-radius: 999px; }
.coverage-bar progress::-moz-progress-bar { background: var(--c3); border-radius: 999px; }
.coverage-text { margin: 6px 0; }
.gap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gap-chip {
  border: 1px dashed var(--c0-line); background: var(--c0); border-radius: 999px;
  padding: 0.2em 0.7em; font-size: 0.85rem; cursor: pointer; min-height: 30px;
}

.day-grid { display: grid; gap: 3px; }
.day-row { display: grid; grid-template-columns: 52px minmax(140px, 1fr) minmax(0, 1.1fr); gap: 10px; align-items: center; }
.day-hour { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; text-align: right; }
.day-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.cell {
  height: 30px; border-radius: 6px; border: 1px solid transparent; cursor: pointer;
  font-size: 0.78rem; font-weight: 700; padding: 0; font-variant-numeric: tabular-nums;
}
.cell.c0 { background: var(--c0); border: 1px dashed var(--c0-line); }
.cell.c1 { background: var(--c1); }
.cell.c2 { background: var(--c2); }
.cell.c3 { background: var(--c3); color: var(--c3-ink); }
.cell.is-now { box-shadow: 0 0 0 2px var(--ink); }
.cell.is-selected { outline: 3px solid var(--accent-strong); outline-offset: 1px; }
.day-names { font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .day-row { grid-template-columns: 44px 1fr; }
  .day-names { grid-column: 2; margin-top: -2px; font-size: 0.8rem; }
  .day-names.muted { display: none; }
  .focus-filter { margin-left: 0; width: 100%; }
  .focus-filter select { max-width: none; width: 100%; }
}

.slot-detail { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.slot-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.slot-people { padding-left: 1.1em; margin: 6px 0 12px; }
.slot-people li { margin-bottom: 4px; }

.week-grid { display: grid; gap: 6px; }
.week-scale, .week-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.week-ticks { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }
.week-row { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; cursor: pointer; text-align: left; }
.week-row:hover { background: var(--surface-2); }
.week-row.is-today { border-color: var(--accent); }
.week-day { font-weight: 600; font-size: 0.9rem; }
.week-strip { display: flex; height: 22px; border-radius: 5px; overflow: hidden; }
.mini { flex: 1 1 0; min-width: 0; }
.mini.c0 { background: var(--c0); }
.mini.c1 { background: var(--c1); }
.mini.c2 { background: var(--c2); }
.mini.c3 { background: var(--c3); }
.week-pct { font-variant-numeric: tabular-nums; font-size: 0.85rem; text-align: right; color: var(--muted); }
@media (max-width: 560px) {
  .week-scale, .week-row { grid-template-columns: 64px minmax(0, 1fr) 38px; gap: 6px; }
  .week-day { font-size: 0.8rem; }
}

/* ── Entries list ────────────────────────────────────────────────────── */
.list-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.list-toolbar h2 { margin: 0; }
.list-toolbar input[type=search] { flex: 1 1 200px; max-width: 320px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.entry-list { display: grid; gap: 8px; margin-top: 10px; }
.entry-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface);
}
.entry-row.is-past { opacity: 0.6; }
.entry-row.is-now { border-color: var(--accent); }
.entry-focus { color: var(--muted); font-size: 0.9rem; }
.entry-email { color: var(--muted); word-break: break-all; }
.entry-actions { display: flex; gap: 6px; }
@media (max-width: 640px) {
  .entry-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ── Admin ───────────────────────────────────────────────────────────── */
.admin { display: grid; gap: 16px; }
.focus-table { display: grid; gap: 8px; margin: 10px 0; }
.focus-row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.5fr) auto auto; gap: 8px; align-items: center; }
.focus-row.is-retired input:not([type=checkbox]) { color: var(--muted); text-decoration: line-through; }
.focus-move { display: flex; gap: 4px; }
.focus-move .btn-icon { width: 32px; min-height: 32px; font-size: 0.95rem; }
.focus-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: 8px; margin-top: 8px; }
.app-name-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; max-width: 520px; }
@media (max-width: 720px) {
  .focus-row { grid-template-columns: auto 1fr; }
  .focus-row > input { grid-column: 1 / -1; }
  .focus-add { grid-template-columns: 1fr; }
}
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.deleted-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.change-log { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.log-table th, .log-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table th { color: var(--muted); font-weight: 600; }
.log-login_fail td { color: var(--danger); }

/* ── Dialogs ─────────────────────────────────────────────────────────── */
.dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.dialog-small { width: min(420px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(10, 15, 25, 0.55); }
.dialog form { padding: 20px; display: grid; gap: 12px; max-height: calc(100vh - 40px); overflow-y: auto; }
.field { display: grid; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-weight: 600; font-size: 0.9rem; }
.field legend { padding: 0; margin-bottom: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row .field { flex: 1 1 140px; }
.time-pick { display: flex; align-items: center; gap: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pills label {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.35em 0.9em; cursor: pointer; min-height: 38px;
}
.pills label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); font-weight: 600; }
.pills input { accent-color: var(--accent); }
.preview { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 0.9rem; margin: 0; }
.preview:empty { display: none; }
.form-error { color: var(--danger); margin: 0; font-weight: 600; }
.form-error:empty { display: none; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 0.65em 1.1em; border-radius: 999px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); font-weight: 600;
}
.toast-error { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  main { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .topbar-actions { margin-left: 0; width: 100%; }
  #add-button { flex: 1; }
}
