:root {
  --bg: #110e0c;
  --iron: #1b1613;
  --panel: #161210;
  --line: #3d332c;
  --cream: #f3eadf;
  --muted: #cbbbaa;
  --ember: #ff6a2a;
  --ember-2: #ffb15a;
  --danger: #ffb4bc;
  color-scheme: dark;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 280px at 0% -10%, #3a2418 0%, transparent 55%),
    var(--bg);
  color: var(--cream);
}

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

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }

.lede {
  margin: 0;
  flex: 1 1 18rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.98rem;
  max-width: 40rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #2a221c;
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  line-height: 1.2;
  min-height: 36px;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(180deg, #ff8a3d, #e85d04);
  color: #1a0d07;
  border-color: transparent;
  font-weight: 600;
}
.btn.danger { color: var(--danger); border-color: #6a3038; background: #2a1618; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.bench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.rail {
  border-right: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  background: #140f0ccc;
}
.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.rail-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
#live-count {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--ember-2);
}
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.empty { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; }

.forge {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.forge.is-on { background: #2a211c; border-color: #5a3a2a; }
.forge-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.left {
  flex: none;
  color: var(--ember-2);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.stage { min-height: 0; display: flex; flex-direction: column; }

.cold {
  margin: auto;
  max-width: 28rem;
  padding: 24px 20px 48px;
  text-align: center;
}
.cold h2 { margin: 12px 0 8px; font-size: 1.8rem; font-weight: 550; letter-spacing: -0.03em; }
.cold p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.ember-dot {
  width: 18px;
  height: 18px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 18px var(--ember);
}

.work { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.work-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px 8px;
}
.work-bar h2 { margin: 0; font-size: 1.25rem; font-weight: 550; letter-spacing: -0.02em; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.meta strong { color: var(--ember-2); font-variant-numeric: tabular-nums; font-weight: 600; }

.work-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: none; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 12px;
  min-height: 36px;
  color: var(--muted);
}
.seg button[aria-selected="true"] { background: #3a2a22; color: var(--cream); }

.heat { height: 3px; background: #3a302a; }
.heat span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--ember), var(--ember-2));
}

.confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 16px;
  background: #2a1618;
  color: var(--danger);
}

.status {
  margin: 0;
  padding: 6px 16px 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.status:empty { padding: 0; }
.share-out { margin: 4px 16px 0; }
.share-out input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}
.editor-wrap, .preview-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.preview-wrap { border-left: 1px solid var(--line); }
.pane-label {
  margin: 0;
  padding: 8px 12px 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
textarea, iframe { flex: 1; width: 100%; min-height: 0; border: 0; }
textarea {
  resize: none;
  background: var(--panel);
  color: var(--cream);
  padding: 12px 14px 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
iframe { background: #fff; }

dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: min(90dvh, 640px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--iron);
  color: var(--cream);
}
dialog::backdrop { background: #000a; }
form { padding: 18px 18px 16px; }
dialog h2 { margin: 0 0 12px; font-size: 1.35rem; font-weight: 550; }
form label { display: grid; gap: 6px; margin: 0 0 12px; font-size: 0.85rem; color: var(--muted); }
input[type="text"], select {
  background: #120e0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 10px 12px 12px; }
legend { padding: 0 6px; color: var(--muted); font-size: 0.85rem; }
.lives { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.lives label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--cream); font-size: 0.95rem; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

@media (max-width: 860px) {
  body { height: auto; overflow: auto; }
  .bench { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .rail ul { display: flex; gap: 8px; overflow-x: auto; }
  .rail li { flex: 0 0 auto; }
  .forge { width: auto; max-width: 16rem; }
  .work-bar { flex-direction: column; }
  .work-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }
  .seg { display: flex; grid-column: 1 / -1; }
  .seg button { flex: 1; }
  .panes { grid-template-columns: 1fr; min-height: 62dvh; }
  .panes[data-pane="source"] .preview-wrap { display: none; }
  .panes[data-pane="preview"] .editor-wrap { display: none; }
  .preview-wrap { border-left: 0; }
  textarea, input, select { font-size: 16px; }
}

@media (max-width: 420px) {
  .top, .work-bar { padding-left: 12px; padding-right: 12px; }
  .lede { flex-basis: 100%; }
  .btn { padding: 8px 10px; }
  .brand h1 { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .heat span { transition: none; }
}

@media (min-width: 861px) {
  body { height: 100%; overflow: hidden; }
}
