/* ============================================================
   TV Designer — editor area (canvas, rulers, palette, inspector)
   ============================================================ */

/* ---------------- Center / canvas ---------------- */
#center {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: 22px 1fr 26px;
  grid-template-areas:
    "corner rulerH"
    "rulerV viewport"
    "status status";
  background: #0a0c11;
  min-height: 0;
}
#rulerCorner { grid-area: corner; background: var(--bg-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#rulerH { grid-area: rulerH; background: var(--bg-2); border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
#rulerV { grid-area: rulerV; background: var(--bg-2); border-right: 1px solid var(--line); position: relative; overflow: hidden; }
.ruler-tick { position: absolute; color: var(--txt-2); font-size: 9px; }
#rulerH .ruler-tick { top: 2px; border-left: 1px solid #38415440; height: 100%; padding-left: 3px; }
#rulerV .ruler-tick { left: 2px; border-top: 1px solid #38415440; width: 100%; }

#canvasViewport { grid-area: viewport; overflow: auto; position: relative; }
#canvasScroll { position: relative; width: 1100px; height: 700px; }

#stage {
  position: absolute;
  left: 60px; top: 60px;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  background: #000;
  box-shadow: 0 0 0 1px #000, 0 30px 80px rgba(0,0,0,.6);
  overflow: hidden;
}
#stageBg { position: absolute; inset: 0; }
#nodeRoot { position: absolute; inset: 0; }

#safeArea {
  position: absolute; pointer-events: none; z-index: 5;
  border: 2px dashed rgba(91,140,255,.5);
  display: none;
}
#safeArea.on { display: block; }
#safeArea::after {
  content: "safe area"; position: absolute; top: 2px; left: 6px;
  font-size: 13px; color: rgba(91,140,255,.8); letter-spacing: 1px;
}

#gridOverlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; display: none; }
#gridOverlay.on { display: block; }

#guideLayer { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
.guide { position: absolute; background: var(--focus); }
.guide.v { width: 1px; top: 0; bottom: 0; }
.guide.h { height: 1px; left: 0; right: 0; }
.guide-dim {
  position: absolute; background: var(--focus); color:#fff; font-size: 12px;
  padding: 1px 5px; border-radius: 4px; transform: translate(-50%,-50%); white-space: nowrap;
}

#selectionLayer { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
.sel-box { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.sel-handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; pointer-events: all; }
.sel-handle.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.sel-handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.sel-handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.sel-handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.sel-handle.n  { left: 50%; top: -7px; transform: translateX(-50%); cursor: ns-resize; }
.sel-handle.s  { left: 50%; bottom: -7px; transform: translateX(-50%); cursor: ns-resize; }
.sel-handle.w  { left: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.sel-handle.e  { right: -7px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.sel-tag {
  position: absolute; top: -22px; left: -2px; background: var(--accent); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 5px 5px 0 0; white-space: nowrap; font-weight: 700;
}
.hover-box { position: absolute; border: 1px dashed var(--accent-2); pointer-events: none; }
.drop-box { position: absolute; border: 2px solid #36e0a0; background: rgba(54,224,160,.14); box-shadow: 0 0 0 2px rgba(54,224,160,.3) inset; pointer-events: none; border-radius: 4px; }

#statusbar {
  grid-area: status; display: flex; align-items: center; padding: 0 12px;
  background: var(--bg-2); border-top: 1px solid var(--line); font-size: 11px; color: var(--txt-2);
}
.sb-spacer { flex: 1; }

/* ---------------- Palette ---------------- */
#palettePanel { padding: 10px; }
.pal-group-title { font-size: 10px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .8px; margin: 12px 2px 6px; font-weight: 700; }
.pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pal-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 6px; cursor: grab; transition: .12s; text-align: center;
}
.pal-item:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.pal-item .material-symbols-rounded { font-size: 24px; color: var(--accent); }
.pal-item span.lbl { font-size: 11px; color: var(--txt-1); font-weight: 600; }

/* ---------------- Layers tree ---------------- */
#layersPanel { padding: 8px; }
.layer-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.layer-row:hover { background: var(--bg-2); }
.layer-row.sel { background: rgba(91,140,255,.18); color: var(--accent); }
.layer-row .material-symbols-rounded { font-size: 16px; color: var(--txt-2); }
.layer-row.sel .material-symbols-rounded { color: var(--accent); }
.layer-row .ico-btn { margin-left: auto; opacity: .5; }
.layer-row .ico-btn:hover { opacity: 1; }

/* ---------------- Inspector ---------------- */
#inspectorPanel { padding: 0 0 30px; }
.insp-empty { padding: 30px 16px; color: var(--txt-2); text-align: center; font-size: 12px; }
.insp-section { border-bottom: 1px solid var(--line-soft); }
.insp-head {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-1); font-weight: 700;
}
.insp-head .material-symbols-rounded { font-size: 16px; color: var(--txt-2); }
.insp-head .chev { margin-left: auto; transition: .15s; }
.insp-section.collapsed .chev { transform: rotate(-90deg); }
.insp-section.collapsed .insp-content { display: none; }
.insp-content { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.field { display: flex; align-items: center; gap: 8px; }
.field > label { width: 78px; font-size: 11px; color: var(--txt-2); flex-shrink: 0; }
.field-col { flex-direction: column; align-items: stretch; gap: 5px; }
.field-col > label { width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; flex: 1; }

.inp {
  background: var(--bg-0); color: var(--txt-0); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font-size: 12px; width: 100%; outline: none;
}
.inp:focus { border-color: var(--accent); }
.inp-num { position: relative; }
.inp-num .unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--txt-2); pointer-events: none; }
.inp-num input { padding-right: 26px; }

