:root {
  --ink: #12151a;
  --ink-2: #1c222b;
  --paper: #e8e2d6;
  --paper-dim: #cfc7b8;
  --line: rgba(232, 226, 214, 0.14);
  --amber: #e3a008;
  --mint: #3dba8a;
  --coral: #e85d4c;
  --sky: #6ea8d8;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Newsreader", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(227, 160, 8, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(62, 186, 138, 0.08), transparent 50%),
    linear-gradient(165deg, #0d1014 0%, #171c24 45%, #10141a 100%);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--line);
  animation: rise 0.7s ease both;
}

.usage-banner {
  margin: 0;
  padding: 0.75rem 1.5rem;
  background: rgba(232, 93, 76, 0.12);
  border-bottom: 1px solid rgba(232, 93, 76, 0.35);
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.5;
}
.usage-banner a {
  color: var(--amber);
}
.usage-banner strong {
  color: var(--coral);
}

.brand {
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  color: var(--paper);
}

.thesis {
  margin: 0;
  max-width: 36rem;
  color: var(--paper-dim);
  font-size: 0.95rem;
}

.stage {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
  animation: rise 0.8s 0.08s ease both;
}

@media (max-width: 1100px) {
  .stage { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .stage { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}

.lane {
  background: rgba(18, 21, 26, 0.92);
  min-height: 22rem;
  display: flex;
  flex-direction: column;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.lane.active {
  background: rgba(28, 34, 43, 0.98);
  box-shadow: inset 0 0 0 1px rgba(227, 160, 8, 0.35);
}

.lane header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.lane h2 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.lane header p {
  margin: 0.2rem 0 0;
  color: var(--paper-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lane-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.label { color: var(--paper-dim); }

code {
  font-family: var(--mono);
  color: var(--sky);
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  color: var(--paper-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill.on {
  color: var(--mint);
  border-color: rgba(61, 186, 138, 0.45);
}
.pill.bad {
  color: var(--coral);
  border-color: rgba(232, 93, 76, 0.45);
}

.panel-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--paper-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, button {
  font: inherit;
}

input, select {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

input:focus, select:focus {
  outline: 1px solid var(--amber);
  border-color: var(--amber);
}

button {
  cursor: pointer;
  border: 1px solid rgba(227, 160, 8, 0.55);
  background: linear-gradient(180deg, rgba(227, 160, 8, 0.18), rgba(227, 160, 8, 0.05));
  color: var(--paper);
  padding: 0.65rem 0.75rem;
  text-align: left;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

button:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(227, 160, 8, 0.28), rgba(227, 160, 8, 0.1));
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.ghost {
  border-color: var(--line);
  background: transparent;
  padding: 0.5rem 0.75rem;
}

button.danger {
  border-color: rgba(232, 93, 76, 0.5);
  background: linear-gradient(180deg, rgba(232, 93, 76, 0.2), rgba(232, 93, 76, 0.05));
}

.hint {
  margin: 0;
  color: var(--paper-dim);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}
.hint.tight { margin-bottom: 0.25rem; }

.callout {
  border-left: 2px solid var(--amber);
  padding: 0.55rem 0.65rem;
  background: rgba(227, 160, 8, 0.06);
  color: var(--paper-dim);
  font-size: 0.78rem;
}
.callout strong {
  display: block;
  color: var(--amber);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.attack-box {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.attack-title {
  margin: 0 0 0.2rem;
  color: var(--coral);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log li {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  animation: fadein 0.35s ease both;
  font-size: 0.72rem;
}

.log .kind {
  color: var(--amber);
  margin-right: 0.35rem;
}
.log .kind.user { color: var(--sky); }
.log .kind.blinding-setup { color: var(--paper-dim); }
.log .valid { color: var(--mint); }
.log .invalid { color: var(--coral); }

.lane-hsm.active {
  animation: hsm-pulse 0.9s ease;
}

@keyframes hsm-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(227, 160, 8, 0.35); }
  40% { box-shadow: inset 0 0 0 1px rgba(110, 168, 216, 0.7), 0 0 24px rgba(110, 168, 216, 0.15); }
}

.finding {
  padding: 0.75rem;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 4.5rem;
}
.finding.idle { color: var(--paper-dim); }
.finding.ok {
  border-color: rgba(61, 186, 138, 0.5);
  background: rgba(61, 186, 138, 0.08);
}
.finding.alarm {
  border-color: rgba(232, 93, 76, 0.55);
  background: rgba(232, 93, 76, 0.1);
  animation: alarm-flash 1.2s ease;
}
.finding-result {
  font-family: var(--display);
  font-size: 1.15rem;
}
.finding.ok .finding-result { color: var(--mint); }
.finding.alarm .finding-result { color: var(--coral); }

@keyframes alarm-flash {
  0%, 100% { filter: brightness(1); }
  30% { filter: brightness(1.25); }
}

.subhead {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  font-weight: 500;
}

.narrative {
  padding: 1.5rem;
  animation: rise 0.85s 0.12s ease both;
}

.narrative-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.narrative h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  margin: 0;
  font-weight: 600;
}

.last-result {
  margin: 0;
  color: var(--mint);
  font-size: 0.8rem;
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.events li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  background: rgba(18, 21, 26, 0.75);
  animation: slide 0.4s ease both;
}

@media (max-width: 640px) {
  .events li { grid-template-columns: 1fr; }
}

.events .actor {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber);
  padding-top: 0.15rem;
}
.events .actor.wallet { color: var(--sky); }
.events .actor.hsm { color: var(--sky); }
.events .actor.monitor { color: var(--mint); }
.events .actor.wsca { color: var(--amber); }
.events .actor.wire { color: var(--paper-dim); }

.events h3 {
  margin: 0 0 0.3rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 550;
}

.events .detail {
  margin: 0;
  color: var(--paper-dim);
  font-size: 0.8rem;
}

.events .lesson {
  margin: 0.45rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
  color: var(--mint);
  font-size: 0.78rem;
}

.events li.secure {
  border-color: rgba(61, 186, 138, 0.35);
}
.events li.danger {
  border-color: rgba(232, 93, 76, 0.4);
}
.events li.danger .lesson { color: var(--coral); }

.foot {
  padding: 1rem 1.5rem 2rem;
  color: var(--paper-dim);
  font-size: 0.72rem;
  border-top: 1px solid var(--line);
}
.foot a {
  color: var(--amber);
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  max-width: 22rem;
  padding: 0.75rem 1rem;
  background: var(--ink-2);
  border: 1px solid var(--coral);
  color: var(--paper);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  animation: slide 0.3s ease both;
  z-index: 20;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.timeline-panel, .archive-panel {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  animation: rise 0.85s 0.1s ease both;
}

.timeline {
  margin-top: 0.75rem;
}

.timeline-track {
  position: relative;
  height: 4.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  overflow: hidden;
}

.timeline-empty {
  padding: 1.5rem 1rem;
  color: var(--paper-dim);
  font-size: 0.8rem;
}

.tw {
  position: absolute;
  top: 0.85rem;
  height: 1.6rem;
  background: linear-gradient(180deg, rgba(227, 160, 8, 0.35), rgba(227, 160, 8, 0.12));
  border: 1px solid rgba(227, 160, 8, 0.55);
  display: flex;
  align-items: center;
  padding: 0 0.35rem;
  font-size: 0.65rem;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  animation: fadein 0.4s ease both;
}

.tm {
  position: absolute;
  top: 3rem;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 1px;
  background: var(--amber);
  transform: rotate(45deg);
  animation: fadein 0.35s ease both;
}
.tm.user { background: var(--sky); top: 3.15rem; }
.tm.blinding { background: var(--mint); }
.tm.orphan {
  background: var(--coral);
  box-shadow: 0 0 0 3px rgba(232, 93, 76, 0.35);
  animation: alarm-flash 1.2s ease;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.65rem;
  color: var(--paper-dim);
  font-size: 0.72rem;
}
.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.3rem;
  vertical-align: -1px;
}
.swatch.win { background: rgba(227, 160, 8, 0.45); border: 1px solid var(--amber); }
.swatch.blind { background: var(--mint); transform: rotate(45deg); }
.swatch.user { background: var(--sky); transform: rotate(45deg); }
.swatch.orphan { background: var(--coral); transform: rotate(45deg); }

.wallet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.wallet-tab {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--paper-dim);
  cursor: pointer;
}
.wallet-tab.on {
  color: var(--paper);
  border-color: var(--amber);
  background: rgba(227, 160, 8, 0.12);
}

.log .acct {
  color: var(--paper-dim);
  font-size: 0.68rem;
  margin-right: 0.25rem;
}

.judge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}
.file-btn {
  cursor: pointer;
  margin: 0;
}

.archive-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.linkish {
  text-decoration: none;
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  color: var(--paper);
}

.dispute-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.dispute-row label {
  min-width: 8rem;
}
.dispute-row input {
  width: 6rem;
}

.judge-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 800px) {
  .judge-main { grid-template-columns: 1fr; }
}
.judge-card {
  background: rgba(18, 21, 26, 0.92);
  padding: 1.25rem 1.5rem;
  min-height: 16rem;
}
.judge-card h2 {
  font-family: var(--display);
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}
.judge-card button {
  margin: 0.35rem 0.35rem 0.35rem 0;
}
.pkg-meta {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--sky);
  font-size: 0.75rem;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 14rem;
}

