:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #11141c;
  --panel-2: #171b25;
  --line: #292e3b;
  --muted: #8b93a7;
  --text: #f4f7fb;
  --cyan: #2de4d2;
  --pink: #ff5d9b;
  --yellow: #ffd75e;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; overflow: hidden; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
button, input, select { font: inherit; }
button, select, input { color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.editor-header { height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 20px; border-bottom: 1px solid var(--line); background: #0c0f15; }
.editor-header p, .editor-header h1 { margin: 0; }
.editor-header p { color: var(--cyan); font-size: 9px; font-weight: 850; letter-spacing: 1.8px; }
.editor-header h1 { margin-top: 2px; font-size: 21px; letter-spacing: -.5px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
button, .link-button { min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.ghost, .link-button { padding: 7px 11px; color: #cbd2e0; }
.link-button { text-decoration: none; font-size: 12px; }
.primary { padding: 7px 14px; border-color: #1c9e92; color: #061311; background: var(--cyan); font-weight: 800; }
button:hover, .link-button:hover { border-color: #657087; }
button:disabled { cursor: default; opacity: .35; }
.save-status { max-width: 250px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.save-status[data-state="saved"] { color: var(--cyan); }
.save-status[data-state="dirty"] { color: var(--yellow); }
.save-status[data-state="error"] { color: #ff7b8c; }
.autosave, .grid-toggle { display: flex; align-items: center; gap: 6px; color: #aeb5c4; font-size: 11px; cursor: pointer; }
.autosave input, .grid-toggle input { accent-color: var(--cyan); }

.editor-shell { height: calc(100vh - 70px); display: grid; grid-template-columns: 250px minmax(400px, 1fr) 290px; }
.sidebar { min-height: 0; overflow: auto; background: var(--panel); scrollbar-width: thin; }
.left-sidebar { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.sidebar section { padding: 16px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title span { color: #dfe4ee; font-size: 10px; font-weight: 850; letter-spacing: 1.35px; }
.section-title small { color: var(--muted); font-size: 9px; }
.character-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.character-card { position: relative; min-height: 52px; padding: 9px; text-align: left; }
.character-card span, .character-card small { display: block; }
.character-card span { font-size: 11px; font-weight: 750; }
.character-card small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.character-card.active { border-color: var(--cyan); background: #15332f; }
.character-card.dirty::after { content: ""; position: absolute; right: 7px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); }
.layer-section { min-height: 300px; }
.layer-list { display: flex; flex-direction: column; gap: 5px; }
.layer-item { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 7px; width: 100%; padding: 7px 9px; text-align: left; }
.layer-item i { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; color: var(--cyan); background: #202a31; font-size: 9px; font-style: normal; }
.layer-item span { min-width: 0; overflow: hidden; font-size: 11px; text-overflow: ellipsis; }
.layer-item small { color: var(--muted); font-size: 8px; }
.layer-item.active { border-color: var(--pink); background: #2b1d28; }

.workspace { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 45%, #17202b, #080a0f 70%); }
.workspace-toolbar { position: absolute; z-index: 3; top: 12px; left: 50%; display: flex; align-items: center; gap: 5px; transform: translateX(-50%); padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: #10141ced; box-shadow: 0 8px 30px #0008; backdrop-filter: blur(10px); }
.workspace-toolbar > i { width: 1px; height: 26px; margin: 0 3px; background: var(--line); }
.tool { display: flex; align-items: center; gap: 6px; padding: 5px 8px; color: #aeb6c7; background: transparent; }
.tool b { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 5px; background: #232836; font-size: 9px; }
.tool span { font-size: 10px; }
.tool.active { border-color: #27988f; color: #fff; background: #17312f; }
.icon-button { width: 30px; padding: 0; background: transparent; }
.compact-button { padding: 5px 8px; font-size: 10px; background: transparent; }
#zoomLabel { width: 42px; color: var(--muted); font-size: 9px; text-align: center; }
.canvas-scroller { position: absolute; inset: 0; display: grid; overflow: auto; place-items: center; padding: 82px 50px 65px; }
.canvas-mount { position: relative; flex: none; width: 512px; height: 640px; transform-origin: center; box-shadow: 0 0 0 1px #4e596c, 0 24px 80px #000b; }
#editorCanvas { display: block; width: 512px; height: 640px; touch-action: none; background: #0d1017; }
.workspace-help { position: absolute; z-index: 2; right: 14px; bottom: 12px; left: 14px; display: flex; justify-content: center; gap: 18px; color: var(--muted); font-size: 9px; pointer-events: none; }
.workspace-help span { display: flex; align-items: center; gap: 5px; }
.workspace-help b { width: 7px; height: 7px; border-radius: 50%; }
.cyan-dot { background: var(--cyan); }.pink-dot { background: var(--pink); }.yellow-dot { background: var(--yellow); }

.empty-inspector { padding: 25px 8px; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: center; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row.single { grid-template-columns: 1fr; }
label > span, .field-group > label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; }
input[type="number"], select { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: #0c0f15; font-size: 11px; }
input:focus, select:focus { border-color: var(--cyan); }
.field-group { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.field-group > strong { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 10px; }
.field-group > strong small { color: var(--muted); font-size: 8px; font-weight: 500; }
.field-group .field-row + .field-row { margin-top: 8px; }
.field-group > label { display: block; margin-top: 9px; }
.range-field { display: grid; grid-template-columns: 1fr 58px 11px; align-items: center; gap: 5px; }
.range-field input[type="range"] { min-width: 0; accent-color: var(--pink); }
.range-field em { color: var(--muted); font-size: 9px; font-style: normal; }
.check-field { display: flex !important; align-items: center; gap: 7px; }
.check-field span { margin: 0 !important; }
.check-field input { accent-color: var(--cyan); }
.anchor-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.anchor-presets button { min-height: 27px; color: var(--pink); background: #18131b; }
.joint-editor { padding-bottom: 8px !important; }
.joint-list { display: flex; flex-direction: column; gap: 5px; }
.joint-row { display: grid; grid-template-columns: 1fr 58px 58px; align-items: center; gap: 5px; }
.joint-row button { min-width: 0; overflow: hidden; padding: 5px 7px; color: #dce1eb; background: transparent; font-size: 9px; text-align: left; text-overflow: ellipsis; }
.joint-row button.active { border-color: var(--yellow); color: var(--yellow); }
.joint-row input { height: 28px; padding: 0 5px; }
.danger { width: calc(100% - 32px); margin: 16px; color: #ff8c9e; background: #28151a; }
.source-note { margin: 0 16px 20px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.source-note code { color: #cbd1dc; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 22px; max-width: min(520px, 85vw); transform: translate(-50%, 15px); padding: 10px 15px; border: 1px solid var(--line); border-radius: 9px; opacity: 0; color: #fff; background: #202631; box-shadow: 0 12px 40px #0008; transition: .2s; pointer-events: none; font-size: 11px; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .editor-shell { grid-template-columns: 210px minmax(380px, 1fr); }
  .inspector { position: fixed; z-index: 6; top: 70px; right: 0; bottom: 0; width: 290px; box-shadow: -20px 0 50px #000b; transform: translateX(calc(100% - 12px)); transition: transform .2s; }
  .inspector:hover, .inspector:focus-within { transform: translateX(0); }
  .header-actions .link-button, .save-status { display: none; }
}
