:root {
  color-scheme: dark;
  --ink: #eef5f7;
  --muted: #9baab0;
  --faint: #66747b;
  --ground: #080b0f;
  --surface: #10161c;
  --surface-raised: #151d24;
  --line: #27333b;
  --line-bright: #3c4b54;
  --cyan: #45d9ff;
  --cyan-soft: rgba(69, 217, 255, 0.12);
  --amber: #e6b96d;
  --amber-soft: rgba(230, 185, 109, 0.12);
  --red: #e78476;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(69, 217, 255, 0.08), transparent 32rem),
    radial-gradient(circle at 85% 20%, rgba(230, 185, 109, 0.06), transparent 30rem),
    var(--ground);
}

button, select, textarea { font: inherit; }
button, select { min-height: 2.75rem; }
button { color: inherit; }

button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(69, 217, 255, 0.45);
  outline-offset: 2px;
}

.topbar {
  min-height: 5rem;
  padding: 1rem clamp(1rem, 4vw, 4rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, 0.85);
  backdrop-filter: blur(16px);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.45rem; letter-spacing: 0.02em; }
h2 { margin-bottom: 0.35rem; font-size: 1.2rem; }
h3 { margin-bottom: 0; font-size: 1rem; }

.eyebrow, .step-label {
  margin-bottom: 0.25rem;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar-note { margin: 0; color: var(--muted); font-size: 0.88rem; }

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 3vw, 3rem) 3rem;
}

.brief {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(230, 185, 109, 0.28);
  background: linear-gradient(100deg, var(--amber-soft), transparent 62%);
}

.brief p:last-child { margin: 0; color: #c9d1d4; line-height: 1.5; }
.brief-mark { color: var(--amber); font-size: 2.2rem; transform: rotate(-12deg); }

.workbench {
  display: grid;
  grid-template-columns: minmax(15rem, 0.85fr) minmax(22rem, 1.35fr) minmax(19rem, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.panel {
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.018), transparent 48%), var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.count, .result-seal {
  flex: none;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line-bright);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.result-seal { border-color: rgba(69, 217, 255, 0.4); color: var(--cyan); }
.hint, .trial-description { color: var(--muted); line-height: 1.45; font-size: 0.88rem; }

.rune-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.rune-button {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.rune-button:hover:not(:disabled) { border-color: var(--cyan); background: var(--cyan-soft); transform: translateY(-1px); }
.rune-button:disabled { opacity: 0.42; cursor: not-allowed; }
.rune-button svg { width: 2.1rem; height: 2.1rem; overflow: visible; }
.rune-button path, .rune-button circle { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.rune-button circle:empty { display: none; }
.rune-button span { font-weight: 650; }

.inscription-panel { display: flex; flex-direction: column; }
.small-actions { display: flex; gap: 0.75rem; }
.text-button { min-height: auto; padding: 0.15rem 0; border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 0.875rem; }
.text-button:hover { color: var(--cyan); }

.inscription-line {
  position: relative;
  min-height: 8rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(3.5rem, 1fr));
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.8rem;
  border-block: 1px solid var(--line);
  background: linear-gradient(90deg, transparent, rgba(69, 217, 255, 0.025), transparent);
}

.inscription-line::before {
  content: "";
  position: absolute;
  left: 8%; right: 8%; top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-bright) 15%, var(--line-bright) 85%, transparent);
}

.mark-slot {
  position: relative;
  z-index: 1;
  min-height: 5.5rem;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-bright);
  background: #0c1116;
  cursor: pointer;
}

