:root {
  --ink: #1b1712;          /* deep umber background */
  --panel: #26201a;        /* raised surfaces */
  --panel-2: #2f2820;      /* inputs, hover */
  --line: #3d342a;         /* hairline borders */
  --parchment: #e8dfce;    /* primary text */
  --parchment-dim: #a89a82;/* secondary text */
  --gold: #c9a86a;         /* accent */
  --known: #7fa65a;        /* party knows */
  --partial: #d9a741;      /* partially known */
  --secret: #a8503c;       /* GM only */
  --display: 'Marcellus', serif;
  --body: 'Alegreya Sans', system-ui, sans-serif;
}

/* Frostbound — northern reaches, ice and steel */
[data-theme="frost"] {
  --ink: #101822; --panel: #182432; --panel-2: #1f2d3d; --line: #2c3d50;
  --parchment: #e2ecf5; --parchment-dim: #8ba3ba; --gold: #7fc3e8;
  --known: #6fb98a; --partial: #e0b96a; --secret: #c4666b;
}

/* Feywild — verdant and unruly */
[data-theme="fey"] {
  --ink: #12190f; --panel: #1b2517; --panel-2: #24301e; --line: #35452b;
  --parchment: #e9f0dd; --parchment-dim: #9db38c; --gold: #cf9de0;
  --known: #8fc46a; --partial: #e6c65c; --secret: #d1657f;
}

/* Bloodmoon — crimson and ash */
[data-theme="bloodmoon"] {
  --ink: #16100f; --panel: #211615; --panel-2: #2c1d1c; --line: #3f2926;
  --parchment: #f0dedb; --parchment-dim: #b0918c; --gold: #d2724f;
  --known: #8aa563; --partial: #d9a03f; --secret: #b83b3b;
}

/* Abyssal — deep water, wildspace, the dark below */
[data-theme="abyssal"] {
  --ink: #0c1618; --panel: #132224; --panel-2: #1a2d30; --line: #254043;
  --parchment: #dcecec; --parchment-dim: #85a5a7; --gold: #5fd0c4;
  --known: #62b98f; --partial: #d9b95e; --secret: #c0616f;
}

/* Arcane — violet and silver */
[data-theme="arcane"] {
  --ink: #15111d; --panel: #1e1929; --panel-2: #272034; --line: #372e4a;
  --parchment: #e8e2f4; --parchment-dim: #a294bd; --gold: #b79bf0;
  --known: #7fb589; --partial: #d7b264; --secret: #c9607f;
}