select.inp { cursor: pointer; }
textarea.inp { resize: vertical; min-height: 50px; font-family: inherit; }

.color-field { display: flex; align-items: center; gap: 6px; flex: 1; }
.color-swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; flex-shrink: 0; }
.color-field input[type=text] { flex: 1; }

.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.swatch { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(255,255,255,.12); cursor: pointer; position: relative; }
.swatch.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch[title]:hover::after {
  content: attr(title); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; z-index: 5;
}

.seg { display: flex; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: 1; }
.seg button { flex: 1; background: transparent; border: none; color: var(--txt-2); padding: 6px; cursor: pointer; font-size: 11px; }
.seg button.on { background: var(--accent); color: #fff; }
.seg button .material-symbols-rounded { font-size: 16px; }

.switch { position: relative; width: 38px; height: 20px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--bg-3); border-radius: 20px; transition: .15s; border: 1px solid var(--line); }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--txt-2); border-radius: 50%; transition: .15s; }
.switch input:checked + .track { background: rgba(91,140,255,.3); border-color: var(--accent); }
.switch input:checked + .track + .thumb { left: 20px; background: var(--accent); }

input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--bg-3); border-radius: 4px; flex: 1; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.range-val { width: 38px; text-align: right; font-size: 11px; color: var(--txt-1); }

.btn-mini { background: var(--bg-3); border: 1px solid var(--line); color: var(--txt-1); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.btn-mini:hover { background: var(--bg-2); color: var(--txt-0); border-color: var(--accent); }
.btn-mini .material-symbols-rounded { font-size: 16px; }
.btn-danger:hover { border-color: var(--accent-err); color: var(--accent-err); }

/* ---------------- Timeline ---------------- */
#timelinePanel { padding: 10px 12px; }
.tl-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tl-track { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.tl-track .tl-name { width: 150px; font-size: 12px; color: var(--txt-1); display: flex; align-items: center; gap: 6px; }
.tl-lane { flex: 1; height: 26px; background: var(--bg-2); border-radius: 6px; position: relative; overflow: hidden; }
.tl-clip { position: absolute; top: 3px; bottom: 3px; background: linear-gradient(180deg,#5b8cff,#3a6de0); border-radius: 5px; display: flex; align-items: center; padding: 0 8px; font-size: 10px; color: #fff; min-width: 30px; box-shadow: var(--shadow-1); }
.tl-empty { color: var(--txt-2); font-size: 12px; padding: 16px; text-align: center; }
.tl-ruler { flex:1; height:16px; position: relative; }
.tl-ruler span { position: absolute; font-size: 9px; color: var(--txt-2); border-left: 1px solid var(--line); padding-left: 2px; height: 100%; }

/* ---------------- Linter ---------------- */
#linterPanel { padding: 8px 12px; }
.lint-item { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; margin-bottom: 6px; background: var(--bg-2); border-left: 3px solid var(--accent-warn); cursor: pointer; }
.lint-item:hover { background: var(--bg-3); }
.lint-item.err { border-left-color: var(--accent-err); }
.lint-item.info { border-left-color: var(--accent); }
.lint-item .material-symbols-rounded { font-size: 18px; color: var(--accent-warn); }
.lint-item.err .material-symbols-rounded { color: var(--accent-err); }
.lint-item.info .material-symbols-rounded { color: var(--accent); }
.lint-text { flex: 1; }
.lint-title { font-size: 12px; font-weight: 600; color: var(--txt-0); }
.lint-desc { font-size: 11px; color: var(--txt-2); margin-top: 2px; }
.lint-fix { font-size: 11px; color: var(--accent-2); margin-top: 4px; }
.lint-ok { padding: 24px; text-align: center; color: var(--accent-2); font-size: 13px; }
.lint-ok .material-symbols-rounded { font-size: 32px; display: block; margin-bottom: 8px; }
