
/* Layout: control-room shell - fixed left rail of sections (bottom bar on phones), a top strip with network health,
   and a working area of cards. Same green/Kanit identity as whatsmp.net, but flat and dense for scanning. */
:root {
  --bg: #f3f5f1; --surface: #ffffff; --surface-2: #eceff0; --line: #dfe3dc;
  --fg: #161a15; --dim: #59615a; --faint: #8a918a;
  --primary: #2f7d3b; --on-primary: #ffffff; --primary-soft: #e3f1e3;
  --ok: #2f9a45; --warn: #c07a0a; --bad: #c73a32; --info: #2a7fb0;
  --ok-soft: #e2f3e5; --warn-soft: #fbefd9; --bad-soft: #fbe3e1; --info-soft: #e0eef7;
  --player: #3d6f9e; --item: #9a7400; --amount: #5d7f1f; --money: #c76a00;
  --font: "Kanit", "Noto Sans Thai", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e0d; --surface: #151917; --surface-2: #1c211e; --line: #272d29;
    --fg: #eef1ee; --dim: #a0a8a2; --faint: #6e766f;
    --primary: #7fd68f; --on-primary: #0c0e0d; --primary-soft: #1d3322;
    --ok: #7fd68f; --warn: #f2b54a; --bad: #ff7d72; --info: #6cc0ee;
    --ok-soft: #1b3020; --warn-soft: #3a2c12; --bad-soft: #3d1c1a; --info-soft: #14303f;
    --player: #8eb1d1; --item: #ffe08a; --amount: #a6c261; --money: #ff9f1c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e0d; --surface: #151917; --surface-2: #1c211e; --line: #272d29;
  --fg: #eef1ee; --dim: #a0a8a2; --faint: #6e766f;
  --primary: #7fd68f; --on-primary: #0c0e0d; --primary-soft: #1d3322;
  --ok: #7fd68f; --warn: #f2b54a; --bad: #ff7d72; --info: #6cc0ee;
  --ok-soft: #1b3020; --warn-soft: #3a2c12; --bad-soft: #3d1c1a; --info-soft: #14303f;
  --player: #8eb1d1; --item: #ffe08a; --amount: #a6c261; --money: #ff9f1c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-weight: 300; font-size: 15px; line-height: 1.55; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .86em; }

.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: var(--on-primary); font-weight: 600; }
.brand b { font-weight: 600; letter-spacing: .02em; }
.brand small { display: block; color: var(--faint); font-size: 12px; margin-top: -3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 9px; padding: 9px 10px; cursor: pointer; color: var(--dim); font-weight: 400; }
.nav button:hover { background: var(--surface-2); color: var(--fg); }
.nav button[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav button:focus-visible, .btn:focus-visible, .chip:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .lock { margin-left: auto; font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.nav button.locked { opacity: .55; }
.nav-sep { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 4px; }
.rail-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--dim); display: grid; gap: 8px; }

main { min-width: 0; padding-inline: 28px; padding-block: 18px 40px; }
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 24px; font-weight: 500; text-wrap: balance; }
.top .sub { color: var(--dim); font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.role-switch { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.role-switch button { border: 0; background: none; padding: 4px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--dim); }
.role-switch button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 500; }
.demo-note { font-size: 12px; color: var(--faint); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }

