/* hang — poster wall planner */

:root {
  --bg: #191b20;
  --panel: #1f222a;
  --panel2: #262a33;
  --line: #32363f;
  --ink: #e8e6e1;
  --dim: #9a988f;
  --accent: #d9a441;
  --accent-ink: #171307;
  --danger: #e06c5a;
  --wall: #f2eee4;
  --snap: #ff4fa3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.45 system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}
button {
  font: inherit;
  color: var(--ink);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: var(--dim); }
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.wide { flex: 1; }
input, select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 6px;
  min-width: 0;
}
input:focus, select:focus { outline: 1px solid var(--accent); }
input[type="range"] { accent-color: var(--accent); }
input.len { width: 62px; text-align: right; }
.hint { color: var(--dim); font-size: 12px; }
.row { display: flex; gap: 6px; align-items: center; }
.row.right { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid2 label, .row label { display: flex; gap: 5px; align-items: center; color: var(--dim); }

/* ---- top bar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.brand .sub { font-size: 11px; font-weight: 400; color: var(--dim); margin-left: 4px; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tgroup {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 2px;
  background: var(--bg);
  border-radius: 8px;
}
.tgroup button { border: none; background: transparent; padding: 4px 8px; }
.tgroup button:hover { background: var(--panel2); }
.tgroup button.on { background: var(--accent); color: var(--accent-ink); }
.tgroup select {
  background: transparent;
  border: none;
  color: var(--dim);
  padding: 3px 2px;
  font-size: 12px;
  cursor: pointer;
}
.tgroup select:hover { color: var(--ink); }
.tgroup select option { background: var(--panel); color: var(--ink); }
.gap-label { color: var(--dim); padding-left: 6px; }
.gap-label input { width: 48px; text-align: right; }

/* ---- layout ---- */
#app { display: flex; height: calc(100vh - 45px); }
#sidebar {
  width: 292px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 10px 12px 30px;
}
#sidebar section { margin-bottom: 18px; }
#sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--dim);
  margin: 0 0 8px;
}
#sidebar .row { margin-bottom: 6px; }
#sidebar .footer { border-top: 1px solid var(--line); padding-top: 12px; }

/* ---- poster cards ---- */
.pcard {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pthumb {
  width: 54px;
  height: 72px;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pthumb img { max-width: 100%; max-height: 100%; }
.pbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pbody .row { margin-bottom: 0; }
.pname { width: 100%; font-weight: 600; }
.psize input.len { width: 56px; }
.plock { padding: 3px 6px; opacity: 0.45; }
.plock.on { opacity: 1; background: var(--accent); border-color: var(--accent); }
.ppreset, .pframe { flex: 1; font-size: 12px; }
.phooks { font-size: 12px; }
.pcount { color: var(--dim); font-size: 11px; margin-left: auto; }
.padd { flex: 1; }
.pdel { color: var(--danger); }

/* ---- zones list ---- */
.zcard {
  padding: 8px;
  margin-bottom: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.zcard .grid2 input.len { width: 100%; }
.zlabel-in { flex: 1; }
.zdel { color: var(--danger); }

/* ---- viewport & wall ---- */
#viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  background:
    radial-gradient(ellipse at 50% 0%, #31343c 0%, var(--bg) 70%);
}
#wallwrap { margin: auto; padding: 55px; position: relative; }
#wall {
  position: relative;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0) 40%),
    var(--wall);
  box-shadow: 0 18px 50px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.12);
  touch-action: none;
}
#floor {
  height: 13px;
  background: linear-gradient(#6b503633, #4a37244d), linear-gradient(90deg, #7a5c3d, #5c452e);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  position: relative;
}
#floor span {
  position: absolute;
  right: 4px;
  top: -2px;
  font-size: 9px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.wall-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}
.eyeline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #b09a68;
  pointer-events: none;
  z-index: 1;
}
.eyeline span {
  position: absolute;
  right: 3px;
  top: 1px;
  font-size: 10px;
  color: #a08b5c;
  background: rgba(242,238,228,0.7);
  padding: 0 3px;
  border-radius: 3px;
}

