/* Roll Call — parchment by day, arcane by night. */

:root {
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Crimson Pro", "Iowan Old Style", Georgia, serif;

  --bg: #eadcbd;
  --bg-glow: #f6ecd3;
  --card: #fbf4e2;
  --card-edge: #cfb988;
  --inset: #f3e8cc;
  --ink: #2a1f14;
  --ink-soft: #6b5a44;
  --line: #dccba6;
  --accent: #8b1e1e;
  --accent-hover: #a32626;
  --accent-ink: #fff5e1;
  --gold: #9a6c12;
  --focus: #1f5fa8;

  --yes: #2c7448;
  --yes-bg: #d3e7cc;
  --maybe: #a2670a;
  --maybe-bg: #f6e2ad;
  --no: #9b3a34;
  --no-bg: #efd2c9;
  --none: #d6c7a4;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 10px 30px -18px rgba(60, 35, 10, 0.55);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #100e18;
  --bg-glow: #1c1730;
  --card: #1d1929;
  --card-edge: #3b3157;
  --inset: #16131f;
  --ink: #ece4d2;
  --ink-soft: #a69fb6;
  --line: #2f2845;
  --accent: #d9b45a;
  --accent-hover: #e8c873;
  --accent-ink: #1b1424;
  --gold: #d9b45a;
  --focus: #8fb8ff;

  --yes: #62c98b;
  --yes-bg: #1b3a2b;
  --maybe: #e8b751;
  --maybe-bg: #3c3015;
  --no: #e58177;
  --no-bg: #40212a;
  --none: #383050;

  --shadow: 0 0 0 1px rgba(217, 180, 90, 0.04) inset, 0 14px 34px -18px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--bg);
  background-attachment: fixed, scroll, scroll;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ shell */

.shell { max-width: 1180px; margin: 0 auto; padding: 0 20px 56px; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--card-edge);
  margin-bottom: 22px;
  position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand-mark { width: 42px; height: 42px; flex: none; }
.brand-mark .die { fill: var(--accent); }
.brand-mark .facets { fill: none; stroke: var(--accent-ink); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; opacity: 0.9; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; letter-spacing: 0.06em; line-height: 1.1; }
.brand-sub { color: var(--ink-soft); font-style: italic; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text { min-width: 0; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 1px solid var(--card-edge);
}
.icon-btn:hover { background: var(--card); }

.user-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 4px 14px 4px 4px; height: 40px;
  border-radius: 999px; border: 1px solid var(--card-edge); background: var(--card);
  max-width: 220px;
}
.user-chip:hover { border-color: var(--gold); }
.user-chip span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.avatar {
  position: relative; flex: none;
  width: 30px; height: 30px; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center;
  background: var(--none); color: var(--ink);
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 700;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 24px; height: 24px; font-size: 0.6rem; }

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

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.card::before {
  /* inner rule, like a bookplate */
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  border: 1px solid var(--line); border-radius: 6px;
}
.card > * { position: relative; }

.card-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.86rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.card-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to right, var(--card-edge), transparent); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.side { display: grid; gap: 18px; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.92rem; }

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; min-height: 42px;
  border-radius: 8px; border: 1px solid var(--card-edge);
  background: var(--inset); font-weight: 600;
  text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: 0.95rem; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; font-size: 1.1rem; padding: 12px 22px; }
