/* ---------- Theme variables (all of these can be overridden in Settings or custom CSS) ---------- */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --font-ui: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "DejaVu Sans Mono", Menlo, monospace;
  --editor-font-size: 14px;

  --fg: #cccccc;
  --fg-dim: #8b8b8b;
  --fg-strong: #ffffff;
  --border: #3c3c3c;
  --accent: #007acc;
  --accent-fg: #ffffff;
  --button-bg: #0e639c;
  --button-hover: #1177bb;
  --focus: #007fd4;
  --error: #f14c4c;
  --warning: #cca700;

  --activitybar-bg: #333333;
  --activitybar-fg: #858585;
  --sidebar-bg: #252526;
  --tab-bg: #2d2d2d;
  --tab-active-bg: #1e1e1e;
  --panel-bg: #1e1e1e;
  --statusbar-bg: #007acc;
  --statusbar-fg: #ffffff;
  --input-bg: #3c3c3c;
  --list-hover: #2a2d2e;
  --list-active: #37373d;
  --popup-bg: #252526;

  --editor-bg: #1e1e1e;
  --editor-fg: #d4d4d4;
  --editor-gutter: #858585;
  --editor-gutter-active: #c6c6c6;
  --editor-selection: #264f78;
  --editor-line: #ffffff0d;
  --editor-caret: #aeafad;
  --editor-match: #515c6a;

  --tok-comment: #6a9955;
  --tok-keyword: #569cd6;
  --tok-control: #c586c0;
  --tok-string: #ce9178;
  --tok-number: #b5cea8;
  --tok-function: #dcdcaa;
  --tok-type: #4ec9b0;
  --tok-variable: #9cdcfe;
  --tok-property: #9cdcfe;
  --tok-tag: #569cd6;
  --tok-operator: #d4d4d4;
  --tok-bracket: #ffd700;
  --tok-regexp: #d16969;
  --tok-meta: #9b9b9b;
  --tok-invalid: #f44747;
}

[data-theme="light"] {
  color-scheme: light;
  --fg: #3b3b3b;
  --fg-dim: #717171;
  --fg-strong: #000000;
  --border: #d4d4d4;
  --button-bg: #007acc;
  --button-hover: #0062a3;
  --error: #e51400;
  --warning: #bf8803;

  --activitybar-bg: #2c2c2c;
  --activitybar-fg: #858585;
  --sidebar-bg: #f3f3f3;
  --tab-bg: #ececec;
  --tab-active-bg: #ffffff;
  --panel-bg: #ffffff;
  --input-bg: #ffffff;
  --list-hover: #e8e8e8;
  --list-active: #e4e6f1;
  --popup-bg: #f3f3f3;

  --editor-bg: #ffffff;
  --editor-fg: #000000;
  --editor-gutter: #237893;
  --editor-gutter-active: #0b216f;
  --editor-selection: #add6ff;
  --editor-line: #0000000a;
  --editor-caret: #000000;
  --editor-match: #e8e8e8;

  --tok-comment: #008000;
  --tok-keyword: #0000ff;
  --tok-control: #af00db;
  --tok-string: #a31515;
  --tok-number: #098658;
  --tok-function: #795e26;
  --tok-type: #267f99;
  --tok-variable: #001080;
  --tok-property: #001080;
  --tok-tag: #800000;
  --tok-operator: #000000;
  --tok-bracket: #0431fa;
  --tok-regexp: #811f3f;
  --tok-meta: #666666;
  --tok-invalid: #cd3131;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--fg);
  background: var(--editor-bg);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 1px solid var(--focus); outline-offset: -1px; }
[hidden] { display: none !important; }
kbd { font-family: var(--font-mono); font-size: 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: #79797966; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #646464b3; }

.btn { padding: 6px 14px; border-radius: 2px; background: var(--input-bg); border: 1px solid var(--border); }
.btn.primary { background: var(--button-bg); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--button-hover); }
input[type=text], input:not([type]), input[type=password], input[type=number], select, textarea {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 2px; padding: 4px 6px; color: var(--fg);
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--focus); outline-offset: -1px; }

