:root {
  --ink: #11120f;
  --muted: #686960;
  --paper: #f3f1eb;
  --surface: #fbfaf6;
  --surface-strong: #fff;
  --line: #d8d5cc;
  --line-dark: #b8b4aa;
  --accent: #ff5e35;
  --accent-soft: #ffe4da;
  --green: #276a4c;
  --green-soft: #dceee4;
  --red: #9c3027;
  --red-soft: #f5deda;
  --yellow: #976f17;
  --yellow-soft: #f5e9c7;
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --shadow: 0 18px 50px rgba(35, 32, 25, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 8%, rgba(255, 94, 53, .08), transparent 26rem),
    var(--paper);
  color: var(--ink);
  font-family: Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(17, 18, 15, .14);
  background: rgba(250, 249, 245, .9);
  backdrop-filter: blur(18px);
}
.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 30px;
  width: min(100% - 40px, 1240px);
  height: 76px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 22px;
  font-style: italic;
}
.brand b { display: block; font-size: 15px; letter-spacing: .08em; line-height: 1.1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .17em; }
.main-tabs { display: flex; justify-content: center; gap: 4px; }
.main-tab {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #74756d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: .18s ease;
}
.main-tab:hover { background: #ebe9e2; color: var(--ink); }
.main-tab.active { background: var(--ink); color: #fff; box-shadow: 0 6px 18px rgba(17,18,15,.14); }
.tab-icon { width: 15px; font-size: 13px; text-align: center; }
.tab-count {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
}
.system-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .11em; }
.system-state i { width: 8px; height: 8px; border-radius: 50%; background: #42a275; box-shadow: 0 0 0 4px rgba(66,162,117,.13); }

.app-main { width: min(100% - 40px, 1180px); min-height: calc(100vh - 150px); margin: 0 auto; }
.tab-panel { padding: 68px 0 90px; animation: panel-in .24s ease both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(7px); } }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 10px; font-weight: 950; letter-spacing: .18em; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 60px; margin-bottom: 42px; }
.page-head h1 { margin: 0; font-size: clamp(44px, 6.8vw, 82px); line-height: .98; letter-spacing: -.065em; }
.page-head h1 em { color: var(--accent); font-family: Georgia, serif; font-weight: 400; }
.page-head .lead { max-width: 650px; margin: 25px 0 0; color: #5d5e57; font-size: 16px; }
.capture-mode-badge { display: inline-flex; min-height: 27px; align-items: center; margin-bottom: 12px; padding: 0 11px; border: 1px solid var(--ink); border-radius: 99px; background: var(--surface); color: var(--ink); font-size: 9px; font-weight: 950; }
.capture-mode-badge.template { border-color: var(--accent); background: var(--accent); }
.compact-head { align-items: center; }
.compact-head h1 { font-size: clamp(42px, 5vw, 64px); }
.compact-head .lead { margin-top: 13px; }
.calibration-actions { display: flex; align-items: center; gap: 10px; }
.calibration-actions .button { white-space: nowrap; }

.quick-specs {
  display: grid;
  flex: 0 0 300px;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 6px 6px 0 var(--ink);
}
.quick-specs div { padding: 20px 12px; text-align: center; }
.quick-specs div + div { border-left: 1px solid var(--line); }
.quick-specs b { display: block; font-family: Georgia, serif; font-size: 23px; }
.quick-specs span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 800; }

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 0 24px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: rgba(255,255,255,.54);
  list-style: none;
}
.flow-steps li { position: relative; display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 14px 20px; }
.flow-steps li + li { border-left: 1px solid var(--line); }
.flow-steps li > span { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line-dark); border-radius: 50%; font-family: Georgia, serif; font-size: 13px; }
.flow-steps li.active > span { border-color: var(--ink); background: var(--ink); color: #fff; }
.flow-steps b, .flow-steps small { display: block; }
.flow-steps b { font-size: 12px; }
.flow-steps small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.capture-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.capture-card { padding: 29px; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.card-title-row { display: flex; align-items: center; gap: 14px; }
.card-title-row .eyebrow { margin-bottom: 2px; }
.card-title-row h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
.card-number { display: grid; flex: 0 0 48px; width: 48px; height: 48px; place-items: center; border-radius: 15px; background: var(--ink); color: #fff; font-family: Georgia, serif; font-size: 15px; font-style: italic; }
.camera-card .card-number { background: var(--accent); color: var(--ink); }
.card-copy { margin: 17px 0 20px; color: var(--muted); font-size: 12px; }
.drop-zone {
  display: flex;
  min-height: 288px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  border: 1.5px dashed #a7a49a;
  border-radius: 18px;
  background: #f1efe8;
  text-align: center;
  cursor: pointer;
  transition: .18s ease;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.drop-symbol { display: grid; width: 62px; height: 62px; margin-bottom: 18px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; background: var(--surface); font-size: 31px; }
.drop-zone strong { display: block; max-width: 100%; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone small { max-width: 330px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.camera-frame { position: relative; min-height: 288px; overflow: hidden; border-radius: 18px; background: #252620; }
.camera-frame video { display: block; width: 100%; height: 288px; object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; color: #eee; }
.camera-placeholder b { margin-top: 6px; font-size: 13px; }
.camera-placeholder small { margin-top: 4px; color: #aaa; font-size: 9px; }
.camera-target { color: var(--accent); font-size: 54px; line-height: 1; }
.camera-guide { position: absolute; inset: 18px; pointer-events: none; }
.camera-guide i { position: absolute; width: 20px; height: 20px; border-color: rgba(255,255,255,.7); border-style: solid; }
.camera-guide i:nth-child(1) { left: 0; top: 0; border-width: 1px 0 0 1px; }
.camera-guide i:nth-child(2) { right: 0; top: 0; border-width: 1px 1px 0 0; }
.camera-guide i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 1px 1px; }
.camera-guide i:nth-child(4) { right: 0; bottom: 0; border-width: 0 1px 1px 0; }
.record-badge { position: absolute; z-index: 2; top: 14px; left: 14px; display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 99px; background: rgba(0,0,0,.72); color: #fff; font-size: 11px; }
.record-badge i { width: 8px; height: 8px; border-radius: 50%; background: #ff4938; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 12px; padding: 0 21px; border: 1px solid var(--ink); border-radius: 14px; cursor: pointer; font-size: 12px; font-weight: 900; text-decoration: none; transition: .16s ease; }
.button:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(17,18,15,.13); }
.button:disabled { cursor: not-allowed; opacity: .35; }
.button.primary { background: var(--ink); color: #fff; }
.button.secondary { background: var(--surface); color: var(--ink); }
.button.accent { background: var(--accent); color: var(--ink); }
.button.danger { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.button.compact { min-height: 38px; padding: 0 14px; font-size: 10px; }
.button.full { width: 100%; }
.drop-zone + .button, .camera-card > .button { margin-top: 15px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.capture-tip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; margin-top: 22px; padding: 18px 22px; border-radius: var(--radius); background: var(--ink); color: #fff; }
.capture-tip > span { padding: 5px 9px; border-radius: 8px; background: var(--accent); color: var(--ink); font-size: 9px; font-weight: 950; }
.capture-tip p { margin: 0; color: #d0d0cb; font-size: 11px; }
.capture-tip button { padding: 0; border: 0; background: transparent; color: #fff; cursor: pointer; font-size: 10px; font-weight: 900; }

.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; padding: 13px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.search-box { display: flex; min-width: 280px; flex: 1; align-items: center; gap: 9px; }
.search-box span { color: var(--muted); font-size: 22px; }
.search-box input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search-box input::placeholder { color: #9b9c95; }
.filter-tabs, .segmented { display: flex; padding: 4px; border-radius: 13px; background: #ebe9e2; }
.filter-tabs button, .segmented button { min-height: 35px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 900; }
.filter-tabs button.active, .segmented button.active { background: var(--ink); color: #fff; box-shadow: 0 3px 8px rgba(17,18,15,.12); }
.list-summary { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 0 3px; }
.list-summary b { font-size: 12px; }
.list-summary span { color: var(--muted); font-size: 9px; }
.template-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 34px; }
.template-overview > div { padding: 22px; border: 1px solid var(--ink); border-radius: 20px; background: var(--surface); box-shadow: 4px 4px 0 var(--ink); }
.template-overview span, .template-overview small { display: block; color: var(--muted); font-size: 9px; font-weight: 800; }
.template-overview b { display: block; margin: 8px 0 3px; font-size: 20px; letter-spacing: -.035em; }
.template-list-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 13px; padding: 0 3px; }
.template-list-head b { font-size: 12px; }
.template-list-head span { color: var(--muted); font-size: 9px; }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.template-slot { display: flex; min-height: 238px; flex-direction: column; padding: 20px; border: 1px dashed var(--line-dark); border-radius: 20px; background: rgba(255,255,255,.35); }
.template-slot.registered { border-style: solid; border-color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.template-slot.standard { border-color: #1d6060; background: linear-gradient(155deg, #f5fffc 0%, var(--surface) 72%); box-shadow: 4px 4px 0 #1d6060; }
.template-slot-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.template-number { font-family: Georgia, serif; font-size: 15px; font-style: italic; }
.template-state { padding: 5px 8px; border-radius: 99px; background: #e4e1d9; color: var(--muted); font-size: 8px; font-weight: 950; }
.registered .template-state { background: var(--green-soft); color: var(--green); }
.template-slot.standard .template-state { background: #d9f4ee; color: #155d59; }
.template-slot.standard .template-shape { background: #155d59; }
.template-slot.processing .template-state { background: var(--accent-soft); color: #9a3b20; }
.template-slot.failed .template-state { background: #f8d7d1; color: #9a2c20; }
.template-slot h2 { margin: 27px 0 6px; overflow-wrap: anywhere; font-size: 17px; line-height: 1.25; letter-spacing: -.035em; }
.template-slot.empty h2 { color: #999990; }
.template-source { margin: 0; color: var(--muted); font-size: 9px; }
.template-geometry { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 11px; margin: 18px 0; }
.template-shape { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 42% 58% 48% 52%; background: var(--ink); color: #fff; font-family: Georgia, serif; font-size: 11px; font-style: italic; }
.template-geometry b, .template-geometry small { display: block; }
.template-geometry b { font-size: 10px; }
.template-geometry small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.template-slot .button { min-height: 40px; margin-top: auto; padding: 0 14px; font-size: 10px; }
.template-slot.empty .template-source { margin-bottom: 20px; }
.template-add { align-items: center; justify-content: center; border-width: 1.5px; background: rgba(255,255,255,.45); cursor: pointer; text-align: center; transition: .16s ease; }
.template-add:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); box-shadow: var(--shadow); }
.template-add-symbol { display: grid; width: 58px; height: 58px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; background: var(--surface); font-size: 30px; line-height: 1; }
.template-add h2 { margin: 15px 0 5px; color: var(--ink); }
.template-add p { margin: 0; color: var(--muted); font-size: 9px; }
.standard-headform-modal { width: min(1050px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--ink); border-radius: 24px; background: var(--surface); box-shadow: 14px 14px 0 rgba(17,18,15,.22); }
.standard-headform-modal::backdrop { background: rgba(17,18,15,.72); backdrop-filter: blur(5px); }
.standard-headform-modal-layout > header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.standard-headform-modal-layout > header h2 { margin: 3px 0 0; font-size: 25px; letter-spacing: -.04em; }
.standard-headform-modal-body { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(250px, .75fr); min-height: 570px; }
.standard-headform-viewer-shell { position: relative; min-height: 570px; overflow: hidden; background: #d8e6e2; }
.standard-headform-viewer { position: absolute; inset: 0; }
.standard-headform-viewer canvas { display: block; width: 100%; height: 100%; }
.standard-headform-direction { position: absolute; top: 15px; right: 15px; left: 15px; display: flex; justify-content: space-between; pointer-events: none; }
.standard-headform-direction span { padding: 6px 9px; border-radius: 99px; background: rgba(17,18,15,.78); color: #fff; font-size: 9px; font-weight: 900; }
.standard-headform-direction span:first-child { color: #ffbd79; }
.standard-headform-modal-body > aside { display: flex; flex-direction: column; padding: 25px; border-left: 1px solid var(--line); }
.standard-headform-modal-body dl { display: grid; gap: 0; margin: 20px 0; }
.standard-headform-modal-body dl div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.standard-headform-modal-body dt { color: var(--muted); font-size: 10px; }
.standard-headform-modal-body dd { margin: 0; font-size: 12px; font-weight: 900; }
.standard-headform-modal-body aside > p:not(.eyebrow) { margin: 0 0 20px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.standard-headform-modal-body aside .button { margin-top: auto; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; width: 100%; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); cursor: pointer; text-align: left; transition: .16s ease; }
.history-item:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.history-item.selected { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.history-thumb { position: relative; display: grid; width: 58px; height: 58px; place-items: center; overflow: hidden; border-radius: 14px; background: #e6e3da; font-family: Georgia, serif; font-size: 16px; font-style: italic; }
.history-thumb.completed { background: var(--green-soft); color: var(--green); }
.history-thumb.failed { background: var(--red-soft); color: var(--red); }
.history-main { min-width: 0; }
.history-main strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: flex; flex-wrap: wrap; gap: 8px 15px; margin-top: 6px; color: var(--muted); font-size: 9px; }
.history-progress { width: min(240px, 100%); height: 3px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #dfddd5; }
.history-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.history-side { display: flex; align-items: center; gap: 14px; }
.history-status, .detail-status, .status-pill { display: inline-flex; min-height: 27px; align-items: center; padding: 0 10px; border-radius: 99px; background: #e5e3dc; color: #575851; font-size: 9px; font-weight: 950; white-space: nowrap; }
.history-status.completed, .detail-status.completed, .status-pill.completed { background: var(--green-soft); color: var(--green); }
.history-status.failed, .detail-status.failed, .status-pill.failed { background: var(--red-soft); color: var(--red); }
.history-status.processing, .detail-status.processing, .status-pill.processing { background: var(--accent-soft); color: #85361f; }
.history-status.queued, .detail-status.queued, .status-pill.queued { background: var(--yellow-soft); color: var(--yellow); }
.history-arrow { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; }
.empty-state, .detail-empty { display: flex; min-height: 420px; align-items: center; justify-content: center; flex-direction: column; padding: 50px 25px; border: 1px dashed var(--line-dark); border-radius: var(--radius-lg); background: rgba(255,255,255,.45); text-align: center; }
.empty-state > span { font-size: 40px; }
.empty-state h2, .detail-empty h1 { margin: 13px 0 4px; letter-spacing: -.04em; }
.empty-state p, .detail-empty > p:not(.eyebrow) { max-width: 520px; margin: 0 0 24px; color: var(--muted); font-size: 12px; }

.detail-empty .eyebrow { margin-top: 26px; }
.empty-visual { display: grid; width: 120px; height: 120px; place-items: center; border: 1px solid var(--ink); border-radius: 35% 55% 48% 42%; background: var(--accent); box-shadow: 8px 8px 0 var(--ink); transform: rotate(-6deg); }
.empty-visual span { font-family: Georgia, serif; font-size: 34px; font-style: italic; transform: rotate(6deg); }
.detail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.detail-head-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.back-button { margin-bottom: 21px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 900; }
.detail-head h1 { max-width: 900px; margin: 0; overflow-wrap: anywhere; font-size: clamp(34px, 5vw, 58px); line-height: 1.05; letter-spacing: -.055em; }
.detail-meta { margin: 12px 0 0; color: var(--muted); font-size: 10px; }
.detail-status { margin-bottom: 5px; }
.progress-card { padding: 28px; border-radius: var(--radius-lg); background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.progress-top, .progress-bottom { display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.progress-top .eyebrow { margin-bottom: 4px; }
.progress-top strong { font-size: 20px; letter-spacing: -.025em; }
.progress-top > b { color: var(--accent); font-family: Georgia, serif; font-size: 32px; font-style: italic; }
.progress-track { height: 9px; margin: 23px 0 17px; overflow: hidden; border-radius: 99px; background: #3f403b; }
.progress-track div { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #ffad58); transition: width .45s ease; }
.progress-bottom p { margin: 0; color: #bfc0ba; font-size: 11px; }
.error-box { margin-top: 19px; padding: 15px; border: 1px solid #6a3732; border-radius: 13px; background: #2f201e; color: #ffc0b5; }
.error-box summary { cursor: pointer; font-size: 10px; font-weight: 900; }
.error-box pre { overflow-x: auto; white-space: pre-wrap; font-size: 9px; }
.result-section { margin-top: 58px; }
.section-title-row, .pattern-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.result-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.result-actions > .button { min-height: 43px; }
.section-title-row h2, .pattern-head h2 { margin: 0; font-size: 38px; letter-spacing: -.05em; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, .75fr); gap: 18px; }
.viewer-shell { position: relative; min-height: 600px; overflow: hidden; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: #dedbd2; }
model-viewer { width: 100%; height: 600px; --poster-color: #dedbd2; }
.stl-viewer { width: 100%; height: 600px; background: #dedbd2; }
.stl-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.rounded-overlay-viewer { width: 100%; height: 600px; background: #171814; }
.rounded-overlay-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.rounded-overlay-viewer.loading::after { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; background: rgba(23,24,20,.7); color: #fff; content: "원본과 국소 보정 3D를 겹치는 중…"; font-size: 10px; font-weight: 900; }
.stl-viewer[hidden], .rounded-overlay-viewer[hidden], model-viewer[hidden] { display: none; }
.rounded-overlay-legend { position: absolute; z-index: 3; top: 15px; left: 15px; display: flex; gap: 7px; padding: 7px; border-radius: 99px; background: rgba(17,18,15,.82); backdrop-filter: blur(8px); }
.rounded-overlay-legend[hidden], .rounded-overlay-controls[hidden] { display: none; }
.rounded-overlay-legend span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; color: #fff; font-size: 9px; font-weight: 900; }
.rounded-overlay-legend span::before { width: 9px; height: 9px; border-radius: 50%; content: ""; }
.rounded-overlay-legend .corrected::before { background: #e28f58; }
.rounded-overlay-legend .original::before { background: conic-gradient(#f2a27b, #74c4e7, #f4d58d, #f2a27b); }
.rounded-overlay-controls { position: absolute; z-index: 3; top: 15px; right: 15px; display: grid; min-width: 190px; gap: 9px; padding: 12px 14px; border-radius: 14px; background: rgba(17,18,15,.88); color: #fff; backdrop-filter: blur(8px); }
.rounded-overlay-controls label { display: flex; align-items: center; justify-content: space-between; gap: 9px; font-size: 9px; font-weight: 900; }
.rounded-overlay-controls input[type="checkbox"] { accent-color: var(--accent); }
.rounded-overlay-controls .rounded-opacity { display: grid; grid-template-columns: 1fr auto; }
.rounded-overlay-controls input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.rounded-overlay-controls b { font-family: Georgia, serif; font-size: 14px; }
.viewer-hint { position: absolute; z-index: 3; bottom: 15px; left: 15px; padding: 7px 10px; border-radius: 99px; background: rgba(255,255,255,.8); color: var(--ink); font-size: 9px; font-weight: 800; backdrop-filter: blur(8px); }
.measure-card { display: flex; min-height: 600px; justify-content: space-between; flex-direction: column; padding: 27px; border-radius: var(--radius-lg); background: var(--ink); color: #fff; }
.measure-card h3 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.scale-note { min-height: 58px; color: #aeb0a9; font-size: 10px; }
.measure-card dl { margin: 25px 0; }
.measure-card dl > div { display: flex; align-items: flex-end; justify-content: space-between; padding: 15px 0; border-bottom: 1px solid #3f403b; }
.measure-card dt { color: #aeb0a9; font-size: 9px; }
.measure-card dd { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.measure-card .button.secondary { border-color: #fff; background: transparent; color: #fff; }
.orientation-section { margin-top: 58px; padding-top: 50px; border-top: 1px solid var(--line); }
.orientation-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.orientation-head h2 { margin: 0; font-size: 38px; letter-spacing: -.05em; }
.orientation-head > div > p:last-child { max-width: 700px; margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.orientation-status { display: inline-flex; min-height: 30px; align-items: center; padding: 0 11px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 9px; font-weight: 950; white-space: nowrap; }
.orientation-status.missing { background: #ffe0d6; color: #a63d22; }
.orientation-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, .72fr); gap: 18px; }
.orientation-viewer-shell { position: sticky; top: 100px; align-self: start; min-height: 520px; overflow: hidden; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: #171814; }
.density-view-controls { position: absolute; bottom: 55px; left: 12px; right: 12px; display: grid; gap: 6px; pointer-events: none; }
.density-camera-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.density-camera-actions .button { pointer-events: auto; min-height: 34px; padding: 6px 10px; font-size: 11px; }
@media (max-width: 900px) { .orientation-viewer-shell { position: relative; top: auto; } }
.orientation-viewer { width: 100%; height: 520px; }
.orientation-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.orientation-viewer.loading::after { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(23,24,20,.58); color: #fff; content: "방향 설정 3D 불러오는 중…"; font-size: 10px; font-weight: 900; }
.orientation-marker-legend { position: absolute; z-index: 2; top: 15px; left: 15px; display: flex; gap: 7px; padding: 7px; border-radius: 99px; background: rgba(17,18,15,.78); backdrop-filter: blur(8px); }
.orientation-marker-legend span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; color: #fff; font-size: 9px; font-weight: 900; }
.orientation-marker-legend span::before { width: 9px; height: 9px; border-radius: 50%; content: ""; }
.orientation-marker-legend .original::before { background: conic-gradient(#f2a27b, #74c4e7, #f4d58d, #f2a27b); }
.orientation-marker-legend .front::before { background: var(--accent); }
.orientation-marker-legend .back::before { background: #55bff3; }
.density-zone-legend { position: absolute; z-index: 2; top: 65px; left: 15px; display: flex; gap: 7px; padding: 7px; border-radius: 99px; background: rgba(17,18,15,.78); backdrop-filter: blur(8px); }
.density-zone-legend[hidden] { display: none; }
.density-zone-legend span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; color: #fff; font-size: 9px; font-weight: 900; }
.density-zone-legend span::before { width: 9px; height: 9px; border-radius: 50%; content: ""; }
.density-zone-legend .zone-a::before { background: #ffb766; }
.density-zone-legend .zone-b::before { background: #a8d5f7; }
.density-zone-legend .zone-c::before { background: #b8efc5; }
.orientation-card { display: flex; min-height: 520px; flex-direction: column; padding: 27px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.orientation-card h3 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.orientation-card > div:first-child > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.orientation-angle { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin: 25px 0 15px; padding: 16px 0; border-block: 1px solid var(--line); }
.orientation-angle span { color: var(--muted); font-size: 9px; }
.orientation-angle b { font-family: Georgia, serif; font-size: 25px; }
.orientation-adjust-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.orientation-adjust-row .button { min-height: 39px; padding-inline: 7px; font-size: 9px; }
.orientation-card > .button { margin-top: 9px; }
.orientation-card > small { margin-top: auto; padding-top: 15px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.density-zone-editor { display: grid; gap: 9px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.density-zone-editor .eyebrow { margin-bottom: 3px; }
.density-zone-editor h4 { margin: 0; font-size: 13px; letter-spacing: -.025em; }
.density-zone-editor p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.density-zone-draw-actions, .density-zone-review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.density-zone-editor .button { min-height: 37px; padding-inline: 7px; font-size: 9px; }
.density-zone-editor .button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.density-zone-assignment { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 10px; border-radius: 10px; background: var(--accent-soft); }
.density-zone-assignment[hidden] { display: none; }
.density-zone-assignment span { color: #833d27; font-size: 9px; font-weight: 950; }
.density-zone-assignment label { color: #833d27; font-size: 8px; font-weight: 800; }
.density-zone-assignment select { min-width: 0; padding: 7px; border: 1px solid #d9a58f; border-radius: 7px; background: #fff; font: inherit; font-size: 10px; }
.density-zone-assignment .button { grid-column: 1 / -1; }
#densityZoneStatus { color: var(--muted); font-size: 9px; font-weight: 700; line-height: 1.5; }
.density-pattern-section { margin-top: 30px; padding: 25px; border: 1px solid #d9a58f; border-radius: var(--radius-lg); background: linear-gradient(135deg, #fff7f1, #f8f6ef); }
.density-pattern-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.density-pattern-head h2 { margin: 0; font-size: 28px; letter-spacing: -.045em; }
.density-pattern-head p:last-child { max-width: 690px; margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.density-pattern-status { margin-top: 16px; color: #7b4934; font-size: 10px; font-weight: 800; line-height: 1.55; }
.density-pattern-card { margin-top: 18px; overflow: hidden; border: 1px solid var(--ink); border-radius: 16px; background: #e1ded6; text-align: center; }
.density-pattern-card[hidden] { display: none; }
.density-pattern-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 13px; background: var(--ink); color: #fff; text-align: left; }
.density-pattern-toolbar > span { color: #d6d4cc; font-size: 9px; font-weight: 800; }
.density-pattern-card img { display: block; width: 100%; max-height: 950px; object-fit: contain; }
.comparison-section { margin-top: 66px; padding-top: 50px; border-top: 1px solid var(--line); }
.comparison-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 20px; }
.comparison-head h2 { margin: 0; font-size: 38px; letter-spacing: -.05em; }
.comparison-head > div > p:last-child { max-width: 670px; margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.comparison-loading { min-height: 180px; align-items: center; justify-content: center; gap: 17px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.comparison-loading:not([hidden]) { display: flex; }
.comparison-loading i { width: 32px; height: 32px; border: 3px solid #d7d4ca; border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
.comparison-loading b, .comparison-loading span { display: block; }
.comparison-loading b { font-size: 12px; }
.comparison-loading span { margin-top: 5px; color: var(--muted); font-size: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }
.comparison-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .7fr); gap: 18px; }
.comparison-viewer-shell { position: relative; min-height: 570px; overflow: hidden; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: #171814; }
.comparison-viewer { width: 100%; height: 570px; }
.comparison-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.comparison-viewer.loading::after { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(23,24,20,.58); color: #fff; content: "3D 포개기 불러오는 중…"; font-size: 10px; font-weight: 900; }
.comparison-legend { position: absolute; z-index: 2; top: 15px; left: 15px; display: flex; gap: 7px; padding: 7px; border-radius: 99px; background: rgba(17,18,15,.78); backdrop-filter: blur(8px); }
.comparison-legend span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; color: #fff; font-size: 9px; font-weight: 900; }
.comparison-legend span::before { width: 9px; height: 9px; border-radius: 50%; content: ""; }
.comparison-legend .query::before { background: linear-gradient(135deg, #e9c7ad 0 42%, #b66f52 43% 68%, #f1e4ce 69%); }
.comparison-legend .template::before { background: #55bff3; }
.comparison-legend .direction::before { border: 2px solid var(--accent); background: linear-gradient(90deg, var(--accent) 0 50%, #55bff3 50%); }
.comparison-viewer-shell .viewer-hint { background: rgba(255,255,255,.86); }
.comparison-score-card { display: flex; min-height: 570px; justify-content: space-between; flex-direction: column; padding: 29px; border-radius: var(--radius-lg); background: var(--ink); color: #fff; }
.winner-slot { display: inline-flex; min-height: 25px; align-items: center; margin-top: 6px; padding: 0 9px; border-radius: 99px; background: var(--accent); color: var(--ink); font-size: 9px; font-weight: 950; }
.comparison-score-card h3 { margin: 12px 0 8px; overflow-wrap: anywhere; font-size: 23px; line-height: 1.18; letter-spacing: -.035em; }
.comparison-label { color: #b7bbb0; font-size: 10px; font-weight: 900; }
.match-score { display: grid; grid-template-columns: auto auto; align-items: end; justify-content: start; margin: 24px 0; }
.match-score b { color: var(--accent); font-family: Georgia, serif; font-size: 74px; font-style: italic; font-weight: 500; line-height: .9; letter-spacing: -.055em; }
.match-score > span { margin: 0 0 7px 4px; color: var(--accent); font-size: 18px; }
.match-score small { grid-column: 1 / -1; margin-top: 9px; color: #aeb0a9; font-size: 9px; font-weight: 900; }
.comparison-score-card dl { margin: 0; }
.comparison-score-card dl > div { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid #3f403b; }
.comparison-score-card dt { color: #aeb0a9; font-size: 9px; }
.comparison-score-card dd { margin: 0; font-family: Georgia, serif; font-size: 17px; }
.comparison-ranking-head { display: flex; align-items: center; justify-content: space-between; margin: 25px 3px 11px; }
.comparison-ranking-head b { font-size: 12px; }
.comparison-ranking-head span { color: var(--muted); font-size: 9px; }
.comparison-ranking { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.comparison-candidate { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; transition: .16s ease; }
.comparison-candidate:hover, .comparison-candidate.selected { border-color: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow); }
.comparison-candidate.selected { box-shadow: inset 4px 0 0 var(--accent), var(--shadow); }
.comparison-candidate .rank { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 50%; background: #e6e3da; font-family: Georgia, serif; font-size: 11px; font-style: italic; }
.comparison-candidate.selected .rank { background: var(--accent); }
.comparison-candidate > span:nth-child(2) { min-width: 0; color: var(--ink); }
.comparison-candidate b, .comparison-candidate small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comparison-candidate b { font-size: 10px; }
.comparison-candidate small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.comparison-candidate strong { color: var(--ink); font-family: Georgia, serif; font-size: 20px; }
.comparison-caveat { margin: 17px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.65; }
.pattern-head { margin-top: 65px; }
.pattern-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.pattern-card { overflow: hidden; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: #e1ded6; text-align: center; }
.pattern-card img { display: block; width: 100%; max-height: 950px; object-fit: contain; }
.pattern-card p { margin: 0; padding: 13px 20px; background: var(--ink); color: #fff; font-size: 10px; }
.print-actions { display: flex; align-items: center; gap: 20px; margin-top: 16px; }
.print-actions small { max-width: 620px; color: var(--muted); font-size: 9px; }
.density-test-section { margin-top: 66px; padding-top: 50px; border-top: 1px solid var(--line); }
.density-test-copy { display: grid; gap: 8px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.density-test-copy p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.density-test-copy strong { margin-top: 4px; color: #a33429; font-size: 10px; }
.density-percent-field { display: flex; align-items: center; gap: 8px; width: fit-content; margin-top: 6px; color: var(--ink); font-size: 11px; font-weight: 700; }
.density-percent-field input { width: 82px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.density-review { display: grid; gap: 14px; }
.density-stage-flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.density-stage-flow button { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 9px; min-height: 65px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; transition: .16s ease; }
.density-stage-flow button:hover, .density-stage-flow button.active { border-color: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow); }
.density-stage-flow button.active { background: var(--ink); color: #fff; }
.density-stage-flow button > span { grid-row: 1 / 3; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: #e8e5dc; color: var(--ink); font-family: Georgia, serif; font-size: 11px; font-style: italic; }
.density-stage-flow button.active > span { background: var(--accent); }
.density-stage-flow b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.density-stage-flow small { color: var(--muted); font-size: 8px; }
.density-stage-flow button.active small { color: #b9bbb4; }
.density-review-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .7fr); gap: 18px; }
.density-stage-viewer-shell { position: relative; min-height: 620px; overflow: hidden; border: 1px solid var(--ink); border-radius: var(--radius-lg); background: #171814; }
.density-stage-viewer { width: 100%; height: 620px; }
.density-stage-viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.density-stage-viewer.loading::after { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; background: rgba(23,24,20,.7); color: #fff; content: "3D 검토 단계 불러오는 중…"; font-size: 10px; font-weight: 900; }
.density-stage-legend { position: absolute; z-index: 3; top: 15px; left: 15px; display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; border-radius: 99px; background: rgba(17,18,15,.82); backdrop-filter: blur(8px); }
.density-stage-legend span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; color: #fff; font-size: 8px; font-weight: 900; }
.density-stage-legend span::before { width: 9px; height: 9px; border-radius: 50%; content: ""; }
.density-stage-legend .outer-line::before { background: #2dd2ff; }
.density-stage-legend .inner-line::before { background: #ff8434; }
.density-stage-legend .u-line::before { background: #ed396f; }
.density-stage-legend .zone-a::before { background: #ffb766; }
.density-stage-legend .zone-b::before { background: #a8d5f7; }
.density-stage-legend .zone-c::before { background: #b8efc5; }
.density-stage-card { display: flex; min-height: 620px; flex-direction: column; padding: 27px; border-radius: var(--radius-lg); background: var(--ink); color: #fff; }
.density-stage-card h3 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.density-stage-card > p:not(.eyebrow) { margin: 14px 0; color: #b9bbb4; font-size: 10px; line-height: 1.7; }
.density-opacity-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; margin: 16px 0; padding: 15px 0; border-block: 1px solid #3f403b; }
.density-opacity-field span { font-size: 9px; font-weight: 900; }
.density-opacity-field input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.density-opacity-field b { font-family: Georgia, serif; font-size: 18px; }
.density-review-warning { display: grid; gap: 7px; margin-top: auto; margin-bottom: 18px; padding: 16px; border: 1px solid #744638; border-radius: 14px; background: #2f211d; }
.density-review-warning b { color: var(--accent); font-size: 10px; }
.density-review-warning span { color: #dfc8bd; font-size: 9px; line-height: 1.6; }
.density-stage-card .button.secondary { border-color: #fff; background: transparent; color: #fff; }

.a4-layout { display: grid; grid-template-columns: minmax(320px, 540px) 1fr; align-items: center; gap: clamp(45px, 7vw, 100px); }
.paper-shell { padding: 18px; border-radius: var(--radius-lg); background: #dedbd2; }
.paper-preview { overflow: hidden; border: 1px solid #aaa; background: #fff; box-shadow: 0 18px 38px rgba(25,25,20,.18); aspect-ratio: 210 / 297; }
.paper-preview svg { display: block; width: 100%; height: 100%; }
.info-chip { display: inline-flex; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: #88351f; font-size: 9px; font-weight: 950; }
.a4-copy h2 { margin: 19px 0 27px; font-size: clamp(28px, 4vw, 46px); line-height: 1.08; letter-spacing: -.055em; }
.a4-copy ol { margin: 0; padding: 0; list-style: none; }
.a4-copy li { display: flex; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.a4-copy li > span { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-family: Georgia, serif; font-size: 12px; }
.a4-copy li b { font-size: 12px; }
.a4-copy li p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.mobile-print { display: none; margin-top: 20px; }
.micro { color: var(--muted); font-size: 9px; }

.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 27px max(20px, calc((100vw - 1180px) / 2)); background: var(--ink); color: #fff; }
.app-footer b { font-size: 12px; letter-spacing: .12em; }
.app-footer p { margin: 0; color: #94968e; font-size: 9px; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 14px 17px; border: 1px solid #fff; border-radius: 13px; background: var(--ink); color: #fff; box-shadow: 0 16px 40px rgba(0,0,0,.25); font-size: 11px; }

@media (max-width: 960px) {
  .header-inner { grid-template-columns: auto 1fr; height: auto; min-height: 70px; padding: 12px 0 9px; }
  .system-state { display: none; }
  .main-tabs { grid-column: 1 / -1; justify-content: flex-start; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
  .main-tabs::-webkit-scrollbar { display: none; }
  .main-tab { flex: 0 0 auto; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 30px; }
  .quick-specs { width: 100%; flex-basis: auto; }
  .flow-steps { grid-template-columns: repeat(2, 1fr); }
  .flow-steps li:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .flow-steps li:nth-child(4) { border-top: 1px solid var(--line); }
  .capture-grid, .result-grid, .orientation-layout, .comparison-layout, .density-review-grid, .a4-layout { grid-template-columns: 1fr; }
  .density-stage-card { min-height: auto; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comparison-ranking { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .measure-card { min-height: auto; }
  .a4-layout { align-items: start; }
}

@media (max-width: 640px) {
  .header-inner, .app-main { width: min(100% - 28px, 1180px); }
  .header-inner { gap: 10px; }
  .brand-mark { width: 34px; height: 34px; font-size: 18px; }
  .brand b { font-size: 13px; }
  .main-tab { min-height: 39px; padding: 0 12px; font-size: 11px; }
  .tab-panel { padding: 42px 0 70px; }
  .page-head { margin-bottom: 30px; }
  .page-head h1 { font-size: clamp(39px, 13vw, 58px); }
  .page-head .lead { margin-top: 18px; font-size: 13px; }
  .compact-head .button { width: 100%; }
  .calibration-actions { width: 100%; flex-direction: column; }
  .quick-specs { box-shadow: 4px 4px 0 var(--ink); }
  .quick-specs div { padding: 15px 8px; }
  .flow-steps li { min-height: 67px; padding: 11px; }
  .flow-steps li > span { width: 26px; height: 26px; flex-basis: 26px; }
  .flow-steps small { display: none; }
  .capture-card { padding: 20px; border-radius: 22px; }
  .card-title-row h2 { font-size: 20px; }
  .card-number { width: 42px; height: 42px; flex-basis: 42px; }
  .drop-zone, .camera-frame { min-height: 235px; }
  .camera-frame video { height: 235px; }
  .capture-tip { grid-template-columns: auto 1fr; }
  .capture-tip button { grid-column: 1 / -1; text-align: right; }
  .list-toolbar { align-items: stretch; flex-direction: column; }
  .template-overview, .template-grid { grid-template-columns: 1fr; }
  .standard-headform-modal-body { grid-template-columns: 1fr; }
  .standard-headform-viewer-shell { min-height: 420px; }
  .standard-headform-modal-body > aside { border-top: 1px solid var(--line); border-left: 0; }
  .template-list-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .search-box { min-width: 0; }
  .filter-tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
  .filter-tabs button { padding: 0 6px; }
  .history-item { grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 14px; }
  .history-thumb { width: 48px; height: 48px; }
  .history-side { grid-column: 2; justify-content: space-between; }
  .history-progress { width: 100%; }
  .detail-head { align-items: flex-start; flex-direction: column; }
  .detail-head-actions { width: 100%; justify-content: flex-start; }
  .detail-status { margin: 0; }
  .progress-card { padding: 20px; border-radius: 22px; }
  .progress-top strong { font-size: 16px; }
  .progress-top > b { font-size: 25px; }
  .progress-bottom { align-items: flex-start; flex-direction: column; gap: 10px; }
  .section-title-row, .pattern-head { align-items: flex-start; flex-direction: column; }
  .density-pattern-head { align-items: flex-start; flex-direction: column; }
  .comparison-head { align-items: stretch; flex-direction: column; }
  .comparison-head h2 { font-size: 32px; }
  .comparison-ranking { grid-template-columns: 1fr; }
  .comparison-viewer-shell, .comparison-viewer { min-height: 450px; height: 450px; }
  .orientation-viewer-shell, .orientation-viewer { min-height: 430px; height: 430px; }
  .comparison-score-card { min-height: auto; }
  .result-actions { width: 100%; justify-content: flex-start; }
  .result-actions > .button { width: 100%; }
  .section-title-row h2, .pattern-head h2 { font-size: 32px; }
  .density-stage-flow { grid-template-columns: 1fr; }
  .density-stage-viewer-shell, .density-stage-viewer { min-height: 450px; height: 450px; }
  .density-stage-legend { right: 15px; border-radius: 14px; }
  .pattern-controls { width: 100%; justify-content: flex-start; }
  .pattern-controls .segmented { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .viewer-shell, model-viewer, .stl-viewer, .rounded-overlay-viewer { min-height: 450px; height: 450px; }
  .rounded-overlay-controls { top: auto; right: 15px; bottom: 54px; left: 15px; min-width: 0; }
  .print-actions { align-items: stretch; flex-direction: column; }
  .print-actions .button { width: 100%; }
  .density-pattern-section { padding: 19px; }
  .density-pattern-toolbar { align-items: flex-start; flex-direction: column; }
  .paper-shell { padding: 10px; }
  #tab-a4 .compact-head .calibration-actions { display: none; }
  .mobile-print { display: inline-flex; }
  .app-footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  .app-header, .app-main, .app-footer, .toast { display: none !important; }
}

.physics-original-control { position: absolute; top: 60px; left: 16px; z-index: 4; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.94); font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.physics-original-control[hidden], #physicsMetrics[hidden] { display: none; }
#comparisonResultStatus:empty { display: none; }
#physicsStatus { max-width: 160px; font-size: 12px; }
.comparison-score-card { min-width: 0; }
.comparison-score-card dd { max-width: 68%; overflow-wrap: anywhere; text-align: right; }
#comparisonOrientationConfidence { font-size: 12px; }