.btn.discord:hover { background: #4752c4; border-color: #4752c4; }
.btn.discord svg { width: 24px; height: 24px; fill: currentColor; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 0.9rem; color: var(--ink-soft); }
.input {
  width: 100%; min-height: 42px; padding: 8px 10px;
  background: var(--inset); border: 1px solid var(--card-edge); border-radius: 8px;
}
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 0.95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ------------------------------------------------------ next session */

.next-session {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 22px; padding: 14px 20px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; box-shadow: var(--shadow);
  border: 1px solid var(--accent);
  width: 100%; text-align: left;
}
.next-session .icon { width: 26px; height: 26px; }
.next-session .eyebrow { font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.85; }
.next-session .when { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em; }
.next-session .note { font-style: italic; opacity: 0.92; }
.next-session .countdown { margin-left: auto; font-weight: 600; border: 1px solid currentColor; border-radius: 999px; padding: 2px 12px; font-size: 0.92rem; white-space: nowrap; }

/* --------------------------------------------------------- calendar */

.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.cal-title { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; letter-spacing: 0.04em; flex: 1; text-align: center; }

.status-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 12px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600;
  border: 1px solid var(--card-edge); background: var(--inset); color: var(--ink-soft);
}
.pill.open { color: var(--yes); border-color: var(--yes); background: var(--yes-bg); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.brushes {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px; margin-bottom: 14px;
  background: var(--inset); border: 1px solid var(--line); border-radius: 10px;
}
.brush {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; min-height: 38px; border-radius: 8px;
  border: 1px solid var(--card-edge); background: var(--card); font-weight: 600; font-size: 0.98rem;
}
.brush[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px currentColor; }
.brush.yes { color: var(--yes); background: var(--yes-bg); border-color: var(--yes); }
.brush.maybe { color: var(--maybe); background: var(--maybe-bg); border-color: var(--maybe); }
.brush.no { color: var(--no); background: var(--no-bg); border-color: var(--no); }
.brush.clear, .brush.look { color: var(--ink-soft); }
.brush-sep { width: 1px; align-self: stretch; background: var(--card-edge); margin: 0 2px; }
.brush-hint { flex-basis: 100%; }

.save-state { margin-left: auto; font-size: 0.9rem; color: var(--ink-soft); min-width: 5.5em; text-align: right; }
.save-state.saved { color: var(--yes); }
.save-state.error { color: var(--no); }

.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow {
  font-family: var(--font-display); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase;
  text-align: center; color: var(--ink-soft);
  background: none; border: 0; padding: 6px 0; border-radius: 6px;
}
button.dow:hover { color: var(--ink); background: var(--inset); }

.day {
  position: relative; display: flex; flex-direction: column;
  min-height: 88px; padding: 6px 7px 7px;
  background: var(--inset); border: 1px solid var(--line); border-radius: 8px;
  text-align: left; overflow: hidden;
}
.day.blank { visibility: hidden; }
.day:hover { border-color: var(--gold); }
.day.is-yes { background: var(--yes-bg); border-color: color-mix(in srgb, var(--yes) 45%, transparent); }
.day.is-maybe { background: var(--maybe-bg); border-color: color-mix(in srgb, var(--maybe) 45%, transparent); }
.day.is-no { background: var(--no-bg); border-color: color-mix(in srgb, var(--no) 45%, transparent); }
.day.is-past { opacity: 0.5; }
.day.is-selected { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--gold); z-index: 1; }
.day.has-session { border: 2px solid var(--accent); padding: 5px 6px 6px; }

.day-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.day-num { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1; }
.is-today .day-num { background: var(--ink); color: var(--card); border-radius: 999px; padding: 3px 7px; margin: -3px 0 -3px -4px; }
.day-mine { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; }
.day-mine .icon { width: 13px; height: 13px; stroke-width: 3; }
.is-yes .day-mine { background: var(--yes); }
.is-maybe .day-mine { background: var(--maybe); }
.is-no .day-mine { background: var(--no); }
:root[data-theme="dark"] .day-mine { color: #14111d; }

.day-session {
  display: flex; align-items: center; gap: 4px; margin-top: 5px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); white-space: nowrap; overflow: hidden;
}
.day-session .icon { width: 13px; height: 13px; }

.day-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; }
.tally { flex: 1; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--none); gap: 1px; }
.tally i { display: block; min-width: 0; }
.tally .t-yes { background: var(--yes); }
.tally .t-maybe { background: var(--maybe); }
.tally .t-no { background: var(--no); }
.tally .t-none { background: var(--none); }
.day-count { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); line-height: 1; white-space: nowrap; }
.day.is-full .day-count { color: var(--yes); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 0.88rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 6px; border-radius: 3px; }

.progress { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-bar { flex: 1; min-width: 120px; height: 8px; background: var(--none); border-radius: 4px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }

/* ------------------------------------------------------------ side */

.detail-date { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; }
.group { margin-top: 12px; }
.group-label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.group-label.yes { color: var(--yes); }
.group-label.maybe { color: var(--maybe); }
.group-label.no { color: var(--no); }
.group-label.none { color: var(--ink-soft); }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 3px; border-radius: 999px; background: var(--inset); border: 1px solid var(--line); font-size: 0.93rem; }

