:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1c2130;
  --muted: #6b7280;
  --line: #e3e6ec;
  --accent: #4f7cff;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --code-bg: #0f1422;
  --code-text: #d7deea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --panel: #161b24;
    --text: #e4e8ef;
    --muted: #8b94a5;
    --line: #262d3a;
    --accent: #6b8fff;
    --code-bg: #0a0d14;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 16px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; }
nav { display: flex; align-items: center; gap: 12px; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 60px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.field { margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }

pre.log {
  background: var(--code-bg); color: var(--code-text); padding: 12px; border-radius: 8px;
  max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 24px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }

#toast { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
#toast div { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
#toast div.err { border-left-color: var(--err); }
#toast div.ok { border-left-color: var(--ok); }

.login { max-width: 360px; margin: 10vh auto; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv > div:nth-child(odd) { color: var(--muted); }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv > div:nth-child(odd) { margin-top: 6px; } }

/* ---------- file manager / code editor ---------- */
.fm-note { padding: 10px 14px; font-size: 13px; }
.fm {
  display: grid; grid-template-columns: 260px 1fr; gap: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  height: max(460px, calc(100vh - 290px));
}
.fm-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.fm-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.fm-bar { display: flex; gap: 4px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fm-bar select { width: auto; padding: 3px 6px; font-size: 13px; }
.ftree { overflow: auto; flex: 1; padding: 4px 0; font-size: 13px; }
.fitem { padding: 3px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.fitem:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.fitem.sel { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.fitem .caret { display: inline-block; width: 14px; color: var(--muted); }
.fitem .dot, .etab .x { color: var(--accent); }
.etabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); min-height: 34px; }
.etab { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--muted); }
.etab.active { color: var(--text); background: var(--bg); box-shadow: inset 0 -2px 0 var(--accent); }
.etab .x { width: 16px; text-align: center; border-radius: 4px; }
.etab .x:hover { background: var(--line); }
.monaco-wrap { position: relative; flex: 1; min-height: 0; }
#code-editor { position: absolute; inset: 0; }
.enote[hidden] { display: none; }
.enote { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 16px; text-align: center; }
@media (max-width: 760px) {
  .fm { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; height: auto; }
  .fm-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .fm-main { height: 70vh; }
}
@media (max-width: 480px) {
  .top { padding: 10px 12px; }
  .brand-name { display: none; }
  nav { gap: 8px; }
}
