:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --border: #e2e2e8;
  --text: #1c1c22;
  --muted: #6b6b76;
  --accent: #d6336c;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e3f5ea;
  --warn: #9a6400;
  --warn-bg: #fff3d6;
  --err: #c0322b;
  --err-bg: #fde6e4;
  --info: #2f5fb3;
  --info-bg: #e5edfb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1a1a1f;
    --surface-2: #232329;
    --border: #2e2e36;
    --text: #ececf1;
    --muted: #9a9aa6;
    --accent: #f06595;
    --accent-text: #16060c;
    --ok: #5fd08e;
    --ok-bg: #16301f;
    --warn: #f0b84a;
    --warn-bg: #33270e;
    --err: #ff8078;
    --err-bg: #3a1614;
    --info: #86aef5;
    --info-bg: #17233a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.error { color: var(--err); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .6rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { white-space: nowrap; }
nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
nav a {
  padding: .4rem .75rem; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap;
}
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

main { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
#banner { max-width: 1040px; margin: 0 auto; padding: 0 1rem; }
#banner:empty { display: none; }
#banner .alert { margin-top: 1rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .9rem; }

label { display: block; font-weight: 600; font-size: .9rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; margin-top: .3rem; padding: .6rem .7rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.counter { font-size: .8rem; color: var(--muted); text-align: right; margin-top: .2rem; }
.counter.over { color: var(--err); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.big { padding: .8rem 1.5rem; font-size: 1.05rem; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--info); }

.alert { padding: .75rem 1rem; border-radius: 10px; border: 1px solid transparent; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--info-bg); color: var(--info); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card .btn { width: 100%; margin-top: 1rem; }
.login-card label { margin-top: 1rem; }

.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem;
  text-align: center; cursor: pointer; background: var(--surface-2);
}
.drop.over { border-color: var(--accent); }
.drop input { display: none; }
.preview { display: flex; gap: 1rem; align-items: flex-start; text-align: left; }
.preview video { width: 120px; aspect-ratio: 9 / 16; object-fit: contain; background: #000; border-radius: 8px; flex: none; }
.preview ul { margin: .4rem 0 0; padding-left: 1.1rem; }

.plat-select { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.plat-option {
  border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; background: var(--surface);
}
.plat-option .muted { font-size: .8rem; margin-top: .25rem; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.progress.indeterminate > div { width: 35%; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.steps { display: flex; flex-direction: column; gap: .6rem; }
.step {
  display: grid; grid-template-columns: 36px 1fr auto; gap: .8rem; align-items: center;
  padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.step .icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-size: 1rem;
}
.step.running .icon { background: var(--info-bg); color: var(--info); }
.step.done .icon { background: var(--ok-bg); color: var(--ok); }
.step.error .icon { background: var(--err-bg); color: var(--err); }
.step .msg { font-size: .88rem; color: var(--muted); margin-top: .1rem; word-break: break-word; }
.step.error .msg { color: var(--err); }
.step .progress { margin-top: .45rem; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
td.lvl-error { color: var(--err); font-weight: 600; }
td.lvl-warning { color: var(--warn); font-weight: 600; }
details summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
details pre { white-space: pre-wrap; word-break: break-all; font-size: .75rem; background: var(--surface-2); padding: .5rem; border-radius: 6px; max-height: 260px; overflow: auto; }

.acct-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.field > label { margin-bottom: 0; }
.field input[type=number] { max-width: 180px; }
.field .help { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.field .clear { margin-top: .35rem; font-weight: 400; }
.field-error { font-size: .85rem; color: var(--err); font-weight: 600; margin-top: .25rem; }
.field.invalid input, .field.invalid select { border-color: var(--err); }
.copy-row { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; }
.copy-row code { flex: 1; min-width: 0; padding: .5rem .6rem; background: var(--surface-2); border-radius: 8px; }
.settings-toc { gap: .35rem .9rem; margin-bottom: 1rem; }
.settings-toc a { text-decoration: none; }
form[data-group], #group-password, #group-system { scroll-margin-top: 70px; }
.badge-col { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; font-size: .9rem; margin: .8rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 20; max-width: calc(100% - 2rem);
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; }
  nav { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  .step { grid-template-columns: 30px 1fr; }
  .step .actions { grid-column: 1 / -1; }
  .preview { flex-direction: column; }
}