.locked-box { margin-top: 14px; padding: 12px; border-radius: 8px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.locked-box .head { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; color: var(--accent); letter-spacing: 0.04em; }
.dm-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--card-edge); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }

.best { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.best button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; background: var(--inset); border: 1px solid var(--line);
}
.best button:hover { border-color: var(--gold); }
.best .rank { font-family: var(--font-display); font-weight: 700; color: var(--gold); width: 1.3em; text-align: center; }
.best .what { flex: 1; min-width: 0; }
.best .date { font-weight: 600; }
.badge { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--yes-bg); color: var(--yes); border: 1px solid var(--yes); white-space: nowrap; }
.badge.locked { background: transparent; color: var(--accent); border-color: var(--accent); }

.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.roster li { display: flex; align-items: center; gap: 10px; }
.roster .who { flex: 1; min-width: 0; line-height: 1.2; }
.roster .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .char { font-style: italic; color: var(--ink-soft); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .state { font-size: 0.84rem; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.roster .state.done { color: var(--yes); }
.roster .state.waiting { color: var(--maybe); }
.dm-tag { font-family: var(--font-display); font-size: 0.62rem; letter-spacing: 0.1em; color: var(--gold); border: 1px solid var(--gold); border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 2px; }
.remove { width: 26px; height: 26px; border-radius: 50%; border: 1px solid transparent; background: none; color: var(--ink-soft); display: inline-grid; place-items: center; }
.remove:hover { color: var(--no); border-color: var(--no); }

/* --------------------------------------------------------- landing */

.landing { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; }
.landing .card { max-width: 480px; width: 100%; text-align: center; padding: 40px 30px 30px; }
.landing .brand-mark { width: 84px; height: 84px; margin: 0 auto 14px; }
.landing h1 { font-family: var(--font-display); font-size: 2.5rem; letter-spacing: 0.08em; line-height: 1.1; }
.landing .campaign { font-style: italic; color: var(--ink-soft); font-size: 1.15rem; margin-top: 4px; }
.rule { display: flex; align-items: center; gap: 12px; color: var(--gold); margin: 20px 0; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--card-edge); }
.landing .pitch { font-size: 1.15rem; margin-bottom: 22px; }
.landing ul { list-style: none; padding: 0; margin: 24px 0 0; text-align: left; display: grid; gap: 10px; color: var(--ink-soft); }
.landing li { display: flex; gap: 10px; align-items: flex-start; }
.landing li .icon { color: var(--gold); margin-top: 3px; }
.notice { margin-bottom: 16px; padding: 10px 12px; border-radius: 8px; background: var(--no-bg); color: var(--no); border: 1px solid var(--no); }
.dev-login { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--card-edge); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.landing .theme-corner { position: fixed; top: 16px; right: 16px; }

/* --------------------------------------------------- dialog + toast */

dialog {
  border: 1px solid var(--card-edge); border-radius: 10px; padding: 24px;
  background: var(--card); color: var(--ink); width: min(420px, calc(100vw - 32px));
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(10, 6, 2, 0.55); }
dialog h2 { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: 0.05em; margin-bottom: 14px; }
.dialog-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; }
code.id { font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; background: var(--inset); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); user-select: all; }