.grid { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h2 .meta { color: var(--faint); font-size: 12px; font-weight: 300; }

.servers { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1300px) { .servers { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .servers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.srv { display: grid; gap: 8px; }
.srv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.srv-name { font-weight: 500; }
.pill { font-size: 12px; border-radius: 999px; padding: 1px 9px; font-weight: 400; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: var(--surface-2); color: var(--dim); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; text-align: right; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.bar i.warn { background: var(--warn); }
.spark { width: 100%; height: 40px; display: block; }
.rangebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.rangebar .role-switch { flex-wrap: wrap; }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.v3d { position: relative; height: 420px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.v3d canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.v-badge { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; border-radius: 7px; padding: 3px 9px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.live { width: 7px; height: 7px; border-radius: 50%; background: #ff5a4f; }
@media (prefers-reduced-motion: no-preference) { .live { animation: blink 1.4s infinite; } @keyframes blink { 50% { opacity: .3; } } }
.v-note { font-size: 12px; color: var(--faint); margin: 8px 0 0; line-height: 1.6; }
.mapbox { position: relative; height: 440px; border-radius: 10px; overflow: hidden; background: #0e1a2b; }
.mapbox canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.map-ui { position: absolute; right: 10px; top: 10px; display: grid; gap: 6px; }
@media (max-width: 760px) { .v3d { height: 320px; } .mapbox { height: 360px; } }
.chart .plot { position: relative; }
.plotrow { display: flex; gap: 6px; }
.plotrow .plot { flex: 1; min-width: 0; }
.chart.big .axis { padding-left: 52px; font-size: 11px; }
.ylab { flex: none; width: 46px; display: flex; flex-direction: column; justify-content: space-between; font-size: 10px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.chart.big .dot { margin-left: 0; }
.hm-wrap { overflow-x: auto; }
.hm-grid { display: grid; grid-template-columns: 28px repeat(24, minmax(10px, 1fr)); gap: 2px; min-width: 330px; font-size: 10px; color: var(--faint); }
.hm { aspect-ratio: 1; border-radius: 3px; background: color-mix(in srgb, var(--primary) calc(var(--a) * 100%), var(--surface-2)); }
.hm-day { align-self: center; }
.hm-h { padding-top: 2px; }
.split-bar { display: flex; height: 22px; border-radius: 7px; overflow: hidden; font-size: 11px; }
.split-bar i { display: flex; align-items: center; padding: 0 8px; color: var(--on-primary); font-style: normal; white-space: nowrap; overflow: hidden; }
.chart { position: relative; touch-action: pan-y; cursor: crosshair; }
.chart .dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 2px var(--surface); }
.chart .axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); margin-top: 2px; }
.chart .tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); background: var(--fg); color: var(--bg); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.45; white-space: nowrap; pointer-events: none; z-index: 5; font-variant-numeric: tabular-nums; }
.chart .tip b { font-weight: 500; }

.split { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.list { display: grid; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.row:first-child { border-top: 0; }
.row .t { color: var(--faint); font-size: 12px; white-space: nowrap; }
.sev { width: 8px; height: 8px; border-radius: 2px; }
.sev.bad { background: var(--bad); } .sev.warn { background: var(--warn); } .sev.ok { background: var(--ok); } .sev.info { background: var(--info); }
.p { color: var(--player); font-weight: 400; }
.it { color: var(--item); }
.amt { color: var(--amount); }
.money { color: var(--money); }

.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--faint); font-size: 12px; }
.stat .val { font-size: 24px; font-weight: 500; }
.stat .delta { font-size: 12px; color: var(--dim); }

.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 9px 12px; font: inherit; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 400; white-space: nowrap; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.ph { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 10px; image-rendering: pixelated; background: var(--surface-2); }
.ph h2 { margin: 0; font-size: 22px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--dim); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-color: var(--primary); font-weight: 500; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 400; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.avatar.sm { width: 26px; height: 26px; border-radius: 5px; display: block; }
.plist tr[data-open] { cursor: pointer; }
.plist tr[data-open]:hover td, .plist tr[data-open]:focus-visible td { background: var(--surface-2); }
.plist tr[data-open]:focus-visible { outline: 2px solid var(--primary); }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 13px; color: var(--dim); }
.chip.on { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 500; }
.inv { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; max-width: 460px; }
.slot { aspect-ratio: 1; max-width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; position: relative; display: grid; place-items: center; font-size: 10px; color: var(--dim); overflow: hidden; }
.slot i { width: 58%; height: 58%; border-radius: 3px; display: block; }
.slot b { position: absolute; right: 3px; bottom: 0; font-size: 11px; font-weight: 500; color: var(--fg); font-family: var(--mono); }
.inv-label { font-size: 12px; color: var(--faint); margin: 10px 0 6px; }

.actions { display: grid; gap: 10px; }
.act-group { display: grid; gap: 6px; }
.act-group .lbl { font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; }
.act-row { display: flex; flex-wrap: wrap; gap: 6px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border-radius: 14px; border: 1px solid var(--line); max-width: 420px; width: 100%; padding: 20px; display: grid; gap: 12px; }
.modal h3 { margin: 0; font-weight: 500; font-size: 18px; }
.modal p { margin: 0; color: var(--dim); font-size: 14px; }
.modal .code { display: flex; gap: 6px; }
.modal .code input { width: 100%; text-align: center; font-family: var(--mono); font-size: 20px; letter-spacing: .3em; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); border-radius: 10px; padding: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 10px; font-size: 14px; z-index: 30; }

.soon { display: grid; place-items: center; text-align: center; gap: 8px; padding: 40px 16px; color: var(--dim); }
.soon h2 { color: var(--fg); justify-content: center; }
.example { font-size: 12px; color: var(--faint); border: 1px dashed var(--line); border-radius: 8px; padding: 4px 10px; display: inline-block; }

@media (max-width: 1100px) { .split, .two { grid-template-columns: minmax(0, 1fr); } .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); z-index: 10; }
  .brand, .nav-sep, .rail-foot, .nav .lock, .nav .extra { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav button { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; text-align: center; justify-content: center; }
  main { padding-inline: 16px; padding-block: 14px 96px; }
  .ph { grid-template-columns: auto minmax(0, 1fr); }
  .ph .ph-act { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: no-preference) { .card { transition: border-color .15s; } }

/* ---- login page ---- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding-inline: 16px; padding-block: 32px; }
.login { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login .brand { padding: 0 0 4px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--dim); }
.login > *, .login label { min-width: 0; }
.login input { width: 100%; min-width: 0; box-sizing: border-box; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 15px; }
.login .code-in { text-align: center; font-family: var(--mono); font-size: 22px; letter-spacing: .3em; }
.login .err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0; }
.login .qr { justify-self: center; border-radius: 10px; background: #fff; width: auto; height: auto; max-width: 100%; image-rendering: pixelated; }
.login .secret { font-family: var(--mono); text-align: center; font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 8px; user-select: all; word-break: break-all; }
.login .codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); font-size: 15px; text-align: center; }
.login .codes span { background: var(--surface-2); border-radius: 8px; padding: 6px; }
.login .hint { font-size: 13px; color: var(--dim); margin: 0; }
.login .btn { width: 100%; padding: 10px; }
.login .rem { display: flex; gap: 8px; align-items: center; flex-direction: row; font-size: 13px; color: var(--dim); cursor: pointer; }
.login .rem input { width: auto; accent-color: var(--primary); }
.sec-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.sec-row:first-child { border-top: 0; }
.sec-row small { display: block; color: var(--faint); font-size: 12px; overflow-wrap: anywhere; }
.banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; background: var(--info-soft); color: var(--fg); border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px; font-size: 14px; }
.mobile-only { display: none !important; }
@media (max-width: 760px) { .mobile-only { display: flex !important; } .icon-btn.mobile-only { display: grid !important; } }
.skinhead { width: var(--s); height: var(--s); display: inline-block; vertical-align: middle; border-radius: 4px; image-rendering: pixelated; background-size: calc(var(--s) * 8); background-position: calc(var(--s) * -1) calc(var(--s) * -1); position: relative; flex: none; background-color: var(--surface-2); }
.skinhead i { position: absolute; inset: 0; background-size: calc(var(--s) * 8); background-position: calc(var(--s) * -5) calc(var(--s) * -1); image-rendering: pixelated; }
.sortbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.sortbtn:hover, th[aria-sort="ascending"] .sortbtn, th[aria-sort="descending"] .sortbtn { color: var(--fg); }
.sorticon { font-size: 10px; opacity: .6; }
th[aria-sort="none"] .sorticon { opacity: .3; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.linkbtn:hover { text-decoration: underline; }
.slot img { width: 70%; height: 70%; object-fit: cover; object-position: top; image-rendering: pixelated; }
.slot .abbr { font-size: 10px; color: var(--dim); font-weight: 500; }
.slot.ench { box-shadow: inset 0 0 0 2px color-mix(in srgb, #a970ff 55%, transparent); }
.slot b { text-shadow: 1px 1px 0 var(--surface); }
.enchlist { display: grid; gap: 8px; }
.enchrow { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; }
.enchrow .slot { width: 44px; }
.ench-pill { background: color-mix(in srgb, #a970ff 16%, var(--surface)); color: color-mix(in srgb, #a970ff 70%, var(--fg)); }
/* Minecraft-style item tooltip */
.mctip { position: fixed; z-index: 50; pointer-events: none; max-width: 300px; padding: 6px 9px; background: rgba(16, 0, 16, .94);
  border: 2px solid #2a0a5c; box-shadow: inset 0 0 0 1px #5000ff55; border-radius: 4px; font-size: 13px; line-height: 1.45; color: #fff; }
.mctip .t-name { color: #fff; font-weight: 500; }
.mctip .t-name.ench { color: #55ffff; }
.mctip .t-ench { color: #a8a8a8; }
.mctip .t-lore { color: #aa00aa; font-style: italic; }
.mctip .t-meta { color: #d0d0d0; }
.mctip .t-id { color: #555; font-size: 11px; margin-top: 2px; }
.slot[data-tip] { cursor: default; }
.mapframe { height: calc(100vh - 210px); min-height: 420px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: #000; }
.mapframe iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 760px) { .mapframe { height: calc(100vh - 260px); min-height: 360px; } }
a.btn { text-decoration: none; color: var(--fg); }
