:root {
  --bg: #eef2f7;
  --ink: #1f2a3d;
  --muted: #64748b;
  --card: #ffffff;
  --line: #dbe2ec;
  --floor: #f8fafd;
  --navy: #334155;
  --wood: #c08a4c;
  --wood-dark: #a4713a;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --b1: #334155;
  --b2: #5b8a63;
  --b3: #cba64a;
  --b4: #b96b74;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1623;
    --ink: #e6ecf5;
    --muted: #93a1b8;
    --card: #182233;
    --line: #2a3850;
    --floor: #141d2c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
}
.brand h1 { font-size: 18px; margin: 0; line-height: 1.1; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.ok { box-shadow: 0 0 0 0 rgba(22,163,74,.6); animation: ping 2.4s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 16px;
  padding: 16px; max-width: 1700px; margin: 0 auto; align-items: start;
}
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto;
}
.field { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.search { position: relative; }
.search input {
  width: 100%; font: inherit; padding: 12px 40px 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--floor); color: var(--ink); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); font-size: 22px; cursor: pointer;
}
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.results li button {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
}
.results li button:hover, .results li button:focus-visible { background: var(--floor); border-color: var(--line); outline: none; }
.results .no { flex: none; min-width: 34px; text-align: center; font-weight: 700; font-size: 12px;
  background: var(--navy); color: #fff; border-radius: 8px; padding: 4px 6px; }
.results .empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

.guide { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.guide-head { display: flex; gap: 12px; align-items: center; }
.guide-seat {
  flex: none; width: 56px; height: 56px; border-radius: 14px; background: var(--accent); color: #fff;
  display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 22px; line-height: 1;
}
.guide-seat small { display: block; font-size: 9px; font-weight: 600; letter-spacing: .08em; opacity: .85; }
.guide h2 { font-size: 16px; margin: 0; }
.guide-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.guide ol { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.guide ol li { counter-increment: s; position: relative; padding-left: 34px; font-size: 14px; line-height: 1.4; }
.guide ol li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--floor); border: 2px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.guide-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.mine { margin-top: 14px; display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12px; font-weight: 700; border: 0; background: var(--navy); color: #fff;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.link { font: inherit; font-size: 12px; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.meta { font-size: 11px; color: var(--muted); margin: 8px 0 0; }

/* ---------- Peta ---------- */
.mapwrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; overflow: hidden; }
.stage-sizer { position: relative; width: 100%; }
.stage {
  position: absolute; left: 0; top: 0; width: 1780px; height: 1260px; transform-origin: 0 0;
  background: var(--floor);
  background-image:
    linear-gradient(rgba(100,116,139,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100,116,139,.08) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: 28px; border: 6px solid #d5dde8; font-family: inherit; user-select: none;
}
.stage .abs { position: absolute; }
.title { left: 0; right: 0; top: 46px; text-align: center; }
.title h2 { margin: 0; font-size: 42px; font-weight: 800; color: var(--navy); }
.title p { margin: 4px 0 0; font-size: 20px; font-weight: 700; color: var(--muted); }
@media (prefers-color-scheme: dark) { .title h2 { color: #e6ecf5; } }

.door { background: linear-gradient(135deg, #8b5a48, #b07659); border: 6px solid #774a3a; border-radius: 6px; }
.teacher { background: linear-gradient(135deg, #c8965b, #bd8a4c); border: 6px solid #a66f3a; border-radius: 16px; }
.teacher::after { content: ""; position: absolute; left: 118px; top: 26px; width: 72px; height: 40px; border-radius: 8px;
  background: linear-gradient(#e2e8f0 60%, #64748b 60%); }
.tag {
  background: #fff; color: var(--navy); border: 4px solid var(--navy); border-radius: 14px;
  font-weight: 800; letter-spacing: .06em; font-size: 20px; padding: 10px 18px; white-space: nowrap;
}
.wall { background: linear-gradient(#334155, #475569); border-radius: 28px; }
.sticker {
  background: #fff; color: var(--navy); border: 4px solid #e2e8f0; border-radius: 12px; text-align: center;
  font-weight: 800; letter-spacing: .06em; font-size: 16px; line-height: 1.2; padding: 10px 8px;
  display: grid; place-items: center;
}
.mading { background: #0f172a; border: 5px solid #334155; border-radius: 10px; color: #fff; display: grid; place-items: center;
  font-weight: 800; letter-spacing: .18em; font-size: 22px; }
.plant { width: 44px; height: 44px; }
.plant::before { content: ""; position: absolute; inset: 0 0 8px 0; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #7bb07f, #3f6f45); border: 3px solid #2f5a39; }
.plant::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -8px; height: 18px; border-radius: 0 0 12px 12px; background: #9c6a45; z-index: -1; }

.banjar {
  color: #fff; font-weight: 800; letter-spacing: .12em; font-size: 20px; text-align: center; padding: 8px 20px 10px;
  border-radius: 14px; line-height: 1.1; white-space: nowrap; box-shadow: 0 6px 14px rgba(15,23,42,.18);
}
.banjar small { display: block; font-size: 12px; letter-spacing: .14em; margin-top: 2px; opacity: .92; }

.desk {
  background: linear-gradient(#d6a76a, #c08a4c); border: 5px solid #a97238; border-radius: 16px;
  box-shadow: 0 16px 0 -4px rgba(100,116,139,.35);
}
.desk::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: rgba(120,80,30,.35); }
.seat {
  position: absolute; width: 116px; height: 62px; padding: 4px 6px; border-radius: 12px; cursor: pointer;
  background: #fffdf8; border: 2px solid transparent; box-shadow: 0 3px 8px rgba(15,23,42,.2);
  text-align: center; font: inherit; color: #334155; z-index: 2; transition: transform .15s, opacity .2s, box-shadow .2s;
}
.seat b { display: block; font-size: 17px; font-weight: 600; line-height: 1.25; }
.seat span { display: block; font-size: 15px; font-weight: 800; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat:hover, .seat:focus-visible { transform: translateY(-3px); outline: none; border-color: var(--accent); }
.seat.empty span { color: #94a3b8; font-weight: 600; }
.stage.navigating .seat:not(.target):not(.mate) { opacity: .4; }
.seat.mate { border-color: #93c5fd; }
.seat.target { border-color: var(--accent); background: #eff6ff; box-shadow: 0 0 0 6px rgba(37,99,235,.28), 0 8px 18px rgba(37,99,235,.35); transform: scale(1.06); z-index: 5; }
.seat.mine::before { content: "★"; position: absolute; top: -12px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: #f59e0b; color: #fff; display: grid; place-items: center; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.3); }

.route { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: visible; }
.route path.halo { fill: none; stroke: #fff; stroke-width: 18; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.route path.line { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 4 22; animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -26; } }
.route .start { fill: #16a34a; stroke: #fff; stroke-width: 5; }
.route text { font-size: 18px; font-weight: 800; fill: #16a34a; paint-order: stroke; stroke: #fff; stroke-width: 6px; }
@media (prefers-reduced-motion: reduce) { .route path.line { animation: none; } .dot.ok { animation: none; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .panel { position: static; max-height: none; }
  .status span:last-child { max-width: 150px; }
  .mapwrap { padding: 6px; }
}

/* ---------- Mode 3D ---------- */
.modebar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 4px 4px 12px; }
.seg { display: inline-flex; background: var(--floor); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--accent); color: #fff; }
.views button:hover:not(:disabled) { color: var(--ink); background: var(--card); }
.views button:disabled { opacity: .45; cursor: not-allowed; }
.view3d { position: relative; width: 100%; height: min(72vh, 760px); min-height: 380px; border-radius: 20px; overflow: hidden; background: var(--floor); }
.v3-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); font-weight: 600; z-index: 2; pointer-events: none; }
.v3-msg:empty { display: none; }
.v3-hint { position: absolute; left: 12px; bottom: 10px; margin: 0; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--card) 85%, transparent); padding: 5px 10px; border-radius: 999px; pointer-events: none; }
@media (max-width: 900px) { .view3d { height: 62vh; } }