/* Old Parchment — daylight reading */
[data-theme="parchment"] {
  --ink: #e9e0cc; --panel: #f3ecdc; --panel-2: #e2d7c0; --line: #c9b995;
  --parchment: #2f2618; --parchment-dim: #7a6c53; --gold: #8a6a2f;
  --known: #4d7a35; --partial: #a87a17; --secret: #9a3d2c;
}
[data-theme="parchment"] .entry-art,
[data-theme="parchment"] .feed-art { box-shadow: 0 3px 10px rgba(90,70,40,0.25); }
[data-theme="parchment"] .pin-label { background: rgba(243,236,220,0.9); }
[data-theme="parchment"] .btn-google { background: #2f2618; color: #f3ecdc; }
[data-theme="parchment"] .comment-avatar-letter { color: #8a6a2f; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}
.hidden { display: none !important; }

h1, h2, h3, .brand { font-family: var(--display); font-weight: 400; letter-spacing: 0.02em; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  padding: 32px 28px;
}
.brand { color: var(--gold); margin: 0 0 4px; font-size: 28px; }
.brand.small { font-size: 18px; }
.login-sub { color: var(--parchment-dim); margin: 0 0 24px; font-style: italic; }

label { display: block; margin-bottom: 14px; color: var(--parchment-dim); font-size: 14px; }
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--parchment);
  font-family: var(--body);
  font-size: 16px;
  padding: 9px 10px;
  border-radius: 3px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

button {
  font-family: var(--body);
  font-size: 15px;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.btn-primary {
  width: 100%;
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  border: none;
  padding: 11px;
  margin-top: 8px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--parchment-dim);
  padding: 7px 12px;
}
.btn-ghost:hover { color: var(--gold); border-color: var(--gold); }
.error { color: var(--secret); font-size: 14px; }

/* ---------- Layout ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.campaign-controls { display: flex; gap: 8px; flex: 1; max-width: 420px; }
#campaign-select { margin-top: 0; }

#layout {
  display: flex;
  height: calc(100vh - 53px);
}
#sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 0 40px;
}
#editor {
  flex: 1;
  overflow-y: auto;
  padding: 28px clamp(16px, 4vw, 48px) 80px;
}
#empty-state { color: var(--parchment-dim); font-style: italic; margin-top: 20vh; text-align: center; }

/* ---------- Sidebar ---------- */
.type-section { margin-bottom: 6px; }
.type-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px 4px;
  color: var(--gold);
  font-family: var(--display);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.type-header button {
  border: none; background: none; color: var(--parchment-dim);
  font-size: 18px; line-height: 1; padding: 0 4px;
}
.type-header button:hover { color: var(--gold); }
.type-toggle {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  text-align: left;
  color: var(--gold) !important;
  font-family: var(--display);
  font-size: 14px !important;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 0 !important;
}
.type-toggle:hover { filter: brightness(1.2); }
.chev { font-size: 11px; color: var(--parchment-dim); width: 12px; }
.entry-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none;
  color: var(--parchment);
  padding: 6px 14px 6px 22px;
  font-size: 15px;
  border-left: 3px solid transparent;
  border-radius: 0;
}
.entry-item:hover { background: var(--panel-2); }
.entry-item.active { border-left-color: var(--gold); background: var(--panel-2); }
.entry-item.is-public::after { content: ' \2726'; color: var(--gold); }
/* Players see only public cards, so the star would be on every row */
body.player-mode .entry-item.is-public::after { content: none; }
.loc-row { display: flex; align-items: center; border-left: 3px solid transparent; }
.loc-row:hover { background: var(--panel-2); }
.loc-row.active { border-left-color: var(--gold); background: var(--panel-2); }
.loc-row .entry-item { flex: 1; padding-left: 2px; border-left: none; }
.loc-row:hover .entry-item, .loc-row.active .entry-item { background: none; }
.loc-twisty {
  background: none; border: none; border-radius: 0;
  color: var(--parchment-dim);
  font-size: 11px;
  padding: 4px 4px;
  width: 18px;
}
.loc-twisty:hover { color: var(--gold); }
.loc-twisty-spacer { width: 18px; display: inline-block; }
.loc-count { color: var(--parchment-dim); font-size: 12px; }
.type-empty { color: var(--parchment-dim); font-size: 13px; padding: 2px 22px 6px; font-style: italic; }

