:root {
  --bg: #0f0f0f;
  --panel: #131313;
  --raise: #1a1a1a;
  --line: #222;
  --fg: #d6d6d6;
  --dim: #6e6e6e;
  --faint: #4a4a4a;
  --accent: #8fb573;
  --warn: #c9a85c;
  --err: #cf6f6f;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 13px/1.5 var(--sans); overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--fg); background: none; border: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer; }
button:hover { background: var(--raise); }
button:disabled { color: var(--faint); cursor: default; background: none; }
.dim { color: var(--dim); }
::selection { background: #3a3a3a; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #262626; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

#login { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
#login input { width: 240px; background: var(--panel); border: 1px solid var(--line); color: var(--fg); padding: 9px 12px; border-radius: 6px; font: inherit; outline: none; }
#login input:focus { border-color: #333; }
#loginerr { margin: 0; height: 18px; color: var(--err); font-size: 12px; }

#app { height: 100%; display: flex; flex-direction: column; }

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 42px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.status { display: flex; align-items: center; gap: 10px; min-width: 0; white-space: nowrap; overflow: hidden; }
#dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
#dot.active { background: var(--accent); }
#dot.activating, #dot.deactivating, #dot.reloading { background: var(--warn); }
#dot.failed { background: var(--err); }
#headline { overflow: hidden; text-overflow: ellipsis; white-space: pre; }
nav { display: flex; gap: 2px; flex: none; }
nav button.confirm { color: var(--err); }
#pending { color: var(--warn); }
#toggle-side { display: none; }

main { flex: 1; display: flex; min-height: 0; }

#console { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#log { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 16px 6px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; cursor: text; }
#log .l { min-height: 1.55em; }
#log .ts { color: var(--faint); }
#log .warn { color: var(--warn); }
#log .error { color: var(--err); }
#log .echo { color: var(--accent); }
#log .sys { color: var(--dim); font-style: italic; }
#jump { position: absolute; right: 18px; bottom: 54px; background: var(--raise); color: var(--dim); font-size: 12px; }

#input { position: relative; border-top: 1px solid var(--line); flex: none; }
#line { display: flex; align-items: center; height: 44px; padding: 0 16px; font: 13px var(--mono); }
.prompt { color: var(--faint); margin-right: 2px; }
.field { position: relative; flex: 1; height: 100%; }
#cmd, #ghost { position: absolute; inset: 0; font: inherit; letter-spacing: 0; padding: 0; margin: 0; line-height: 44px; white-space: pre; }
#cmd { width: 100%; background: transparent; border: 0; outline: none; color: var(--fg); caret-color: var(--fg); }
#cmd::placeholder { color: var(--faint); }
#ghost { color: transparent; pointer-events: none; overflow: hidden; }
#ghost span { color: var(--faint); }
#ghost .bad { color: transparent; text-decoration: underline wavy var(--err); text-underline-offset: 4px; }

#suggest { position: absolute; bottom: 100%; margin-bottom: 4px; max-height: 260px; overflow-y: auto; background: var(--raise); border-radius: 6px; padding: 4px 0; font: 12.5px var(--mono); min-width: 160px; max-width: min(560px, 90vw); box-shadow: 0 6px 24px rgba(0, 0, 0, .45); }
#suggest div { display: flex; gap: 18px; justify-content: space-between; padding: 3px 12px; cursor: pointer; white-space: nowrap; }
#suggest div:hover { background: #202020; }
#suggest div.sel { background: #262626; }
#suggest .tip { color: var(--dim); font-family: var(--sans); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
#suggest b { font-weight: normal; color: var(--accent); }
#hint { position: absolute; bottom: 100%; margin-bottom: 4px; background: var(--raise); border-radius: 6px; padding: 5px 12px; font: 12.5px var(--mono); color: var(--dim); white-space: pre; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; }
#hint.error { color: var(--err); }

#side { width: 280px; flex: none; border-left: 1px solid var(--line); overflow-y: auto; padding: 6px 0 20px; background: var(--bg); }
.block { padding: 12px 16px 8px; }
h2 { margin: 0 0 8px; font-size: 11.5px; font-weight: 500; color: var(--dim); text-transform: lowercase; letter-spacing: .02em; }
ul { list-style: none; margin: 0; padding: 0; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
dt { color: var(--dim); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dd.warn { color: var(--warn); }
dd.error { color: var(--err); }

#players li { display: flex; align-items: center; gap: 9px; padding: 5px 6px; margin: 0 -6px; border-radius: 4px; cursor: pointer; }
#players li:hover { background: var(--raise); }
#players img { width: 16px; height: 16px; image-rendering: pixelated; border-radius: 2px; background: var(--raise); }
#players .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#players .tag { color: var(--dim); font-size: 11.5px; }
#players .empty, #plugins .empty { color: var(--faint); cursor: default; padding: 2px 0; }
#players .empty, #players .empty:hover { background: none; margin: 0; padding: 2px 0; }
#plugins li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
#plugins .v { color: var(--dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
#plugins .off { color: var(--err); }

#menu { position: fixed; z-index: 10; background: var(--raise); border-radius: 6px; padding: 4px 0; min-width: 170px; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
#menu .head { padding: 5px 12px 6px; color: var(--dim); font-size: 11.5px; }
#menu button { display: block; width: 100%; text-align: left; border-radius: 0; padding: 5px 12px; }
#menu button:hover { background: #242424; }
#menu button.danger { color: var(--err); }
#menu hr { border: 0; border-top: 1px solid #262626; margin: 4px 0; }

.tabs { display: flex; gap: 2px; margin-right: auto; margin-left: 18px; }
.tabs button { color: var(--dim); }
.tabs button.on { color: var(--fg); background: var(--raise); }
body[data-tab="files"] #side, body[data-tab="files"] #toggle-side { display: none !important; }

#files { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.fbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line); flex: none; }
#crumbs { display: flex; align-items: center; flex-wrap: wrap; min-width: 0; font: 12.5px var(--mono); }
#crumbs button { padding: 3px 5px; color: var(--dim); }
#crumbs button.cur { color: var(--fg); }
#crumbs .sep { color: var(--faint); }
.factions { display: flex; gap: 2px; flex: none; }
#flist { flex: 1; overflow-y: auto; padding: 4px 0 40px; }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) 90px 150px 220px; align-items: center; gap: 12px; padding: 0 16px; height: 32px; cursor: pointer; }
.frow:hover { background: var(--panel); }
.frow.fhead { cursor: default; height: 28px; color: var(--faint); font-size: 11.5px; }
.frow.fhead:hover { background: none; }
.fname { font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow.dir .fname { color: #e6e6e6; }
.fsize, .fdate { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fsize { text-align: right; }
.facts { display: flex; justify-content: flex-end; gap: 2px; visibility: hidden; }
.frow:hover .facts, .frow:focus-within .facts { visibility: visible; }
.facts button { padding: 2px 8px; font-size: 12px; color: var(--dim); }
.facts button:hover { color: var(--fg); }
button.danger, .facts button.danger { color: var(--err); }
.finput { font: 12.5px var(--mono); background: var(--bg); border: 1px solid #333; border-radius: 4px; color: var(--fg); padding: 3px 6px; outline: none; width: 100%; max-width: 420px; }
.fnote { padding: 18px 16px; color: var(--faint); }
.fnote.error { color: var(--err); }
#fdrop { position: absolute; inset: 8px; border: 1px dashed #444; border-radius: 8px; background: rgba(15, 15, 15, .85); display: flex; align-items: center; justify-content: center; color: var(--dim); pointer-events: none; z-index: 3; font: 12.5px var(--mono); }
#fuploads { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
#fuploads .up { position: relative; overflow: hidden; display: flex; justify-content: space-between; gap: 16px; min-width: 240px; max-width: 360px; background: var(--raise); border-radius: 6px; padding: 7px 12px; font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
#fuploads .up span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fuploads .pct { color: var(--dim); flex: none; }
#fuploads .up i { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--accent); }
#fuploads .up.error { color: var(--err); }
#fuploads .up.error .pct { color: var(--err); }
#editor { position: absolute; inset: 0; z-index: 6; background: var(--bg); display: flex; flex-direction: column; }
.ebar { display: flex; align-items: center; gap: 12px; padding: 6px 10px 6px 16px; border-bottom: 1px solid var(--line); flex: none; font-size: 12.5px; }
#epath { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ebar .grow { flex: 1; }
#etext { flex: 1; resize: none; border: 0; outline: none; background: var(--bg); color: var(--fg); font: 12.5px/1.6 var(--mono); padding: 12px 16px; tab-size: 2; white-space: pre; }

@media (max-width: 860px) {
  .tabs { margin-left: 4px; }
  .frow { grid-template-columns: minmax(0, 1fr) 64px; height: auto; min-height: 34px; padding: 6px 12px; row-gap: 2px; }
  .frow .fdate { display: none; }
  .facts { grid-column: 1 / -1; visibility: visible; justify-content: flex-start; margin-left: -8px; }
  .frow.fhead span:nth-child(3), .frow.fhead span:nth-child(4) { display: none; }
  header { flex-wrap: wrap; height: auto; padding: 6px 8px 6px 12px; row-gap: 2px; }
  .tabs { margin-left: auto; margin-right: 0; }
  nav { width: 100%; overflow-x: auto; margin-left: -6px; }
  main { position: relative; }
  #side { top: 0 !important; }
  .fbar { flex-direction: column; align-items: stretch; gap: 4px; }
  #toggle-side { display: inline-block; }
  #side { position: absolute; right: 0; top: 42px; bottom: 0; z-index: 5; display: none; width: min(300px, 86vw); box-shadow: -8px 0 24px rgba(0, 0, 0, .4); }
  #side.open { display: block; }
  #headline { display: none; }
  header { padding-left: 12px; }
  #log, #line { padding-left: 12px; padding-right: 12px; }
  nav button { padding: 4px 7px; }
}

#settings { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
#settings-form { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; background: var(--panel); border-radius: 8px; padding: 20px 22px 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
#settings h1 { margin: 0 0 14px; font-size: 14px; font-weight: 500; }
#settings .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; }
#settings label { display: flex; flex-direction: column; }
#settings small { color: var(--dim); font-size: 11.5px; }
#settings small.lim { color: var(--faint); }
.num { display: flex; align-items: center; background: var(--bg); border-radius: 6px; flex: none; }
.num button { width: 28px; padding: 5px 0; color: var(--dim); }
.num input { width: 46px; background: none; border: 0; color: var(--fg); text-align: center; font: 13px var(--mono); outline: none; padding: 5px 0; }
#settings-msg { min-height: 18px; margin: 8px 0 0; font-size: 12px; color: var(--dim); }
#settings-msg.error { color: var(--err); }
#settings .actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
#settings .primary { background: var(--raise); }
#settings .primary:hover { background: #242424; }
