:root {
  color-scheme: light;
  --paper: #f6f2e8;
  --panel: #fffdf7;
  --ink: #1e2b22;
  --muted: #4d5c50;
  --line: #c8cdbe;
  --green: #18543b;
  --green-pale: #e1eddf;
  --rust: #8e3a28;
  --rust-pale: #f8e3d6;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: var(--green); text-underline-offset: 0.25em; }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.frame { width: min(1120px, calc(100% - 56px)); margin-inline: auto; }
.skip { position: absolute; top: -5rem; left: 1rem; background: var(--panel); padding: 0.75rem; }
.skip:focus { top: 0.75rem; }

.masthead {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  line-height: 1.08;
}
.brand small { display: block; letter-spacing: 0.1em; font-size: 0.63rem; color: var(--muted); }
.mark {
  height: 38px;
  width: 38px;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  background: var(--green);
  color: white;
  border-radius: 9px;
}
nav { display: flex; gap: clamp(0.9rem, 4vw, 2.25rem); align-items: center; }
nav a { font-size: 0.875rem; font-weight: 650; }

.intro { padding-block: clamp(2rem, 5vw, 4rem) 1.5rem; }
h1 {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-weight: 560;
  letter-spacing: -0.055em;
  font-size: clamp(2.7rem, 7vw, 5.4rem);
  line-height: 0.98;
}
.intro p { margin: 0.9rem 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); }

.toolbar, .toolbar-group { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.toolbar { justify-content: space-between; margin-bottom: 0.85rem; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 680;
  line-height: 1.3;
}
button:hover { border-color: var(--green); }
button:disabled { cursor: wait; opacity: 0.6; }
.sample[aria-pressed="true"] { background: var(--green-pale); border-color: var(--green); color: var(--green); }
.file-button span, .primary span { margin-inline: 0.2rem; }
.story-import {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: 0.55rem;
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.83rem;
}
.story-import[data-dragging] { border-color: var(--green); background: var(--green-pale); color: var(--green); }
#import-feedback { flex-basis: 100%; margin: 0; padding-inline: 0.25rem; color: var(--rust); }
#import-feedback:not(:empty) { margin-top: 0.35rem; }
.primary { background: var(--green); color: white; border-color: var(--green); white-space: nowrap; }
.primary:hover { background: #103c2a; }
.quiet { background: transparent; color: var(--green); border-color: transparent; }
.quiet:hover { border-color: var(--line); }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; padding-bottom: 3rem; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-head {
  min-height: 73px;
  padding: 0.7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head label { font-size: 1.08rem; font-weight: 750; margin: 0; }
.panel-head p { margin: 0.18rem 0 0; font-size: 0.8rem; overflow-wrap: anywhere; color: var(--muted); }
.editor-head { flex-wrap: wrap; }
.editor-head > div { min-width: 0; }
.editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }
.panel-head .format-picker { display: flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.format-picker select {
  min-height: 44px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding-inline: 0.4rem;
  background: var(--panel);
  color: var(--ink);
}
textarea, code, kbd { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
textarea {
  display: block;
  width: 100%;
  min-height: 400px;
  padding: 1rem;
  border: 0;
  border-radius: 0;
  background: #212f27;
  color: #edf4e8;
  caret-color: #fbdf9c;
  line-height: 1.6;
  font-size: 0.88rem;
  tab-size: 2;
  resize: vertical;
}
textarea:focus-visible { outline-color: #ffc979; outline-offset: -4px; }
textarea::placeholder { color: #bac7ba; }
.panel-foot { margin: 0; padding: 0.8rem 1rem; color: var(--muted); font-size: 0.8rem; line-height: 1.55; }
#format-help:not([hidden]) + #privacy { padding-top: 0; }
kbd { border: 1px solid var(--line); border-radius: 3px; padding: 0.04em 0.24em; white-space: nowrap; }

.status { margin: 0; padding: 1rem; color: var(--muted); font-weight: 700; }
.status[data-tone="bad"] { color: var(--rust); background: var(--rust-pale); }
.status[data-tone="ok"] { color: var(--green); background: var(--green-pale); }
.playable-export { padding: 0.85rem 1rem; }
.playable-export p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.83rem; }
.review-export { display: grid; justify-items: start; gap: 0.4rem; padding: 0.85rem 1rem; }
.playable-export:not([hidden]) + .review-export { border-top: 1px solid var(--line); }
.review-option { display: flex; align-items: flex-start; gap: 0.45rem; padding-block: 0.3rem; font-size: 0.88rem; }
.review-option input { accent-color: var(--green); flex: none; margin: 0.17rem 0 0; }
.review-export p { margin: 0; color: var(--muted); font-size: 0.83rem; line-height: 1.5; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
  border-block: 1px solid var(--line);
  padding: 0.8rem 1rem;
}
.metrics dt { font-size: 0.76rem; color: var(--muted); }
.metrics dd { margin: 0; font-size: 1.2rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.issues { display: grid; gap: 0.55rem; margin: 0; padding: 0.8rem 1rem 1rem; list-style: none; }
.issues:empty { display: none; }
.issue { padding: 0.68rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.issue strong { display: block; font-size: 0.88rem; color: var(--rust); }
.issue p, .issue-footer { margin: 0.28rem 0 0; font-size: 0.83rem; line-height: 1.5; }
.issue-footer { color: var(--muted); }
.issue-link { border: 0; padding: 0.35rem 0.25rem; margin-inline-start: -0.25rem; color: var(--green); text-decoration: underline; text-underline-offset: 0.2em; }
.scenes { border-top: 1px solid var(--line); font-size: 0.85rem; }
.scenes summary { cursor: pointer; padding: 0.9rem 1rem; font-weight: 720; }
#scene-list { display: grid; gap: 0.5rem; padding: 0 1rem 1rem; overflow-wrap: anywhere; }
.scene { padding: 0.65rem; border-radius: 6px; border: 1px solid var(--line); scroll-margin-block: 2rem; }
.scene[data-selected] { background: var(--green-pale); border-color: var(--green); }
.scene p { margin: 0.25rem 0; }
.scene ol { margin: 0.35rem 0 0; padding-inline-start: 1.3rem; }
.scene [data-selected] { color: var(--rust); font-weight: 700; }

@media (max-width: 760px) {
  .frame { width: calc(100% - 32px); }
  .work-grid { grid-template-columns: 1fr; }
  textarea { min-height: 190px; font-size: 1rem; }
}
@media (max-width: 390px) {
  .masthead { gap: 0.5rem; }
  nav { gap: 0.75rem; }
  .toolbar { gap: 0.45rem; }
  .toolbar-group { gap: 0.3rem; }
  button { padding-inline: 0.65rem; }
}
