:root {
  color-scheme: dark;
  --bg: #15181c;
  --panel: #1d2127;
  --line: #333a43;
  --hover: #2a3038;
  --text: #e4e7eb;
  --muted: #98a2ae;
  --accent: #5fae57;
  --accent-text: #0c1a0a;
  --danger: #f0776c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }

button, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 5px 11px; cursor: pointer; }
button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.redirect-note { max-width: 480px; margin: 20vh auto 0; padding: 0 16px; text-align: center; color: var(--muted); }
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 320px; display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.card h1 { margin: 0; font-size: 20px; }
.card label { display: grid; gap: 4px; color: var(--muted); }
.card input { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; color: var(--text); }
.error { margin: 0; min-height: 1.4em; color: var(--danger); }

.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.server-state { padding: 2px 9px; border-radius: 10px; background: var(--hover); color: var(--muted); font-size: 12px; white-space: nowrap; }
.server-state.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.server-state.off { color: var(--danger); }
.server-buttons { display: flex; gap: 4px; }
.server-buttons button { padding: 3px 8px; font-size: 13px; }
.status { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.bad { color: var(--danger); }

.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: flex-start; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 150px; font-size: 12px; color: var(--muted); }
.stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.stat progress { width: 100%; height: 6px; accent-color: var(--accent); }
.stat.players { flex: 1; min-width: 200px; }
button.stat.players { background: none; border: 0; border-radius: 4px; padding: 0 6px; align-items: flex-start; text-align: left; }
button.stat.players:hover { background: var(--hover); }
.players-names { color: var(--text); overflow-wrap: anywhere; }

.players-dialog { width: min(680px, calc(100vw - 32px)); max-height: 85vh; padding: 16px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.players-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dialog-head h2 { flex: 1; margin: 0; font-size: 17px; }
.dialog-note { margin: 0 0 10px; color: var(--muted); }
.dialog-note.bad { color: var(--danger); }
.dialog-section { margin: 18px 0 8px; font-size: 15px; }
.player { padding: 10px 0; border-top: 1px solid var(--line); }
.player-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.player-name { flex: 1; min-width: 120px; font-size: 15px; font-weight: 600; }
.player-op { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 400; }
.player .danger { color: var(--danger); }
.player-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 16px; margin: 0; font-size: 12px; }
.player-details div { display: flex; justify-content: space-between; gap: 8px; }
.player-details dt { color: var(--muted); }
.player-details dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.browser { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.crumbs { padding: 10px 12px 4px; display: flex; flex-wrap: wrap; gap: 2px; }
.crumbs button { border: 0; background: none; padding: 1px 4px; color: var(--accent); }
.crumbs span { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.actions button { padding: 3px 8px; font-size: 13px; }

.files { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 4px 0; }
.files li { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; }
.files li:hover, .files li.active { background: var(--hover); }
.files .open { flex: 1; min-width: 0; display: flex; gap: 10px; justify-content: space-between; border: 0; background: none; padding: 5px 0; text-align: left; }
.files .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .dir .name { font-weight: 600; }
.files .dir .name::after { content: "/"; color: var(--muted); }
.files .size { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.files .tools { display: flex; gap: 2px; opacity: 0; }
.files li:hover .tools, .files li:focus-within .tools, .files li.active .tools { opacity: 1; }
.files .tools button { padding: 0 5px; font-size: 12px; border-color: transparent; background: none; color: var(--muted); }
.files .tools button:hover { color: var(--text); background: var(--panel); }
.files .tools button.del:hover { color: var(--danger); }
.files .note { padding: 12px; color: var(--muted); }

.editor { min-width: 0; min-height: 0; display: flex; }
.empty { margin: auto; color: var(--muted); }
.editor-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.editor-bar { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.back { display: none; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info { flex: 1; color: var(--muted); font-size: 12px; white-space: nowrap; }
#text { flex: 1; width: 100%; resize: none; border: 0; outline: 0; padding: 12px 14px; background: var(--bg); color: var(--text); font: 13px/1.5 Consolas, "Cascadia Mono", monospace; tab-size: 4; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .status { order: 5; flex-basis: 100%; }
  .panes { grid-template-columns: 1fr; }
  .browser { border-right: 0; }
  .back { display: inline-block; }
  .app.editing .browser { display: none; }
  .app:not(.editing) .editor { display: none; }
  .files .tools { opacity: 1; }
}
