:root {
  --bg: #f6f5f2; --card: #fff; --text: #22211f; --muted: #75716a; --line: #e2dfd8;
  --accent: #8c3522; --accent-2: #b0563f; --ok: #2f7d4f; --warn: #a86a00; --bad: #b3261e;
  --chip: #efece6; --code-bg: #faf9f6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171615; --card: #201f1d; --text: #ecebe8; --muted: #a29d94; --line: #34322e;
    --accent: #d57a62; --accent-2: #e59a85; --ok: #6cc08b; --warn: #e0a640; --bad: #f08a80;
    --chip: #2c2a27; --code-bg: #1b1a18;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-2); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button.small, .small { font-size: 12px; }
a.link { color: var(--accent); text-decoration: none; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label { display: block; margin: 8px 0; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 650; }
.brand span { color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; }
.tabs button.on { background: var(--chip); font-weight: 600; }
.bar-right { margin-left: auto; display: flex; gap: 16px; align-items: center; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.narrow { max-width: 380px; margin: 60px auto; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 280px; }
#warnings .warn { background: color-mix(in srgb, var(--warn) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }

.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .zones { grid-template-columns: 1fr; } }
.zone h3 { margin: 4px 0 8px; font-size: 15px; }
.mods { list-style: none; margin: 0; padding: 0; counter-reset: m; }
.mod { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 4px; }
.mod.off { opacity: .55; }
.mod.drag-over { border-color: var(--accent); box-shadow: 0 -2px 0 var(--accent); }
.mod .handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 2px; }
.mod .name { flex: 1; min-width: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod .name:hover { color: var(--accent); }
.mod .chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chip { background: var(--chip); color: var(--muted); border-radius: 10px; padding: 1px 8px; font-size: 11.5px; white-space: nowrap; }
.chip.adm { color: var(--accent); }
.chip.changed { color: var(--warn); }
.chip.err { color: var(--bad); }

.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 30px; height: 18px; border-radius: 9px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--card); color: var(--text); width: min(1200px, 96vw); max-height: 94vh; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 16px 20px; display: flex; flex-direction: column; max-height: 94vh; }
#importer { width: min(800px, 96vw); }
#im-html { height: 50vh; font: 12.5px/1.45 ui-monospace, Consolas, monospace; background: var(--code-bg); }
.ed-head { display: flex; gap: 16px; align-items: center; }
.ed-title { font-size: 18px; font-weight: 600; border-color: transparent; }
.ed-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; overflow: auto; min-height: 0; flex: 1; }
@media (max-width: 900px) { .ed-grid { grid-template-columns: 1fr; } }
.ed-code { display: flex; flex-direction: column; }
#ed-html { flex: 1; min-height: 60vh; font: 12.5px/1.45 ui-monospace, Consolas, monospace; tab-size: 2; white-space: pre; background: var(--code-bg); }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 8px 10px; }
legend { padding: 0 4px; font-weight: 600; }
.cond { border: 1px dashed var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; position: relative; }
.cond + .cond::before { content: "или"; position: absolute; top: -12px; left: 10px; background: var(--card); color: var(--muted); font-size: 11px; padding: 0 4px; }
.cond label { margin: 4px 0; font-size: 12.5px; }
.cond .rm { position: absolute; right: 6px; top: 4px; border: 0; background: none; color: var(--muted); padding: 0 4px; }
.cond select[multiple] { height: 70px; }
.ed-foot { display: flex; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px; }
.spacer { flex: 1; }
#ed-revs { list-style: none; padding: 0; max-height: 200px; overflow: auto; }
#ed-revs li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }

.copyrow { display: flex; gap: 8px; align-items: center; margin: 6px 0 14px; }
.copyrow code { flex: 1; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
#build-info table { border-collapse: collapse; margin-top: 8px; }
#build-info td, #build-info th { border-bottom: 1px solid var(--line); padding: 4px 12px 4px 0; text-align: left; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
#toast.bad { background: var(--bad); color: #fff; }
