:root {
  --bg: #10141a;
  --bg-2: #171c24;
  --bg-3: #222833;
  --line: #313846;
  --text: #f4f1ea;
  --muted: #b7b1a6;
  --teal: #3dbea5;
  --teal-ink: #06241e;
  --good: #1f8f55;
  --bad: #c4473d;
  --sans: "Liberation Sans", "Nimbus Sans", "DejaVu Sans", sans-serif;
  --mono: "DejaVu Sans Mono", "Liberation Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 340px;
  grid-template-rows: 62px minmax(0, 1fr) 34px;
  grid-template-areas:
    "head head head"
    "nav main aside"
    "foot foot foot";
}

header {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #141922;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.mark {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 4px;
  background: var(--teal);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.28);
}
.title { font-weight: 700; letter-spacing: 0.01em; line-height: 1.2; }
.sub { color: var(--muted); font-size: 12px; line-height: 1.2; }
.head-meta { flex: 1; min-width: 0; }
.scenename { font-weight: 650; }
.progress { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.head-actions { display: flex; gap: 8px; }

.ghost, .solid {
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 8px;
  padding: 7px 12px;
}
.solid { background: var(--teal); color: var(--teal-ink); border-color: #2e9b86; font-weight: 700; }
.ghost:hover { border-color: #6e9e94; }

nav {
  grid-area: nav;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #12171f;
  padding: 8px 8px 20px;
}
.navlabel {
  margin: 14px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.navitem {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}
.navitem:hover { background: #222836; }
.navitem.on { background: #17332e; color: #dff7f1; }
.navitem.locked { opacity: 0.45; }
.navitem.locked:hover { background: transparent; }
.navkicker {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.navitem.on .navkicker { color: #8fd9cb; }
.tick {
  width: 14px;
  flex: none;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 12px;
  padding-top: 2px;
}

main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px 28px 40px;
}
aside {
  grid-area: aside;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #141922;
  padding: 16px;
}
footer {
  grid-area: foot;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: #12171f;
}
footer span { min-width: 0; }

h1 { font-size: 28px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 16px; line-height: 1.35; margin: 16px 0 8px; }
.kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.prose { max-width: 68ch; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.file, .calc {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  background: #12171f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow: auto;
  max-width: 760px;
  white-space: pre-wrap;
}
.file { margin: 0 0 16px; }

.panel {
  max-width: 760px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}
.choice {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  background: #1c222c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 8px;
  line-height: 1.35;
}
.choice:hover { border-color: #6e9e94; }
.choice .key {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #2a3140;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  display: grid;
  place-items: center;
}
.choice.good, .choice.on { border-color: var(--teal); background: #17332e; }
.choice.good { border-color: var(--good); background: #143226; }
.choice.bad { border-color: var(--bad); background: #3a1d1b; }
.why { margin: 8px 0 0; }
.goodline { color: #b7ebc9; }
.badline { color: #f3c7c2; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.powrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.powrow input {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--mono);
  background: #12171f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid var(--line);
  background: #1c222c;
  border-radius: 999px;
  padding: 4px 8px;
}
.chip:hover { border-color: #6e9e94; }

.tool { margin-top: 14px; }
.tool h2 { margin: 0 0 6px; font-size: 14px; }
.tool p { margin: 6px 0 0; }

.score {
  font-family: var(--mono);
  font-size: 42px;
  line-height: 1;
  margin: 0 0 8px;
}
.review { margin: 0 0 12px; padding-left: 18px; }
.review li { margin: 0 0 8px; }

.sheet { width: 100%; border-collapse: collapse; }
.sheet td { border-top: 1px solid var(--line); padding: 7px 4px 7px 0; vertical-align: baseline; }
.sheet .sym { font-family: var(--mono); color: var(--teal); width: 52px; }
.sheet .val { font-family: var(--mono); font-weight: 700; padding-right: 8px; overflow-wrap: break-word; }
.sheet .note { color: var(--muted); font-size: 13px; }

#selftest {
  position: fixed;
  left: 8px;
  bottom: 40px;
  margin: 0;
  max-width: min(720px, calc(100% - 16px));
  max-height: 40vh;
  overflow: auto;
  padding: 8px;
  background: #06241e;
  color: #b7ebdd;
  z-index: 5;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .app {
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
  }
  header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand reset" "meta meta";
    height: auto;
    min-height: 0;
    padding: 10px 12px 8px;
    align-items: center;
    gap: 2px 12px;
  }
  .brand { grid-area: brand; min-width: 0; }
  .head-actions { grid-area: reset; }
  .head-meta { grid-area: meta; display: flex; gap: 8px; flex-wrap: wrap; }
  .scenename, .progress { font-size: 12px; }
  nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px;
  }
  .navlabel { display: none; }
  .navitem { width: auto; white-space: nowrap; align-items: center; }
  .navkicker { display: none; }
  main { padding: 18px 16px 28px; }
  footer { height: auto; padding: 8px 12px; }
  footer span { white-space: normal; }
  aside { border-left: 0; border-top: 1px solid var(--line); }
  .sheet .note { font-size: 12px; }
}