/* ---------- Editor ---------- */
.entry-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
#entry-name {
  font-family: var(--display);
  font-size: 30px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  padding: 2px 0;
  color: var(--parchment);
  flex: 1;
  min-width: 200px;
}
#entry-name:hover, #entry-name:focus { border-bottom-color: var(--line); }
.entry-type-badge {
  color: var(--gold);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.entry-meta { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0 24px; }
.entry-meta label { flex: 1; min-width: 180px; max-width: 320px; margin: 0; }

.section-title {
  color: var(--gold);
  font-size: 17px;
  margin: 28px 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

/* Card top: meta + art */
.card-top { display: flex; gap: 24px; align-items: flex-start; }
.card-top .entry-meta { flex: 1; }
.art-panel { width: 200px; flex-shrink: 0; margin: 12px 0 24px; }
.entry-art {
  width: 100%;
  display: block;
  border: 1px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}
.art-actions { display: flex; gap: 6px; margin-top: 6px; }
.art-actions .btn-ghost { font-size: 13px; padding: 4px 8px; }
.art-remove:hover { color: var(--secret); border-color: var(--secret); }
.art-empty {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--panel);
  border: 1px dashed var(--line);
  color: var(--parchment-dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px;
}
.art-empty:hover { border-color: var(--gold); color: var(--gold); }
.art-empty-icon { font-size: 22px; color: var(--gold); }
@media (max-width: 720px) {
  .card-top { flex-direction: column-reverse; }
  .art-panel { width: 100%; max-width: 280px; margin-bottom: 0; }
}

/* Link fields & chips */
.link-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 18px; }
.link-field-label { color: var(--parchment-dim); font-size: 13px; margin-bottom: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  overflow: hidden;
}
.chip-name, .chip.chip-nav {
  background: none; border: none;
  color: var(--parchment);
  padding: 4px 6px 4px 12px;
  font-size: 14px;
}
.chip.chip-nav { padding: 4px 12px; border-radius: 999px; }
.chip-name:hover, .chip.chip-nav:hover { color: var(--gold); }
.chip-type { color: var(--parchment-dim); font-size: 12px; }
.chip-x {
  background: none; border: none; color: var(--parchment-dim);
  padding: 4px 10px 4px 2px; font-size: 12px;
}
.chip-x:hover { color: var(--secret); }
.picker-wrap { position: relative; }
.picker-input { width: 150px; margin-top: 0; font-size: 14px; padding: 5px 10px; border-radius: 999px; }
.suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.suggestion {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-radius: 0;
  color: var(--parchment);
  padding: 8px 12px; font-size: 14px;
}
.suggestion:hover { background: var(--ink); color: var(--gold); }
.suggestion-none { color: var(--parchment-dim); font-size: 13px; padding: 8px 12px; font-style: italic; }
.extra-refs { margin-top: 14px; color: var(--parchment-dim); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hint { color: var(--parchment-dim); font-size: 13px; font-style: italic; margin-top: 10px; }

/* Info blocks — the signature element */
.info-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--secret);
  margin-bottom: 14px;
  padding: 12px 14px;
}
.info-block[data-status="party_knows"]    { border-left-color: var(--known); }
.info-block[data-status="partially_known"]{ border-left-color: var(--partial); }
.info-block[data-status="gm_only"]        { border-left-color: var(--secret); }

.info-block-top { display: flex; gap: 10px; margin-bottom: 8px; align-items: center; }
.info-block-top input[type="text"] { margin-top: 0; font-weight: 500; }
.info-block-top select { margin-top: 0; width: auto; font-size: 13px; }
.info-block textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.55;
}
.block-delete {
  background: none; border: none; color: var(--parchment-dim);
  font-size: 16px; padding: 4px 6px;
}
.block-delete:hover { color: var(--secret); }
.block-toggle {
  background: none; border: none; color: var(--parchment-dim);
  font-size: 15px; padding: 4px 6px;
}
.block-toggle:hover { color: var(--gold); }
.block-heading-view { flex: 1; font-weight: 700; color: var(--parchment); }
.block-body { position: relative; }
.block-rendered {
  white-space: pre-wrap;
  line-height: 1.55;
  min-height: 24px;
  padding: 2px 1px;
}
.wiki-link {
  background: none; border: none; padding: 0;
  color: var(--gold);
  font-size: inherit; font-family: inherit;
  text-decoration: underline dotted;
  cursor: pointer;
}
.wiki-link:hover { text-decoration-style: solid; background: rgba(201,168,106,0.12); }
.wiki-broken { color: var(--parchment-dim); border-bottom: 1px dashed var(--parchment-dim); }
.bracket-sug { top: auto; bottom: calc(100% + 4px); left: 8px; }

.editor-actions { display: flex; gap: 10px; margin-top: 28px; align-items: center; }
.editor-actions .btn-primary { width: auto; padding: 10px 22px; margin: 0; }
#save-note { color: var(--parchment-dim); font-size: 14px; }
.btn-danger {
  background: transparent; color: var(--secret);
  border: 1px solid var(--secret);
  padding: 9px 14px;
}
.btn-danger:hover { background: var(--secret); color: var(--parchment); }

