/* =============================================================================
   Tervnézet — a felület "hőse": szerkesztőrácsos rajzasztal, rajta a tervlap
   ========================================================================== */
.plan-layout { display: flex; height: 100%; overflow: hidden; }

/* ---------- Tervlista (bal oldali sáv) ---------- */
.plans-sidebar {
  width: 260px; background: var(--sheet);
  border-right: 1px solid var(--rule);
  overflow-y: auto; flex-shrink: 0;
}
.plans-sidebar h3 {
  padding: 12px 12px 12px 14px; font-family: var(--font-cond); font-size: 17px; font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--ink);
  border-bottom: 1px solid var(--rule); background: var(--sheet);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  position: sticky; top: 0; z-index: 2;
}
.plans-sidebar h3 .btn { min-height: 30px; padding: 3px 9px; font-size: 13px; }
.plan-card { padding: 10px 12px; border-bottom: 1px solid var(--rule); cursor: pointer; display: flex; gap: 10px; align-items: center; position: relative; }
.plan-card:hover { background: var(--sheet-3); }
.plan-card.active { background: var(--primary-tint); box-shadow: inset 3px 0 0 var(--primary); }
.plan-thumb { width: 52px; height: 38px; background: var(--sheet-3); border: 1px solid var(--rule); border-radius: var(--r-xs); flex-shrink: 0; background-size: cover; background-position: center; }
.plan-card .plan-title { font-size: 14px; font-weight: 500; word-break: break-word; }
.plan-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.plan-del { opacity: 0; background: none; border: none; color: var(--ink-3); font-size: 16px; padding: 2px 6px; border-radius: var(--r-xs); flex-shrink: 0; transition: opacity .15s; }
.plan-card:hover .plan-del { opacity: 1; }
.plan-del:hover { background: var(--danger-tint); color: var(--danger); }
/* Mappák és tervkártyák (570-plan-multiselect.js) */
#plansList { padding: 8px 8px 16px; }
.plans-empty { padding: 22px 12px; color: var(--ink-3); font-size: 14px; text-align: center; }
.plans-folder { margin-bottom: 10px; border-radius: var(--r-md); transition: background var(--transition); }
.plans-folder.is-drop { background: var(--primary-tint-2); box-shadow: inset 0 0 0 2px var(--primary); }
.plans-folder-head { display: flex; align-items: center; gap: 2px; }
.plans-folder-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  background: none; border: none; border-radius: var(--r-sm); padding: 6px; text-align: left;
  font-family: var(--font-cond); font-size: 15px; font-weight: 600; color: var(--ink);
}
.plans-folder-toggle:hover { background: var(--sheet-3); }
.pf-chevron { width: 14px; height: 14px; flex: 0 0 auto; background: currentColor; opacity: .55; -webkit-mask: var(--i-chevron) center / contain no-repeat; mask: var(--i-chevron) center / contain no-repeat; transition: transform .15s; }
.plans-folder.is-collapsed .pf-chevron { transform: rotate(-90deg); }
.pf-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-count { color: var(--ink-3); font-weight: 500; }
.plans-folder-actions, .ptc-actions { display: flex; gap: 0; opacity: 0; transition: opacity var(--transition); }
.plans-folder-head:hover .plans-folder-actions, .plans-folder-head:focus-within .plans-folder-actions,
.plan-thumb-card:hover .ptc-actions, .plan-thumb-card:focus-within .ptc-actions { opacity: 1; }
@media (hover: none) { .plans-folder-actions, .ptc-actions { opacity: 1; } }
.plans-folder-actions .btn, .ptc-actions .btn { background: transparent; border-color: transparent; color: var(--ink-3); }
.plans-folder-actions .btn:hover, .ptc-actions .btn:hover { background: var(--sheet-3); border-color: transparent; color: var(--ink); }
.plans-folder-actions .btn.danger:hover, .ptc-actions .btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.plans-folder-empty { padding: 6px 10px 12px 26px; color: var(--ink-3); font-size: 13px; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px 2px 2px; }
.plan-thumb-card {
  position: relative; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md);
  cursor: pointer; overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition);
}
.plan-thumb-card:hover { border-color: var(--ink-3); }
.plan-thumb-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan-thumb-card.is-selected { border-color: var(--primary); background: var(--primary-tint-2); }
.ptc-img { position: relative; aspect-ratio: 1.4; background: var(--sheet-2) center / cover no-repeat; border-bottom: 1px solid var(--rule); }
.ptc-ph { position: absolute; inset: 0; margin: auto; width: 30px; height: 30px; background: var(--rule-2); -webkit-mask: var(--i-plan) center / contain no-repeat; mask: var(--i-plan) center / contain no-repeat; }
.ptc-pins {
  position: absolute; top: 5px; right: 5px; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--ink); color: #fff; font-family: var(--font-cond); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.ptc-name {
  padding: 6px 8px 0; font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
  min-height: calc(2.6em + 6px);
}
.ptc-actions { justify-content: flex-end; padding: 0 2px 2px; }
.ptc-actions .btn.icon-only { width: 30px; min-width: 30px; min-height: 28px; }
.ptc-check { position: absolute; top: 6px; left: 6px; z-index: 2; width: 22px; height: 22px; border-radius: var(--r-xs); background: var(--sheet); border: 2px solid var(--rule-2); }
.ptc-check.on { background: var(--primary); border-color: var(--primary); }
.ptc-check.on::after { content: ''; position: absolute; inset: 1px; background: #fff; -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.plan-drag-handle {
  position: absolute; top: 5px; left: 5px; width: 32px; height: 32px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .94); border: 1px solid var(--rule-2); touch-action: none; cursor: grab;
}
.plan-drag-handle::before {
  content: ''; position: absolute; inset: 7px 9px; background-image: radial-gradient(circle, var(--ink-2) 1.5px, transparent 1.9px);
  background-size: 7px 6px; background-position: center;
}