.mark-slot:hover { border-color: var(--red); }
.mark-slot svg { width: 2.8rem; height: 2.8rem; color: var(--cyan); }
.mark-slot path, .mark-slot circle { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mark-slot span { margin-top: 0.2rem; font-size: 0.8125rem; color: var(--muted); }
.empty-slot { border-style: dashed; color: var(--faint); cursor: default; }
.empty-slot:hover { border-color: var(--line-bright); }
.empty-slot::after { content: "·"; font-size: 2rem; }

.trial-controls { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 0.75rem; margin-top: auto; }
label > span, .notebook-compose > label { display: block; margin-bottom: 0.35rem; color: #c9d3d6; font-size: 0.875rem; font-weight: 650; }
select, textarea {
  width: 100%;
  border: 1px solid var(--line-bright);
  border-radius: 0;
  color: var(--ink);
  background: #0b1015;
}
select { padding: 0.6rem 2rem 0.6rem 0.65rem; }
textarea { padding: 0.75rem; resize: vertical; line-height: 1.5; }
.trial-description { min-height: 2.5rem; margin: 0.7rem 0; }

.cast-button, .save-button, .quiet-button {
  border: 1px solid var(--cyan);
  padding: 0.65rem 1rem;
  background: var(--cyan);
  color: #041015;
  font-weight: 780;
  cursor: pointer;
}

.cast-button:hover, .save-button:hover:not(:disabled) { filter: brightness(1.12); }
.cast-button:disabled, .save-button:disabled { opacity: 0.42; cursor: not-allowed; }
.quiet-button { border-color: rgba(230, 185, 109, 0.55); background: transparent; color: var(--amber); }
.quiet-button:hover { background: var(--amber-soft); }

.observation-panel { min-height: 28rem; }
.empty-observation { min-height: 20rem; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-observation span { color: var(--faint); font-size: 3rem; }
.empty-observation p { max-width: 18rem; line-height: 1.5; }
.outcome-summary { padding-left: 0.8rem; border-left: 2px solid var(--cyan); color: #dce5e7; font-weight: 650; line-height: 1.5; }
.event-list { margin: 1rem 0 0; padding: 0; list-style: none; }
.event-list li { position: relative; padding: 0.75rem 0 0.75rem 1.15rem; border-top: 1px solid var(--line); color: #b9c5c9; line-height: 1.45; }
.event-list li::before { content: ""; position: absolute; left: 0; top: 1.1rem; width: 0.38rem; height: 0.38rem; border: 1px solid var(--cyan); transform: rotate(45deg); }

.notebook {
  display: grid;
  grid-template-columns: minmax(18rem, 0.85fr) minmax(22rem, 1.65fr);
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.25rem;
  border: 1px solid rgba(230, 185, 109, 0.24);
  background:
    linear-gradient(90deg, transparent 3.4rem, rgba(230, 185, 109, 0.08) 3.45rem, transparent 3.5rem),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0, rgba(255, 255, 255, 0.018) 1px, transparent 1px, transparent 2rem),
    #101416;
}

.save-button { width: 100%; margin-top: 0.65rem; border-color: var(--amber); background: var(--amber); }
.save-status { min-height: 1.3rem; margin: 0.45rem 0 0; color: var(--amber); font-size: 0.82rem; }
.notebook-pages { min-width: 0; padding-left: 1rem; border-left: 1px solid rgba(230, 185, 109, 0.2); }
.page-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.notebook-page { min-width: 0; padding: 0.85rem; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.16); }
.page-meta { margin-bottom: 0.45rem; color: var(--amber); font-size: 0.75rem; }
.page-marks { margin-bottom: 0.5rem; font-weight: 700; }
.page-summary, .page-note { margin-bottom: 0.4rem; color: #b8c2c5; font-size: 0.86rem; line-height: 1.45; }
.page-note { color: #d7dee0; font-style: italic; }
.empty-pages { color: var(--muted); }

@media (max-width: 1080px) {
  .workbench { grid-template-columns: 0.8fr 1.2fr; }
  .observation-panel { grid-column: 1 / -1; min-height: auto; }
  .empty-observation { min-height: 10rem; }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; }
  .topbar-note { max-width: 11rem; text-align: right; }
  main { padding-inline: 0.75rem; }
  .brief { grid-template-columns: auto 1fr; }
  .brief .quiet-button { grid-column: 1 / -1; width: 100%; }
  .workbench, .notebook { grid-template-columns: 1fr; }
  .trial-controls { grid-template-columns: 1fr; }
  .notebook-pages { padding: 1rem 0 0; border-left: 0; border-top: 1px solid rgba(230, 185, 109, 0.2); }
  .page-list { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .topbar-note { display: none; }
  .rune-grid { grid-template-columns: 1fr; }
  .inscription-line { grid-template-columns: repeat(2, minmax(4.5rem, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