/* View toggle & graph */
#view-toggle { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.toggle-btn {
  background: transparent; border: none; border-radius: 0;
  color: var(--parchment-dim);
  padding: 7px 14px; font-size: 14px;
}
.toggle-btn.active { background: var(--gold); color: var(--ink); font-weight: 700; }
.toggle-btn:not(.active):hover { color: var(--gold); }
#graph-view { flex: 1; position: relative; }
#graph-canvas { position: absolute; inset: 0; }
#graph-legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; gap: 12px; flex-wrap: wrap;
  background: rgba(38,32,26,0.85);
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 13px; color: var(--parchment-dim);
  pointer-events: none;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Modals, dates, timeline */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,12,9,0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: min(460px, 100%);
  max-height: 82vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  padding: 22px 24px;
}
.modal h2 { color: var(--gold); font-size: 20px; margin: 0 0 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary { width: auto; padding: 9px 22px; margin: 0; }
.month-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.month-row input[type="text"] { flex: 1; margin-top: 0; }
.month-row input[type="number"] { width: 74px; margin-top: 0; }
.date-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.date-row input[type="number"] { width: 76px; margin-top: 0; }
.date-row select { width: auto; flex: 1; margin-top: 0; }
.era { color: var(--gold); font-size: 14px; }
#today-chip { white-space: nowrap; }

#timeline-view { flex: 1; overflow-y: auto; padding: 28px 16px 80px; }
.timeline {
  max-width: 620px; margin: 0 auto;
  position: relative;
  padding-left: 26px;
}
.timeline::before {
  content: '';
  position: absolute; left: 7px; top: 44px; bottom: 8px;
  width: 1px; background: var(--line);
}
.tl-heading { color: var(--gold); font-size: 24px; margin: 0 0 24px; margin-left: -26px; }
.tl-item { position: relative; margin-bottom: 22px; }
.tl-item::before {
  content: '';
  position: absolute; left: -23px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--partial);
}
.tl-item-undated::before { background: var(--parchment-dim); }
.tl-item-letter::before { background: #9b7fae; }
.tl-date { color: var(--parchment-dim); font-size: 13px; letter-spacing: 0.04em; }
.tl-name {
  background: none; border: none; padding: 0;
  font-family: var(--display); font-size: 19px;
  color: var(--parchment); text-align: left;
}
.tl-name:hover { color: var(--gold); }
.tl-title { color: var(--parchment-dim); font-size: 14px; font-style: italic; }
.tl-today {
  position: relative;
  color: var(--secret);
  font-family: var(--display);
  font-size: 15px;
  margin: 26px 0;
  padding: 6px 0;
  border-top: 1px solid var(--secret);
  border-bottom: 1px solid var(--secret);
}
.tl-undated-heading { color: var(--parchment-dim); font-size: 15px; margin: 34px 0 14px; }

/* Correspondence forum */
.corr-heading { color: var(--gold); font-size: 24px; margin: 0 0 18px; }
.corr-row { border: 1px solid var(--line); border-bottom: none; background: var(--panel); }
.corr-row:last-of-type { border-bottom: 1px solid var(--line); }
.corr-row-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  width: 100%;
  background: none; border: none; border-radius: 0;
  padding: 12px 16px;
  text-align: left;
}
.corr-row-head:hover { background: var(--panel-2); }
.corr-row-head.open { background: var(--panel-2); border-bottom: 1px solid var(--line); }
.corr-label { color: var(--parchment); font-size: 15px; font-weight: 500; }
.corr-row-head:hover .corr-label { color: var(--gold); }
.corr-date { color: var(--parchment-dim); font-size: 13px; white-space: nowrap; }
.corr-expand { padding: 14px 16px 16px; }
.corr-meta { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.corr-intercept { color: var(--parchment-dim); font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Map view */
#map-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#map-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
#map-toolbar .btn-ghost.placing { color: var(--ink); background: var(--gold); border-color: var(--gold); }
.map-count { color: var(--parchment-dim); font-size: 13px; }
.map-spacer { flex: 1; }
#map-scroll { flex: 1; overflow: auto; background: var(--ink); }
.map-wrap { position: relative; width: 100%; transition: width 0.15s ease; }
.map-wrap.placing { cursor: crosshair; }
.map-img { display: block; width: 100%; height: auto; user-select: none; }
.map-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  height: 100%; min-height: 50vh; color: var(--parchment-dim); text-align: center; padding: 24px;
}
.map-empty .btn-primary { width: auto; padding: 10px 22px; }

.map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center;
  cursor: grab;
  touch-action: none;
}
.map-pin.dragging { cursor: grabbing; z-index: 10; }
.pin-dot {
  width: 13px; height: 13px;
  background: var(--secret);
  border: 2px solid var(--parchment);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 5px rgba(0,0,0,0.6);
}
.map-pin:hover .pin-dot { background: var(--gold); }
.pin-label {
  margin-top: 3px;
  font-size: 12px;
  color: var(--parchment);
  background: rgba(27,23,18,0.82);
  border: 1px solid var(--line);
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
}
.pin-picker { max-height: 46vh; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); }

