:root {
  --ink: #141414;
  --sub: #6d6d6d;
  --line: #e4e4e2;
  --soft: #f6f6f4;
  --bg: #ffffff;
  --mark: #c8102e;
  --r: 2px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  font-size: 14px; line-height: 1.55; font-weight: 400;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; }
input[type=checkbox] { accent-color: var(--ink); }
body { word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
.small { font-size: 12px; }
.muted { color: var(--sub); }
.label { display: block; font-size: 12px; color: var(--sub); letter-spacing: .02em; margin: 18px 0 8px; }
.label:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > button { flex-shrink: 0; white-space: nowrap; }
.between { justify-content: space-between; }

/* header */
.top { display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; font-weight: 500; letter-spacing: .14em; font-size: 15px; }
.brand span { letter-spacing: 0; font-weight: 400; color: var(--sub); font-size: 13px; margin-left: 12px; }
.top-right { display: flex; gap: 18px; align-items: center; }
.link { text-decoration: none; }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: 210px minmax(0, 1fr) 300px; min-height: 0; }
.history { border-right: 1px solid var(--line); padding: 20px 16px; overflow-y: auto; max-height: calc(100vh - 110px); position: sticky; top: 0; }
.h-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.h-head .label { margin: 0; }
.h-list { display: grid; gap: 10px; }
.h-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; cursor: pointer; padding: 4px; border-radius: var(--r); border: 1px solid transparent; background: none; text-align: left; }
.h-item:hover { background: var(--soft); }
.h-item.on { border-color: var(--ink); }
.h-item img { width: 64px; height: 44px; object-fit: cover; border-radius: var(--r); background: var(--soft); display: block; }
.h-item span { font-size: 12px; color: var(--sub); line-height: 1.4; }
.h-item b { display: block; font-weight: 500; color: var(--ink); font-size: 12px; }

.stage-wrap { padding: 24px 28px; min-width: 0; }
.panel { border-left: 1px solid var(--line); padding: 24px 22px; }
.block { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }

/* drop */
.drop { border: 1px solid var(--line); border-radius: var(--r); min-height: 62vh; display: flex; align-items: center; padding: 40px; transition: background .15s; }
.drop.over { background: var(--soft); border-color: var(--ink); }
.drop-inner { max-width: 440px; }
.drop-title { font-size: 22px; line-height: 1.45; margin: 0 0 10px; font-weight: 400; }
.drop-title b { font-weight: 400; }
.file-btn { display: inline-block; margin-top: 18px; padding: 9px 14px; border: 1px solid var(--ink); border-radius: var(--r); cursor: pointer; background: #fff; }
.file-btn.small { padding: 6px 10px; margin-top: 8px; }
.consent { display: flex; gap: 8px; align-items: flex-start; margin-top: 22px; color: var(--sub); }
.consent input { margin-top: 3px; }

/* stage */
.stage { min-width: 0; }
.viewer { position: relative; background: var(--soft); border-radius: var(--r); overflow: hidden; user-select: none; -webkit-user-select: none; line-height: 0; }
.viewer img { width: 100%; height: auto; display: block; }
.result-layer { position: absolute; inset: 0; }
.result-layer img { width: 100%; height: 100%; object-fit: fill; }
.divider { position: absolute; top: 0; bottom: 0; width: 1px; background: #fff; cursor: ew-resize; }
.divider span { position: absolute; top: 50%; left: -9px; width: 18px; height: 18px; margin-top: -9px; border: 1px solid #fff; border-radius: var(--r); background: rgba(20,20,20,.45); }
.divider::before { content: ""; position: absolute; inset: 0 -14px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px; background: rgba(255,255,255,.92); line-height: 1.4; }
.progress p { margin: 8px 0 0; font-size: 12px; color: var(--sub); }
.bar { height: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .5s linear; }
.stage-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.stage-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tags { font-size: 12px; color: var(--sub); }
.note { margin: 10px 0 0; }
.pins { position: absolute; inset: 0; pointer-events: none; }
.pins.active { pointer-events: auto; cursor: crosshair; }
.pin { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 12px; line-height: 20px; text-align: center; border: 1px solid #fff; font-weight: 500; }

/* controls */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 8px 0; cursor: pointer; color: var(--sub); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { color: var(--ink); font-weight: 500; box-shadow: inset 0 0 0 1px var(--ink); }
textarea, input[type=text], input[type=password], input:not([type]), select { width: 100%; border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; background: #fff; outline: none; }
textarea { resize: vertical; min-height: 74px; }
textarea:focus, input:focus, select:focus { border-color: var(--ink); }
.memo-meta { display: flex; justify-content: space-between; margin-top: 4px; }
.more { margin-top: 14px; }
.more summary { cursor: pointer; color: var(--sub); font-size: 12px; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary .c { display: none; }
.more[open] summary .o { display: none; }
.more[open] summary .c { display: inline; }
.refs { display: flex; gap: 6px; flex-wrap: wrap; }
.refs img { width: 56px; height: 40px; object-fit: cover; border-radius: var(--r); }
.primary { width: 100%; margin-top: 20px; padding: 12px; border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: var(--r); cursor: pointer; font-weight: 500; }
.primary:disabled { background: #fff; border-color: var(--line); color: #9a9a98; cursor: default; }
.ghost { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: var(--r); cursor: pointer; }
.ghost:hover { border-color: var(--ink); }
.ghost.on { border-color: var(--ink); }
.ghost.wide { width: 100%; text-align: left; padding: 11px 12px; margin-bottom: 8px; }
.ghost.wide small { display: block; color: var(--sub); font-size: 12px; margin-top: 2px; }
.ghost em, .ghost.wide em { font-style: normal; font-size: 11px; color: var(--sub); margin-left: 6px; border: 1px solid var(--line); padding: 0 4px; border-radius: var(--r); }
.text-btn { border: 0; background: none; padding: 0; cursor: pointer; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }
.toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--sub); }
#renderHint { margin: 8px 0 0; }

/* sketchup bar */
.su-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.su-bar .label { margin: 0 6px 0 0; }
.su-bar select { width: auto; min-width: 140px; padding: 6px 8px; }

/* pins list */
.pin-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pin-row .n { width: 22px; height: 22px; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 11px; line-height: 22px; text-align: center; }
.pin-row img { width: 34px; height: 34px; object-fit: cover; border-radius: var(--r); vertical-align: middle; margin-right: 8px; }
.pin-row .t { font-size: 12px; line-height: 1.4; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20,20,20,.28); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-box { background: #fff; width: min(520px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px; border-radius: var(--r); }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 14px 0; }
.lib button { border: 1px solid var(--line); background: #fff; padding: 6px; border-radius: var(--r); cursor: pointer; text-align: left; font-size: 11px; line-height: 1.35; }
.lib button:hover { border-color: var(--ink); }
.lib img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; margin-bottom: 6px; border-radius: var(--r); }
.new-mat { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.new-mat .label { margin: 0; }
.new-mat .file-btn { justify-self: start; margin-top: 0; }

.toast { position: fixed; left: 28px; bottom: 28px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 13px; z-index: 30; max-width: 90vw; }
.foot { display: flex; justify-content: space-between; gap: 16px; padding: 14px 28px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.foot a { margin-left: 12px; }

/* embedded in SketchUp */
body.embed .top { padding: 12px 18px; }
body.embed #extLink { display: none; }
body.embed .layout { grid-template-columns: 180px minmax(0, 1fr) 280px; }
body.embed .foot { padding: 10px 18px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .history { order: 3; border-right: 0; border-top: 1px solid var(--line); max-height: none; position: static; }
  .h-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .panel { border-left: 0; border-top: 1px solid var(--line); order: 2; }
  .stage-wrap { order: 1; padding: 16px; }
  .drop { min-height: 30vh; padding: 24px 20px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
  .drop-title { font-size: 19px; }
  .top { padding: 14px 16px; }
  .brand span { display: none; }
  .foot { padding: 14px 16px; }
}

.modal-box b { font-weight: 500; }
#roleBadge { color: var(--sub); }
.ai-tag { position: absolute; right: 10px; bottom: 10px; font-size: 11px; line-height: 1; color: rgba(255,255,255,.9); background: rgba(20,20,20,.35); padding: 4px 6px; border-radius: var(--r); }
