/* Campaign Writer — the structured view and the raw file, side by side. */

.writer-load {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 18px 0 10px;
}
.writer-loadbtn {
  display: inline-block; padding: 9px 16px; border-radius: 6px;
  background: #7b2cbf; color: #fff; cursor: pointer; font-weight: 600;
}
.writer-loadbtn:hover { background: #6a25a5; }
.writer-or { color: #8892b0; font-size: 0.9rem; }
.writer-paste {
  flex: 1; min-width: 260px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem; padding: 8px; border: 1px solid #2a2a4a; border-radius: 6px;
  background: #16213e; color: #e0e0e0; resize: vertical;
}
.writer-btn {
  padding: 9px 16px; border: 0; border-radius: 6px; cursor: pointer;
  background: #7b2cbf; color: #fff; font-weight: 600; font-size: 0.9rem;
}
.writer-btn:hover { background: #6a25a5; }
.writer-btn-ghost { background: transparent; color: #7b2cbf; border: 1px solid #2a2a4a; }
.writer-btn-ghost:hover { background: rgba(123, 44, 191, 0.12); }

.writer-actions { display: flex; gap: 8px; margin: 10px 0 14px; }

/* Status is the first thing an author reads, so it states the outcome in
   words rather than only colouring something. */
.writer-status {
  padding: 10px 13px; border-radius: 6px; font-size: 0.9rem;
  background: #16213e; color: #8892b0; border: 1px solid #2a2a4a;
}
.writer-status-good { background: rgba(100, 255, 218, 0.08); color: #64ffda; border-color: #1e5f52; }
.writer-status-bad  { background: rgba(255, 107, 107, 0.08); color: #ff6b6b; border-color: #6f2626; }

.writer-split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px; margin: 14px 0;
}
@media (max-width: 900px) { .writer-split { grid-template-columns: 1fr; } }

.writer-pane {
  border: 1px solid #2a2a4a; border-radius: 8px; overflow: hidden;
  background: #16213e; display: flex; flex-direction: column;
}
.writer-pane-head {
  padding: 8px 12px; background: #1a1a2e; border-bottom: 1px solid #2a2a4a;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8892b0;
}
.writer-outline, .writer-raw {
  /* Both panes scroll independently and to the same height, so a long
     campaign does not push the page itself into a mile of scrolling. */
  height: 460px; overflow: auto; margin: 0;
}
.writer-outline { padding: 10px 12px; }
.writer-raw {
  padding: 10px 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.76rem; line-height: 1.5; color: #cfd6e6; white-space: pre;
}

.writer-field { display: flex; gap: 8px; padding: 3px 0; font-size: 0.86rem; }
.writer-label { color: #8892b0; min-width: 96px; }
.writer-value { color: #e0e0e0; }

.writer-section {
  margin: 16px 0 6px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: #7b2cbf;
  display: flex; align-items: center; gap: 8px;
}
.writer-section-controls { margin-left: auto; display: flex; gap: 6px; }
.writer-mini {
  background: transparent; border: 1px solid #2a2a4a; border-radius: 4px;
  color: #8892b0; font-size: 0.68rem; padding: 2px 7px; cursor: pointer;
  text-transform: none; letter-spacing: 0;
}
.writer-mini:hover { border-color: #7b2cbf; color: #cfd6e6; }

/* ── Episodes: collapsible, because 73 scenes in one flat list is the file
   again rather than an outline. ────────────────────────────────────────── */
.writer-episode {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; margin: 10px 0 2px; border-radius: 5px;
  background: #1a1a2e; color: #e0e0e0; font-weight: 600; cursor: pointer;
  user-select: none;
}
.writer-episode:hover { background: #22224a; }
.writer-episode.selected { background: #2d2d5c; outline: 1px solid #7b2cbf; }
.writer-caret { color: #7b2cbf; width: 10px; flex: none; }
.writer-episode-title { flex: none; }
.writer-episode-body { margin-left: 4px; }

/* ── A scene and its branches ─────────────────────────────────────────── */
.writer-scene-block { margin: 6px 0 10px; }

.writer-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 3px 8px; border-radius: 5px; cursor: pointer;
  font-size: 0.86rem; color: #cfd6e6;
}
.writer-row:hover { background: #22224a; }
.writer-row.selected { background: #2d2d5c; outline: 1px solid #7b2cbf; }

.writer-scene-id {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem; color: #e0e0e0;
}
/* Prose is a hint, never the identifier - it may be absent entirely. */
.writer-prose { color: #6f7891; font-size: 0.78rem; font-style: italic; }

.writer-quest { color: #ffd479; padding-left: 16px; }
.writer-dungeon { color: #9ad0ff; }

/* One destination per line, indented, so a branch reads as a tree instead of
   wrapping into a paragraph of ids. */
.writer-branch {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  padding: 1px 8px 1px 26px; font-size: 0.79rem; color: #8892b0;
}
.writer-branch-stem {
  color: #3d4463; font-family: ui-monospace, Menlo, Consolas, monospace; flex: none;
}
.writer-branch-end { color: #5a6380; font-style: italic; padding-left: 26px; }
.writer-choice-text { color: #b8c0d4; }

.writer-link {
  font-size: 0.76rem; color: #64ffda;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
/* Leaves this episode. Legal and common - it is how a campaign advances - but
   distinguishable, because picking one where an in-episode scene was meant is
   a quiet and expensive mistake. */
.writer-link-cross { color: #ffd479; }
.writer-link-broken { color: #ff6b6b; text-decoration: line-through; }
/* No destination at all: the choice acts, the scene stays. Shown because a
   MISSING nextScene and a deliberate one look identical in the JSON. */
.writer-link-none { color: #5a6380; }

.writer-tag {
  font-size: 0.7rem; color: #8892b0; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}
.writer-tag-quest {
  color: #ffd479; background: rgba(255, 212, 121, 0.1);
  border-radius: 3px; padding: 1px 5px;
}

.writer-issues { margin-bottom: 24px; }
.writer-issue-cat {
  margin: 12px 0 4px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: #ff6b6b;
}
.writer-issue-list { margin: 0 0 0 18px; font-size: 0.86rem; color: #cfd6e6; }
.writer-issue-list li { margin: 3px 0; }
.writer-empty { color: #5a6380; font-style: italic; font-size: 0.88rem; }

/* A link that leaves this episode. Legal and common — it is how a campaign
   advances — but distinguishable, because picking one by accident where an
   in-episode scene was meant is a quiet and expensive mistake. */
.writer-link-cross { color: #ffd479; }

/* An ending. Deliberately not styled like a link — it is the opposite of one:
   nothing follows it. */
.writer-end {
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.03em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.writer-end-victory   { color: #64ffda; }
.writer-end-defeat    { color: #ff6b6b; }
.writer-end-abandoned { color: #b08cd9; }
.writer-end-unknown   { color: #ffb454; text-decoration: underline wavy; }

/* Loops back to an earlier scene. Legal and useful — a refused offer often
   returns the party to where they were — but invisible in raw JSON. */
.writer-link-back { color: #9ad0ff; }

.writer-tag-warn {
  color: #ffb454; background: rgba(255, 180, 84, 0.1);
  border-radius: 3px; padding: 1px 5px;
}

/* A suggested destination for a choice that has none. Offered, never applied:
   the inference is right about 70% of the time, and the rest would put a party
   somewhere wrong mid-session with no sign it was a guess. */
.writer-suggest {
  font-size: 0.74rem; color: #9ad0ff; font-style: italic;
  border-bottom: 1px dotted #3d5a75; cursor: help;
}

/* ── The editor ─────────────────────────────────────────────────────────── */

.writer-editor {
  border: 1px solid #2a2a4a; border-radius: 8px; background: #16213e;
  padding: 12px 14px; margin-bottom: 20px;
}
.writer-editing-what {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem; color: #7b2cbf; margin-bottom: 10px;
}
.writer-field-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.writer-field-label {
  flex: none; width: 92px; font-size: 0.78rem; color: #8892b0;
}
.writer-input {
  flex: 1; min-width: 0; padding: 7px 9px; border-radius: 6px;
  background: #1a1a2e; border: 1px solid #2a2a4a; color: #e0e0e0;
  font-size: 0.86rem;
}
.writer-input:focus { border-color: #7b2cbf; outline: none; }
.writer-input:disabled { opacity: 0.5; }
.writer-suggest-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid #2a2a4a;
}

.writer-field-row-top { align-items: flex-start; }
.writer-actions-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.writer-action-row { display: flex; gap: 6px; align-items: center; }
.writer-input-narrow { flex: none; width: 110px; }
/* A quest name that is not in this episode. Kept and shown rather than snapped
   to something valid: it is the author's text, and losing it is worse than
   displaying it as wrong. */
.writer-input-bad { border-color: #ffb454; color: #ffb454; }

/* ── Constrained rich text for read-aloud ───────────────────────────────── */

.writer-rich-stack { flex: 1; min-width: 0; }
.writer-toolbar {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.writer-tool {
  width: 30px; height: 28px; border-radius: 5px; cursor: pointer;
  background: #1a1a2e; border: 1px solid #2a2a4a; color: #cfd6e6;
  font-weight: 700; font-size: 0.85rem;
}
.writer-tool:hover { border-color: #7b2cbf; color: #fff; }
.writer-palette { flex: 1; max-width: 260px; font-size: 0.8rem; padding: 5px 7px; }

/* The surface only ever contains tags the sanitiser allows, because the
   toolbar cannot produce others and everything is sanitised on the way in. */
.writer-rich {
  min-height: 120px; max-height: 260px; overflow-y: auto;
  padding: 10px 12px; border-radius: 6px;
  background: #1a1a2e; border: 1px solid #2a2a4a; color: #e0e0e0;
  font-size: 0.9rem; line-height: 1.6;
}
.writer-rich:focus { border-color: #7b2cbf; outline: none; }
.writer-rich p { margin: 0 0 0.7em; }
.writer-rich ul, .writer-rich ol { margin: 0 0 0.7em 1.2em; }
.writer-rich strong { color: #fff; }

/* Add buttons sit where the thing they create will appear, rather than in a
   toolbar: "+ scene" at the end of an episode's scenes, "+ dungeon" beside the
   dungeon heading. Deliberately NOT in the rich-text toolbar - that acts on a
   text selection, and "add an episode" has no relationship to one. */
.writer-add {
  background: transparent; border: 1px dashed #3d4463; border-radius: 5px;
  color: #8892b0; font-size: 0.74rem; padding: 3px 9px; cursor: pointer;
  text-transform: none; letter-spacing: 0;
}
.writer-add:hover { border-color: #7b2cbf; border-style: solid; color: #cfd6e6; }
.writer-add-row { display: flex; gap: 6px; padding: 6px 8px 2px 20px; }

/* Row tools appear on hover: an outline of 73 scenes with three buttons on
   every line is unreadable, and a delete button that is always visible is one
   that eventually gets pressed by accident. */
.writer-row-tools {
  margin-left: auto; display: flex; gap: 3px;
  opacity: 0; transition: opacity 0.12s;
}
.writer-row:hover .writer-row-tools,
.writer-episode:hover .writer-row-tools,
.writer-row.selected .writer-row-tools,
.writer-episode.selected .writer-row-tools { opacity: 1; }

.writer-move, .writer-del {
  background: transparent; border: 1px solid #2a2a4a; border-radius: 4px;
  color: #8892b0; font-size: 0.7rem; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.writer-move:hover { border-color: #7b2cbf; color: #cfd6e6; }
.writer-del:hover { border-color: #ff6b6b; color: #ff6b6b; }