#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { padding: 10px 16px; border-radius: 8px; background: var(--ink); color: var(--card); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6); text-align: center; }
.toast.error { background: var(--no); color: #fff; }

.loading { min-height: 60vh; display: grid; place-items: center; color: var(--ink-soft); font-style: italic; }

/* ------------------------------------------------- views + heatmap */

:root { --heat-ink: #fff; --hatch: repeating-linear-gradient(135deg, var(--no-bg) 0 5px, transparent 5px 10px); }
:root[data-theme="dark"] { --heat-ink: #0e1d15; }

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--inset); border: 1px solid var(--line); border-radius: 10px; }
.tab { flex: 1; min-height: 36px; padding: 5px 8px; border: 1px solid transparent; border-radius: 7px; background: none; font-weight: 600; color: var(--ink-soft); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--card); border-color: var(--card-edge); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.h0 { background-color: var(--inset); }
.h1 { background-color: color-mix(in srgb, var(--yes) 20%, var(--inset)); }
.h2 { background-color: color-mix(in srgb, var(--yes) 42%, var(--inset)); }
.h3 { background-color: color-mix(in srgb, var(--yes) 66%, var(--inset)); color: var(--heat-ink); }
.h4 { background-color: color-mix(in srgb, var(--yes) 92%, var(--inset)); color: var(--heat-ink); }
.blocked, .col-blocked { background-color: var(--inset); background-image: var(--hatch); }

.day.heat.h3, .day.heat.h4 { border-color: transparent; }
.day.heat.blocked { color: var(--ink-soft); }
.day.heat.tier-needs-dm { border: 2px dashed var(--maybe); padding: 5px 6px 6px; }
.day.heat.has-session { border: 2px solid var(--accent); }
.day.heat.h3 .day-session, .day.heat.h4 .day-session { color: inherit; }
.heat-count { margin: auto auto 2px; font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; line-height: 1; }
.heat-count small { font-size: 0.6em; opacity: 0.75; }
.day-star .icon { width: 15px; height: 15px; fill: currentColor; }
.h0 .day-star, .h1 .day-star, .h2 .day-star { color: var(--gold); }
.day-dmout {
  display: flex; align-items: center; gap: 3px; margin-top: 4px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--no); white-space: nowrap;
}
.day-dmout .icon { width: 12px; height: 12px; }
.day.heat .day-dmout { margin: auto 0 2px; }

.legend .icon { width: 14px; height: 14px; color: var(--gold); fill: currentColor; }
.ramp { display: inline-flex !important; gap: 2px !important; }
.ramp i { width: 16px; height: 12px; border-radius: 2px; border: 1px solid var(--line); }
.swatch.hatch { height: 12px; width: 16px; border: 1px solid var(--line); background-color: var(--inset); background-image: var(--hatch); }
.swatch.dashed { height: 12px; width: 16px; border: 2px dashed var(--maybe); background: none; }

.verdict { display: flex; gap: 6px; align-items: flex-start; font-weight: 600; font-size: 0.96rem; margin: 2px 0 6px; }
.verdict .icon { margin-top: 3px; }
.verdict.tier-blocked { color: var(--no); }
.verdict.tier-ideal, .verdict.tier-viable { color: var(--yes); }
.verdict.tier-needs-dm, .verdict.tier-short { color: var(--maybe); }
.badge.warn { background: var(--maybe-bg); color: var(--maybe); border-color: var(--maybe); }

/* party grid */
.pgrid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.pgrid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.86rem; }
.pgrid th, .pgrid td { padding: 0; text-align: center; min-width: 25px; height: 32px; border-bottom: 1px solid var(--line); border-right: 1px solid color-mix(in srgb, var(--line) 50%, transparent); font-weight: 600; }
.pgrid tr:last-child > * { border-bottom: 0; }
.pgrid .pname {
  position: sticky; left: 0; z-index: 1; background: var(--card);
  text-align: left; padding: 3px 10px 3px 8px; white-space: nowrap; min-width: 118px;
  border-right: 1px solid var(--card-edge);
}
.pgrid tbody .pname { display: flex; align-items: center; gap: 6px; height: 33px; }
.pgrid .pname .dm-tag { margin-left: 0; }
.pgrid thead th { font-weight: 400; }
.pgrid thead button { display: grid; width: 100%; padding: 3px 0; background: none; border: 0; font-size: 0.66rem; line-height: 1.1; color: var(--ink-soft); }
.pgrid thead b { font-family: var(--font-display); font-size: 0.86rem; color: var(--ink); }
.pgrid td.c-yes { background-color: var(--yes-bg); color: var(--yes); }
.pgrid td.c-maybe { background-color: var(--maybe-bg); color: var(--maybe); }
.pgrid td.c-no { background-color: var(--no-bg); color: var(--no); }
.pgrid td.c-none { color: var(--ink-soft); }
.pgrid .col-past { opacity: 0.45; }
.pgrid .col-sel { box-shadow: inset 2px 0 var(--gold), inset -2px 0 var(--gold); }
.pgrid .sum td { font-family: var(--font-display); }