/* Landing / seat picker */
#landing-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card.landing { text-align: center; }
.seat-btn {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--parchment);
  padding: 16px 18px;
  margin-top: 12px;
}
.seat-btn:hover { border-color: var(--gold); }
.seat-title { font-family: var(--display); font-size: 19px; color: var(--gold); }
.seat-sub { font-size: 13px; color: var(--parchment-dim); }
.btn-google {
  width: 100%;
  background: var(--parchment);
  color: #1b1712;
  border: none;
  font-weight: 700;
  padding: 11px;
  margin-bottom: 6px;
}
.btn-google:hover { filter: brightness(1.05); }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--parchment-dim); font-size: 13px; margin: 14px 0; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.btn-ghost.full { width: 100%; margin-top: 8px; }
.role-badge {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 3px 9px; border: 1px solid var(--line); color: var(--parchment-dim);
}
.role-badge.dm { color: var(--gold); border-color: var(--gold); }
.invite-url { margin: 10px 0; font-size: 13px; }

/* Comments */
#comments { margin-top: 4px; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line);
}
.comment-avatar-letter {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--gold);
  font-family: var(--display); font-size: 16px;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-author { font-weight: 700; color: var(--parchment); }
.comment-when { color: var(--parchment-dim); font-size: 12px; }
.comment-del { background: none; border: none; color: var(--parchment-dim); font-size: 12px; margin-left: auto; padding: 2px 4px; }
.comment-del:hover { color: var(--secret); }
.comment-text { white-space: pre-wrap; line-height: 1.5; }
.comment-compose { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; }
.comment-input { flex: 1; margin-top: 0; resize: vertical; }
.comment-post { width: auto !important; padding: 9px 18px !important; margin: 0 !important; }

/* Session notes */
#sessions-view { flex: 1; overflow-y: auto; padding: 28px 16px 80px; }
.sessions-wrap { max-width: 680px; margin: 0 auto; }
.session-note { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--gold); padding: 14px 16px; margin-bottom: 14px; }
.session-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.session-title { font-family: var(--display); font-size: 19px; color: var(--parchment); }
.session-meta { color: var(--parchment-dim); font-size: 13px; margin-bottom: 8px; }
.session-del { font-size: 13px; padding: 3px 8px; margin-top: 8px; }
.session-compose { margin-top: 30px; position: relative; }
.session-compose input, .session-compose textarea { margin-bottom: 8px; }
.session-compose .btn-primary { width: auto; padding: 10px 22px; }

/* The feed */
#feed-view { flex: 1; overflow-y: auto; padding: 28px 16px 80px; }
.feed-wrap { max-width: 620px; margin: 0 auto; }
.feed-heading.renamable { cursor: pointer; }
.feed-heading.renamable:hover { filter: brightness(1.15); }
.feed-composer { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 22px; position: relative; }
.feed-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.feed-card.feed-reveal { border-left: 4px solid var(--known); }
.feed-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.feed-head .comment-avatar { width: 28px; height: 28px; }
.feed-kind { color: var(--parchment-dim); font-size: 13px; }
.feed-card .comment-when { margin-left: auto; }
.feed-title {
  background: none; border: none; padding: 0;
  font-family: var(--display); font-size: 20px;
  color: var(--gold); text-align: left;
}
.feed-title:hover { text-decoration: underline; }
.feed-title-static { font-family: var(--display); font-size: 18px; color: var(--parchment); }
.feed-art {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  margin: 10px 0; border: 1px solid var(--line);
}
.feed-body { white-space: pre-wrap; line-height: 1.55; margin-top: 6px; }
.feed-link { font-size: 13px; padding: 4px 10px; margin-top: 10px; }

