/* v3 editor */
.ed-root { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.ed-toolbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
.ed-name { font-family: var(--font-ui); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; border: none; background: transparent; outline: none; padding: 6px 8px; border-radius: 8px; color: var(--ink); width: 220px; }
.ed-name:hover, .ed-name:focus { background: var(--bg-soft); }
.ed-tb-spacer { flex: 1; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-sink); border-radius: 999px; }
.seg button { padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); border-radius: 999px; transition: all 0.12s; }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg.seg-full { display: flex; width: 100%; }
.seg.seg-full button { flex: 1; }

.ed-body { flex: 1; display: grid; grid-template-columns: 264px 1fr 300px; overflow: hidden; }
.ed-panel { overflow-y: auto; background: var(--bg); }
.ed-left { border-right: 1px solid var(--line); }
.ed-right { border-left: 1px solid var(--line); }
.ed-panel-head { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.ed-panel-title { font-family: var(--font-ui); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3); }
.ed-remove { font-size: 13px; font-weight: 600; color: #c0392b; }

/* palette */
.ed-palette { padding: 6px 10px 14px; }
.ed-pal { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; width: 100%; padding: 8px; border-radius: 12px; align-items: center; text-align: left; transition: background 0.1s; }
.ed-pal:hover { background: var(--bg-soft); }
.ed-pal-prev { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--paper); }
.ed-pal-prev .v3w { position: absolute; inset: 0; transform: scale(0.42); transform-origin: top left; width: 238%; height: 238%; }
.ed-pal-label { display: block; font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }
.ed-pal-desc { display: block; font-size: 12px; color: var(--ink-3); }
.ed-pal-add { font-size: 18px; color: var(--ink-3); width: 22px; height: 22px; display: grid; place-items: center; }
.ed-pal:hover .ed-pal-add { color: var(--accent); }

.ed-presets { padding: 10px 14px 20px; display: flex; flex-direction: column; gap: 6px; }
.ed-preset { padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 10px; font-weight: 600; font-size: 14px; text-align: left; transition: all 0.12s; }
.ed-preset:hover { border-color: var(--ink); background: var(--bg-soft); }

/* stage */
.ed-stage { background: var(--bg-sink); overflow: auto; display: flex; align-items: center; justify-content: center; padding: 40px; }
.ed-frame { position: relative; background: #fff; border-radius: 14px; padding: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.ed-frame-lab { position: absolute; top: -22px; left: 2px; font-size: 11px; color: var(--ink-3); }
.ed-screen { background: var(--paper); position: relative; overflow: hidden; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06); }

/* canvas & tiles */
.ed-canvas { position: absolute; inset: 0; }
.ed-canvas.is-dragging { background-image: radial-gradient(rgba(47,94,204,0.28) 1px, transparent 1.4px); background-size: calc(100%/12) calc(100%/20); background-position: -0.5px -0.5px; }
.ed-tile { position: absolute; overflow: hidden; cursor: grab; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(26,26,24,0.12); }
.ed-tile:active { cursor: grabbing; }
/* Selected tile keeps its paint order (matches PNG); the ring is a separate overlay drawn above everything. */
.ed-tile.sel { box-shadow: inset 0 0 0 1px rgba(26,26,24,0.12); }
.ed-canvas.is-dragging .ed-tile.sel { z-index: 3; }
.ed-selbox { position: absolute; pointer-events: none; z-index: 5; border-radius: 7px; box-shadow: 0 0 0 2px var(--accent); }
.ed-tile .v3w { border-radius: 7px; }
.ed-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 6px; background: rgba(255,255,255,0.92); border: 1px solid var(--line-2); color: var(--ink); font-size: 15px; line-height: 1; display: none; align-items: center; justify-content: center; z-index: 4; }
.ed-tile.sel .ed-del { display: flex; }
.ed-resize { position: absolute; bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; z-index: 4; opacity: 0; }
.ed-tile.sel .ed-resize { opacity: 1; background: linear-gradient(135deg, transparent 46%, var(--accent) 46% 62%, transparent 62%); }
.ed-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 15px; padding: 20px; text-align: center; }

