:root {
  --bg: #030806;
  --panel: #07110c;
  --fg: #b8ffd2;
  --dim: #5ea978;
  --hot: #55ff88;
  --amber: #ffd166;
  --red: #ff5d73;
  --line: #1f5f38;
  --mono: ui-monospace, SFMono-Regular, Consolas, Monaco, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 50% 20%, #0b2114 0, var(--bg) 55%);
  color: var(--fg);
  font-family: var(--mono);
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0, rgba(255,255,255,.025) 1px, transparent 1px, transparent 3px);
  z-index: 20;
}

.shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1180px;
  margin: auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(0,0,0,.28);
}
header, footer { background: #06100b; }
header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  font-weight: 800;
  letter-spacing: .16em;
  color: var(--hot);
  text-shadow: 0 0 12px rgba(85,255,136,.4);
}
.status { font-size: .78rem; color: var(--dim); }
main { overflow: auto; padding: 18px; }
.panel {
  border: 1px solid var(--line);
  background: rgba(4,15,9,.86);
  padding: 16px;
  margin: 0 auto 16px;
  max-width: 960px;
  box-shadow: 0 0 24px rgba(34,129,69,.12);
}
h1, h2, h3 { margin: .15rem 0 1rem; color: var(--hot); }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
.ascii {
  white-space: pre;
  overflow: auto;
  color: var(--hot);
  font-size: clamp(.55rem, 1.4vw, .9rem);
  line-height: 1.12;
  text-align: center;
  margin: 0 0 12px;
}
.screen-art { text-align: left; }
.muted { color: var(--dim); }
.warning { color: var(--amber); }
.error { color: var(--red); min-height: 1.2em; }
.success { color: var(--hot); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.grid.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  border: 1px solid var(--line);
  background: #07120c;
  padding: 14px;
  cursor: pointer;
}
.card:hover, .card:focus {
  border-color: var(--hot);
  outline: none;
  box-shadow: inset 0 0 14px rgba(85,255,136,.12);
}
button, input, textarea, select { font: inherit; }
button {
  background: #0b2917;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 9px 12px;
  cursor: pointer;
}
button:hover, button:focus, button.active {
  border-color: var(--hot);
  color: #fff;
  outline: none;
}
button:disabled { cursor: not-allowed; opacity: .55; }
.danger { border-color: #6f2633; color: #ff9aaa; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar.compact { margin: 0; justify-content: flex-end; }
label { display: block; color: var(--dim); margin: .75rem 0 .3rem; }
input, textarea, select {
  width: 100%;
  background: #020704;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--hot); }
input[type="checkbox"], input[type="range"] { width: auto; }
textarea { min-height: 130px; resize: vertical; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button.active { border-color: var(--hot); color: var(--hot); }
.row { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; }
.row > div:first-child { min-width: 0; }
.meta { font-size: .78rem; color: var(--dim); margin-top: 5px; }
.subject { color: var(--fg); font-weight: 700; overflow-wrap: anywhere; }
.post { border-top: 1px dashed var(--line); padding: 14px 0; }
.post:first-child { border-top: 0; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; color: #d7ffe3; }
.badge {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 1px 6px;
  font-size: .7rem;
  color: var(--amber);
  margin-left: 6px;
}
a { color: var(--hot); }
footer {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: .76rem;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.modal-code {
  font-size: 1rem;
  overflow-wrap: anywhere;
  border: 1px dashed var(--hot);
  padding: 12px;
  color: var(--hot);
  background: #020704;
}
.empty { padding: 22px; text-align: center; color: var(--dim); border: 1px dashed var(--line); }
.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
  color: var(--red);
  z-index: 50;
}

.ansi-editor {
  min-height: 260px;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  line-height: 1.15;
}
.ansi-controls {
  margin: 12px 0;
  padding: 12px;
  border: 1px dashed var(--line);
  background: #020704;
}
.ansi-palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  gap: 4px;
  margin: 5px 0 12px;
}
.ansi-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  font-size: .7rem;
}
.ansi-swatch.selected { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,.35); }
.ansi-chip { width: 16px; height: 16px; display: inline-block; border: 1px solid #666; }
.inline-option { display: inline-flex; align-items: center; gap: 8px; margin-right: 12px; }
.ansi-canvas {
  margin: 8px 0 16px;
  padding: 12px;
  min-height: 80px;
  overflow: auto;
  white-space: pre;
  background: #000;
  border: 1px solid #555;
  color: #aaa;
  font-size: clamp(.48rem, 1.35vw, .82rem);
  line-height: 1.05;
  text-align: left;
}
.gallery-art { max-height: 430px; }
.creation-card {
  border: 1px solid var(--line);
  background: #06100b;
  padding: 14px;
  margin: 0 0 14px;
}
.ansi-bold { font-weight: 800; }
.ansi-fg-0 { color: #000000; } .ansi-bg-0 { background-color: #000000; }
.ansi-fg-1 { color: #aa0000; } .ansi-bg-1 { background-color: #aa0000; }
.ansi-fg-2 { color: #00aa00; } .ansi-bg-2 { background-color: #00aa00; }
.ansi-fg-3 { color: #aa5500; } .ansi-bg-3 { background-color: #aa5500; }
.ansi-fg-4 { color: #0000aa; } .ansi-bg-4 { background-color: #0000aa; }
.ansi-fg-5 { color: #aa00aa; } .ansi-bg-5 { background-color: #aa00aa; }
.ansi-fg-6 { color: #00aaaa; } .ansi-bg-6 { background-color: #00aaaa; }
.ansi-fg-7 { color: #aaaaaa; } .ansi-bg-7 { background-color: #aaaaaa; }
.ansi-fg-8 { color: #555555; } .ansi-bg-8 { background-color: #555555; }
.ansi-fg-9 { color: #ff5555; } .ansi-bg-9 { background-color: #ff5555; }
.ansi-fg-10 { color: #55ff55; } .ansi-bg-10 { background-color: #55ff55; }
.ansi-fg-11 { color: #ffff55; } .ansi-bg-11 { background-color: #ffff55; }
.ansi-fg-12 { color: #5555ff; } .ansi-bg-12 { background-color: #5555ff; }
.ansi-fg-13 { color: #ff55ff; } .ansi-bg-13 { background-color: #ff55ff; }
.ansi-fg-14 { color: #55ffff; } .ansi-bg-14 { background-color: #55ffff; }
.ansi-fg-15 { color: #ffffff; } .ansi-bg-15 { background-color: #ffffff; }

.tracker-scroll { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); }
.tracker { border-collapse: collapse; min-width: 1050px; width: 100%; background: #020704; }
.tracker th, .tracker td { border: 1px solid #153d25; padding: 3px; text-align: center; }
.tracker thead th { color: var(--amber); font-size: .72rem; }
.tracker tbody th { position: sticky; left: 0; z-index: 2; min-width: 125px; background: #06100b; color: var(--hot); }
.tracker tbody th span { display: block; margin-bottom: 4px; }
.tracker select { min-width: 54px; padding: 4px; font-size: .72rem; }
.tracker tbody th select { min-width: 105px; }
.tracker tbody th input[type="range"] { display: block; max-width: 105px; margin: 5px auto 0; }
.tracker-text {
  white-space: pre;
  overflow-x: auto;
  padding: 10px;
  background: #020704;
  border: 1px dashed var(--line);
  color: var(--dim);
  font-size: .72rem;
}

@media (max-width: 650px) {
  header { align-items: flex-start; flex-direction: column; }
  main { padding: 10px; }
  .panel { padding: 12px; }
  .row { flex-direction: column; }
  .ascii { font-size: .5rem; }
  .grid.two-column { grid-template-columns: 1fr; }
  .ansi-palette { grid-template-columns: repeat(4, minmax(38px, 1fr)); }
  .ansi-editor { min-height: 220px; }
  .toolbar.compact { justify-content: flex-start; }
  footer { display: block; }
}

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