/* ---------- Rajzterület ---------- */
.canvas-area { flex: 1; background: var(--paper); position: relative; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }

/* Műszersáv-eszköztár */
.canvas-toolbar {
  background: var(--sheet); padding: 6px 10px;
  border-bottom: 1px solid var(--rule);
  display: flex; gap: 2px; align-items: center; flex-wrap: wrap;
  position: relative; z-index: 20;
}
.canvas-toolbar .btn {
  min-height: 38px; min-width: 38px; padding: 0 9px;
  background: transparent; color: var(--ink-2);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 15px;
}
.canvas-toolbar .btn:hover { background: var(--sheet-3); color: var(--ink); border-color: transparent; }
.canvas-toolbar .btn.active { background: var(--primary-tint); color: var(--primary-ink); border-color: transparent; box-shadow: inset 0 -2px 0 var(--primary); }
/* Pin-gomb: az egyetlen kiemelt művelet */
.canvas-toolbar .btn[data-tool="pin"] { background: var(--primary); color: #fff; padding: 0 13px 0 10px; font-weight: 600; margin-right: 4px; }
.canvas-toolbar .btn[data-tool="pin"]:hover { background: var(--primary-hover); color: #fff; }
.canvas-toolbar .btn[data-tool="pin"].active { box-shadow: inset 0 -3px 0 var(--signal); color: #fff; background: var(--primary-press); }
.canvas-toolbar .btn[data-tool="pin"]::before { content: ''; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--i-pin) center / contain no-repeat; mask: var(--i-pin) center / contain no-repeat; }
/* Eszközök: emoji/karakter helyett vonalikon */
.canvas-toolbar .btn[data-tool]:not([data-tool="pin"]), .canvas-toolbar .btn[data-action="calibrate"], #btnUndo, #btnRedo {
  font-size: 0 !important; width: 38px; padding: 0 !important;
}
.canvas-toolbar .btn[data-tool]:not([data-tool="pin"])::before, .canvas-toolbar .btn[data-action="calibrate"]::before, #btnUndo::before, #btnRedo::before {
  content: ''; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--ti, var(--i-layers)) center / contain no-repeat; mask: var(--ti, var(--i-layers)) center / contain no-repeat;
}
.canvas-toolbar [data-tool="cursor"] { --ti: var(--i-hand); }
.canvas-toolbar [data-tool="pencil"] { --ti: var(--i-pencil); }
.canvas-toolbar [data-tool="line"] { --ti: var(--i-line); }
.canvas-toolbar [data-tool="arrow"] { --ti: var(--i-arrow); }
.canvas-toolbar [data-tool="polyline"] { --ti: var(--i-polyline); }
.canvas-toolbar [data-tool="rect"] { --ti: var(--i-rect); }
.canvas-toolbar [data-tool="rect-filled"] { --ti: var(--i-rectfill); }
.canvas-toolbar [data-tool="ellipse"] { --ti: var(--i-ellipse); }
.canvas-toolbar [data-tool="ellipse-filled"] { --ti: var(--i-ellipsefill); }
.canvas-toolbar [data-tool="triangle"] { --ti: var(--i-triangle); }
.canvas-toolbar [data-tool="text"] { --ti: var(--i-text); }
.canvas-toolbar [data-tool="erase"] { --ti: var(--i-eraser); }
.canvas-toolbar [data-tool="measure"] { --ti: var(--i-ruler); }
.canvas-toolbar [data-action="calibrate"] { --ti: var(--i-scale); }
#btnUndo { --ti: var(--i-undo); }
#btnRedo { --ti: var(--i-redo); }
.toolbar-divider { width: 1px; height: 24px; background: var(--rule); margin: 0 6px; }
.canvas-toolbar input[type=number], .canvas-toolbar select { min-height: 32px; height: 32px !important; font-size: 13px !important; border-color: var(--rule-2); }
#zoomLabel { font-family: var(--font-cond); font-weight: 600; font-size: 14px !important; color: var(--ink-2); }