/* Reactions */
.reaction-bar { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 10px; }
.reaction-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 14px;
  line-height: 1.6;
}
.reaction-pill:hover { border-color: var(--gold); }
.reaction-pill.mine { border-color: var(--gold); background: rgba(201,168,106,0.16); }
.reaction-count { color: var(--parchment-dim); font-size: 12px; }
.reaction-pill.mine .reaction-count { color: var(--gold); }
.reaction-add-wrap { position: relative; display: inline-block; }
.reaction-add {
  background: none; border: 1px solid transparent; border-radius: 999px;
  color: var(--parchment-dim);
  font-size: 13px; padding: 2px 8px;
}
.reaction-add:hover { color: var(--gold); border-color: var(--line); }
.reaction-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 2px;
  width: 200px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
  padding: 6px;
}
.reaction-choice {
  background: none; border: none;
  font-size: 19px; padding: 4px 6px; line-height: 1;
}
.reaction-choice:hover { background: var(--ink); }

/* New-to-you marker */
.new-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px;
  margin-left: 6px;
  background: var(--secret);
  color: var(--parchment);
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.section-mark { background: var(--gold); color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .new-mark { animation: mark-in 0.25s ease; }
  @keyframes mark-in { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.theme-swatch {
  border: 1px solid var(--line);
  background: none;
  padding: 0;
  overflow: hidden;
  text-align: left;
}
.theme-swatch.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.theme-preview { display: flex; height: 46px; }
.theme-bar { flex: 1; }
.theme-name { display: block; padding: 7px 10px; font-size: 14px; color: var(--parchment); }
.theme-swatch:hover .theme-name { color: var(--gold); }

/* Gear menu */
#gear-wrap { position: relative; }
#gear-btn { font-size: 18px; line-height: 1; padding: 6px 10px; }
#gear-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 190px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  box-shadow: 0 8px 22px rgba(0,0,0,0.55);
  padding: 4px 0;
}
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-radius: 0;
  color: var(--parchment);
  padding: 9px 14px;
  font-size: 14px;
}
.menu-item:hover { background: var(--ink); color: var(--gold); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

.diag { margin-top: 22px; color: var(--parchment-dim); font-size: 13px; text-align: left; max-width: 460px; }
.diag summary { cursor: pointer; }
.diag-body { white-space: pre-wrap; margin-top: 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); font-family: ui-monospace, monospace; font-size: 12px; }

/* Join code */
.join-code {
  font-family: var(--display);
  font-size: 38px;
  letter-spacing: 0.22em;
  text-align: center;
  color: var(--gold);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 18px 10px;
  margin: 14px 0 10px;
}
.code-actions { display: flex; gap: 8px; }

/* Roster */
.roster-list { margin-top: 12px; }
.roster-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.roster-name { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 8px; }
.roster-role {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--line); padding: 1px 6px; color: var(--parchment-dim);
}
.roster-role.dm { color: var(--gold); border-color: var(--gold); }
.roster-you { color: var(--parchment-dim); font-size: 12px; font-style: italic; }
.roster-pc { margin: 0; font-size: 12px; color: var(--parchment-dim); }
.roster-pc select { margin-top: 2px; width: auto; min-width: 150px; font-size: 13px; padding: 5px 8px; }
.roster-remove { font-size: 13px; padding: 6px 12px; }

/* Drag to reorder */
.side-row { display: flex; align-items: center; border-left: 3px solid transparent; }
.side-row:hover { background: var(--panel-2); }
.side-row.active { border-left-color: var(--gold); background: var(--panel-2); }
.side-row .entry-item { flex: 1; padding-left: 2px; border-left: none; }
.side-row:hover .entry-item, .side-row.active .entry-item { background: none; }
.drag-handle {
  width: 18px; flex-shrink: 0;
  color: transparent;
  font-size: 13px; text-align: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  padding: 4px 0;
}
.side-row:hover .drag-handle, .loc-row:hover .drag-handle { color: var(--parchment-dim); }
.drag-handle:hover { color: var(--gold) !important; }
.dragging-row {
  opacity: 0.85;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  position: relative; z-index: 40;
  cursor: grabbing;
  pointer-events: none;
}
.drop-line { height: 2px; background: var(--gold); margin: 0 8px; }
body.player-mode .drag-handle { display: none; }
@media (pointer: coarse) {
  .drag-handle { color: var(--parchment-dim); }
}

