:root {
  color-scheme: dark;
  --bg: #100e0b;
  --panel: #17140f;
  --ink: #f3efe4;
  --muted: #b3a894;
  --line: #3a3228;
  --amber: #e2a23a;
  --amber-ink: #2a1d08;
  --danger: #e07a68;
  --font: ui-sans-serif, system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

button:disabled { opacity: 0.45; cursor: default; }

button.on, .tabs button.on {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: var(--amber);
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 240px minmax(0, 1.15fr) minmax(320px, 0.95fr);
}

.side, .chat, .stage {
  min-height: 0;
  min-width: 0;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: #14110d;
}

.brand, .side-foot, header, .tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand { padding: 0 6px; }

.brand strong, .brand small, .side-foot span {
  display: block;
}

.brand small, .hint, #status, .side-foot span {
  color: var(--muted);
  font-size: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--amber);
  color: var(--amber-ink);
  font-weight: 700;
}

.create { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.create input, .card input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 10px;
}

#create-error, .create .error { grid-column: 1 / -1; }

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
  min-height: 0;
  flex: 1;
}

nav button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border-radius: 12px;
  text-align: left;
}

nav button small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

nav button.on {
  background: #2a241c;
  color: var(--ink);
  border-color: var(--amber);
}

.wide { width: 100%; }

.kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--amber);
}

dialog {
  width: min(520px, calc(100% - 24px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #17140f;
  color: inherit;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

dialog h2 { margin: 8px 0; }

dialog p { color: var(--muted); line-height: 1.45; }

dialog input, .domain-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 10px;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  margin: 8px 0;
  border-radius: 14px;
  text-align: left;
}

.choice small { color: var(--muted); }

.domain-row { display: flex; align-items: center; gap: 8px; }

.domain-row span { color: var(--amber); white-space: nowrap; }

.wizard-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }

#accounts-form, #wizard-form { display: grid; gap: 8px; }

.fresh {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #2a241c;
  color: var(--ink);
}

.drop {
  display: grid;
  place-items: center;
  min-height: 92px;
  margin: 8px 0;
  border: 1px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
}

.drop.over { border-color: var(--amber); color: var(--amber); }

.side-foot {
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.chat, .stage {
  display: flex;
  flex-direction: column;
}

.chat { border-right: 1px solid var(--line); }

header, .tabs {
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.titles { min-width: 0; }

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

#status { margin: 4px 0 0; }

.actions, .tabs { flex-wrap: wrap; }

.actions { justify-content: flex-end; }

#delete-site { color: var(--danger); }

.banner, .error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.banner { padding: 8px 14px; }

#term { flex: 1; min-height: 0; padding: 0 8px 8px; }

.empty {
  margin: auto;
  max-width: 360px;
  text-align: center;
  color: var(--muted);
}

.empty p { margin: 0 0 8px; }

.tabs a {
  margin-left: auto;
  color: var(--amber);
  font-size: 14px;
}

.stage iframe, .pane { flex: 1; min-height: 0; }

.stage iframe {
  width: 100%;
  border: 0;
  background: white;
}

.pane {
  overflow: auto;
  padding: 14px;
}

.pane article, .pane section {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.mail-subject { margin: 0 0 4px; font-weight: 650; }

.mail-to, .mail-body, .empty-copy { margin: 0 0 6px; }

.mail-body { white-space: pre-wrap; }

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
  font-family: var(--mono);
  font-size: 12px;
}

#mail-count:not(:empty)::before { content: "· "; }

.gate {
  display: grid;
  place-items: center;
  min-height: 100%;
  background:
    radial-gradient(circle at top, #3a2a16, transparent 36%),
    var(--bg);
}

.card {
  width: min(420px, calc(100% - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #17140f;
}

.card h1 { font-size: 36px; }

.lede { color: var(--muted); line-height: 1.45; }

.card form { display: grid; gap: 12px; }

.card label, .card .text { display: grid; gap: 6px; font-size: 13px; }

.card .text {
  margin-top: 14px;
  padding: 0;
  border: 0;
  color: var(--amber);
  background: none;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(320px, 52vh) minmax(280px, 48vh);
    height: auto;
    min-height: 100%;
  }

  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  nav { max-height: 180px; }
  .chat { border-right: 0; border-bottom: 1px solid var(--line); }
}