/* Súgó → CAD-szerű állapotsor a rajzterület alján (korábban az eszköztárban volt, és rácsúszott a szem-gombra) */
.plan-statusbar {
  flex: 0 0 auto; height: 30px; display: flex; align-items: center;
  padding: 0 14px 0 64px; background: var(--sheet); border-top: 1px solid var(--rule);
  font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden;
}
.plan-statusbar .sb-hint { display: flex; gap: 20px; min-width: 0; overflow: hidden; }
.plan-statusbar .sb-hint > span { flex: 0 0 auto; }
.plan-statusbar kbd { font-size: 11px; padding: 0 4px; }

/* Csoportos eszközök (lenyíló) */
.tool-group { position: relative; display: inline-flex; }
.tool-group .group-btn { position: relative; }
.tool-group .group-btn::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 0; height: 0; border-left: 4px solid transparent; border-top: 4px solid currentColor; transform: rotate(-45deg); opacity: .6; }
.tool-flyout {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 4px;
  display: none; flex-direction: row; gap: 2px; z-index: 200; white-space: nowrap;
  box-shadow: var(--sh-float);
}
.tool-group.open .tool-flyout { display: flex; }
.tool-group.open .group-btn { background: var(--primary-tint); color: var(--primary-ink); }
.tool-flyout .btn { min-width: 38px; }
.tool-group::after { content: ''; position: absolute; top: 100%; left: 0; right: 0; height: 6px; }

/* Színválasztó */
.color-group { position: relative; margin: 0 4px; }
.color-main-btn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--rule-2); cursor: pointer; padding: 0; }
.color-main-btn:hover { box-shadow: 0 0 0 1px var(--ink-3); }
.color-popup {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 10px;
  display: none; flex-wrap: wrap; gap: 8px; width: 204px; z-index: 200; box-shadow: var(--sh-float);
}
.color-group.open .color-popup { display: flex; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--rule-2); cursor: pointer; transition: transform .1s; }
.swatch:hover { transform: scale(1.12); }
.swatch.active, .color-popup .swatch.active { box-shadow: 0 0 0 2px var(--ink); transform: none; }
.ann-color-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--rule-2); cursor: pointer; }
.ann-color-dot:hover { transform: scale(1.12); }
.ann-color-dot.active { box-shadow: 0 0 0 2px var(--ink); }
.color-picker { display: flex; gap: 4px; align-items: center; padding: 0 6px; background: var(--sheet-2); border: 1px solid var(--rule); border-radius: var(--r-sm); height: 30px; }
.stroke-width-input { width: 50px; padding: 4px 6px; font-size: 12px; height: 28px; }

