:root {
  --bg: #f3f1ee;
  --panel: #ffffff;
  --panel-2: #f7f5f2;
  --border: #ddd8d0;
  --text: #24211d;
  --muted: #6e675e;
  --accent: #d9761c;
  --accent-text: #ffffff;
  --ok: #2f8a3e;
  --warn: #b7791f;
  --bad: #c0392b;
  --log-bg: #1d1b18;
  --log-text: #d8d3ca;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --panel: #22201d;
    --panel-2: #2a2724;
    --border: #3a3631;
    --text: #ece7df;
    --muted: #a39b90;
    --accent: #e8892f;
    --accent-text: #1b1a17;
    --ok: #5cbf6b;
    --warn: #e0a83a;
    --bad: #e5645a;
    --log-bg: #0f0e0d;
    --log-text: #d8d3ca;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 18px; margin: 0; }
header .user { color: var(--muted); display: flex; gap: 10px; align-items: center; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

section.wide { grid-column: 1 / -1; }
summary { cursor: pointer; }
summary h2 { display: inline; }
section h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.badge.running { color: var(--ok); border-color: currentColor; }
.badge.stopped { color: var(--muted); }
.badge.starting, .badge.stopping, .badge.busy { color: var(--warn); border-color: currentColor; }
.badge.new { color: var(--accent); border-color: currentColor; margin-left: 6px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button, .button {
  font: inherit;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.small, .button.small { padding: 2px 8px; font-size: 13px; }

input[type=text], input[type=password], textarea {
  font: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  min-width: 0;
}
input[type=file] { max-width: 100%; }

.notice { margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--accent); }
.notice.error { border-left-color: var(--bad); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.countdown { font-weight: 700; color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.name { white-space: normal; overflow-wrap: anywhere; }
td.actions { text-align: right; }
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
tr.selected td { background: var(--panel-2); }
tr.selected td.name::before { content: "▶ "; color: var(--accent); }

progress { width: 100%; height: 10px; accent-color: var(--accent); }

.uploads { display: grid; gap: 10px; margin-bottom: 14px; }

textarea#settings-text { width: 100%; min-height: 320px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

pre#log {
  margin: 0;
  background: var(--log-bg);
  color: var(--log-text);
  border-radius: 6px;
  padding: 10px 12px;
  height: 340px;
  overflow: auto;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
#toast.error { background: var(--bad); color: #fff; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-wrap form { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-wrap h1 { font-size: 20px; margin: 0 0 4px; }