/* planning tools */
.mini { font-weight: 600; margin-bottom: 8px; }
.plan-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.plan-controls select { flex: 1; min-width: 0; min-height: 38px; padding: 4px 6px; font-size: 0.95rem; }
.wk { display: grid; grid-template-columns: 2.4em 1fr 8.2em; gap: 8px; align-items: center; font-size: 0.9rem; padding: 2px 0; color: var(--ink-soft); }
.wk.top { color: var(--ink); font-weight: 600; }
.wk-bar { height: 8px; background: var(--none); border-radius: 4px; overflow: hidden; }
.wk-bar i { display: block; height: 100%; background: var(--yes); border-radius: 4px; }
.wk-note { white-space: nowrap; }

/* ------------------------------------------------------ responsive */

@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .shell { padding: 0 12px 40px; }
  .card { padding: 16px 14px; }
  .brand-name { font-size: 1.2rem; }
  .brand-mark { width: 36px; height: 36px; }
  .user-chip { padding: 4px; }
  .user-chip span.label { display: none; }
  .cal-title { font-size: 1.25rem; }
  .grid { gap: 4px; }
  .day { min-height: 62px; padding: 4px; border-radius: 6px; }
  .day.has-session { padding: 3px; }
  .day-num { font-size: 0.92rem; }
  .day-mine { width: 16px; height: 16px; }
  .day-mine .icon { width: 10px; height: 10px; }
  .day-count { display: none; }
  .day-session span { display: none; }
  .day-session { margin-top: 3px; }
  .day-dmout span { display: none; }
  .day-dmout { margin-top: 3px; }
  .heat-count { font-size: 1.05rem; }
  .tab { font-size: 0.92rem; padding: 5px 4px; }
  .dow { font-size: 0.62rem; letter-spacing: 0.06em; }
  .brushes { gap: 6px; padding: 8px; }
  .brush { padding: 5px 8px; font-size: 0.88rem; gap: 4px; min-height: 36px; }
  .brush-sep { display: none; }
  .next-session { padding: 12px 14px; gap: 6px 12px; }
  .next-session > .icon { display: none; }
  .next-session .when { font-size: 1rem; }
  .next-session .countdown { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .day, .btn, .brush { transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s; }
}

/* ---------------------------------------------------- theme switch */

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; flex: none; border-radius: 999px; border: 1px solid var(--card-edge); background: var(--card); }
.theme-switch button { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 0; background: none; color: var(--ink-soft); }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.hero { display: flex; justify-content: center; align-items: flex-end; gap: 22px; }
.landing .hero .brand-mark { margin: 0 0 14px; }
.candle { display: none; }

/* ==================================================== tavern theme
   A dark plank wall lit by candles; every panel is a parchment notice
   tacked to the board. Inside the notices the palette is ink-on-paper,
   so all status colours keep their light-theme contrast. */

:root[data-theme="tavern"] {
  --font-display: "IM Fell English SC", "Cinzel", Georgia, serif;
  --font-sign: "Pirata One", "IM Fell English SC", Georgia, serif;
  --font-hand: "Caveat", "Crimson Pro", cursive;

  --bg: #24150a;
  --card: #f0dfb6;
  --card-edge: #b3915a;
  --inset: #e7d3a4;
  --ink: #2b1a0c;
  --ink-soft: #654d30;
  --line: #cfb682;
  --accent: #7a1b1b;
  --accent-hover: #952323;
  --accent-ink: #f9e8c1;
  --gold: #855411;
  --focus: #1f4f8a;

  --yes: #2c6a3a;
  --yes-bg: #cddbb0;
  --maybe: #96590a;
  --maybe-bg: #f1d28c;
  --no: #8f2c27;
  --no-bg: #e9c2ad;
  --none: #cbb586;
  --heat-ink: #fff;

  --shadow: 0 16px 26px -12px rgba(0, 0, 0, 0.85), 0 2px 5px rgba(0, 0, 0, 0.45);
  color-scheme: light;
  overflow-x: clip; /* candle glow may spill past the right edge */
}