/* inspector */
.ed-inspect { padding: 6px 18px 24px; }
.ed-group-t { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.ed-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-num { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 10px; }
.ed-num span { font-size: 11px; color: var(--ink-3); }
.ed-num input { flex: 1; width: 100%; border: none; outline: none; background: transparent; font-family: var(--font-ui); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink); }
.ed-field { margin-bottom: 14px; }
.ed-refresh { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.ed-refresh button { padding: 9px 0; font-size: 13px; font-weight: 600; border: 1px solid var(--line-2); border-radius: 9px; color: var(--ink-2); transition: all 0.12s; }
.ed-refresh button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.ed-url { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.ed-url-box { font-size: 12px; padding: 10px 12px; background: var(--bg-soft); border: 1px dashed var(--line-2); border-radius: 9px; word-break: break-all; color: var(--ink-2); }
textarea.field { resize: vertical; font-family: var(--font-ui); }
.ed-screen-box { position: relative; }
.ed-tile { transform: scale(0.985); }
.ed-loading { flex: 1; display: grid; place-content: center; gap: 12px; justify-items: center; }
.ed-status { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ed-status.is-err { color: #c0392b; }
.ed-tb-url { white-space: nowrap; }
.ed-todo { display: flex; flex-direction: column; gap: 6px; }
.ed-todo-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.ed-todo-row .field { padding: 8px 10px; font-size: 14px; }
.ed-todo-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); }
.ed-todo-del { width: 26px; height: 26px; border-radius: 7px; color: var(--ink-3); font-size: 16px; }
.ed-todo-del:hover { background: var(--bg-soft); color: #c0392b; }
/* Timetable inspector: day switcher (dot = day has entries), text entry, actions */
.ed-tt { display: flex; flex-direction: column; }
.ed-tt-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
.ed-tt-day { position: relative; padding: 7px 0 10px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink-2); transition: all 0.12s; }
.ed-tt-day.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.ed-tt-day.has::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.ed-tt-help { margin: 6px 0 0; }
.ed-tt-help code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
.ed-tt-errs { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: #c0392b; }
.ed-tt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.ed-tt-actions .btn { justify-content: center; }
.ed-tt-after { display: flex; align-items: center; gap: 10px; }
.ed-tt-after .field { flex: 1; }
.ed-tt-after .field:disabled { opacity: 0.5; }
.ed-tt-never { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.ed-tt-never input { accent-color: var(--ink); }
.ed-canvas.is-loading .v3w { opacity: 0.45; transition: opacity 0.2s; }
.ed-back { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.ed-back:hover { color: var(--ink); }
.ed-stage { align-items: safe center; justify-content: safe center; }
.btn.ed-saved, .btn.ed-saved:disabled { opacity: 1; background: transparent; color: var(--ink-3); border-color: var(--line); box-shadow: none; transform: none; cursor: default; }
.ed-draft { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 20px; background: var(--bg-soft); border-bottom: 1px solid var(--line); color: var(--ink-2); flex-shrink: 0; }
.ed-err { color: #a5524a; margin-top: 10px; }

/* Layers (paint order, top of list = drawn last = on top) */
.ed-nav { position: fixed; z-index: 40; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg, 0 18px 50px -12px rgba(0,0,0,0.25)); display: flex; flex-direction: column; max-height: min(60vh, 520px); overflow: hidden; }
.ed-nav-head { display: flex; align-items: center; gap: 8px; padding: 9px 8px 9px 12px; cursor: move; user-select: none; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.ed-nav.is-collapsed .ed-nav-head { border-bottom: 0; }
.ed-nav-grip { color: var(--ink-3); font-size: 11px; letter-spacing: -2px; }
.ed-nav-btn { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.ed-nav-btn:hover { background: var(--bg-soft); color: var(--ink); }
.ed-layers { padding: 6px 8px 10px; overflow-y: auto; min-height: 0; }
.btn.is-on { background: var(--accent-soft); color: var(--accent-ink); }
.ed-layer { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.ed-layer:hover { background: var(--bg-soft); }
.ed-layer.sel { background: var(--accent-soft); border-color: rgba(47,94,204,0.25); }
.ed-layer:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ed-layer-main { display: flex; flex-direction: column; min-width: 0; }
.ed-layer-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.ed-layer-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-layer-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-layer-warn { font-family: var(--font-ui); font-size: 10px; font-weight: 600; letter-spacing: 0.02em; color: #a5481f; background: #fbeee6; border-radius: 4px; padding: 1px 5px; flex-shrink: 0; }
.ed-layer-geo { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; margin-top: 1px; }
.ed-layer-btns { display: flex; gap: 2px; opacity: 0.35; transition: opacity .12s; }
.ed-layer:hover .ed-layer-btns, .ed-layer.sel .ed-layer-btns { opacity: 1; }
.ed-layer-btns button { width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ed-layer-btns button:last-child { font-size: 14px; }
.ed-layer-btns button:hover:not(:disabled) { background: rgba(0,0,0,0.07); color: var(--ink); }
.ed-layer-btns button:disabled { opacity: 0.3; cursor: default; }
.ed-tile.overlap { box-shadow: inset 0 0 0 1px rgba(26,26,24,0.12); outline: 1.5px dashed rgba(192,57,43,0.55); outline-offset: -3px; }
.ed-tile.hov { z-index: 4; outline: 2px dashed var(--accent); outline-offset: -2px; }
.ed-tile.sel.overlap, .ed-tile.sel.hov { outline: none; }