/* ---------- Small screens (iPhone) ---------- */
@media (max-width: 720px) {
  #topbar { flex-wrap: wrap; row-gap: 8px; }
  #layout { flex-direction: column; height: auto; }
  #graph-view { min-height: 70vh; }
  #map-view { min-height: 70vh; }
  #sessions-view { min-height: 60vh; }
  #feed-view { min-height: 60vh; }
  #sidebar { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
  #editor { padding-bottom: 120px; }
}

@media (prefers-reduced-motion: no-preference) {
  .entry-item, button, .info-block { transition: all 0.12s ease; }
}

/* Calendar + timeline split */
.cal-split { display: flex; gap: 18px; align-items: flex-start; max-width: 1100px; margin: 0 auto; }
.cal-block {
  width: 320px; flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  position: sticky; top: 0;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { color: var(--gold); font-family: var(--display); font-size: 16px; }
.cal-arrow {
  background: none; border: none; color: var(--parchment-dim);
  font-size: 20px; line-height: 1; padding: 2px 10px;
}
.cal-arrow:hover { color: var(--gold); }
.cal-week { display: grid; gap: 3px; margin-bottom: 4px; }
.cal-wd { text-align: center; font-size: 10px; color: var(--parchment-dim); letter-spacing: 0.04em; }
.cal-grid { display: grid; gap: 3px; }
.cal-day {
  aspect-ratio: 1;
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  color: var(--parchment);
  font-size: 11px;
}
.cal-day:hover { border-color: var(--gold); }
.cal-day.is-today { border-color: var(--secret); border-width: 2px; background: rgba(168,80,60,0.14); }
.cal-day.is-selected { background: var(--panel-2); border-color: var(--gold); }
.cal-num { line-height: 1; }
.cal-dots { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.cal-bar { height: 3px; border-radius: 2px; display: block; }
.cal-daylist { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.cal-daylist-head { font-size: 11px; color: var(--parchment-dim); margin-bottom: 6px; letter-spacing: 0.04em; }
.cal-dayitem {
  display: flex; align-items: center; gap: 7px;
  width: 100%; text-align: left;
  background: none; border: none; border-radius: 0;
  color: var(--parchment); font-size: 13px; padding: 4px 0;
}
.cal-dayitem:hover { color: var(--gold); }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cal-pub { color: var(--gold); }
.cal-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.cal-actions .btn-ghost { font-size: 13px; padding: 5px 10px; }
.tl-column { flex: 1; min-width: 0; }
.tl-item-recurring::before { background: var(--dot, var(--partial)); }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--parchment); font-size: 14px; }
.check-row input[type="checkbox"] { width: auto; margin: 0; }
.scope-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.scope-actions .btn-primary { width: 100%; margin: 0; }
.scope-overlay { z-index: 120; }

@media (max-width: 900px) {
  .cal-split { flex-direction: column; }
  .cal-block { width: 100%; max-width: 420px; position: static; }
}

/* Date order controls */
.order-toggle {
  border: none; background: none;
  color: var(--parchment-dim);
  font-size: 13px; line-height: 1; padding: 0 4px;
}
.order-toggle:hover { color: var(--gold); }
.corr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.corr-top .corr-heading { margin: 0; }
.order-btn { font-size: 13px; padding: 4px 10px; white-space: nowrap; }

/* Date and its note stay stacked together */
.date-group { flex: 1 1 260px; min-width: 240px; max-width: 340px; display: flex; flex-direction: column; }
.date-group .date-label { margin: 0; }
.date-group .date-note { margin: 8px 0 0; }
.date-group .date-check { margin: 10px 0 0; font-size: 13px; }

/* Deceased */
.dead-mark { color: var(--secret); }
.entry-item.is-dead { color: var(--parchment-dim); }
.dead-badge { color: var(--secret); font-size: 20px; }