/* ---------- Layout ---------- */
#app { display: flex; height: calc(100% - 22px); min-height: 0; }
#activitybar { width: 48px; background: var(--activitybar-bg); display: flex; flex-direction: column; flex: none; }
#activitybar button { height: 48px; color: var(--activitybar-fg); display: flex; align-items: center; justify-content: center; }
#activitybar button:hover { color: #fff; }
#activitybar button .i { width: 24px; height: 24px; stroke-width: 1.5; }
#activitybar .spacer { flex: 1; }
#activitybar button.active { color: #fff; box-shadow: inset 2px 0 0 var(--accent); }

#sidebar { width: var(--sidebar-w, 260px); background: var(--sidebar-bg); display: flex; flex-direction: column; flex: none; min-width: 0; }
#sidebar header { height: 35px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 20px; color: var(--fg-dim); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; flex: none; }
#sidebar header .actions { display: flex; }
#sidebar header button, .bar button, .panel-actions button, #tabactions button { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--fg); }
#sidebar header button:hover, .bar button:hover, .panel-actions button:hover, #tabactions button:hover { background: #5a5d5e50; }
#tree { flex: 1; overflow: auto; outline: none; padding-bottom: 20px; }
.node { display: flex; align-items: center; height: 24px; padding-right: 8px; cursor: pointer; white-space: nowrap; user-select: none; }
.node:hover { background: var(--list-hover); }
.node.selected { background: var(--list-active); }
#tree:focus-within .node.selected { background: var(--accent); color: var(--accent-fg); }
.node .chev { width: 16px; display: flex; justify-content: center; color: var(--fg-dim); }
.node .i { margin-right: 4px; }
.node .name { overflow: hidden; text-overflow: ellipsis; }
.node.file-py .i { color: #519aba; } .node.file-js .i { color: #cbcb41; } .node.file-html .i { color: #e37933; } .node.file-css .i { color: #519aba; }
.empty-hint { padding: 12px 20px; color: var(--fg-dim); }

.resizer { width: 4px; margin: 0 -2px; z-index: 5; cursor: col-resize; flex: none; position: relative; background: transparent; }
.resizer:hover, .resizer.drag { background: var(--focus); }
.resizer.h { width: auto; height: 4px; margin: -2px 0; cursor: row-resize; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--editor-bg); }
#tabbar { display: flex; height: 35px; background: var(--tab-bg); flex: none; }
#tabs { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; min-width: 0; max-width: 200px; flex: none; color: var(--fg-dim); border-right: 1px solid var(--sidebar-bg); background: var(--tab-bg); cursor: pointer; user-select: none; }
.tab.active { background: var(--tab-active-bg); color: var(--fg-strong); box-shadow: inset 0 1px 0 var(--accent); }
.tab .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .close { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.tab .close:hover { background: #5a5d5e50; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tab.dirty .close .i { display: none; }
.tab:not(.dirty) .dot { display: none; }
.tab.dirty .close:hover .i { display: block; } .tab.dirty .close:hover .dot { display: none; }
#tabactions { display: flex; align-items: center; padding: 0 6px; gap: 2px; flex: none; }

#workarea { flex: 1; display: flex; min-height: 0; }
#editorarea { flex: 1; min-width: 0; position: relative; }
#editor, #settings-view { position: absolute; inset: 0; }
#welcome { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--fg-dim); }
#welcome p { margin: 4px; }

#preview { width: var(--preview-w, 45%); display: flex; flex-direction: column; min-width: 160px; border-left: 1px solid var(--border); background: #fff; }
#preview .bar { display: flex; gap: 4px; padding: 4px; background: var(--tab-bg); flex: none; }
#preview .bar input { flex: 1; min-width: 0; }
#preview iframe { flex: 1; border: 0; background: #fff; width: 100%; }

#panel { height: var(--panel-h, 220px); display: flex; flex-direction: column; background: var(--panel-bg); border-top: 1px solid var(--border); flex: none; min-height: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; height: 35px; padding: 0 8px; flex: none; }
.panel-tabs { display: flex; gap: 14px; }
.panel-tabs button { height: 35px; color: var(--fg-dim); border-bottom: 1px solid transparent; padding: 0 2px; }
.panel-tabs button.active { color: var(--fg-strong); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: var(--accent-fg); border-radius: 8px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.panel-actions { display: flex; }
.panel-body { flex: 1; overflow: auto; padding: 4px 12px; min-height: 0; font-family: var(--font-mono); font-size: 12.5px; }
#out { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
#out .err { color: var(--error); } #out .info { color: var(--fg-dim); } #out .echo { color: var(--tok-string); }
#stdin-form { display: flex; padding: 4px 8px; border-top: 1px solid var(--border); flex: none; }
#stdin-form input { flex: 1; font-family: var(--font-mono); }
.problem { display: flex; gap: 8px; padding: 3px 4px; cursor: pointer; align-items: baseline; font-family: var(--font-ui); font-size: 13px; }
.problem:hover { background: var(--list-hover); }
.problem .i.err { color: var(--error); } .problem .i.warn { color: var(--warning); }
.problem .where { color: var(--fg-dim); }
.console-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; border-bottom: 1px solid #ffffff0a; }
.console-line.warn { color: var(--warning); } .console-line.error { color: var(--error); } .console-line.info, .console-line.debug { color: var(--fg-dim); }
.panel-empty { color: var(--fg-dim); font-family: var(--font-ui); padding: 6px 0; }

#statusbar { position: fixed; left: 0; right: 0; bottom: 0; height: 22px; background: var(--statusbar-bg); color: var(--statusbar-fg); display: flex; justify-content: space-between; align-items: center; padding: 0 8px; font-size: 12px; z-index: 10; }
#statusbar .left, #statusbar .right { display: flex; gap: 14px; align-items: center; min-width: 0; }
#statusbar button { color: inherit; display: flex; align-items: center; gap: 4px; height: 22px; padding: 0 4px; }
#statusbar button:hover { background: #ffffff1f; }
#statusbar .i { width: 14px; height: 14px; }
#st-message { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Editor chrome (high specificity so it wins over CodeMirror's injected styles) ---------- */
#editor .cm-editor { height: 100%; background: var(--editor-bg); color: var(--editor-fg); font-size: var(--editor-font-size); }
#editor .cm-editor.cm-focused { outline: none; }
#editor .cm-scroller { font-family: var(--font-mono); line-height: 1.5; }
#editor .cm-content { caret-color: var(--editor-caret); }
#editor .cm-cursor, #editor .cm-dropCursor { border-left-color: var(--editor-caret); }
#editor .cm-gutters { background: var(--editor-bg); color: var(--editor-gutter); border: 0; }
#editor .cm-activeLine { background: var(--editor-line); }
#editor .cm-activeLineGutter { background: transparent; color: var(--editor-gutter-active); }
#editor .cm-selectionBackground, #editor .cm-content ::selection { background: var(--editor-selection) !important; }
#editor .cm-selectionMatch { background: var(--editor-match); }
#editor .cm-matchingBracket { background: #ffffff1a; outline: 1px solid #888888; color: inherit !important; }
#editor .cm-nonmatchingBracket { color: var(--error) !important; }
#editor .cm-foldPlaceholder { background: var(--input-bg); border: 0; color: var(--fg-dim); }
#editor .cm-lintRange-error { background-image: none; text-decoration: underline wavy var(--error); text-underline-offset: 3px; }
#editor .cm-lintRange-warning { background-image: none; text-decoration: underline wavy var(--warning); text-underline-offset: 3px; }
#editor .cm-tooltip { background: var(--popup-bg); color: var(--fg); border: 1px solid var(--border); }
#editor .cm-tooltip-autocomplete > ul { font-family: var(--font-mono); font-size: 12.5px; max-height: 14em; }
#editor .cm-tooltip-autocomplete > ul > li { padding: 1px 6px; }
#editor .cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--accent); color: var(--accent-fg); }
#editor .cm-completionMatchedText { text-decoration: none; font-weight: bold; }
#editor .cm-completionDetail { color: var(--fg-dim); margin-left: 1em; font-style: normal; }
#editor li[aria-selected] .cm-completionDetail { color: inherit; opacity: .8; }
#editor .cm-panels { background: var(--popup-bg); color: var(--fg); border-color: var(--border); }
#editor .cm-panels-top { border-bottom: 1px solid var(--border); }
#editor .cm-panel.cm-search { padding: 6px 28px 6px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#editor .cm-panel.cm-search br { display: none; }
#editor .cm-panel.cm-search input, #editor .cm-panel.cm-search button { margin: 0; font-size: 12px; }
#editor .cm-panel.cm-search input[type=text] { background: var(--input-bg); border: 1px solid var(--border); color: var(--fg); padding: 2px 6px; }
#editor .cm-panel.cm-search button { background: var(--input-bg); border: 1px solid var(--border); padding: 2px 8px; border-radius: 2px; background-image: none; color: var(--fg); }
#editor .cm-panel.cm-search label { font-size: 12px; }
#editor .cm-panel.cm-search [name=close] { position: absolute; top: 4px; right: 6px; background: none; border: 0; font-size: 16px; }
#editor .cm-searchMatch { background: #ea5c0055; outline: 1px solid #ea5c0090; }
#editor .cm-searchMatch-selected { background: #a8ac94; }

/* ---------- Palette, dialogs, menus ---------- */
#overlay:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette, .dialog { background: var(--popup-bg); border: 1px solid var(--border); box-shadow: 0 4px 24px #0008; width: min(600px, 94vw); }
.palette input { width: calc(100% - 12px); margin: 6px; padding: 5px 8px; }
.palette ul { list-style: none; margin: 0; padding: 0 0 4px; max-height: 50vh; overflow: auto; }
.palette li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; cursor: pointer; }
.palette li.sel { background: var(--accent); color: var(--accent-fg); }
.palette li .detail { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette li.sel .detail { color: inherit; opacity: .8; }
.palette .none { padding: 8px 12px; color: var(--fg-dim); }
.dialog { padding: 14px; width: min(420px, 94vw); margin-top: 8vh; }
.dialog p { margin: 0 0 10px; }
.dialog input { width: 100%; margin-bottom: 12px; }
.dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
.menu { position: fixed; z-index: 60; background: var(--popup-bg); border: 1px solid var(--border); box-shadow: 0 2px 10px #0008; min-width: 170px; padding: 4px 0; }
.menu button { display: block; width: 100%; text-align: left; padding: 4px 14px; }
.menu button:hover { background: var(--accent); color: var(--accent-fg); }
.menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu .head { padding: 4px 14px; color: var(--fg-dim); }

/* ---------- Settings view ---------- */
#settings-view { overflow: auto; padding: 8px 28px 60px; background: var(--editor-bg); }
#settings-view .wrap { max-width: 820px; }
#settings-view h2 { font-size: 15px; font-weight: 600; margin: 26px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); color: var(--fg-strong); }
#settings-view h2:first-child { margin-top: 12px; }
#settings-view .row { display: flex; align-items: center; gap: 10px; padding: 5px 0; flex-wrap: wrap; }
#settings-view .row > label { width: 200px; flex: none; }
#settings-view .hint { color: var(--fg-dim); font-size: 12px; margin: 2px 0 6px; }
#settings-view textarea { width: 100%; min-height: 160px; font-family: var(--font-mono); font-size: 12.5px; resize: vertical; }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 20px; }
.color-item { display: flex; align-items: center; gap: 8px; }
.color-item input[type=color] { width: 28px; height: 22px; padding: 0; border: 1px solid var(--border); background: none; }
.color-item span { flex: 1; }
.color-item .reset { color: var(--fg-dim); visibility: hidden; }
.color-item.changed .reset { visibility: visible; }
table.keys { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.keys th { text-align: left; color: var(--fg-dim); font-weight: normal; padding: 4px 8px; border-bottom: 1px solid var(--border); }
table.keys td { padding: 3px 8px; border-bottom: 1px solid #ffffff0a; }
table.keys td.cat { color: var(--fg-dim); }
table.keys .keycell { min-width: 150px; text-align: left; padding: 2px 8px; border: 1px solid transparent; border-radius: 2px; font-family: var(--font-mono); font-size: 12px; }
table.keys .keycell:hover { border-color: var(--border); background: var(--input-bg); }
table.keys .keycell.capture { border-color: var(--focus); background: var(--input-bg); color: var(--fg-dim); }
table.keys .modified td:nth-child(2) { color: var(--fg-strong); }
table.keys .warn { color: var(--warning); font-size: 12px; }
table.keys .small { color: var(--fg-dim); padding: 2px 6px; }
table.keys .small:hover { color: var(--fg); }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; overflow: auto; }
.login-box { width: min(360px, 92vw); background: var(--sidebar-bg); border: 1px solid var(--border); padding: 24px; }
.login-box h1 { font-size: 18px; font-weight: 600; margin: 0 0 16px; color: var(--fg-strong); }
.login-tabs { display: flex; gap: 16px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.login-tabs button { padding: 6px 0; color: var(--fg-dim); border-bottom: 1px solid transparent; }
.login-tabs button.active { color: var(--fg-strong); border-bottom-color: var(--accent); }
.login-box label { display: block; margin-bottom: 10px; color: var(--fg-dim); }
.login-box input { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; color: var(--fg); }
.login-msg { min-height: 18px; margin: 4px 0 10px; }
.login-msg.err { color: var(--error); } .login-msg.ok { color: var(--fg); }
.login-note { color: var(--fg-dim); font-size: 12px; margin: 12px 0 0; }
.login-box .btn { width: 100%; }

/* ---------- Small screens ---------- */
@media (max-width: 800px) {
  #sidebar { position: fixed; left: 48px; top: 0; bottom: 22px; width: min(82vw, 320px); z-index: 30; box-shadow: 4px 0 16px #0008; }
  #rz-sidebar { display: none; }
  #workarea { flex-direction: column; }
  #preview { width: 100%; height: 45%; border-left: 0; border-top: 1px solid var(--border); }
  #rz-preview { display: none; }
  #settings-view { padding: 8px 14px 60px; }
  #settings-view .row > label { width: 100%; }
  .tab { max-width: 150px; }
}

button:disabled { opacity: .35; cursor: default; }
button:disabled:hover { background: none !important; }

/* ---------- Sites ---------- */
#sites-view { flex: 1; overflow: auto; padding: 0 0 20px; }
#sites-view .site-new { margin: 6px 12px 10px; }
.site { padding: 6px 12px; border-bottom: 1px solid #ffffff0a; }
.site .top { display: flex; align-items: baseline; gap: 8px; }
.site .slug { color: var(--fg-strong); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.site .slug:hover { text-decoration: underline; }
.site .kind { color: var(--fg-dim); font-size: 11px; text-transform: uppercase; }
.site .state { margin-left: auto; font-size: 12px; color: var(--fg-dim); display: flex; align-items: center; gap: 5px; }
.site .state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fg-dim); }
.site .state.running::before, .site .state.static::before { background: #3fb950; }
.site .state.installing::before, .site .state.starting::before { background: var(--warning); }
.site .state.crashed::before { background: var(--error); }
.site .meta { color: var(--fg-dim); font-size: 12px; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site .btns { display: flex; gap: 2px; }
.site .btns button { width: 26px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.site .btns button:hover { background: #5a5d5e50; }
#server-log { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; }
.site-form label { display: block; margin-bottom: 8px; color: var(--fg-dim); }
.site-form input, .site-form select, .site-form textarea { display: block; width: 100%; margin-top: 3px; color: var(--fg); }
.site-form textarea { min-height: 54px; font-family: var(--font-mono); font-size: 12px; }
.site-form .hint { color: var(--fg-dim); font-size: 12px; margin: -4px 0 8px; }
.site-form .err { color: var(--error); min-height: 16px; margin: 0 0 6px; }
.dialog.wide { width: min(460px, 94vw); }

/* ---------- Sign-up notice ---------- */
.terms { max-height: 220px; overflow: auto; white-space: pre-wrap; font: 12px/1.45 var(--font-ui); background: var(--editor-bg); border: 1px solid var(--border); padding: 8px; margin: 0 0 8px; color: var(--fg); }
.login-box.wide { width: min(560px, 94vw); }
.check { display: flex !important; gap: 8px; align-items: flex-start; color: var(--fg) !important; }
.check input { width: auto !important; margin-top: 3px !important; }

/* ---------- Administration ---------- */
body.admin-body { overflow: auto; height: auto; min-height: 100%; display: block; }
.admin-head { display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 44px; background: var(--activitybar-bg); color: #ddd; position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.admin-head strong { color: #fff; }
#admin-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#admin-tabs button { padding: 4px 10px; color: #bbb; border-radius: 3px; }
#admin-tabs button.active { color: #fff; background: #ffffff1f; }
#admin-main { padding: 16px; max-width: 1200px; margin: 0 auto; }
#admin-main h2 { font-size: 15px; font-weight: 600; margin: 4px 0 10px; color: var(--fg-strong); }
#admin-main .hint { color: var(--fg-dim); font-size: 12px; margin: 0 0 10px; }
.atable { width: 100%; border-collapse: collapse; font-size: 13px; }
.atable th { text-align: left; color: var(--fg-dim); font-weight: normal; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.atable td { padding: 6px 8px; border-bottom: 1px solid #ffffff0d; vertical-align: top; }
.atable tr.pending td { background: #cca7000f; }
.atable .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.atable .acts button, .abtn { padding: 2px 8px; border: 1px solid var(--border); border-radius: 2px; background: var(--input-bg); font-size: 12px; }
.atable .acts button:hover, .abtn:hover { border-color: var(--focus); }
.atable .acts button.danger:hover { border-color: var(--error); color: var(--error); }
.tag { font-size: 11px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border); color: var(--fg-dim); }
.tag.ok { color: #3fb950; border-color: #3fb95066; } .tag.warn { color: var(--warning); border-color: #cca70066; } .tag.bad { color: var(--error); border-color: #f14c4c66; }
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card { border: 1px solid var(--border); padding: 8px 12px; min-width: 150px; }
.card b { display: block; font-size: 18px; color: var(--fg-strong); font-weight: 600; }
.card span { color: var(--fg-dim); font-size: 12px; }
.lim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 24px; }
.lim-grid label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lim-grid input, .lim-grid select { width: 130px; }
.dialog.xl { width: min(980px, 96vw); margin-top: 4vh; }
.dialog .err { color: var(--error); min-height: 16px; margin: 6px 0; }
.filebrowser { display: flex; gap: 12px; height: min(60vh, 520px); }
.filebrowser .list { width: 280px; overflow: auto; border: 1px solid var(--border); flex: none; }
.filebrowser .list div { padding: 3px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.filebrowser .list div:hover { background: var(--list-hover); } .filebrowser .list div.sel { background: var(--accent); color: var(--accent-fg); }
.filebrowser .view { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.filebrowser pre { flex: 1; margin: 0; overflow: auto; border: 1px solid var(--border); padding: 8px; font: 12px/1.45 var(--font-mono); background: var(--editor-bg); white-space: pre-wrap; word-break: break-word; }
.logbox { max-height: 60vh; overflow: auto; margin: 0 0 12px; border: 1px solid var(--border); padding: 8px; font: 12px/1.45 var(--font-mono); white-space: pre-wrap; word-break: break-word; background: var(--editor-bg); }
@media (max-width: 800px) { .filebrowser { flex-direction: column; height: auto; } .filebrowser .list { width: 100%; max-height: 200px; } .atable { display: block; overflow-x: auto; } }
