:root {
  --bg: #14120e;
  --raise: #1c1915;
  --inset: #100e0c;
  --line: #3a342c;
  --text: #f4efe6;
  --muted: #b3a79a;
  --ember: #e3874a;
  --ember-ink: #1a1008;
  --paper: #f6f0e4;
  --ink: #241c14;
  --ink-soft: #5e5348;
  --hit: #d7e7a4;
  --hit-bg: #24301c;
  --hit-line: #3e5230;
  --gap: #d2c4b4;
  --serif: Palatino, "Palatino Linotype", "Iowan Old Style", "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(227, 135, 74, 0.16), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

body { min-height: 100vh; }

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 40px;
}

.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  transform: translateY(-140%);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 3;
}

.skip:focus { transform: none; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 16px 0 8px;
}

.brand { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }

.mark { width: 36px; height: 36px; flex: none; margin-top: 2px; }

h1.brand-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand-line { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

.top-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

button, .btn {
  appearance: none;
  border: 0;
  background: var(--ember);
  color: var(--ember-ink);
  font: inherit;
  font-weight: 650;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.ghost, .btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 550;
}

button:hover, .btn:hover { filter: brightness(1.06); }

button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.text-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 550;
}

.text-btn:hover { color: var(--text); background: #2a261f; }

.file { position: relative; cursor: pointer; }

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus { outline: none; }

:focus-visible, .file:focus-within {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

.status {
  min-height: 1.25rem;
  margin: 0 0 8px;
  color: var(--hit);
  font-size: 0.92rem;
}

.status.bad { color: #f0b4a0; }

.workspace { display: block; }

.source, .packet { min-width: 0; }

.panel {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 16px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hint { margin: 0; color: var(--muted); font-size: 0.85rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

textarea, input[type="text"] {
  width: 100%;
  background: var(--inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
}

textarea { resize: vertical; min-height: 148px; line-height: 1.45; }

textarea::placeholder, input::placeholder { color: #8d8276; font-style: italic; }

.field:first-of-type, .pair:first-of-type { margin-top: 0; }

.add-row { display: flex; gap: 8px; }

.add-row input { flex: 1; min-width: 0; }

.proofs { list-style: none; margin: 8px 0 0; padding: 0; }

.proofs .hint { padding: 4px 0 0; }

.proof {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-top: 1px solid var(--line);
  padding: 8px 0 0;
  margin-top: 8px;
}

.proof p { margin: 0; flex: 1; color: var(--text); overflow-wrap: anywhere; }

.shelf { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }

.shelf-empty { margin: 0; }

.shelf-card {
  flex: none;
  width: 200px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shelf-open {
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  padding: 4px 6px;
  text-align: left;
  font-weight: 550;
  min-height: 0;
  display: block;
  width: 100%;
}

.shelf-open strong { display: block; font-weight: 650; }
.shelf-open span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 450; }

.packet { outline: none; }

.packet-card {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.empty { padding: 28px 8px 12px; }

.empty-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.empty p { margin: 0; color: var(--muted); max-width: 38ch; }

.score-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}

.score-num {
  margin: 0;
  min-width: 4.6ch;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  font-size: 2.8rem;
  line-height: 0.85;
  letter-spacing: -0.04em;
}

.score-num span { font-size: 1.2rem; color: var(--muted); margin-left: 1px; }

.forged-for { margin: 0; font-family: var(--serif); font-size: 1.15rem; }

.score-caption { margin: 4px 0 8px; color: var(--muted); font-size: 0.92rem; }

.meter {
  height: 8px;
  background: #2a261f;
  border-radius: 99px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a85a28, #e3874a 45%, #d6e39a);
  border-radius: inherit;
}

.chip-block { margin: 0 0 8px; }

.chip-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.86rem;
  border: 1px solid var(--line);
  color: var(--gap);
}

.chip.hit { background: var(--hit-bg); color: var(--hit); border-color: var(--hit-line); }

.chip.skill { background: #2c2618; color: #f0d7b0; border-color: #5a4a32; }

.block-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin: 8px 0 6px;
}

.subhead { margin: 14px 0 0; }

.letter {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  border-left: 4px solid var(--ember);
  border-radius: 4px 12px 12px 8px;
  padding: 14px 16px 16px;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.bullets { list-style: none; margin: 0; padding: 0; }

.bullet {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.bullet p { margin: 0; overflow-wrap: anywhere; }

.bullet .chips { margin-top: 6px; }

.checks { list-style: none; margin: 0; padding: 0; }

.checks li {
  position: relative;
  padding: 8px 0 8px 22px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.checks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--ember);
  border-radius: 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.noscript {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 24px;
  color: var(--muted);
}

@media (min-width: 901px) {
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .source, .packet {
    max-height: calc(100dvh - 118px);
    overflow: auto;
  }
}

@media (max-width: 700px) {
  .page { width: min(1180px, calc(100% - 20px)); }
  .top { flex-direction: column; align-items: stretch; padding-top: 14px; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .top-actions button:first-child { grid-column: 1 / -1; }
  h1.brand-name { font-size: 1.5rem; }
  .score-num { font-size: 2.6rem; }
}

@media (max-width: 420px) {
  .pair, .add-row { grid-template-columns: 1fr; display: grid; }
  .add-row button { width: 100%; }
  .letter { padding: 16px; font-size: 1rem; }
  .score-row { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