:root[data-theme="tavern"] body {
  overflow-x: clip;
  background-color: var(--bg);
  background-image:
    /* wood grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='900'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.22 .006' numOctaves='4' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .05 0 0 0 0 .02 0 0 0 0 0 0 0 0 1.5 -.55'/%3E%3C/filter%3E%3Crect width='480' height='900' filter='url(%23g)'/%3E%3C/svg%3E"),
    /* plank seams with a lit edge */
    repeating-linear-gradient(90deg, transparent 0 157px, rgba(0, 0, 0, 0.6) 157px 160px, rgba(255, 205, 140, 0.07) 160px 161px, transparent 161px 320px),
    linear-gradient(180deg, #4a2d16 0%, #37210f 45%, #24150a 100%);
  background-attachment: scroll, scroll, fixed;
}

/* Warm pools of candlelight on the wall, and darkness at the edges. */
:root[data-theme="tavern"] body::before,
:root[data-theme="tavern"] body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; }
:root[data-theme="tavern"] body::before {
  background:
    radial-gradient(520px 420px at 6% 2%, rgba(255, 170, 70, 0.3), transparent 70%),
    radial-gradient(520px 420px at 94% 2%, rgba(255, 160, 60, 0.26), transparent 70%);
  animation: candle-glow 5.3s ease-in-out infinite;
}
:root[data-theme="tavern"] body::after { background: radial-gradient(ellipse at 50% 30%, transparent 45%, rgba(0, 0, 0, 0.55) 100%); }
:root[data-theme="tavern"] .shell,
:root[data-theme="tavern"] .landing { position: relative; z-index: 1; }

/* --- the shelf: sign, candles, controls */

