/* Холст в духе Figma: тёмная оболочка, светлые кадры экранов. */
:root {
  --bg: #1E1E1E;
  --panel: #2C2C2C;
  --panel-2: #383838;
  --line: #444;
  --text: #FFFFFF;
  --text-2: #B3B3B3;
  --text-3: #8A8A8A;
  --blue: #0D99FF;
  --note: #9747FF;
  --note-deep: #7A2EE8;
  --side-w: 248px;
  --bar-h: 48px;
  color-scheme: dark;
}
/* Оболочка одинаково тёмная в любой теме системы, как у Figma. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #1E1E1E; } }
:root[data-theme="dark"] { --bg: #1E1E1E; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 400 13px/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; display: flex;
  overscroll-behavior: none; touch-action: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Левая панель ── */
.side {
  width: var(--side-w); flex: none; height: 100%; background: var(--panel);
  border-right: 1px solid #1A1A1A; display: flex; flex-direction: column; z-index: 20;
}
.side-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--panel-2); }
.file { font-weight: 600; font-size: 14px; }
.file-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.side-cap { padding: 14px 16px 6px; color: var(--text-3); font-size: 11px; font-weight: 600; }
.tree { flex: 1; overflow: auto; padding: 0 8px 12px; }
.tree-sec {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 30px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; color: var(--text); font-weight: 600; font-size: 12px;
  cursor: pointer; text-align: left; margin-top: 6px;
}
.tree-sec:hover { background: var(--panel-2); }
.tree-sec svg { color: var(--text-3); flex: none; }
.tree-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 8px 0 26px;
  border: 0; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; text-align: left;
}
.tree-item:hover { background: var(--panel-2); color: var(--text); }
.tree-item.on { background: rgba(13, 153, 255, .18); color: var(--text); }
.tree-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .cnt {
  flex: none; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
  background: rgba(151, 71, 255, .22); color: #D3B5FF; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.tree-item svg { flex: none; color: var(--text-3); }
.side-help { padding: 12px 16px 16px; border-top: 1px solid var(--panel-2); color: var(--text-3); font-size: 11.5px; display: grid; gap: 6px; }
kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px; background: var(--panel-2);
  color: var(--text-2); font: 500 11px/1.4 Inter, sans-serif;
}

/* ── Верхняя панель ── */
.stage { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; position: relative; }
.bar {
  height: var(--bar-h); flex: none; background: var(--panel); border-bottom: 1px solid #1A1A1A;
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; z-index: 15;
}
.crumb { flex: 1; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--text); font-weight: 500; }
.bar-right { display: flex; align-items: center; gap: 6px; }
.ic {
  width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.ic:hover { background: var(--panel-2); }
.ic[aria-pressed="true"] { background: var(--blue); }
.menu { display: none; }
.pill {
  height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
}
.pill:hover { background: var(--panel-2); }
.sw { width: 28px; height: 16px; border-radius: 8px; background: #555; position: relative; transition: background .15s; flex: none; }
.sw::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.notes-btn[aria-pressed="true"] .sw { background: var(--note); }
.notes-btn[aria-pressed="true"] .sw::after { transform: translateX(12px); }
.zoom { display: flex; align-items: center; }
.zoom-val {
  min-width: 52px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--text);
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.zoom-val:hover { background: var(--panel-2); }

/* ── Холст ── */
.canvas {
  flex: 1; position: relative; overflow: hidden; cursor: default;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(255, 255, 255, .07) 1px, transparent 1.4px);
}
.canvas.panning, .canvas.panning * { cursor: grabbing !important; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world.moving { will-change: transform; }

.sec-box {
  position: absolute; border-radius: 24px; background: rgba(255, 255, 255, .025);
  border: 2px solid rgba(255, 255, 255, .07);
}
.frame {
  position: absolute; background: #F3F1EE; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 12px 40px rgba(0, 0, 0, .35);
}
.frame iframe { display: block; border: 0; width: 100%; height: 100%; background: #F3F1EE; }
.frame.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 12px var(--blue), 0 12px 40px rgba(0, 0, 0, .35); } 100% { box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 12px 40px rgba(0, 0, 0, .35); } }

/* Пояснения к блокам — справа от кадра, в масштабе холста. */
.legend { position: absolute; width: 520px; }
.legend svg { position: absolute; left: -64px; top: 0; overflow: visible; pointer-events: none; }
.legend path { fill: none; stroke: rgba(151, 71, 255, .55); stroke-width: 2.5; }
.legend circle { fill: var(--note); }
.legend path.on { stroke: var(--note); stroke-width: 4; }
.note {
  position: absolute; left: 0; width: 100%; display: flex; gap: 18px; padding: 22px 26px 24px 22px;
  border-radius: 18px; background: #2C2C2C; border: 2px solid #3A3A3A; color: var(--text);
  transition: border-color .15s, background-color .15s; cursor: pointer;
}
.note:hover, .note.on { border-color: var(--note); background: #33294A; }
.note .n {
  flex: none; width: 44px; height: 44px; border-radius: 22px; background: var(--note); color: #fff;
  font: 700 22px/44px Inter, sans-serif; text-align: center;
}
.note .t { font: 700 27px/1.2 Inter, sans-serif; letter-spacing: -.01em; margin: 6px 0 8px; }
.note .d { font: 400 21px/1.45 Inter, sans-serif; color: #CFCFCF; margin: 0; }
body.notes-off .legend { display: none; }

/* Подписи кадров и секций — постоянного размера, как в Figma. */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.flabel {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 8px; height: 22px;
  white-space: nowrap; overflow: hidden; pointer-events: auto; color: var(--text-2); font-size: 12px;
}
.flabel .t { color: var(--text-2); cursor: pointer; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.flabel .t:hover, .flabel.on .t { color: var(--text); }
.flabel .sz { color: var(--text-3); flex: none; }
.flabel a { color: var(--blue); text-decoration: none; flex: none; }
.flabel a:hover { text-decoration: underline; }
.flabel.tiny .sz, .flabel.tiny a { display: none; }
.slabel {
  position: absolute; left: 0; top: 0; height: 28px; line-height: 28px; padding: 0 12px; border-radius: 8px;
  display: block; align-items: center; gap: 8px; background: #3A3A3A; color: var(--text);
  font-weight: 600; font-size: 13px; white-space: nowrap; pointer-events: auto; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis;
}

.shield { position: absolute; inset: 0; display: none; cursor: grab; z-index: 5; }
.hand .shield { display: block; }

.toast {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px));
  padding: 10px 16px; border-radius: 10px; background: rgba(44, 44, 44, .96); color: var(--text-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); font-size: 12.5px; text-align: center; z-index: 10;
  transition: opacity .4s; pointer-events: none;
}
.toast.gone { opacity: 0; }

/* ── Телефон: панель экранов выезжает по кнопке ── */
@media (max-width: 820px) {
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .4);
  }
  body.side-open .side { transform: none; }
  .menu { display: inline-flex; }
  .notes-btn .lbl { display: none; }
  #handBtn, .zoom .ic { display: none; }
  .crumb { font-size: 12px; }
  .bar { padding: 0 6px; gap: 4px; }
  .side-help { display: none; }
}