/* Rajzasztal: cianotípia-szerkesztőrács (5 mm / 25 mm osztás) */
.canvas-viewport {
  flex: 1; overflow: auto; position: relative;
  background-color: #f1f4f3;
  background-image:
    linear-gradient(rgba(27, 94, 142, .11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 94, 142, .11) 1px, transparent 1px),
    linear-gradient(rgba(27, 94, 142, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 94, 142, .05) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px;
}
/* A tervlap a rajzasztalon */
.plan-stage { position: relative; margin: 32px auto; background: #fff; box-shadow: 0 0 0 1px rgba(28, 36, 33, .14), 0 6px 22px rgba(28, 36, 33, .12); user-select: none; }
.plan-stage img, .plan-stage canvas { display: block; pointer-events: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.annotation-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.annotation-layer.erasing { pointer-events: auto; cursor: not-allowed; }
.annotation-layer .ann { pointer-events: stroke; }
.annotation-layer .ann-text { pointer-events: all; }
.plan-stage.drawing { cursor: crosshair; }
.plan-stage.erasing { cursor: not-allowed; }
.plan-stage.text-tool { cursor: text; }

/* Pin-szűrő (szem) gomb — a rajz bal alsó sarkában, az állapotsor fölött; a lista felfelé nyílik */
#pinFilterFab { position: absolute; left: 12px; bottom: 42px; z-index: 30; }
#pinFilterFabBtn {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--sheet); border: 1px solid var(--rule-2); color: var(--ink-2);
  box-shadow: var(--sh-float); font-size: 0 !important; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#pinFilterFabBtn::before { content: ''; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--i-eye) center / contain no-repeat; mask: var(--i-eye) center / contain no-repeat; }
#pinFilterFabBtn:hover { color: var(--ink); border-color: var(--ink-3); }
#pinFilterDropdown {
  position: absolute; left: 0; bottom: 48px; width: 270px; max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--sh-pop);
}
#pinFilterDropdown label { text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
#pinFilterDropdown label:hover { background: var(--sheet-3); }
#pinFilterDropdown button:hover { background: var(--sheet-3) !important; }

/* ---------- Pinek: jelzőlámpa-színek, kontúrral, hogy zsúfolt rajzon is kiváljanak ---------- */
.pin {
  position: absolute; transform: translate(-50%, -100%);
  width: 32px; height: 40px; cursor: pointer;
  pointer-events: auto; z-index: 5;
  filter: drop-shadow(0 1px 1.5px rgba(28, 36, 33, .35));
  transition: filter .15s;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.pin:hover { z-index: 10; filter: drop-shadow(0 2px 4px rgba(28, 36, 33, .45)); }
.pin.selected { z-index: 20; filter: drop-shadow(0 0 0 var(--primary)) drop-shadow(0 0 2px var(--primary)) drop-shadow(0 0 7px rgba(27, 94, 142, .55)); }
.pin svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pin svg path { stroke: rgba(28, 36, 33, .55); stroke-width: 1.1px; }
.pin .pin-num { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-family: var(--font-cond); font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; letter-spacing: -.01em; pointer-events: none; }
/* Szinkronra váró (offline) pin: kis sárga szinkron-jelvény */
.pin.pending::after {
  content: ''; position: absolute; top: -4px; right: -5px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--signal); border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(28, 36, 33, .35);
}
@media (max-width: 900px) {
  .pin::before { content: ''; position: absolute; inset: -16px -14px -10px -14px; background: transparent; pointer-events: auto; }
}

/* ---------- Pin részletek panel ---------- */
.detail-panel {
  position: absolute; top: 0; right: -440px; bottom: 0; width: 440px;
  background: var(--sheet); border-left: 1px solid var(--rule);
  box-shadow: -10px 0 30px rgba(28, 36, 33, .10);
  transition: right .25s cubic-bezier(.16, 1, .3, 1);
  display: flex; flex-direction: column; z-index: 50;
}
.detail-panel.open { right: 0; }
.detail-head { padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--sheet); }
.detail-head h3 { font-size: 19px; display: flex; gap: 10px; align-items: center; min-width: 0; }
.detail-head .close-btn { background: none; border: 1px solid transparent; font-size: 24px; line-height: 1; color: var(--ink-3); width: 36px; height: 36px; border-radius: var(--r-sm); }
.detail-head .close-btn:hover { background: var(--sheet-3); color: var(--ink); }
.detail-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.detail-body label { margin-top: 2px; }
.detail-foot { padding: 12px 16px; border-top: 1px solid var(--rule); display: flex; gap: 8px; background: var(--sheet-2); }
.detail-foot .btn { flex: 1; justify-content: center; min-height: 42px; }
.pin-num-badge {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-cond); font-size: 14px; font-weight: 700; color: var(--ink);
  background: #fff; box-shadow: inset 0 0 0 4px var(--lamp, var(--primary)), 0 0 0 1px rgba(28, 36, 33, .25);
}
.attach-thumb { border-radius: var(--r-sm) !important; border-color: var(--rule) !important; }
