:root {
  --bg: #f3f5f8; --panel: #fff; --text: #1d2430; --muted: #6a7486; --line: #dfe4ec;
  --accent: #0b5cad; --accent-ink: #fff; --sel: #e3eefb; --ok: #1d7a3e; --bad: #b3261e; --warn: #9a6200;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f; --panel: #1c222b; --text: #e5e9f0; --muted: #98a2b3; --line: #2e3643;
    --accent: #4c9be8; --accent-ink: #0b1220; --sel: #23344b; --ok: #5cc27f; --bad: #f2786d; --warn: #e0b04f;
  }
  .imgbox { background: #fff; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin: 16px 0 8px; }
h3 .small { text-transform: none; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; white-space: pre-line; }
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
input:disabled, select:disabled { opacity: .45; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--text); padding: 6px 8px; }
button.link.active { color: var(--accent); font-weight: 600; }
label { display: block; font-size: 12px; color: var(--muted); }
label input, label select { margin-top: 3px; color: var(--text); font-size: 14px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
label.check input { width: auto; margin: 0; }

.screen { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card.narrow { width: 100%; max-width: 360px; display: grid; gap: 12px; }

.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.top nav { margin-left: auto; display: flex; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; }
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }

#draw { display: grid; grid-template-columns: 320px minmax(0, 1fr) 380px; gap: 12px; padding: 12px; height: calc(100vh - 50px); }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 0; }
.pane.list { display: flex; flex-direction: column; gap: 8px; }
.pane.form { overflow: auto; }
.pane.full { margin: 12px; }
.pane.preview { display: flex; flex-direction: column; gap: 8px; }
.doors { overflow: auto; flex: 1; border-top: 1px solid var(--line); }
.door { display: grid; grid-template-columns: 70px 1fr; gap: 2px 8px; padding: 7px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.door:hover { background: var(--sel); }
.door.selected { background: var(--sel); box-shadow: inset 3px 0 var(--accent); }
.door.off { opacity: .5; }
.door b { font-variant-numeric: tabular-nums; }
.door .kind { color: var(--muted); font-size: 12px; }
.door .head { grid-column: 1 / -1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info { font-weight: 600; white-space: pre-line; }
.imgbox { flex: 1; min-height: 200px; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.imgbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .primary { flex: 1; padding: 10px; }
.notice { padding: 8px 10px; border-radius: 6px; background: var(--sel); font-size: 13px; }
.result { padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); white-space: pre-line; }
.result.ok { border-color: var(--ok); }
.result.bad { border-color: var(--bad); color: var(--bad); }
.result .links { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.result a { color: var(--accent); font-weight: 600; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type=search] { flex: 1; min-width: 200px; }
.tablewrap { overflow: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; }
td a { color: var(--accent); margin-right: 8px; }
.st-done { color: var(--ok); } .st-error { color: var(--bad); white-space: normal; min-width: 200px; } .st-queued, .st-running { color: var(--warn); }
.addrow { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; margin-top: 12px; }
.keybox { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--line); border-radius: 6px; }
.keybox code { cursor: pointer; word-break: break-all; }

@media (max-width: 1100px) {
  #draw { grid-template-columns: 280px minmax(0, 1fr); height: auto; }
  .pane.form { grid-column: 1 / -1; }
  .pane.list { max-height: 70vh; }
}
@media (max-width: 700px) {
  #draw { grid-template-columns: minmax(0, 1fr); padding: 8px 16px; }
  .pane.list { max-height: 45vh; }
  .imgbox { min-height: 220px; }
  .grid, .addrow { grid-template-columns: 1fr; }
  .top { padding: 8px 16px; }
  .pane.full { margin: 8px 16px; }
}