:root[data-theme="tavern"] .topbar,
:root[data-theme="tavern"] .theme-corner {
  --card: #3a2312;
  --card-edge: #8c6a3a;
  --inset: #2a180b;
  --ink: #f4e3bd;
  --ink-soft: #cfb688;
  --none: #5c3e20;
  --focus: #ffd27a;
  color: var(--ink);
}
:root[data-theme="tavern"] .topbar { align-items: center; border-bottom: 0; padding: 18px 6px 11px; margin-bottom: 30px; }
:root[data-theme="tavern"] .topbar::after {
  left: -8px; right: -8px; bottom: 0; height: 11px; border: 0; border-radius: 2px;
  background: linear-gradient(180deg, #8a5c33 0%, #6a4324 35%, #452a14 100%);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 220, 160, 0.35);
}
:root[data-theme="tavern"] .topbar > .theme-switch,
:root[data-theme="tavern"] .topbar > .user-chip { margin-bottom: 12px; }

:root[data-theme="tavern"] .brand {
  flex: 0 1 auto; margin-right: auto; align-self: flex-end;
  padding: 8px 20px 8px 12px;
  background:
    linear-gradient(180deg, rgba(255, 210, 140, 0.12), transparent 30%),
    linear-gradient(180deg, #6b4222, #422711);
  border: 2px solid #1e1108; border-bottom-width: 3px; border-radius: 7px 7px 3px 3px;
  box-shadow: inset 0 0 0 2px rgba(240, 200, 120, 0.22), 0 6px 10px rgba(0, 0, 0, 0.5);
}
:root[data-theme="tavern"] .brand-name {
  font-family: var(--font-sign); font-weight: 400; font-size: 1.9rem; letter-spacing: 0.03em; line-height: 1;
  color: #f3cf7c; text-shadow: 0 2px 0 #1e1108, 0 0 14px rgba(255, 170, 60, 0.35);
}
:root[data-theme="tavern"] .brand-sub { font-family: var(--font-hand); font-style: normal; font-size: 1.15rem; line-height: 1.1; color: #e2c898; }
:root[data-theme="tavern"] .brand .brand-mark .die { fill: #a12626; }
:root[data-theme="tavern"] .brand .brand-mark { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6)); }

/* --- candles */

:root[data-theme="tavern"] .candle { display: block; position: relative; flex: none; align-self: flex-end; width: 18px; height: 58px; }
:root[data-theme="tavern"] .candle .wax {
  position: absolute; left: 2px; bottom: 0; width: 14px; height: 32px; border-radius: 4px 4px 1px 1px;
  background: linear-gradient(90deg, #cdb07a, #fff2cf 42%, #e8d09a 60%, #b99658);
  box-shadow: inset 0 5px 5px -1px rgba(255, 150, 50, 0.65), 0 2px 3px rgba(0, 0, 0, 0.5);
}
:root[data-theme="tavern"] .candle .wax::before { content: ""; position: absolute; left: 6px; top: -5px; width: 2px; height: 6px; border-radius: 1px; background: #23140a; }
:root[data-theme="tavern"] .candle .wax::after { content: ""; position: absolute; left: 1px; top: 3px; width: 4px; height: 12px; border-radius: 0 0 3px 3px; background: #fff0c8; opacity: 0.9; }
:root[data-theme="tavern"] .candle .flame {
  position: absolute; left: 50%; bottom: 35px; width: 10px; height: 21px; margin-left: -5px;
  border-radius: 50% 50% 50% 50% / 66% 66% 34% 34%;
  background: radial-gradient(ellipse at 50% 80%, #fffbe0 0 16%, #ffe06a 36%, #ff9a26 66%, rgba(255, 90, 0, 0) 100%);
  filter: drop-shadow(0 0 5px rgba(255, 170, 50, 0.95)) drop-shadow(0 0 14px rgba(255, 130, 20, 0.6));
  transform-origin: 50% 100%;
  animation: candle-flame 2.3s ease-in-out infinite;
}
:root[data-theme="tavern"] .candle::before {
  content: ""; position: absolute; left: 50%; bottom: 14px; width: 190px; height: 190px; margin-left: -95px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 90, 0.4), rgba(255, 140, 40, 0.13) 42%, transparent 70%);
  mix-blend-mode: screen; pointer-events: none;
  animation: candle-glow 3.7s ease-in-out infinite;
}
:root[data-theme="tavern"] .candle.b .flame { animation-duration: 2.9s; animation-delay: -1.1s; }
:root[data-theme="tavern"] .candle.b::before { animation-duration: 4.6s; animation-delay: -2s; }
:root[data-theme="tavern"] .landing .candle { margin-bottom: 14px; }

@keyframes candle-flame {
  0%, 100% { transform: scale(1, 1) rotate(-1deg); opacity: 1; }
  18% { transform: scale(1.04, 0.95) rotate(1.5deg); opacity: 0.94; }
  37% { transform: scale(0.96, 1.06) rotate(-2deg); opacity: 1; }
  55% { transform: scale(1.03, 0.98) rotate(0.5deg); opacity: 0.9; }
  76% { transform: scale(0.98, 1.04) rotate(2deg); opacity: 1; }
}
@keyframes candle-glow {
  0%, 100% { opacity: 0.86; }
  22% { opacity: 1; }
  41% { opacity: 0.8; }
  63% { opacity: 0.96; }
  82% { opacity: 0.84; }
}

/* --- notices tacked to the board */

:root[data-theme="tavern"] .card {
  border: 0;
  border-radius: 3px 7px 4px 8px / 7px 3px 8px 4px;
  background-color: var(--card);
  background-image:
    radial-gradient(ellipse at 12% 8%, rgba(150, 95, 30, 0.14), transparent 55%),
    radial-gradient(ellipse at 90% 96%, rgba(120, 70, 20, 0.16), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .22 0 0 0 0 .08 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23p)'/%3E%3C/svg%3E");
  box-shadow: var(--shadow), inset 0 0 46px rgba(130, 85, 30, 0.3);
}
:root[data-theme="tavern"] .card::before { display: none; }
:root[data-theme="tavern"] .card::after {
  /* brass tack */
  content: ""; position: absolute; top: -7px; left: 50%; width: 17px; height: 17px; margin-left: -8px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffe9a8, #c9962b 48%, #6a4509 100%);
  box-shadow: 0 4px 5px rgba(0, 0, 0, 0.55), inset 0 -1px 2px rgba(0, 0, 0, 0.35);
}
:root[data-theme="tavern"] .side .card:nth-child(odd) { transform: rotate(0.45deg); }
:root[data-theme="tavern"] .side .card:nth-child(even) { transform: rotate(-0.4deg); }
:root[data-theme="tavern"] .side { gap: 24px; }

:root[data-theme="tavern"] .card-title { font-size: 1.02rem; letter-spacing: 0.1em; text-transform: none; }
:root[data-theme="tavern"] .cal-title,
:root[data-theme="tavern"] .landing h1 { font-family: var(--font-sign); font-weight: 400; letter-spacing: 0.03em; }
:root[data-theme="tavern"] .cal-title { font-size: 2.2rem; line-height: 1.1; }
:root[data-theme="tavern"] .landing h1 { font-size: 3.4rem; color: var(--accent); }
:root[data-theme="tavern"] .landing .campaign,
:root[data-theme="tavern"] .brush-hint,
:root[data-theme="tavern"] .next-session .note { font-family: var(--font-hand); font-style: normal; font-size: 1.25rem; line-height: 1.15; }
:root[data-theme="tavern"] .dow { font-size: 0.9rem; letter-spacing: 0.06em; text-transform: none; }
:root[data-theme="tavern"] .day { border-radius: 3px 5px 4px 6px; box-shadow: 0 1px 2px rgba(80, 50, 15, 0.25); }
:root[data-theme="tavern"] .day-num { font-size: 1.2rem; }
:root[data-theme="tavern"] .detail-date { font-size: 1.3rem; }
:root[data-theme="tavern"] .btn, :root[data-theme="tavern"] .brush, :root[data-theme="tavern"] .input { border-radius: 4px 6px 5px 7px; }
:root[data-theme="tavern"] .btn.primary { box-shadow: inset 0 1px 0 rgba(255, 200, 160, 0.3), 0 2px 3px rgba(60, 20, 10, 0.4); }

/* --- next session: a cloth banner with stitched gold edging */

:root[data-theme="tavern"] .next-session {
  position: relative; border: 0; border-radius: 3px; padding: 18px 24px;
  background: linear-gradient(180deg, #8f2222, #6a1616);
  box-shadow: var(--shadow), inset 0 0 30px rgba(0, 0, 0, 0.35);
  outline: 2px dashed rgba(243, 207, 124, 0.7); outline-offset: -7px;
  color: #fbe9c2;
  animation: candle-lit 4.9s ease-in-out infinite;
}
@keyframes candle-lit {
  0%, 100% { filter: brightness(1); }
  24% { filter: brightness(1.09); }
  43% { filter: brightness(0.97); }
  66% { filter: brightness(1.06); }
  85% { filter: brightness(0.99); }
}
:root[data-theme="tavern"] .next-session .when { font-family: var(--font-sign); font-weight: 400; font-size: 1.6rem; letter-spacing: 0.03em; color: #f6d68a; }
:root[data-theme="tavern"] .next-session .eyebrow { font-size: 0.86rem; text-transform: none; }

:root[data-theme="tavern"] dialog { background-color: var(--card); border: 0; border-radius: 3px 7px 4px 8px; box-shadow: 0 30px 80px -10px rgba(0, 0, 0, 0.9), inset 0 0 46px rgba(130, 85, 30, 0.3); }
:root[data-theme="tavern"] dialog::backdrop { background: rgba(12, 6, 2, 0.7); }
:root[data-theme="tavern"] .toast { background: #f0dfb6; color: #2b1a0c; border: 1px solid #b3915a; }
:root[data-theme="tavern"] .toast.error { background: var(--no); color: #fff; }

@media (max-width: 600px) {
  :root[data-theme="tavern"] .topbar { padding: 14px 2px 11px; gap: 8px; }
  :root[data-theme="tavern"] .topbar .candle.b { display: none; }
  :root[data-theme="tavern"] .brand { padding: 6px 12px 6px 8px; gap: 8px; }
  :root[data-theme="tavern"] .brand-name { font-size: 1.45rem; }
  :root[data-theme="tavern"] .brand-sub { font-size: 1rem; }
  :root[data-theme="tavern"] .cal-title { font-size: 1.7rem; }
  :root[data-theme="tavern"] .next-session .when { font-size: 1.25rem; }
  :root[data-theme="tavern"] .side .card { transform: none; }
  .theme-switch button { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="tavern"] body::before,
  :root[data-theme="tavern"] .candle .flame,
  :root[data-theme="tavern"] .candle::before,
  :root[data-theme="tavern"] .next-session { animation: none; }
}

/* sign-in button: our own styling, not a copy of Discord's */
.btn.signin { font-size: 1.1rem; padding: 12px 22px; }
.btn.signin svg { width: 22px; height: 22px; fill: currentColor; }
.signin-note { margin-top: 12px; }
