:root {
  --bg: #f6f7f9;
  --card: #fff;
  --line: #e5e7eb;
  --fg: #1d2330;
  --muted: #6b7280;
  --accent: #2563eb;
  --warn: #b45309;
  --danger: #b91c1c;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); }
a { color: inherit; text-decoration: none; }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 16px; margin: 24px 0 10px; }

button { font: inherit; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
/* every text box in the page's font: the browser's default for a textarea is 13px monospace,
   where a space is as wide as a letter and Korean text reads as if double-spaced */
textarea, input, select { font: inherit; }
textarea { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; box-sizing: border-box; }
button:hover { border-color: #cbd2dc; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:disabled { opacity: .6; cursor: default; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn); }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

.app-header { display: flex; align-items: center; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.app-header .brand { font-weight: 700; font-size: 18px; }
.app-main { max-width: 960px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 4px; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); }
.error-bar { display: flex; gap: 12px; justify-content: space-between; padding: 10px 20px; background: #fef2f2; color: var(--danger); border-bottom: 1px solid #fecaca; }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 20px; text-align: center; }
.login h1 { margin-bottom: 4px; }
.user-list { list-style: none; padding: 0; display: grid; gap: 8px; margin-top: 20px; }
.user-list button { width: 100%; display: flex; justify-content: space-between; padding: 14px 16px; border-radius: 12px; }
.user-list button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.login-form { display: grid; gap: 10px; margin-top: 16px; text-align: left; }
.login-form .warn { margin: 0; font-size: 13px; }

/* sites */
.site-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.site-card { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.site-card:hover { border-color: #cbd2dc; }
.site-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.distance { font-weight: 600; color: var(--accent); }

/* forms */
.site-form, .upload-form { padding: 16px; margin: 14px 0; display: grid; gap: 10px; }
.upload-form h3 { margin: 0; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { color: var(--fg); font-size: 15px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > .field { flex: 1; }
.actions { display: flex; gap: 8px; }

/* floorplans */
.floorplan-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.floorplan-card { overflow: hidden; }
.floorplan-thumb { aspect-ratio: 3 / 2; background: #fff; border-bottom: 1px solid var(--line); }
.floorplan-thumb img { width: 100%; height: 100%; object-fit: contain; }
.floorplan-info { padding: 10px 12px; display: grid; gap: 3px; }

@media (max-width: 600px) {
  .app-main { padding: 14px; }
  .row { flex-wrap: wrap; }
}
.field.narrow { flex: 0 0 140px; }
p.warn { margin: 0; }

/* floorplan → sessions */
.floorplan-card { cursor: pointer; }
.floorplan-card:hover { border-color: #cbd2dc; }
.session-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.session-card { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.session-card:hover { border-color: #cbd2dc; }
.session-meta { display: flex; gap: 12px; align-items: center; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; }
.badge.manual { background: #fff7ed; color: #c2410c; }

/* session viewer */
.viewer { height: calc(100vh - 49px); display: flex; flex-direction: column; }
.viewer-head { display: flex; align-items: baseline; gap: 14px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.viewer-head .back { margin: 0; }
.viewer-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.plan-pane { min-height: 0; background: #fff; border-right: 1px solid var(--line); }
.plan-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.plan-svg .path { fill: none; stroke: #2563eb; stroke-opacity: .55; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.plan-svg .dir { fill: none; stroke: #1d4ed8; stroke-width: 2; vector-effect: non-scaling-stroke; }
.plan-svg .pt-auto { fill: #2563eb; fill-opacity: .55; stroke: transparent; stroke-width: 10; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-svg .pt-auto:hover { fill-opacity: 1; }
.plan-svg .pt-manual { fill: #f97316; stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-svg .cone { fill: #ef4444; fill-opacity: .25; stroke: #ef4444; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.plan-svg .pt-current { fill: #ef4444; stroke: #fff; stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.photo-pane { min-height: 0; display: flex; flex-direction: column; background: #111; }
.photo-frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.photo-frame img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-frame img { cursor: zoom-in; }
.photo-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; }
.photo-info { flex: 1; display: flex; gap: 10px; align-items: center; justify-content: center; white-space: nowrap; min-width: 0; }
.photo-pane .hint { margin: 0; padding: 0 12px 8px; background: #fff; }

@media (max-width: 800px) {
  .viewer-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .plan-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .viewer-head .muted { display: none; }
  .photo-info .muted, .photo-pane .hint { display: none; }   /* no keyboard on phones */
  .photo-bar { padding: 6px 8px; gap: 6px; }
}

/* playback (Phase 4) */
.plan-svg .path { stroke-opacity: .28; }
.plan-svg .path-done { fill: none; stroke: #1d4ed8; stroke-opacity: .9; stroke-width: 4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.timeline { display: flex; align-items: center; gap: 10px; padding: 10px 12px 4px; background: #fff; }
.timeline .track { position: relative; flex: 1; height: 18px; cursor: pointer; touch-action: none; }
.timeline .track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 4px; border-radius: 2px; background: #e5e7eb; }
.timeline .played { position: absolute; left: 0; top: 7px; height: 4px; border-radius: 2px; background: #2563eb; }
.timeline .tick { position: absolute; top: 3px; width: 3px; height: 12px; margin-left: -1.5px; border-radius: 1px; background: #f97316; }
.timeline .thumb { position: absolute; top: 2px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; border: 2px solid #2563eb; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.playback { display: flex; align-items: center; gap: 8px; padding: 0 12px 8px; background: #fff; }
.playback .play { width: 52px; font-weight: 700; }
.playback .speeds { display: flex; gap: 4px; margin-left: auto; }
.playback button.on { background: #eef2ff; border-color: #2563eb; color: #1d4ed8; }

/* comments (Phase 5) */
.plan-svg .pt-commented { fill: none; stroke: #7c3aed; stroke-width: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.comments-panel { background: #fff; border-top: 1px solid var(--line); padding: 8px 12px; max-height: 38vh; overflow: auto; display: grid; gap: 8px; }
.comments-panel .tabs { display: flex; gap: 6px; }
.comments-panel .tabs button.on, .playback button.on { background: #eef2ff; border-color: #2563eb; color: #1d4ed8; }
.comments-panel p { margin: 0; }
.comment-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.comment { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.comment-head { display: flex; gap: 8px; align-items: baseline; }
.comment-actions { margin-left: auto; display: flex; gap: 8px; font-size: 13px; }
.comment-body { margin: 4px 0 0; white-space: pre-wrap; }
.comment-context { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.comment-context img { height: 44px; border-radius: 4px; cursor: pointer; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea, .comment-edit textarea { flex: 1; width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }

/* integrated map (Phase 6) */
a.button { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-svg .place { cursor: pointer; }
.plan-svg .place circle { fill: #2563eb; fill-opacity: .85; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.plan-svg .place.manual circle { fill: #f97316; }
.plan-svg .place.selected circle { stroke: #111; stroke-width: 3; }
.plan-svg .place.commented circle { fill: #7c3aed; }   /* a memo here: before anything else */
.filters { display: grid; gap: 4px; }
.check.off { color: var(--muted); }
.plan-svg .place text { fill: #fff; font-weight: 700; text-anchor: middle; pointer-events: none; }
.plan-svg .place-area { fill: #111; fill-opacity: .06; stroke: #111; stroke-opacity: .5; stroke-dasharray: 4 3; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan-svg .member-cone { fill-opacity: .18; stroke-opacity: .7; stroke-width: 1; vector-effect: non-scaling-stroke; }
.plan-svg .member { stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.place-panel { overflow: auto; padding: 12px 16px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.place-panel h4 { margin: 6px 0 0; font-size: 14px; }
.place-panel p { margin: 0; }
.place-head { display: flex; align-items: baseline; gap: 10px; }
.settings { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px; }
.check { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.check input { width: auto; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; font-size: 13px; }
.legend li, .session-label, .modal-info { display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.session-photos { display: grid; gap: 4px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.thumb { position: relative; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; width: 120px; height: 90px; background: #eee; }
.thumb.manual { border-color: #f97316; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dir { position: absolute; left: 4px; bottom: 3px; color: #fff; font-weight: 700; text-shadow: 0 0 3px #000; }
.thumb .has-comment { position: absolute; right: 5px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #7c3aed; border: 2px solid #fff; }
.comment-from { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; cursor: pointer; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-body { background: #fff; border-radius: 12px; padding: 12px; width: min(1100px, 94vw); max-height: 94vh; overflow: auto; display: grid; gap: 10px; }
.modal-body img { width: 100%; max-height: 70vh; object-fit: contain; background: #111; border-radius: 8px; }

/* bookmarks (Phase 7) */
.plan-svg .star { fill: #eab308; stroke: #713f12; stroke-width: 1; vector-effect: non-scaling-stroke; text-anchor: middle; cursor: pointer; }
.bookmark-off { align-self: flex-start; }
.bookmark-on { display: flex; gap: 8px; align-items: baseline; }
.bookmark-on a { color: #a16207; font-weight: 700; }
.bookmark-form { display: flex; gap: 6px; align-items: center; }
.bookmark-form input { flex: 1; min-width: 200px; }
.bookmark-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.dir-filter { display: flex; gap: 4px; flex-wrap: wrap; }
.dir-filter button { min-width: 40px; }
.dir-filter button.on { background: #eef2ff; border-color: #2563eb; color: #1d4ed8; }
.same-view { display: flex; gap: 10px; flex-wrap: wrap; }
.same-view-item { display: grid; gap: 4px; }
.same-view-item .thumb { width: 200px; height: 150px; }

/* plan tiles / preview */
.plan-svg .plan-tile { pointer-events: none; }
.plan-preview { height: 420px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; margin: 12px 0; }

.floorplan-foot { display: flex; justify-content: space-between; align-items: center; }
button.link.danger { color: var(--danger); }

.plan-svg.picking { cursor: crosshair; }
.radius { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.radius input[type=range] { width: 100%; padding: 0; }
.radius-row { display: flex; gap: 8px; align-items: flex-end; }
.radius-row .radius { flex: 1; }

/* resizable split (planwalk.layout) */
.splitter { background: var(--line); position: relative; touch-action: none; z-index: 2; }
.splitter.columns { cursor: col-resize; }
.splitter.rows { cursor: row-resize; }
.splitter::after { content: ""; position: absolute; border-radius: 2px; background: #9ca3af; }
.splitter.columns::after { width: 2px; height: 36px; left: 3px; top: calc(50% - 18px); }
.splitter.rows::after { height: 2px; width: 36px; top: 3px; left: calc(50% - 18px); }
.splitter:hover, .splitter:focus-visible { background: #c7d2fe; outline: none; }
.split .plan-pane { border: 0; }

.playback button { white-space: nowrap; }
@media (max-width: 800px) {
  .playback { gap: 4px; padding: 0 8px 8px; }
  .playback button { padding: 6px 8px; }
  .playback .speeds { gap: 2px; }
}

/* a photo tile of the integrated map: the thumb and, under it, where it was taken and what it faces */
.tile { display: grid; gap: 3px; width: 160px; align-content: start; }
.place-panel .thumb { width: 160px; height: 120px; }
.place-panel .tile, .place-panel .stack { width: 160px; }
.tile .cap, .stack .cap { display: block; width: 160px; font-size: 13px; line-height: 1.3; color: #1e3a8a; text-align: left; white-space: normal; }
.stack .cap { margin-top: 10px; }   /* clear the stacked-card shadow (8px down) */
/* same-view stacks (planwalk.photo-stacks) */
.stack { position: relative; padding: 0; border: 0; background: none; cursor: pointer; margin: 0 6px 6px 0; display: inline-grid; gap: 2px; width: 120px; font: inherit; }
.stack .thumb { display: block; box-shadow: 4px 4px 0 -1px #fff, 4px 4px 0 0 #cbd5e1, 8px 8px 0 -1px #fff, 8px 8px 0 0 #cbd5e1; }
.stack-count { position: absolute; right: 6px; top: 5px; padding: 1px 6px; border-radius: 999px; background: rgba(17,24,39,.75); color: #fff; font-size: 12px; font-weight: 700; }
.stack-open { display: grid; gap: 4px; padding: 6px; border: 1px dashed #cbd5e1; border-radius: 8px; }
.stack-one { display: contents; }

/* integrated map: cones are drawing only; a way back to the whole plan */
.plan-svg .member-cone { pointer-events: none; }
.plan-svg .place-area { pointer-events: none; }
.plan-svg circle.member { cursor: pointer; }
.plan-pane { position: relative; }
.map-overview { position: absolute; left: 10px; top: 10px; z-index: 3; background: rgba(255,255,255,.94); box-shadow: 0 1px 4px rgba(0,0,0,.15); }

/* integrated map: photo dots, hover tooltip, plan ⇄ list highlight */
.plan-svg g.member { cursor: pointer; }
.plan-svg .member-hit { fill: transparent; stroke: none; }
.plan-svg .member-dot { stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.plan-svg g.member.manual .member-dot { stroke: #f97316; stroke-width: 2.5; }
.plan-svg g.member.hl .member-dot { stroke: #111; stroke-width: 3; }
.plan-svg .member-cone.hl { fill-opacity: .5; stroke-opacity: 1; stroke-width: 2.5; }
.dot-tooltip { position: fixed; z-index: 20; pointer-events: none; display: flex; gap: 6px; align-items: center; padding: 5px 9px; border-radius: 8px; background: rgba(17,24,39,.92); color: #fff; font-size: 12px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.dot-tooltip .dot { border: 1px solid #fff; }
.thumb.hl, .stack.hl .thumb { outline: 3px solid #2563eb; outline-offset: 1px; }

/* comment roundup (comment-feed) */
.feed { display: grid; gap: 8px; }
.feed-item { display: flex; gap: 8px; align-items: flex-start; }
.feed-item .comment-list { flex: 1; }
.feed-source { flex: none; width: 72px; padding: 0; border: 0; background: none; cursor: pointer; }
.feed-source img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; display: block; }
.modal-body h4 { margin: 4px 0 0; }



/* --- floorplan analysis: regions, structure mask (PLAN A) --- */
.analysis-bar { display: grid; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; font-size: 14px; margin-top: 12px; }
.analysis-bar .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.analysis-bar .actions { padding-top: 8px; border-top: 1px solid var(--line); gap: 10px; }
.analysis-bar button.small { font-size: 13px; padding: 3px 10px; }
/* the floorplan page is the plan's workspace: the plan as tall as the window allows,
   beside it (when there is something) the picked region, the pin card, the record, the list */
.floorplan-page .workspace { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; margin-top: 12px; }
.floorplan-page .workspace.with-side { grid-template-columns: 1fr 320px; }
.floorplan-page .workspace .plan-preview { height: calc(100vh - 270px); min-height: 480px; margin: 0; }
/* the side column is as tall as the plan, never taller: the list scrolls inside it, the page does not grow */
.floorplan-page .side { height: calc(100vh - 270px); min-height: 480px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.floorplan-page .side .selected-region, .floorplan-page .side .pin-draft-form, .floorplan-page .side .region-history { margin: 0; }
.floorplan-page .side .region-list { max-height: none; }
.floorplan-page .side .pin-draft-form .field.narrow { min-width: 120px; }
.floorplan-page .head-actions { align-items: center; }
@media (max-width: 800px) {
  .floorplan-page .workspace.with-side { grid-template-columns: 1fr; }
  .floorplan-page .workspace .plan-preview { height: 60vh; min-height: 360px; }
  .floorplan-page .side { position: static; max-height: none; }
  .floorplan-page .side .region-list { max-height: 320px; }
}
.analysis-bar .spacer { flex: 1; }
.analysis-bar .sep { width: 1px; height: 18px; background: var(--line); }
.analysis-bar .status { font-weight: 600; }
.analysis-bar .toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.analysis-bar .toggle input { width: auto; margin: 0; }
.legend-wall, .legend-door, .legend-window { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 4px; }
.legend-wall { background: #d99a00; } .legend-door { background: #dc2846; } .legend-window { background: #2a8cdc; }
.spinner { width: 14px; height: 14px; border: 2px solid #c7d2fe; border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.plan-svg .regions { pointer-events: none; }
.plan-svg .structure-mask { opacity: 0.85; }
/* six blues: regions that touch never share one (regions/colouring) */
.plan-svg .region path { stroke: rgba(30, 64, 175, 0.55); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.plan-svg .region.c0 path, .swatch.c0 { fill: rgba(59, 130, 246, 0.22); background: rgba(59, 130, 246, 0.35); }
.plan-svg .region.c1 path, .swatch.c1 { fill: rgba(6, 182, 212, 0.22); background: rgba(6, 182, 212, 0.35); }
.plan-svg .region.c2 path, .swatch.c2 { fill: rgba(99, 102, 241, 0.24); background: rgba(99, 102, 241, 0.35); }
.plan-svg .region.c3 path, .swatch.c3 { fill: rgba(14, 165, 233, 0.16); background: rgba(14, 165, 233, 0.3); }
.plan-svg .region.c4 path, .swatch.c4 { fill: rgba(20, 184, 166, 0.22); background: rgba(20, 184, 166, 0.35); }
.plan-svg .region.c5 path, .swatch.c5 { fill: rgba(139, 92, 246, 0.2); background: rgba(139, 92, 246, 0.35); }
.plan-svg .region.none path { stroke: rgba(107, 114, 128, 0.7); stroke-dasharray: 4 3; }
.plan-svg .region.selected path { fill: rgba(249, 115, 22, 0.3); stroke: #c2410c; stroke-width: 2.5px; }
.plan-svg .region text { fill: #1e3a8a; text-anchor: middle; font-weight: 600; paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.9); stroke-linejoin: round; }
.plan-with-list.open { display: grid; grid-template-columns: 1fr 280px; gap: 12px; align-items: start; }
.region-list { padding: 10px 12px; display: grid; gap: 6px; max-height: 560px; overflow-y: auto; }
.region-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.region-list li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.region-list li:hover { background: #f1f5f9; }
.region-list li.on { background: #ffedd5; }
.region-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(30, 64, 175, 0.4); flex: none; }
@media (max-width: 800px) { .plan-with-list.open { grid-template-columns: 1fr; } .region-list { max-height: 320px; } }
.selected-region { padding: 10px 12px; border-color: #93c5fd; background: #eff6ff; display: grid; gap: 4px; margin-bottom: 12px; }
.selected-region-head { display: flex; align-items: center; gap: 8px; }
/* instant tooltip from data-tip (the browser waits about a second before showing a title) */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); display: none; position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 20; padding: 4px 8px; border-radius: 6px; background: rgba(17,24,39,.92); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.3; white-space: nowrap; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
[data-tip]:hover::after { display: block; }
/* inside the scrolling region list the tip sits to the left of the badge, so the top row is not clipped */
.region-list [data-tip]::after { left: auto; right: calc(100% + 6px); bottom: auto; top: 50%; transform: translateY(-50%); }
.selected-region-head .spacer { flex: 1; }
.chip { display: inline-block; font-size: 12px; padding: 1px 7px; margin: 2px 4px 0 0; border-radius: 6px; background: #e0e7ff; color: #3730a3; }

/* --- photo context (PLAN A.6) --- */
.shot-context { color: #1e3a8a; font-size: 15px; }
.modal-body .shot-context { margin: 6px 0 0; }
.photo-where { margin: 2px 0 6px; text-align: center; min-height: 1.3em; color: #c7d2fe; font-size: 15px; }
.plan-preview { position: relative; }
.north-arrow { position: absolute; top: 10px; right: 12px; width: 26px; height: 34px; display: grid; justify-items: center;
  font-size: 12px; color: #1e3a8a; pointer-events: none; background: rgba(255,255,255,0.85); border-radius: 6px; }
.north-arrow .n { font-weight: 700; line-height: 1; }
.analysis-bar select { font: inherit; padding: 2px 4px; }

.badge.comments { background: #fef3c7; color: #92400e; }
.frames-toggle { font-size: 12px; white-space: nowrap; }
.frames-toggle.on { background: #eef2ff; border-color: #a5b4fc; }

/* --- editing regions (Phase 14) --- */
/* the picked region's actions: a list, one a line (what it does under the name); 지우기 apart */
.region-actions { display: grid; gap: 6px; margin-top: 8px; }
.region-actions > button { display: grid; gap: 1px; text-align: left; padding: 7px 10px; font-size: 13px; width: 100%; }
.region-actions > button .label { font-weight: 600; }
.region-actions .danger-row { display: flex; justify-content: flex-end; margin-top: 4px; }
.region-actions .danger-row button { font-size: 13px; padding: 2px 0; }
.region-rename { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-top: 6px; }
.region-rename .field { min-width: 160px; }
.edit-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-top: 8px;
  border: 1px solid #f59e0b; border-radius: 10px; background: #fffbeb; font-size: 14px; }
.edit-bar .spacer { flex: 1; }
.edit-bar.pin-bar { border-color: #10b981; background: #f0fdf4; }
.edit-bar input { width: 200px; }
.plan-svg .region-edit-overlay { pointer-events: none; }
.plan-svg .region-edit-overlay .merging { fill: rgba(245, 158, 11, 0.3); stroke: #d97706; stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.plan-svg .region-edit-overlay .drawing { fill: rgba(245, 158, 11, 0.15); stroke: #d97706; stroke-width: 2.5px;
  stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.plan-svg .region-edit-overlay polyline.drawing { fill: none; }
.plan-svg .region-edit-overlay .vertex { fill: #d97706; stroke: #fff; stroke-width: 1px; vector-effect: non-scaling-stroke;
  pointer-events: all; cursor: move; }
.plan-svg .region-edit-overlay .vertex:hover { stroke-width: 2.5px; }
/* the record of edits: a panel above the plan (like the edit bar); a line an edit
   (when · what · who · 되돌리기 or 되돌림), a few rows high, the rest scrolls */
.region-history { display: grid; gap: 6px; padding: 10px 12px; margin-top: 8px; }
.edit-list { margin: 0; padding: 0; list-style: none; display: grid; max-height: 200px; overflow-y: auto; }
.edit-list li { display: grid; grid-template-columns: 112px 1fr auto auto; gap: 12px; align-items: center; padding: 6px 4px; border-top: 1px solid var(--line); font-size: 13px; }
.edit-list li button { white-space: nowrap; }
.edit-list li .what { min-width: 0; overflow-wrap: anywhere; }
.edit-list li .who { white-space: nowrap; }
.edit-list li > :last-child { justify-self: end; }
.edit-list li.undone .what, .edit-list li.undone .when, .edit-list li.undone .who { text-decoration: line-through; color: var(--muted); }
.region-history p { margin: 0; }

/* --- the day's report (Phase 15) --- */
.app-main.report-page { max-width: 1200px; display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.report-days { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; }
.report-days h4 { margin: 2px 6px 6px; }
.report-days ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
/* one line a day: the day, an AI mark (the counts are the link's tooltip) */
.report-days a { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; color: inherit; text-decoration: none; font-size: 13px; white-space: nowrap; }
.report-days a:hover { background: #f1f5f9; }
.report-days a.on { background: #eff6ff; outline: 1px solid #93c5fd; }
.report-days .day { font-weight: 600; }
.report-days .badge.ai { padding: 0 5px; font-size: 11px; }
.report-page .session-list { margin: 8px 0 4px; gap: 6px; }
.report-page .session-card { padding: 8px 12px; gap: 10px; }
.report-page .session-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.report-page .session-name .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.report-page .session-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-page .session-card .go { white-space: nowrap; }
.report-page .head-actions { align-items: center; }
.badge.ai { background: #ede9fe; color: #6d28d9; }
.head-actions { display: flex; gap: 8px; }
.ai-report { padding: 14px 16px; display: grid; gap: 6px; margin: 12px 0 4px; border-color: #c4b5fd; }
.ai-report.empty { background: #faf5ff; }
.ai-report-head { display: flex; align-items: center; gap: 12px; }
.ai-report-head .spacer { flex: 1; }
.ai-body { display: grid; gap: 6px; }
.ai-report.folded .ai-body { display: none; }
.ai-report h3, .ai-report h4 { margin: 6px 0 2px; }
.ai-report .summary { font-size: 15px; line-height: 1.6; }
.ai-report .note.north-changed { margin: 2px 0 4px; padding: 6px 10px; border-radius: 8px; background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; font-size: 13px; }
.ai-report p { line-height: 1.6; margin: 4px 0; }
.ai-report .issues { display: grid; gap: 8px; }
.issue { display: flex; gap: 12px; padding: 8px; border: 1px solid var(--line); border-left: 4px solid #d1d5db; border-radius: 8px; background: #fff; break-inside: avoid; }
.issue.high { border-left-color: #ef4444; }
.issue.medium { border-left-color: #f59e0b; }
.issue-photos { display: flex; gap: 6px; flex: none; align-items: flex-start; }
.issue-photo { position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
.issue-photo img { width: 180px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.issue-photo .n { position: absolute; top: 5px; left: 5px; min-width: 20px; padding: 0 5px; border-radius: 999px; background: #f97316; color: #fff; font-weight: 700; font-size: 12px; text-align: center; }
.issue-text { display: grid; gap: 2px; align-content: start; min-width: 0; }
.issue-text p { margin: 2px 0; }
.photo-peek { position: fixed; z-index: 50; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); pointer-events: none; display: grid; gap: 4px; }
.photo-peek img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; display: block; }
.by-region td.nowrap { white-space: nowrap; }
.badge.sev { background: #e5e7eb; color: #374151; }
.issue.high .badge.sev { background: #fee2e2; color: #b91c1c; }
.issue.medium .badge.sev { background: #fef3c7; color: #92400e; }
.by-region { border-collapse: collapse; width: 100%; font-size: 14px; }
.by-region th, .by-region td { border-top: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.by-region th { white-space: nowrap; width: 1%; }
.photo-ref { font: inherit; font-size: 12px; padding: 0 5px; margin: 0 1px; border-radius: 5px; border: 1px solid #c4b5fd; background: #f5f3ff; color: #5b21b6; cursor: pointer; }
.photo-ref:disabled { opacity: 0.5; cursor: default; }
.report-map { height: 360px; }
.plan-svg .report-route polyline { fill: none; stroke-opacity: 0.55; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.plan-svg .report-pin { cursor: pointer; }
.plan-svg .report-pin circle { fill: #f97316; stroke: #fff; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.plan-svg .report-pin text { fill: #fff; text-anchor: middle; font-weight: 700; }
.report-photos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.report-photo { display: grid; grid-template-columns: 220px 1fr; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; break-inside: avoid; }
.report-photo .thumb { position: relative; display: block; width: 220px; padding: 0; border: 0; background: none; cursor: pointer; }
.ai-generate { white-space: nowrap; }
.report-photo .thumb img { width: 220px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.report-photo .thumb .n { position: absolute; top: 6px; left: 6px; min-width: 22px; padding: 1px 6px; border-radius: 999px; background: #f97316; color: #fff; font-weight: 700; font-size: 13px; text-align: center; }
.report-photo-info { display: grid; gap: 4px; align-content: start; font-size: 14px; }
.report-photo-info .where { color: #1e3a8a; }
.report-comments { margin: 2px 0 0; padding-left: 16px; display: grid; gap: 2px; }
.report-comments .author { font-weight: 600; }
@media (max-width: 800px) {
  .app-main.report-page { grid-template-columns: 1fr; }
  .report-days { position: static; max-height: none; }
  .report-photo { grid-template-columns: 1fr; }
  .report-photo .thumb, .report-photo .thumb img { width: 100%; }
  .issue { flex-direction: column; }
  .issue-photo img { width: 140px; }
}
@media print {
  .app-header, .report-days, .back, button.print, .add-photos, .session-card .go, .ai-generate, .fold, .error-bar, .photo-peek { display: none !important; }
  .ai-report.folded .ai-body { display: grid; }
  .app-main.report-page { display: block; max-width: none; }
  body { background: #fff; }
}
.analysis-bar .north input.north-deg { width: 58px; font: inherit; padding: 2px 4px; text-align: right; }

/* --- photos registered by hand (PLAN Phase 17) --- */
.badge.pin { background: #ecfdf5; color: #047857; }
.session-card.manual { border-style: dashed; }
.pin-draft-form { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid #10b981; border-radius: 10px; background: #f0fdf4; margin-bottom: 12px; }
.pin-draft-form .row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.pin-draft-form .field.narrow { min-width: 140px; }
.pin-draft-form input[type=date], .pin-draft-form input[type=time] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.plan-svg .pin-draft path { fill: #f59e0b; stroke: #fff; stroke-width: 0.8; }
.plan-svg .pin-draft circle { fill: #fff; }
