:root {
  --bg: #15181d; --panel: #1e232a; --panel2: #262c35; --line: #333b47; --text: #dfe5ec; --muted: #8a96a6;
  --accent: #4f9cf9; --danger: #e5534b; --ok: #3fb950;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, Segoe UI, sans-serif; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 16px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 8px; }
nav button { background: none; border: none; color: var(--muted); padding: 6px 10px; border-bottom: 2px solid transparent; border-radius: 0; }
nav button.active { color: var(--text); border-bottom-color: var(--accent); }
#status { margin-left: auto; }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.small { padding: 2px 6px; font-size: 12px; }
button.active { border-color: var(--accent); color: var(--accent); }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; font: inherit; width: 100%; }
input[type=checkbox] { width: auto; }
input.num { width: 70px; }
label { display: block; color: var(--muted); margin: 6px 0 3px; font-size: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0; }
label.inline select { width: auto; }
label.inline input.num { width: 70px; }
a { color: var(--accent); }
code { background: var(--panel2); padding: 0 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.tab { display: none; flex: 1; min-height: 0; }
.tab.active { display: flex; }
aside { width: 270px; display: flex; flex-direction: column; gap: 8px; padding: 8px; overflow: hidden; flex: none; }
aside.right { width: 250px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.box.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.row > * { flex: 1; }
.row > label.inline { flex: none; }
.list { overflow-y: auto; flex: 1; min-height: 0; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chips button { padding: 1px 7px; font-size: 12px; border-radius: 10px; }
.center { flex: 1; display: flex; flex-direction: column; padding: 8px; gap: 8px; min-width: 0; overflow: auto; }
.center.narrow { max-width: 900px; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.hint { font-size: 12px; }
#mapWrap { position: relative; flex: 1; overflow: auto; background: #0e1013; border: 1px solid var(--line); border-radius: 6px; min-height: 300px; }
#map { display: block; }
#hover { position: absolute; pointer-events: none; background: rgba(0,0,0,.85); padding: 2px 6px; border-radius: 3px; font-size: 12px; display: none; white-space: nowrap; z-index: 2; }
.pal { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 4px; cursor: grab; user-select: none; }
.pal:hover { background: var(--panel2); }
.dragGhost { position: fixed; pointer-events: none; z-index: 30; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.pal.sel { outline: 1px solid var(--accent); }
.pal .sw { width: 16px; height: 16px; border-radius: 3px; flex: none; border: 1px solid rgba(255,255,255,.3); }
.pal .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal .meta { color: var(--muted); font-size: 11px; }
.pal.warn .nm { color: #d29922; }
.sum { display: flex; justify-content: space-between; gap: 8px; padding: 2px 4px; border-radius: 3px; cursor: pointer; }
.sum:hover { background: var(--panel2); }
.sum .lv { color: var(--muted); font-size: 11px; }
.drop { flex: 1; border: 2px dashed var(--line); border-radius: 8px; padding: 10px; min-height: 300px; overflow: auto; }
.drop.over { border-color: var(--accent); background: rgba(79,156,249,.06); }
.dropHint { margin-top: 10px; }
.kindHead { margin: 10px 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.unitRow { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 4px; }
.unitRow .nm { flex: 1; }
.unitRow input.num { width: 80px; }
.unitRow select { width: auto; }
.badge { font-size: 11px; padding: 0 6px; border-radius: 8px; background: #3b2f12; color: #d29922; }
.grid2 { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; align-items: center; }
.grid2 label { margin: 0; }
.out { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px; white-space: pre-wrap; min-height: 40px; margin: 8px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.sel { background: var(--panel2); }
.split { display: grid; grid-template-columns: 1fr 380px; gap: 8px; align-items: start; }
#logDetail pre { white-space: pre-wrap; margin: 0; }
#toast { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 20; }
#modal.hidden { display: none; }
.dlg { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; width: 420px; max-width: 92vw; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.dlg h3 { margin: 0 0 8px; font-size: 15px; }
.dlg .msg { white-space: pre-wrap; margin: 4px 0 8px; }
.row.end { justify-content: flex-end; }
.row.end > * { flex: none; }
.toastMsg { background: var(--panel2); border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 4px; max-width: 480px; white-space: pre-wrap; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.toastMsg.err { border-left-color: var(--danger); }
.toastMsg.ok { border-left-color: var(--ok); }
.equipRow { margin-left: 24px; background: transparent; }
.equipRow select { flex: 1; min-width: 0; }

#shot { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 19; }
#shot.hidden { display: none; }
.dlg.wide { width: 720px; max-height: 94vh; overflow: auto; }
#shotCanvas { max-width: 100%; background: #111; border: 1px solid var(--line); margin: 6px 0; }
#shotOut { max-height: 160px; overflow: auto; font-size: 12px; }

/* in-game layout mode (base editor showing an account's Layout Editor slot) */
body:not(.layoutMode) .layoutOnly { display: none !important; }
body.layoutMode .baseOnly { display: none !important; }
.slots { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-top: 6px; }
.slots button { padding: 3px 4px; font-size: 12px; line-height: 1.25; }
.slots button .st { display: block; color: var(--muted); font-size: 11px; }
.slots button.on { border-color: var(--ok); }
.slots button.on .st { color: var(--ok); }
.slots button.open { background: var(--accent); border-color: var(--accent); color: #fff; }
.slots button.open .st { color: #e8f1ff; }
.slots button.war { background-image: linear-gradient(180deg, rgba(160,60,30,.18), transparent); }

/* village tab */
aside.scroll { overflow-y: auto; }
aside.scroll .box { flex: none; }
.list.short { max-height: 260px; }
.vsum { margin-top: 6px; white-space: pre-line; }
#tab-village .out { max-height: 160px; overflow: auto; font-size: 12px; }
body.noVillage #tab-village .vil, body.noVillage #tab-village > .center:not(#vilEmpty), body.noVillage #tab-village > aside.right { display: none !important; }
body:not(.noVillage) #vilEmpty { display: none; }
#selAttrs { margin: 6px 0; }
#selAttrs label.inline { display: flex; }
