:root {
  --bg: #0f131b; --panel: #171d29; --panel2: #1f2735; --line: #2c3648; --text: #e6ebf3; --muted: #8b97ab;
  --accent: #22c39a; --accent2: #f2b84b; --danger: #e05561;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #062018; border-color: var(--accent); font-weight: 600; }
button.danger { border-color: #5a2a33; color: #ff9aa4; }
button.on, nav button.active { background: var(--accent); color: #062018; border-color: var(--accent); }
input, select, textarea { background: #0d1118; border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; }
input[type=number] { width: 64px; }
input[type=range] { width: 100%; padding: 0; }
textarea { width: 100%; resize: vertical; }
code { background: #0d1118; padding: 1px 4px; border-radius: 3px; font-size: .85em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

#topbar { height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { font-weight: 900; letter-spacing: 2px; font-size: 20px; }
.logo span { color: var(--accent); }
nav { display: flex; gap: 6px; }
#status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
#status img { width: 32px; height: 32px; }

#main { position: absolute; top: 52px; left: 0; right: 0; bottom: 0; display: flex; }
#stage { position: relative; flex: 1; min-width: 0; }
#view { display: block; width: 100%; height: 100%; }
#hud { position: absolute; left: 10px; bottom: 10px; background: rgba(10,14,20,.75); padding: 4px 10px; border-radius: 6px; font-size: 13px; color: #cfd8e6; pointer-events: none; }
#msg { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); width: min(720px, 92%); background: #fdfdf8; color: #1a1a1a;
  border: 4px solid #2c3648; border-radius: 10px; padding: 16px 20px; font-size: 18px; line-height: 1.4; cursor: pointer; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
#msg::after { content: '▼'; position: absolute; right: 14px; bottom: 6px; font-size: 12px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Editor side panel */
#editor { width: 380px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px 12px 40px; font-size: 14px; }
#editor section { border-bottom: 1px solid var(--line); padding: 8px 0 12px; }
#editor h3 { margin: 4px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent2); }
#editor select#ed-map { width: 100%; margin-bottom: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row label { display: flex; gap: 6px; align-items: center; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.palette button { display: flex; flex-direction: column; align-items: center; padding: 4px; font-size: 10px; gap: 2px; }
.palette canvas { width: 40px; height: auto; max-height: 64px; object-fit: contain; }
.list { display: flex; flex-direction: column; gap: 4px; }
.list button { text-align: left; }
.list small, .tbl small { color: var(--muted); }
.list button.on small { color: #0a3a2c; }
.tbl { width: 100%; border-collapse: collapse; margin: 6px 0; }
.tbl td, .tbl th { padding: 2px; text-align: left; font-size: 13px; }
.tbl input[type=number] { width: 52px; }
.tbl select { max-width: 150px; }
.tbl input:not([type]) { width: 100%; }
.zone-edit { background: var(--panel2); border-radius: 8px; padding: 8px; margin-top: 8px; }

/* Sheets */
#sheet { position: fixed; inset: 52px 0 0 0; background: rgba(5,8,12,.6); display: flex; justify-content: center; z-index: 20; }
.sheet-inner { width: min(1200px, 100%); background: var(--panel); border-left: 1px solid var(--line); border-right: 1px solid var(--line); overflow-y: auto; padding: 0 20px 40px; }
.sheet-head { position: sticky; top: 0; background: var(--panel); display: flex; align-items: center; justify-content: space-between; padding: 10px 0; z-index: 2; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; }
.dex-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.dex-tools .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.chk { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dex-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px; background: var(--panel2); }
.dex-card img { width: 112px; height: 112px; }
.dex-card small { color: var(--muted); }
.dex-card.tier-rare { box-shadow: inset 0 0 0 1px #6a8cff; }
.dex-card.tier-legendary { box-shadow: inset 0 0 0 2px var(--accent2); }
.dex-card.tier-starter { box-shadow: inset 0 0 0 1px var(--accent); }
.dex-no { color: var(--muted); font-size: 13px; }
.dex-no.big { font-size: 22px; }
.dex-name { font-weight: 700; }
.type { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.5); margin: 1px; }
.dex-detail { display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
.dd-left label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
.sprites { display: flex; gap: 8px; }
.sprites figure { margin: 0; text-align: center; background: var(--panel2); border-radius: 8px; padding: 6px; }
.sprites img { width: 132px; height: 132px; background: radial-gradient(circle at 50% 60%, #2a3446, transparent 70%); }
.sprites figcaption { font-size: 12px; color: var(--muted); }
.dd-right h4 { margin: 14px 0 6px; }
input.big { font-size: 22px; font-weight: 700; width: 260px; }
input.wide { width: 100%; margin-top: 6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.stats label { display: grid; grid-template-columns: 70px 64px 1fr; align-items: center; gap: 6px; font-size: 13px; }
.bar { height: 8px; background: #0d1118; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.moves input:not([type]) { width: 170px; }
.mon-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.mon-card { display: flex; gap: 10px; background: var(--panel2); border-radius: 8px; padding: 10px; }
.mon-card img { width: 96px; height: 96px; }
.mon-info { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.form label { display: block; margin: 8px 0; }
.form input:not([type=number]), .form select { min-width: 320px; }

/* HP bars */
.hpbar { height: 8px; background: #0d1118; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.hpbar i { display: block; height: 100%; background: #4cd06c; transition: width .6s ease-out, background-color .6s; }

/* Battle */
#battle { position: absolute; inset: 0; display: flex; flex-direction: column; color: #1a1a1a; z-index: 10;
  background: radial-gradient(ellipse at 70% 0%, #fff6d8 0%, rgba(255,246,216,0) 45%), linear-gradient(#a9dcff 0%, #d8f1ff 46%, #b9e08e 47%, #8cc86a 100%); }
.b-field { flex: 1; position: relative; overflow: hidden; }
.b-field::before { content: ''; position: absolute; left: -10%; right: -10%; top: 45%; height: 30px; background: radial-gradient(ellipse at center, rgba(255,255,255,.5), rgba(255,255,255,0) 70%); }
.b-foe { position: absolute; right: 6%; top: 6%; display: flex; align-items: flex-end; gap: 24px; }
.b-me { position: absolute; left: 6%; bottom: 2%; display: flex; align-items: flex-end; gap: 24px; }
.b-foe .b-sprite-wrap, .b-me .b-sprite-wrap { position: relative; }
.b-mon { position: relative; transform-origin: 50% 90%; }
.b-body { transform-origin: 50% 100%; animation: breathe 2.6s ease-in-out infinite; }
.b-mon.me .b-body { animation-duration: 3.1s; animation-delay: -1s; }
.b-sprite { position: relative; display: block; width: 200px; height: 200px; object-fit: contain; }
.b-sprite.back { transform: scaleX(-1); width: 250px; height: 250px; }
@keyframes breathe { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4px) scale(.985, 1.03); } }
#battle.noanim .b-body { animation: none; }
.b-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.b-flash { position: absolute; inset: 0; background: #fff; z-index: 25; pointer-events: none; opacity: 0; }
.b-card .xpbar { height: 4px; background: #0d1118; border-radius: 2px; overflow: hidden; margin-top: 4px; }
.b-card .xpbar i { display: block; height: 100%; width: 0; background: #4aa3ff; transition: width .8s ease-out; }
.b-log .cur { min-height: 1.5em; }
.form label.check { display: flex; align-items: center; gap: 8px; }
.b-foe::after, .b-me::after { content: ''; position: absolute; z-index: -1; border-radius: 50%; background: radial-gradient(ellipse at center, #9fd27a 0%, #79b65a 60%, rgba(121,182,90,0) 72%); }
.b-foe::after { right: -30px; bottom: -14px; width: 280px; height: 70px; }
.b-me::after { left: -30px; bottom: -10px; width: 330px; height: 80px; }
.b-card { background: rgba(253,253,248,.95); border: 3px solid #2c3648; border-radius: 14px; padding: 10px 14px; min-width: 240px; box-shadow: 0 4px 0 rgba(0,0,0,.15); margin-bottom: 30px; }
.b-card .hptext { font-size: 13px; text-align: right; }
.b-bottom { display: flex; gap: 10px; padding: 10px; background: #2c3648; }
.b-log { flex: 1; background: #fdfdf8; border-radius: 8px; padding: 10px 14px; min-height: 110px; font-size: 16px; line-height: 1.5; }
.b-log div:last-child { font-weight: 600; }
.b-actions { width: 46%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.b-actions button { background: #fdfdf8; color: #1a1a1a; border: 2px solid #2c3648; font-weight: 700; display: flex; flex-direction: column; align-items: flex-start; }
.b-actions button small { font-weight: 400; color: #555; font-size: 12px; }

/* Modal / starters */
#modal { position: fixed; inset: 0; background: rgba(5,8,12,.75); display: flex; align-items: center; justify-content: center; z-index: 30; }
.modal-inner { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; width: min(900px, 94%); }
.starters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.starters button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; text-align: center; }
.starters img { width: 128px; height: 128px; }
.starters small { color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: var(--accent); color: #062018; padding: 8px 16px; border-radius: 8px; font-weight: 600; transition: transform .25s; z-index: 50; }
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 800px) {
  #editor { position: absolute; right: 0; top: 0; bottom: 0; width: 320px; z-index: 5; }
  .dex-detail { grid-template-columns: 1fr; }
  .b-bottom { flex-direction: column; }
  .b-actions { width: 100%; }
  nav button { padding: 5px 7px; font-size: 13px; }
}
.b-foe, .b-me { isolation: isolate; }

/* Forge + evolution */
.forge-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.forge-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); }
.chip.ok { color: #7ee2b8; border-color: #1f6b52; }
.chip.bad { color: #ff9aa4; border-color: #5a2a33; }
.forge-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 8px 0; }
.forge-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.forge-form label.grow { flex: 1; min-width: 240px; }
.forge-form label.grow input { width: 100%; }
.jobs { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.job { font-size: 13px; padding: 4px 8px; border-radius: 6px; background: #121823; display: flex; flex-direction: column; }
.job small { color: var(--muted); }
.job.working b, .job.queued b { color: var(--accent2); }
.job.done b { color: var(--accent); }
.job.failed b { color: var(--danger); }
details.quick { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
details.quick summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.quick[open] { display: flex; width: 100%; gap: 6px; }
.dex-card.ph { opacity: .8; }
.dex-card .evo { color: var(--accent2); font-size: 11px; min-height: 14px; }
.concept { margin: 4px 0 10px; }
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--panel2); border-radius: 10px; padding: 8px; margin-bottom: 12px; }
.chain-mon { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; }
.chain-mon img { width: 72px; height: 72px; object-fit: contain; }
.chain-mon.on { background: #24443a; border-color: var(--accent); color: var(--text); }
.chain .arrow { display: flex; flex-direction: column; align-items: center; color: var(--accent2); font-size: 22px; }
.chain .arrow small { font-size: 11px; color: var(--muted); }
.dex-card img, .sprites img, .mon-card img, .starters img, .b-sprite { object-fit: contain; }

.forge-form label.intensity { min-width: 230px; }
.forge-form label.intensity input { width: 100%; accent-color: var(--accent2); }
.forge-form label.intensity span, label.intensity.inline span { color: var(--accent2); font-weight: 600; }
label.intensity.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
label.intensity.inline input { width: 120px; accent-color: var(--accent2); }

.warn { color: #ffb347; font-weight: 700; }
.warnbox { background: #3a2a14; border: 1px solid #7a5a20; color: #ffd08a; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.sprites figure { background: repeating-conic-gradient(#232c3c 0% 25%, #1b2230 0% 50%) 50% / 16px 16px; }

/* genes + gene shinies */
.genes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 8px; margin-top: 4px; }
.gene { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.gene em { font-style: normal; color: var(--muted); width: 44px; }
.gene b { flex: 1; height: 6px; background: #0d1118; border-radius: 3px; overflow: hidden; }
.gene b i { display: block; height: 100%; background: linear-gradient(90deg, #6a7a90, var(--accent2)); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; border: 1px solid #000; margin-left: 3px; }
.shiny-range img { width: 104px; height: 104px; }
#status img { width: 32px; height: 32px; object-fit: contain; }

/* badges, key switch */
.badge { font-size: 11px; margin-left: 2px; }
.badge.hyb { color: #ffd08a; }
.key-toggle { display: flex; gap: 12px; align-items: flex-start; background: var(--panel2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.key-toggle .hyb-info { margin-left: auto; max-width: 380px; border-left: 1px solid var(--line); padding-left: 12px; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2b3446; border-radius: 12px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #cfd8e6; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); background: #fff; }
.switch input:disabled + span { opacity: .5; cursor: default; }
/* forge head + job cards */
.forge-head .grow, .wiz-nav .grow, .wiz-steps .grow, .sc-head .grow { flex: 1; }
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-top: 8px; }
.job-card { background: #121823; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.job-card.failed { border-color: #5a2a33; }
.job-card.done { border-color: #1f6b52; }
.jhead { display: flex; justify-content: space-between; gap: 8px; }
.jstat { font-size: 12px; color: var(--accent2); }
.job-card.done .jstat { color: var(--accent); }
.job-card.failed .jstat { color: var(--danger); }
.jthumbs { display: flex; gap: 6px; }
.jthumb { width: 76px; display: flex; flex-direction: column; align-items: center; font-size: 10px; }
.jthumb img, .jthumb .spin { width: 64px; height: 64px; object-fit: contain; }
.jthumb.wait { opacity: .8; }
.jbar { height: 5px; background: #0d1118; border-radius: 3px; overflow: hidden; }
.jbar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.spin { display: inline-block; border: 4px solid #2b3446; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; box-sizing: border-box; }
.jthumb .spin { width: 40px; height: 40px; margin: 12px; }
.wiz-busy .spin { width: 20px; height: 20px; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* wizard */
.wizard { background: #121823; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.wiz-steps { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.wiz-steps span { padding: 3px 10px; border-radius: 12px; background: #1b2230; color: var(--muted); font-size: 13px; }
.wiz-steps span.on { background: var(--accent); color: #062018; font-weight: 700; }
.wiz-steps span.done { color: var(--accent); }
.wiz-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.wiz-modes .mode { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; text-align: left; }
.wiz-modes .mode small { color: var(--muted); }
.wiz-modes .mode.on { border-color: var(--accent); background: #183a31; }
label.block { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin: 6px 0; }
label.block input, label.block textarea { width: 100%; color: var(--text); }
.wiz-nav { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.quick-forge { font-size: 13px; color: var(--muted); }
.quick-forge input { width: 52px; }
.wiz-busy, .wiz-done { padding: 14px; font-size: 15px; }
.key-pick .row { margin: 6px 0; }
.key-chip { display: inline-flex; align-items: center; gap: 4px; background: #1b2230; border: 1px solid var(--accent); border-radius: 16px; padding: 2px 6px 2px 2px; font-size: 13px; }
.key-chip img { width: 28px; height: 28px; object-fit: contain; }
.key-chip button { padding: 0 5px; border: none; background: none; }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; max-height: 330px; overflow-y: auto; padding: 2px; }
.key-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; font-size: 12px; }
.key-card img { width: 64px; height: 64px; object-fit: contain; }
.key-card.on { border-color: var(--accent); background: #183a31; box-shadow: 0 0 0 2px var(--accent) inset; }
.stage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.stage-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.stage-card label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.stage-card .row label { flex-direction: row; align-items: center; gap: 4px; }
.stage-card input, .stage-card textarea { color: var(--text); width: 100%; }
.stage-card input[data-f="name"] { font-size: 16px; font-weight: 700; }
.stage-card .row input[data-f="note"] { flex: 1; width: auto; }
.moves4 { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
/* gene lab */
.lab-intro { background: var(--panel2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.lab-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.lab-card.unlocked { border-color: #1f6b52; }
.lab-target { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.lab-target img { width: 96px; height: 96px; object-fit: contain; }
img.sil { filter: brightness(0) opacity(.55); }
img.glow { filter: drop-shadow(0 0 10px var(--accent)); }
.lab-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lab-key { display: flex; gap: 8px; align-items: center; background: #121823; border-radius: 10px; padding: 8px; min-width: 260px; }
.lab-key img, .lab-img { width: 72px; height: 72px; object-fit: contain; }
.lab-img.q { display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--muted); }
.lab-key small.ok { color: var(--accent); }
.lab-plus { font-size: 22px; color: var(--accent2); }
.lab-preview { margin-top: 8px; background: #121823; border-radius: 8px; padding: 8px 10px; }
.lab-result { display: flex; gap: 14px; align-items: center; background: #183a31; border: 1px solid var(--accent); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.lab-result img.big { width: 140px; height: 140px; object-fit: contain; }
.lab-result h3 { margin: 0 0 4px; }
.lab-result > div { flex: 1; }
.key-card.on, .wiz-modes .mode.on, .chain-mon.on { color: var(--text); }
.wiz-modes .mode.on b { color: var(--accent); }

.jobs-head { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.jthumb .noart { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; border: 1px dashed var(--line); border-radius: 8px; }

/* editor: palette, rotation, sync */
.rot-ctl { display: flex; align-items: center; gap: 8px; margin-top: 8px; background: var(--panel2); border-radius: 8px; padding: 6px 8px; }
.rot-ctl canvas { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 4px; }
.pal-cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.pal-cats button { padding: 3px 8px; font-size: 12px; }
#editor input.wide { width: 100%; }
.palette { max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.palette button { position: relative; }
.palette canvas.tall { width: 40px; height: 80px; max-height: none; }
.palette .flags { position: absolute; top: 2px; right: 3px; font-style: normal; font-size: 10px; color: var(--accent2); }
.ed-sync { font-size: 12px; margin-top: 6px; padding: 5px 8px; border-radius: 6px; background: #121823; color: var(--muted); }
.ed-sync.shared { color: #7ee2b8; }
.ed-sync.failed, .ed-sync.local-only { color: #ffd08a; }

/* People (NPCs) */
#msg.has-who { display: flex; gap: 14px; align-items: center; }
.msg-who { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; }
.msg-who canvas { width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #e6f4ff, #b8d8ee); border: 2px solid #2c3648; }
.msg-who b { font-size: 12px; color: #2c3648; text-align: center; max-width: 110px; }
.msg-text { flex: 1; }
.npc-edit { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.npc-top { display: flex; gap: 10px; align-items: flex-start; }
.npc-top canvas { background: radial-gradient(circle at 50% 40%, #e6f4ff, #b8d8ee); border-radius: 8px; border: 1px solid var(--line); }
.npc-dirs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
.npc-dirs button { padding: 2px 6px; font-size: 12px; }
.npc-dirs button.on { background: var(--accent); color: #062018; }
.npc-edit textarea { width: 100%; min-height: 84px; resize: vertical; font: inherit; font-size: 13px; }
.npc-edit label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.npc-edit .row2 { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.npc-edit .row2 > * { flex: 1; }
.npc-edit .row2 > button { flex: 0 0 auto; }
.list button canvas { width: 26px; height: 26px; vertical-align: middle; margin-right: 4px; border-radius: 50%; background: #b8d8ee; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--accent); color: #062018; }
