:root {
  --bg: #0e0b14;
  --surface: #16121f;
  --surface-2: #1f1a2b;
  --border: #2e2740;
  --text: #ece8f4;
  --muted: #958da8;
  --accent: #c069f5;
  --accent-strong: #9a3fe0;
  --accent-soft: #2a1c3d;
  /* Green is kept only for "online" and the Start server button. */
  --online: #5fbf4a;
  --online-strong: #4aa338;
  --online-border: #2f5a27;
  --warn: #e6b450;
  --error: #f07068;
  --info: #6cb6ff;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --sans: system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.error { color: var(--error); margin: 0; }

/* Buttons & inputs */
.btn {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
}
.btn:hover { border-color: #463b5e; background: #2a2338; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent); }
#server-start { background: var(--online-strong); border-color: var(--online-strong); color: #0b1408; }
#server-start:hover { background: var(--online); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger:hover { border-color: var(--error); color: var(--error); }
input[type=text], input[type=password], input[type=search], textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent-strong); }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-logo { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; display: block; }

/* Login */
.login-page {
  align-items: center; justify-content: center; padding: 16px; overflow: hidden;
  /* Deep-space glow behind the stars */
  background:
    radial-gradient(ellipse at 50% 55%, #2b1250 0%, #160a2b 35%, #07050d 75%),
    #07050d;
}
#stars { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 340px;
  background: rgba(22, 16, 34, .72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(192, 105, 245, .35); border-radius: 14px;
  box-shadow: 0 0 40px rgba(154, 63, 224, .35), 0 20px 50px rgba(0, 0, 0, .5);
  padding: 28px; display: flex; flex-direction: column; gap: 10px;
}
.login-logo {
  width: 132px; height: 132px; margin: -4px auto 4px; border-radius: 18px; object-fit: cover;
  box-shadow: 0 0 28px rgba(192, 105, 245, .5);
}
.login-title { margin: 0 0 8px; text-align: center; font-size: 19px; letter-spacing: .4px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { background: rgba(10, 8, 16, .8); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; }
.tab {
  font: inherit; color: var(--muted); background: none; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.pill::before { content: "●"; margin-right: 6px; }
.pill.ok { color: var(--online); border-color: var(--online-border); }
.pill.bad { color: var(--error); border-color: #5a2a27; }
.pill.wait { color: var(--warn); border-color: #5a4a27; }

/* Panels */
main { flex: 1; min-height: 0; display: flex; }
.panel { display: none; flex: 1; min-width: 0; flex-direction: column; padding: 14px 18px; gap: 10px; }
.panel.active { display: flex; }

.banner {
  background: #2a2316; border: 1px solid #5a4a27; color: var(--warn);
  padding: 8px 12px; border-radius: 6px;
}

/* Console */
.console {
  flex: 1; min-height: 0; overflow: auto;
  background: #0a0810; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: 13px/1.5 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.console .line { min-height: 1.5em; }
.console .warn { color: var(--warn); }
.console .err { color: var(--error); }
.console .cmd { color: var(--accent); }
.console .reply { color: var(--info); }
.console .sys { color: var(--muted); font-style: italic; }
.console-bar { position: relative; height: 0; }
#jump-bottom { position: absolute; right: 16px; bottom: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.console-input { display: flex; align-items: center; gap: 8px; }
.console-input .prompt { font-family: var(--mono); color: var(--accent); font-weight: 700; }
.console-input input { flex: 1; font-family: var(--mono); }

/* Logs */
.split { flex: 1; min-height: 0; display: flex; gap: 14px; }
.sidebar {
  width: 260px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.list { list-style: none; margin: 0; padding: 4px; overflow: auto; flex: 1; }
.list li { padding: 6px 10px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 12.5px; }
.list li:hover { background: var(--surface-2); }
.list li.active { background: var(--accent-soft); color: var(--accent); }
.list li .size { color: var(--muted); flex-shrink: 0; }
.viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#log-filter { width: 260px; }

/* Files */
.files-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 6px; align-items: center; }
.breadcrumbs { font-family: var(--mono); display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.breadcrumbs a { color: var(--info); text-decoration: none; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.breadcrumbs a:hover { background: var(--surface-2); }
.breadcrumbs .sep { color: var(--muted); }
#files-view, .table-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.files-table { width: 100%; border-collapse: collapse; }
.files-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 12px; }
.files-table td { padding: 6px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
.files-table tr:hover td { background: #1d1729; }
.files-table .num { text-align: right; }
.files-table .name { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.files-table .name:hover { color: var(--accent); }
.files-table .icon { width: 18px; text-align: center; }
.files-table .row-actions { text-align: right; opacity: 0; }
.files-table tr:hover .row-actions, .files-table tr:focus-within .row-actions { opacity: 1; }
.files-table td.muted { color: var(--muted); }
.drop-hint { outline: 2px dashed var(--accent); outline-offset: -6px; }

.editor { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.editor-head { display: flex; align-items: center; gap: 12px; }
.editor-head .toolbar-actions { margin-left: auto; }
#editor-text {
  flex: 1; resize: none; font: 13px/1.5 var(--mono); background: #0a0810;
  tab-size: 2; white-space: pre; overflow: auto;
}

/* Backups */
.backup-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.backup-form label { color: var(--muted); }
.backup-form input { width: 260px; max-width: 100%; }
#backup-preview { font-family: var(--mono); font-size: 13px; }
#backup-preview.bad { color: var(--error); font-family: var(--sans); }
.summary {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px;
}
.summary dt { color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.summary .ok { color: var(--accent); }
.summary .bad { color: var(--error); }
.summary .busy { color: var(--warn); }

/* Players */
.sidebar-search { margin: 8px; width: calc(100% - 16px); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.status-dot.on { background: var(--online); box-shadow: 0 0 6px var(--online); }
.status-dot.off { background: var(--error); }
.status-dot.unknown { background: #6b6380; }
.list li.empty { font-family: var(--sans); white-space: normal; overflow-wrap: anywhere; }
.list li .sub { color: var(--muted); font-size: 11.5px; }
.list li.player { flex-direction: column; gap: 0; font-family: var(--sans); font-size: 13.5px; }
.player-view { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.player-head h2 { margin: 0; font-size: 22px; }
.player-head .uuid { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.player-head .status { margin-top: 4px; }
.player-head .status.online { color: var(--online); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.stat .value.small { font-size: 14px; font-family: var(--mono); font-weight: 500; }
.stat .detail { color: var(--muted); font-size: 12px; }
.bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.hp > span { background: var(--error); }
.bar.food > span { background: #c98a3d; }

.section-title { font-weight: 600; margin: 0 0 8px; }
.section-title .muted { font-weight: 400; }
.inv-wrap { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.inv-column { display: flex; flex-direction: column; gap: 4px; }
.inv-grid { display: grid; grid-template-columns: repeat(9, 40px); gap: 4px; }
.inv-gap { height: 10px; }
.slot {
  width: 40px; height: 40px; position: relative; border-radius: 4px;
  background: #241d31; box-shadow: inset 2px 2px 0 #120e19, inset -2px -2px 0 #3a3050;
  display: flex; align-items: center; justify-content: center; cursor: default;
}
.slot.filled:hover { background: #30263f; }
.slot.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.slot.openable { cursor: pointer; }
.slot.open { outline: 2px solid var(--warn); outline-offset: 1px; }
.slot.empty-label::after { content: attr(data-label); color: #5a4f72; font-size: 9px; text-transform: uppercase; }
.slot img { width: 32px; height: 32px; image-rendering: pixelated; object-fit: cover; object-position: top; pointer-events: none; }
.slot .text-icon {
  font-size: 8.5px; line-height: 1.05; text-align: center; color: var(--text); padding: 2px;
  overflow: hidden; max-height: 36px; word-break: break-word; pointer-events: none;
}
.slot .count {
  position: absolute; right: 2px; bottom: 0; font: 700 13px/1 var(--mono); color: #fff;
  text-shadow: 1px 1px 0 #3f3f3f; pointer-events: none;
}
.slot .dura { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; background: #000; pointer-events: none; }
.slot .dura > span { display: block; height: 100%; }
.slot.glint::before {
  content: ""; position: absolute; inset: 4px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(190, 120, 255, .45) 50%, transparent 70%);
  background-size: 250% 100%; animation: glint 3s linear infinite; mix-blend-mode: screen;
}
@keyframes glint { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .slot.glint::before { animation: none; background-position: 50% 0; } }

.mc-tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 320px;
  background: #100010f0; border: 2px solid #28007a; border-radius: 4px; padding: 6px 8px;
  font: 13px/1.4 var(--mono); color: #aaa; box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
.mc-tooltip .t-name { color: #fff; }
.mc-tooltip .t-name.custom { font-style: italic; }
.mc-tooltip .t-name.enchanted { color: #55ffff; }
.mc-tooltip .t-ench { color: #aaa; }
.mc-tooltip .t-info { color: #5555ff; }
.mc-tooltip .t-id { color: #555; margin-top: 4px; }
.mc-tooltip .t-hint { color: #ffaa00; margin-top: 4px; }

.logins { width: 100%; border-collapse: collapse; }
.logins th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; background: var(--surface-2); }
.logins td { padding: 6px 10px; border-top: 1px solid var(--border); font-size: 13px; }
.logins td.mono { font-family: var(--mono); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.card.table { padding: 0; overflow: auto; max-height: 320px; }
.files-table .player-name { color: var(--accent); margin-left: 6px; }
@media (max-width: 720px) {
  .inv-grid { grid-template-columns: repeat(9, 32px); gap: 3px; }
  .slot { width: 32px; height: 32px; }
  .slot img { width: 24px; height: 24px; }
  .slot .count { font-size: 11px; }
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: calc(100% - 32px);
}
.toast.bad { border-color: var(--error); color: var(--error); }

@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 10px 16px; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .panel { padding: 12px 16px; }
  .split { flex-direction: column; }
  .sidebar { width: auto; max-height: 180px; }
  #log-filter { width: 140px; }
  #files-view .files-table th:nth-child(3), #files-view .files-table td:nth-child(3) { display: none; }
  .files-table .row-actions { opacity: 1; }
}
