:root {
  color-scheme: dark;
  --bg: #11110f;
  --panel: #1b1a17;
  --panel-raised: #25221b;
  --line: #49402f;
  --line-soft: #302c23;
  --muted: #aaa18d;
  --text: #ece6d8;
  --gold: #cfb675;
  --gold-bright: #eddaa1;
  --bronze: #8c7448;
  --mint: var(--gold);
  --stop-zone: #55534e;
  --stop-zone-border: #aaa69b;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.55 "Segoe UI", "Microsoft JhengHei", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, .button {
  background: linear-gradient(#302b20, #211f19); border: 1px solid #685837; border-radius: 4px;
  box-shadow: inset 0 1px 0 #c9af6720, 0 1px 2px #0003; color: var(--text); padding: 7px 10px;
  cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled), .button:hover { background: #3b3323; border-color: var(--gold); color: #fff5d8; }
button:active:not(:disabled), .button:active { box-shadow: inset 0 1px 4px #0006; }
button:disabled { opacity: .34; cursor: default; box-shadow: none; }
button.active { background: #433a23; border-color: var(--gold); color: var(--gold-bright); box-shadow: inset 0 0 0 1px #cfb6751a; }
button.primary, .button { background: linear-gradient(#d7be7e, #b69a5c); border-color: #ddc58b; color: #201b0f; font-weight: 650; text-shadow: 0 1px #fff2; }
button.primary:hover:not(:disabled), .button:hover { background: #e2ca8d; color: #201b0f; border-color: #f1dfa8; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
input, select, textarea { background: #12120f; border: 1px solid #524831; border-radius: 3px; box-shadow: inset 0 1px 3px #0005; color: var(--text); padding: 6px; min-width: 0; width: 100%; }
input:hover, select:hover { border-color: #89754b; }
input[type=checkbox] { width: 14px; height: 14px; flex: 0 0 14px; accent-color: var(--gold); box-shadow: none; }
input[type=color] { padding: 2px; height: 32px; }
input[type=range] { padding: 0; accent-color: var(--gold); border: 0; box-shadow: none; }
input::placeholder, textarea::placeholder { color: #827965; opacity: 1; }
select { cursor: pointer; }
header {
  min-height: 76px; flex-shrink: 0; border-top: 2px solid #8e784b; border-bottom: 1px solid #73613b;
  box-shadow: 0 1px 0 #000, inset 0 1px 0 #cbb47b22; display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; padding: 12px 22px; background: linear-gradient(#242219, #151511);
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 245px; font-size: 18px; font-weight: 600; letter-spacing: 1px; line-height: 1.4; }
.brandmark { font-size: 33px; color: var(--gold); line-height: 1; text-shadow: 0 1px 1px #000; }
small { display: block; font-size: 9px; color: var(--muted); letter-spacing: 1.7px; font-weight: 400; }
#mapSelect { width: 215px; }
.spacer { flex: 1; }
.badge { font-size: 10px; border: 1px solid #5c5036; border-radius: 3px; color: #c0b393; padding: 3px 6px; white-space: nowrap; background: #29251b55; }
main { flex: 1; min-height: 0; display: grid; grid-template-columns: 238px minmax(300px, 1fr) 286px; }
aside { min-width: 0; background: var(--panel); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #6a5c3d #171611; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
section { padding: 16px; border-bottom: 1px solid var(--line-soft); }
.section-title { display: flex; align-items: center; gap: 9px; color: var(--bronze); font-size: 11px; letter-spacing: 1px; margin-bottom: 13px; }
.section-title b { color: #d6c69f; font-size: 13px; letter-spacing: .5px; font-weight: 600; }
.section-title span, .section-title button { margin-left: auto; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tools button { padding: 5px 0; font-size: 21px; background: #24221b; border-color: #4f4530; box-shadow: inset 0 1px #bba66b0d; }
.tools button.active { background: #403723; border-color: var(--gold); color: var(--gold-bright); }
.tools span { display: block; font-size: 10px; }
.row { display: flex; gap: 7px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.history-actions { margin-top: 11px; }
label { display: block; margin: 10px 0 4px; color: #c0b69f; font-size: 11px; }
label input, label select { display: block; margin-top: 4px; font-size: 12px; }
.check { display: flex; align-items: center; gap: 7px; margin: 8px 0; cursor: pointer; }
.check input { margin: 0; }
.unit { color: #8c8065; float: right; font-size: 10px; }
.hint, .empty, .description { font-size: 11px; line-height: 1.75; color: var(--muted); }
.hint { margin: 9px 0 0; }
.description { display: block; margin: 5px 0 8px; letter-spacing: 0; font-weight: 400; overflow-wrap: anywhere; }
.wide { width: 100%; margin-top: 8px; }
.layers { display: grid; grid-template-columns: 1fr 1fr; column-gap: 3px; }
.layers .check { font-size: 11px; }
.catalog-filters { background: linear-gradient(135deg, #302a1b66, #1b1a17); border-bottom-color: #554830; }
.catalog-filters .section-title { margin-bottom: 8px; }
.filter-options { display: flex; flex-wrap: wrap; gap: 0 18px; }
.filter-options .check { margin: 4px 0; }
#catalogInfo { overflow-wrap: anywhere; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: #0e0f0d; }
.stagebar { min-height: 82px; flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid #3d3526; background: linear-gradient(#1b1b16, #151611); }
.stagebar > div:first-child { min-width: 0; }
.stagebar .row { gap: 5px; }
.stagebar .row > * { flex: initial; }
.eyebrow { display: block; font-size: 9px; color: #9e8c62; letter-spacing: 1.6px; }
h1 { font-size: 21px; font-weight: 500; line-height: 1.25; margin: 6px 0 0; color: #e9dfc7; }
.canvas-wrap { flex: 1; position: relative; isolation: isolate; overflow: hidden; min-height: 200px; background: radial-gradient(ellipse at 45% 42%, #25271f, #10120f 75%); }
canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
canvas:focus { outline: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 1px #cdb67266; }
#canvasHint { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); background: #171811e8; border: 1px solid #7e6a4199; padding: 7px 15px; border-radius: 4px; box-shadow: 0 2px 10px #0003; font-size: 11px; color: #d7ccb2; pointer-events: none; text-align: center; }
#finishPolygon { position: absolute; top: 59px; left: 50%; transform: translateX(-50%); z-index: 2; background: #4a3e25; border-color: var(--gold); color: var(--gold-bright); }
.legend { position: absolute; bottom: 18px; left: 20px; right: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 10px; color: #c1b99f; text-shadow: 0 1px 3px #000; pointer-events: none; }
.legend i { width: 8px; height: 8px; display: inline-block; border-radius: 2px; }
.nav-key { background: #a9b68b; }
.slot-key { background: #eed187; }
.zone-key, .stop-zone-swatch { background: var(--stop-zone); border: 1px solid var(--stop-zone-border); }
.legend span { border-left: 1px solid #786947; padding-left: 10px; margin-left: 8px; }
.map-notice { flex-shrink: 0; padding: 6px 17px; border-top: 1px solid #4d442e; color: #c0b693; background: #222117; font-size: 11px; }
#statusbar { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px 15px; align-items: center; min-height: 32px; padding: 5px 17px; background: #181914; color: #a9a185; font: 10px Consolas, monospace; }
#meshInfo { margin-left: auto; white-space: nowrap; }
#message { flex-shrink: 0; padding: 8px 17px; border-top: 1px solid var(--line-soft); font-size: 11px; color: #c9bea1; min-height: 34px; overflow-wrap: anywhere; }
#message.error { color: #ffc3ad; background: #3b2420; border-color: #78533c; }
#zoomLabel { min-width: 42px; text-align: center; font-size: 10px; color: var(--muted); }
.object { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; margin: 4px 0; background: #25231d; }
.object:hover { background: #302c22; }
.object.selected { border-color: #ae9258; background: #393020; box-shadow: inset 2px 0 var(--gold); }
.swatch { width: 9px; height: 20px; border-radius: 2px; flex-shrink: 0; }
.object span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.object small { margin-left: auto; white-space: nowrap; letter-spacing: 0; color: #ada287; }
.tiny { padding: 1px 7px; font-size: 11px; }
.danger { color: #e9ad97; }
.monster-entry { padding: 10px; background: #141510; border: 1px solid #4b422d; border-radius: 5px; margin: 9px 0; }
.monster-entry label { margin: 7px 0; }
.entry-head { display: flex; justify-content: space-between; gap: 7px; color: var(--gold); font-size: 11px; }
.object-header { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.object-header h2 { font-size: 15px; font-weight: 500; margin: 0; color: #e0d2af; }
.profile { font-size: 11px; color: #958b73; background: #171711; }
.profile b { color: #c3b48e; font-weight: 600; }
.profile p { margin: 8px 0; line-height: 1.8; }
.group { display: grid; grid-template-columns: minmax(0, 1fr) 68px 26px; gap: 5px; margin: 6px 0; }
.group input { font-size: 11px; }
.warning { background: #342c19; border: 1px solid #746033; color: #e5c789; padding: 7px; border-radius: 4px; margin-top: 7px; font-size: 11px; overflow-wrap: anywhere; }
#statistics { padding: 12px 0; }
#statistics strong { font-size: 28px; color: var(--gold); font-weight: 400; }
#surfaceChoices button { display: block; width: 100%; margin: 4px 0; font-size: 11px; text-align: left; }
.export-actions { flex-wrap: wrap; }
.export-actions button { padding: 7px 6px; font-size: 11px; }
.work-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: #090b0838; pointer-events: none; }
.work-card { pointer-events: auto; width: min(360px, 100%); padding: 25px; border: 1px solid #967e4a; border-top-color: #d3bc7b; border-radius: 5px; background: linear-gradient(150deg, #29251b, #181912); box-shadow: 0 15px 55px #0008, inset 0 0 0 3px #0002; text-align: center; }
.work-card .eyebrow { color: #b4a16f; }
#workLabel { display: block; margin: 11px 0 17px; color: #eee0ba; font-size: 17px; font-weight: 500; letter-spacing: .4px; }
#workProgress { display: block; appearance: none; width: 100%; height: 7px; overflow: hidden; border: 1px solid #665534; border-radius: 2px; background: #0d100c; accent-color: var(--gold); }
#workProgress::-webkit-progress-bar { background: #0d100c; }
#workProgress::-webkit-progress-value { background: linear-gradient(90deg, #96783d, #e0c787); }
#workProgress::-moz-progress-bar { background: linear-gradient(90deg, #96783d, #e0c787); }
#workProgress:indeterminate::-webkit-progress-bar { background: linear-gradient(90deg, #0d100c 15%, #ad914f 48%, #0d100c 80%); background-size: 220% 100%; animation: work-scan 1.6s linear infinite; }
#workProgress:indeterminate::-moz-progress-bar { background: linear-gradient(90deg, #0d100c 15%, #ad914f 48%, #0d100c 80%); background-size: 220% 100%; animation: work-scan 1.6s linear infinite; }
@keyframes work-scan { from { background-position: 160% 0; } to { background-position: -60% 0; } }
#workDetail { min-height: 34px; margin: 13px 0 17px; color: #b6aa8c; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
#cancelOverlay { min-width: 118px; }
.working aside { opacity: .72; pointer-events: none; }
#cancelWork { border-color: #a48851; color: #e9cc8a; }
dialog { width: min(900px, 92vw); max-height: 90vh; border: 1px solid #9d844f; border-top: 2px solid #cdb779; border-radius: 6px; background: #1d1c16; color: var(--text); padding: 22px; box-shadow: 0 18px 70px #0008; }
dialog::backdrop { background: #080906c7; }
dialog textarea { width: 100%; height: 55vh; resize: vertical; margin: 14px 0; color: #d8cda9; padding: 12px; font: 12px/1.6 Consolas, monospace; }
.button { display: block; text-align: center; text-decoration: none; }
[hidden] { display: none !important; }
@media (max-width: 1200px) {
  header { padding: 10px 14px; gap: 8px; }
  .brand { min-width: 210px; font-size: 17px; }
  #mapSelect { width: 190px; }
  main { grid-template-columns: 215px minmax(260px, 1fr) 267px; }
  section { padding: 13px; }
  .stagebar { padding: 13px 15px; gap: 9px; }
}
@media (max-width: 1000px) {
  header .spacer { display: none; }
  header .brand { flex: 1 1 205px; }
  main { grid-template-columns: 193px minmax(230px, 1fr) 243px; }
  section { padding: 11px; }
  .section-title { gap: 6px; }
  .tools { gap: 4px; }
  .tools span { font-size: 9px; }
  .layers { grid-template-columns: 1fr; }
  .layers .check { margin: 5px 0; }
  .stagebar .row { flex-wrap: wrap; }
  h1 { font-size: 19px; }
  #statusbar { padding-inline: 11px; }
  .group { grid-template-columns: minmax(0, 1fr) 58px 26px; }
}
@media (max-width: 800px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  header { position: relative; padding: 12px; }
  header .brand { flex-basis: 210px; }
  header button { flex: 1 1 auto; font-size: 12px; }
  #mapSelect { flex: 1 1 200px; }
  main { flex: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stage { grid-column: 1 / -1; grid-row: 1; height: 66dvh; min-height: 400px; border-bottom: 1px solid #72603b; }
  .left { grid-column: 1; grid-row: 2; }
  .right { grid-column: 2; grid-row: 2; border-left: 0; }
  aside { overflow: visible; }
  section { padding: 15px; }
  .tools span { font-size: 10px; }
  .layers { grid-template-columns: 1fr 1fr; }
  .stagebar { min-height: 74px; }
  .legend { bottom: 12px; left: 15px; }
  dialog .row { flex-wrap: wrap; }
  dialog .row > * { flex-basis: 45%; }
}
@media (max-width: 480px) {
  header .brand { min-width: 0; font-size: 16px; }
  #mapSelect { flex-basis: 100%; }
  header .badge { margin-left: auto; }
  main { grid-template-columns: minmax(0, 1fr); }
  .left { grid-column: 1; grid-row: 2; border-right: 0; }
  .right { grid-column: 1; grid-row: 3; border-top: 1px solid var(--line); }
  .stage { grid-column: 1; min-height: 440px; }
  .stagebar { padding: 12px; }
  .stagebar .row { width: 100%; justify-content: flex-end; }
  #canvasHint { font-size: 10px; }
  .legend span { display: none; }
  .work-overlay { padding: 15px; }
  .work-card { padding: 20px; }
  dialog { padding: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  button, .button { transition: none; }
  #workProgress:indeterminate::-webkit-progress-bar, #workProgress:indeterminate::-moz-progress-bar { animation: none; }
}
.slider-number { display:grid; grid-template-columns:minmax(0,1fr) 78px; align-items:center; gap:9px; }
.slider-number input { min-width:0; margin:4px 0; }
.slider-number input[type=range] { width:100%; }
.point-panel { margin-top:16px; padding-top:14px; border-top:1px solid var(--line); }
.point-tooltip { position:absolute; z-index:5; pointer-events:none; white-space:pre-line; padding:10px 12px; background:#12171ff2; border:1px solid #a9cced; border-radius:7px; color:#f4f7ff; font-size:11px; line-height:1.6; max-width:280px; box-shadow:0 4px 20px #0009; }
.paint-choice { max-width:380px; }
.paint-choice button { margin-top:9px; }
.apply-actions { margin-top:8px; }
.apply-actions button { font-size:11px; }
#regenerate { margin-top:8px; }

.add-monster-form { margin-top:15px; padding:10px; border:1px solid #625336; background:#242119; border-radius:5px; }
.add-monster-form label { margin-top:0; }
.monster-behavior { margin-top:10px; border-top:1px solid var(--line-soft); }
.monster-behavior summary { cursor:pointer; color:#c9b47d; padding:9px 0; font-size:11px; }
.monster-behavior[open] summary { margin-bottom:5px; }

.species-swatch{display:inline-block;width:10px;height:10px;border-radius:50%;border:1px solid white;box-shadow:0 0 0 1px #101820;margin-right:8px}.region-counts{font-size:11px;line-height:1.7;margin-top:8px;color:var(--muted)}

.tool-group-title{margin:12px 0 6px;font-size:11px;font-weight:600;color:var(--gold);letter-spacing:.12em}.tool-group-title:first-child{margin-top:0}.tools-paint{grid-template-columns:repeat(3,1fr)}.tools-manual{grid-template-columns:repeat(2,1fr)}.tools svg{display:block;width:22px;height:22px;margin:0 auto 3px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}.tools button{min-height:54px}

.legend .npc-legend{color:#59e66c}.legend{flex-wrap:wrap;row-gap:4px}

.selection-pulse{position:absolute;pointer-events:none;border:1.5px dashed var(--selection-color,#fff0bb);box-sizing:border-box;animation:selection-breathe 2.4s ease-in-out infinite}
@keyframes selection-breathe{0%,100%{opacity:.75;border-color:var(--selection-color,#fff0bb);box-shadow:0 0 1px transparent}50%{opacity:1;border-color:#fff;box-shadow:0 0 7px #ffffff50}}
@media(prefers-reduced-motion:reduce){.selection-pulse{animation:none;opacity:.85}}

.object.locked{cursor:url("./lock-cursor.svg") 12 12, default;opacity:.75}.area-lock{margin-left:auto;flex:none;font-size:14px;cursor:pointer}.area-lock[aria-pressed="true"]{background:#514636;border-color:#c69d57}

.monster-picker{position:relative;margin-top:5px}.monster-picker-toggle{width:100%;display:flex;justify-content:space-between;gap:8px;text-align:left;padding:10px}.monster-picker-menu{position:relative;z-index:8;margin-top:5px;padding:8px;border:1px solid #8c7844;background:#171811;box-shadow:0 8px 22px #0008}.monster-picker-menu[hidden]{display:none}.monster-picker-search{width:100%;margin:0 0 7px!important}.monster-picker-options{max-height:240px;overflow-y:auto;overscroll-behavior:contain}.monster-picker-options button{display:block;width:100%;text-align:left;border:0;border-radius:0;padding:9px 7px;background:transparent}.monster-picker-options button:hover,.monster-picker-options button:focus-visible{background:#4d432b;color:#fff0bd;outline:1px solid #c7ad68;outline-offset:-1px}.monster-picker-options [aria-selected=true]{background:#302c1e;color:#e6ce9a}

select[data-customized]{display:none!important}header .monster-picker{min-width:215px;margin:0}header .monster-picker-menu{position:absolute;top:100%;left:0;width:320px;max-width:80vw;z-index:50}.picker-field{display:block;margin:10px 0;color:var(--muted)}
.point-editor{width:min(560px,92vw)}.point-editor label,.point-editor input{display:block;width:100%}.point-editor label{margin:10px 0}.point-editor input{margin-top:5px}.point-behavior{margin:18px 0}.point-edit-error{color:#ffb1a0}.point-editor h2{margin-top:0}#fixedCoordinates{border-top:1px solid var(--line);margin-top:14px;padding-top:6px}

header .contributor{display:flex;align-items:center;gap:6px;white-space:nowrap}header .contributor input{width:120px;margin:0}
.exchange-name{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}.exchange-name h2{overflow-wrap:anywhere}.exchange-name #exportSuffixField{display:flex;align-items:center;gap:5px;margin:0}.exchange-name #exportSuffixField[hidden]{display:none}.exchange-name #exportSuffix{width:150px;max-width:35vw;margin:0}

.monster-entry input:disabled,.point-behavior input:disabled{opacity:.45;cursor:not-allowed}