/* ---- zones on wall ---- */
.zone {
  position: absolute;
  background: repeating-linear-gradient(45deg,
    rgba(90,90,90,0.13) 0 8px, rgba(90,90,90,0.05) 8px 16px);
  border: 1.5px dashed rgba(80,80,80,0.55);
  border-radius: 3px;
  cursor: move;
  z-index: 2;
  touch-action: none;
}
.zlabel {
  position: absolute;
  left: 5px;
  top: 3px;
  font-size: 11px;
  color: rgba(60,60,60,0.75);
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
}
.zone-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  background: var(--panel2);
  border: 1px solid var(--dim);
  border-radius: 3px;
  cursor: nwse-resize;
}

/* ---- posters on wall ---- */
.inst {
  position: absolute;
  cursor: move;
  z-index: 3;
  box-shadow: 2px 5px 12px rgba(30,25,15,0.35);
  overflow: hidden;
  touch-action: none;
  background: #ddd;
}
.inst img { display: block; object-fit: fill; transform-origin: top left; pointer-events: none; }
.inst .noimg { width: 100%; height: 100%; background: repeating-linear-gradient(45deg, #ccc 0 10px, #bbb 10px 20px); }
.inst.framed { border-style: solid; }
.inst.frame-black { border-color: #1c1a18; }
.inst.frame-white { border-color: #fbfaf6; }
.inst.frame-oak { border-color: #b08d57; border-image: linear-gradient(140deg, #c9a76b, #8d6c3f) 1; }
.inst.sel { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 4; }
.inst.overlap { outline: 2px solid #e0a51f; outline-offset: 1px; }
.inst.clash { outline: 2px solid var(--danger); outline-offset: 1px; }
.inst.oob { outline: 2px dashed var(--danger); outline-offset: 1px; }
.inst.sel.overlap, .inst.sel.clash, .inst.sel.oob { outline-width: 3px; }
.inst.locked { cursor: default; }
.inst .num {
  position: absolute;
  left: 2px;
  top: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: rgba(20,20,20,0.72);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  pointer-events: none;
}
.inst .lockicon {
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 10px;
  pointer-events: none;
  filter: drop-shadow(0 0 2px #fff);
}

/* ---- nails, guides, marquee ---- */
.nail {
  position: absolute;
  transform: translate(-50%, -52%);
  color: #b3402e;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 0 3px rgba(255,255,255,0.9);
  pointer-events: none;
  z-index: 6;
}
.guide-v, .guide-h { position: absolute; background: var(--snap); pointer-events: none; z-index: 7; }
.guide-v { top: 0; bottom: 0; width: 1px; }
.guide-h { left: 0; right: 0; height: 1px; }
#marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: rgba(217,164,65,0.12);
  pointer-events: none;
  z-index: 8;
}

/* ---- drag tooltip ---- */
#drag-tip {
  position: fixed;
  z-index: 50;
  background: rgba(20,22,26,0.92);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

/* ---- help popover ---- */
#help-pop {
  position: fixed;
  top: 50px;
  right: 12px;
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  max-width: 380px;
}
#help-pop h3 { margin: 0 0 8px; font-size: 13px; }
#help-pop td { padding: 2px 8px 2px 0; vertical-align: top; }
#help-pop td:first-child { color: var(--accent); white-space: nowrap; font-weight: 600; }

/* ---- hook modal ---- */
#hook-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(10,10,12,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h3 { margin: 0 0 6px; }
.hook-types { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0; }
.hook-types label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.hook-canvas-wrap { display: flex; justify-content: center; margin: 10px 0; }
.hook-canvas {
  position: relative;
  background: #e9e2d2;
  border: 1px solid #a99;
  box-shadow: inset 0 0 14px rgba(120,90,40,0.25);
  cursor: crosshair;
}
.hpt {
  position: absolute;
  transform: translate(-50%, -52%);
  color: #b3402e;
  font-weight: 700;
  font-size: 13px;
  pointer-events: none;
}
.hpt.draggable { pointer-events: auto; cursor: grab; padding: 4px; }
.hpt-list .row { margin-bottom: 4px; color: var(--dim); }
.hnum { width: 22px; }
.hdel { color: var(--danger); padding: 2px 6px; }
.wire-row input { width: 70px; }

/* ---- phone hand-off modal ---- */
#phone-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10,10,12,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.phone-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  width: min(420px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.phone-box h3 { margin: 0; }
.phone-box .spacer { flex: 1; }
.phone-qr { display: flex; justify-content: center; }
.phone-qr svg { border-radius: 8px; }
.phone-url { text-align: center; font-size: 12px; word-break: break-all; }
.phone-url a { color: var(--dim); }
#phone-feed {
  min-height: 40px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.phone-item { font-size: 13px; color: var(--ink); }

/* ---- corner-picker (cropper) modal ---- */
#crop-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgba(10,10,12,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}
.crop-card { width: auto; min-width: 380px; max-width: 94vw; }
.crop-stage {
  position: relative;
  margin: 12px auto;
  user-select: none;
  touch-action: none;
  background: #000;
  border-radius: 4px;
  overflow: visible;
}
.crop-stage img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 4px; }
.crop-stage svg { position: absolute; inset: 0; pointer-events: none; }
.cpt {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: grab;
  box-shadow: 0 1px 5px rgba(0,0,0,0.7);
}
.cpt span {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
.crop-fields { flex-wrap: wrap; margin-bottom: 8px; }
.crop-fields.err input { outline: 1px solid var(--danger); }

/* ---- poster upload wizard ---- */
#wizard {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.wiz-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.wiz-foot { border-top: 1px solid var(--line); border-bottom: none; }
.wiz-bar .spacer { flex: 1; }
.wiz-x { margin-left: auto; }
.wiz-foot .wiz-x { margin-left: 0; }
.wiz-body {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
}
.wiz-drop {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 56px 72px;
  text-align: center;
  margin: auto;
}
.wiz-drop p { margin: 8px 0; }
.wiz-drop.over { border-color: var(--accent); background: rgba(217,164,65,0.07); }
.wiz-thumbs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wiz-thumbs img {
  height: 70px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.wiz-stage { flex-shrink: 0; margin: 0; }
.wiz-stage .cpt { cursor: grab; }
.wiz-qchip {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(18,18,24,0.85);
  color: #fff;
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 12px;
  display: flex;
  gap: 7px;
  align-items: center;
}
.wiz-qdel { cursor: pointer; color: var(--danger); font-weight: 700; }
.wiz-review { align-items: stretch; max-width: 700px; width: 100%; margin: 0 auto; }
.wiz-row {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.wiz-thumb {
  width: 78px;
  height: 102px;
  object-fit: contain;
  background: #101014;
  border-radius: 6px;
  flex-shrink: 0;
}
.wiz-fields { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.wname { width: 100%; font-weight: 600; }
.wiz-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---- mounting guide overlay ---- */
#guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(24,24,26,0.85);
  overflow-y: auto;
}
.paper {
  background: #fff;
  color: #1d1d1f;
  max-width: 820px;
  margin: 26px auto;
  padding: 30px 38px 40px;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  font-size: 14px;
}
.paper header h1 { margin: 0; font-size: 26px; }
.paper header p { color: #666; margin: 4px 0 0; }
.guide-actions { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 6px; }
.guide-actions button { background: #f0f0f0; color: #222; border-color: #ccc; }
.guide-actions button.primary { background: var(--accent); border-color: var(--accent); }
.warnings {
  background: #fdf3e2;
  border: 1px solid #e8c987;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 14px 0;
}
.warnings ul { margin: 6px 0 0; padding-left: 20px; }
.diagram { margin: 18px 0; }
.diagram svg { width: 100%; height: auto; display: block; }
table.marks { width: 100%; border-collapse: collapse; margin: 10px 0 18px; }
table.marks th, table.marks td {
  border-bottom: 1px solid #ddd;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
table.marks th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #777; }
table.marks td.mark { font-weight: 700; color: #b3402e; white-space: nowrap; }
table.marks td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.marks .alt { color: #999; font-size: 12px; }
table.marks td.note { color: #666; font-size: 13px; }
.levels, .tips { margin-top: 18px; }
.levels h2, .tips h2 { font-size: 15px; margin: 0 0 6px; }
.tips ul, .levels ul { margin: 6px 0; padding-left: 20px; }
.tips li, .levels li { margin-bottom: 5px; }

/* ---- print: only the guide ---- */
@media print {
  body { overflow: visible; background: #fff; }
  body > *:not(#guide-overlay) { display: none !important; }
  #guide-overlay { position: static; background: #fff; overflow: visible; }
  .paper { box-shadow: none; margin: 0; max-width: none; border-radius: 0; padding: 0; }
  .no-print { display: none !important; }
}
