:root {
  color-scheme: light;
  --ink: #17221e;
  --muted: #6e7974;
  --green: #1f5b48;
  --green-dark: #123c30;
  --green-pale: #dfe9dc;
  --cream: #f5f2e9;
  --paper: #fbfaf5;
  --line: #dedfd6;
  --gold: #c6943d;
  font-family: Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(220, 229, 211, 0.52), transparent 27rem),
    var(--cream);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(198, 148, 61, 0.45); outline-offset: 3px; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 max(28px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(31, 52, 43, 0.12);
  background: rgba(250, 248, 241, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--green-dark);
  text-decoration: none;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0.17em;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  width: 35px;
  height: 18px;
  align-items: center;
  gap: 3px;
}

.brand-mark i {
  display: block;
  width: 15px;
  height: 13px;
  border: 2px solid var(--green);
  border-radius: 50%;
}

.brand-mark b { position: absolute; width: 5px; border-top: 2px solid var(--green); left: 15px; top: 8px; }

.topbar-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #77817c;
  font-size: 12px;
  letter-spacing: -0.02em;
}

.topbar-note span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b9778;
  box-shadow: 0 0 0 4px rgba(107, 151, 120, 0.13);
}

.help-button {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 2px;
  border: 0;
  padding: 8px 0;
  background: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.help-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.workspace {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 68px 0 72px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--green);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.26em;
}

.intro h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "AppleMyungjo", serif;
  font-size: clamp(40px, 5vw, 66px);
  line-height: 1.06;
  font-weight: 500;
  letter-spacing: -0.055em;
}

.intro h1 em { color: var(--green); font-weight: 500; }

.intro-copy {
  margin: 0 0 8px;
  padding-left: 20px;
  border-left: 1px solid #b9beb7;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: -0.025em;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(320px, 0.74fr);
  gap: 20px;
  align-items: stretch;
}

.viewer-card, .control-panel {
  border: 1px solid rgba(30, 51, 42, 0.12);
  background: var(--paper);
  box-shadow: 0 22px 60px rgba(38, 49, 44, 0.08);
}

.viewer-card { padding: 10px; }

.viewer {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  min-height: 400px;
  background:
    linear-gradient(rgba(249, 247, 239, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249, 247, 239, 0.06) 1px, transparent 1px),
    #d9e1d6;
  background-size: 44px 44px;
}

.viewer::before, .viewer::after {
  content: "";
  position: absolute;
  z-index: 8;
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.viewer::before { left: 18px; top: 18px; border-left: 1px solid rgba(20, 52, 40, 0.45); border-top: 1px solid rgba(20, 52, 40, 0.45); }
.viewer::after { right: 18px; bottom: 18px; border-right: 1px solid rgba(20, 52, 40, 0.45); border-bottom: 1px solid rgba(20, 52, 40, 0.45); }

#videoCanvas, #glCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 300ms ease;
}

#glCanvas { z-index: 3; }
.viewer.is-running #videoCanvas, .viewer.is-running #glCanvas { opacity: 1; }

.viewer-wash {
  position: absolute;
  z-index: 4;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 16, 11, 0.06), transparent 26%, transparent 72%, rgba(4, 16, 11, 0.18));
  opacity: 0;
  pointer-events: none;
}

.viewer.is-running .viewer-wash { opacity: 1; }

.viewer-empty {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1.06fr;
  align-items: center;
  padding: 38px 48px 34px;
  z-index: 5;
}

.viewer-empty[hidden] { display: none; }

.face-guide { position: relative; width: min(94%, 250px); aspect-ratio: 1; margin: auto; }

.guide-orbit {
  position: absolute;
  inset: 4%;
  border: 1px solid rgba(39, 92, 71, 0.31);
  border-radius: 50%;
  box-shadow: inset 0 0 0 20px rgba(255,255,255,0.1);
}

.guide-orbit::before, .guide-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(39, 92, 71, 0.16);
}
.guide-orbit::before { inset: 13%; }
.guide-orbit::after { inset: -9%; }

.guide-head {
  position: absolute;
  width: 45%;
  height: 58%;
  left: 27.5%;
  top: 22%;
  border-radius: 47% 47% 44% 44% / 41% 41% 56% 56%;
  background: #bdcbbd;
  box-shadow: 0 14px 32px rgba(30, 74, 57, 0.16);
}

.guide-head::before {
  content: "";
  position: absolute;
  width: 76%;
  height: 39%;
  left: 12%;
  top: -4%;
  border-radius: 50% 50% 30% 30%;
  background: #1f4336;
  clip-path: polygon(0 0, 100% 0, 94% 52%, 72% 32%, 54% 51%, 34% 31%, 4% 59%);
}

.guide-glasses {
  position: absolute;
  width: 57%;
  height: 21%;
  left: 21.5%;
  top: 44%;
  display: flex;
  justify-content: space-between;
}

.guide-glasses i { width: 43%; border: 5px solid #214f3e; border-radius: 45%; background: rgba(245,242,233,0.14); }
.guide-glasses b { position: absolute; width: 18%; border-top: 5px solid #214f3e; left: 41%; top: 35%; }

.guide-spark { position: absolute; color: var(--gold); }
.guide-spark svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.2; }
.guide-spark--one { width: 25px; height: 25px; top: 21%; right: 7%; }
.guide-spark--two { width: 14px; height: 14px; left: 8%; bottom: 22%; }

.empty-copy { position: relative; padding-left: 30px; }
.empty-copy::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 1px; background: rgba(26, 79, 59, 0.19); }
.empty-step { color: var(--green); font-size: 10px; font-weight: 850; letter-spacing: .18em; }
.empty-copy h2 { margin: 14px 0 13px; font-size: clamp(22px, 2.4vw, 29px); line-height: 1.35; letter-spacing: -0.055em; }
.empty-copy p { margin: 0; color: #6e7d75; font-size: 12px; line-height: 1.6; }

.viewer-status {
  position: absolute;
  z-index: 9;
  top: 19px;
  left: 19px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-status[hidden] { display: none; }
.live-pill, .tracking-pill { height: 27px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: 30px; font-size: 10px; font-weight: 800; backdrop-filter: blur(12px); }
.live-pill { color: white; background: rgba(21, 34, 29, .75); letter-spacing: .12em; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: #ef6a58; animation: pulse 1.5s infinite; }
.tracking-pill { color: #173f31; background: rgba(245, 248, 240, .77); }
.tracking-pill.is-tracking { color: white; background: rgba(33, 91, 72, .78); }
@keyframes pulse { 50% { opacity: .38; transform: scale(.78); } }

.viewer-message { position: absolute; z-index: 15; left: 50%; bottom: 20px; translate: -50% 0; width: max-content; max-width: calc(100% - 40px); padding: 11px 16px; color: white; background: rgba(35, 42, 39, .88); border-radius: 5px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }

.viewer-actions { display: flex; align-items: center; gap: 9px; padding: 10px 0 0; }
.viewer-actions button { height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 0; cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.viewer-actions button:hover { transform: translateY(-1px); }
.viewer-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.primary-button { flex: 1; color: white; background: var(--green-dark); font-size: 14px; font-weight: 750; }
.primary-button:hover { background: #1b5140; }
.secondary-button { padding: 0 18px; color: var(--green-dark); border: 1px solid #cbd0c8 !important; background: #f7f6f1; font-size: 12px; font-weight: 700; }
.stop-button { width: 100%; color: #46534e; border: 1px solid #d5d7d1 !important; background: #f6f4ee; font-weight: 700; }

.control-panel { display: flex; flex-direction: column; padding: 27px 28px 24px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; }
.panel-head span { color: var(--green); font-size: 9px; font-weight: 850; letter-spacing: .18em; }
.panel-head h2 { margin: 5px 0 0; font-size: 23px; letter-spacing: -.05em; }
.panel-head .manifest-count { margin-top: 5px; padding: 6px 7px; color: #78827d; border: 1px solid #d8dad4; letter-spacing: .08em; }
.panel-description { margin: 7px 0 17px; color: #7d8581; font-size: 11px; }
.frame-list { display: grid; gap: 8px; }

.frame-card {
  width: 100%;
  min-height: 71px;
  display: grid;
  grid-template-columns: 82px 1fr 20px;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid #dedfd9;
  background: #f8f7f2;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.frame-card:hover { border-color: #9cac9f; transform: translateX(2px); }
.frame-card.is-active { border-color: #315e4d; background: #edf1e8; box-shadow: inset 3px 0 var(--green); }
.frame-copy { display: flex; flex-direction: column; gap: 4px; }
.frame-copy strong { font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.frame-copy small { color: #7b827e; font-size: 9px; }
.frame-check { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #ced2cb; }
.frame-check svg { width: 11px; fill: none; stroke: transparent; stroke-width: 2; }
.frame-card.is-active .frame-check { border-color: var(--green); background: var(--green); }
.frame-card.is-active .frame-check svg { stroke: white; }

.frame-swatch { position: relative; height: 46px; display: flex; align-items: center; justify-content: space-between; }
.frame-swatch i { width: 36px; height: 27px; border: 3px solid var(--frame-color); border-radius: 45%; opacity: .88; }
.frame-swatch b { position: absolute; left: 34px; top: 22px; width: 14px; border-top: 3px solid var(--frame-color); }
.frame-swatch--square i { border-radius: 5px; }
.frame-swatch--soft-square i { border-radius: 9px 9px 12px 12px; }

.measure-card { margin-top: 18px; padding-top: 17px; border-top: 1px solid #e0e1dc; }
.measure-head { display: flex; align-items: center; justify-content: space-between; }
.measure-head > span { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 750; }
.measure-head > span i { width: 7px; height: 7px; border-radius: 50%; background: #9ba79f; }
.measure-head strong { color: #858c88; font-size: 10px; }
.measure-head strong.is-pass { color: #277053; }
.measure-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 13px; }
.measure-grid div { padding-right: 8px; border-right: 1px solid #e2e2dd; }
.measure-grid div:not(:first-child) { padding-left: 10px; }
.measure-grid div:last-child { border: 0; }
.measure-grid span { display: block; margin-bottom: 6px; color: #8a908d; font-size: 8px; }
.measure-grid strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.quality-bar { height: 3px; margin-top: 13px; overflow: hidden; background: #e3e4de; }
.quality-bar span { display: block; width: 0; height: 100%; background: var(--green); transition: width 300ms ease; }
.measure-card p { margin: 8px 0 0; color: #8a918d; font-size: 8px; }

.session-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 17px; }
.session-row div { display: flex; flex-direction: column; gap: 3px; }
.session-row span { color: #969c99; font-size: 8px; letter-spacing: .08em; }
.session-row strong { color: var(--green); font-family: ui-monospace, monospace; font-size: 11px; }
.session-row button { height: 30px; display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid #d7d9d3; background: transparent; font-size: 9px; font-weight: 750; cursor: pointer; }
.session-row button:disabled { opacity: .4; cursor: not-allowed; }
.session-row svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.how-card {
  display: grid;
  grid-template-columns: 1fr 1px 1fr 1px 1fr;
  gap: 34px;
  margin-top: 20px;
  padding: 25px 35px;
  border: 1px solid rgba(30, 51, 42, .11);
  background: rgba(251, 250, 245, .66);
}
.how-card > i { width: 1px; background: #dbddd6; }
.how-card > div { display: flex; align-items: flex-start; gap: 15px; }
.how-index { color: var(--gold); font-family: Georgia, serif; font-size: 21px; font-style: italic; }
.how-card p { margin: 0; color: #7c8580; font-size: 10px; line-height: 1.7; }
.how-card strong { color: #34423c; font-size: 12px; }

footer {
  display: flex;
  justify-content: space-between;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 28px;
  border-top: 1px solid rgba(30, 51, 42, .12);
  color: #8a918d;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .13em;
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 24px; }
  .topbar-note { display: none; }
  .workspace { width: min(680px, calc(100% - 32px)); padding-top: 45px; }
  .intro { align-items: flex-start; gap: 25px; }
  .intro-copy br { display: none; }
  .studio-grid { grid-template-columns: 1fr; }
  .control-panel { min-height: 560px; }
  footer { width: calc(100% - 32px); }
}

@media (max-width: 600px) {
  .topbar { height: 64px; padding: 0 17px; }
  .brand { font-size: 15px; }
  .help-button { font-size: 10px; }
  .workspace { width: calc(100% - 20px); padding: 35px 0 50px; }
  .intro { display: block; margin-bottom: 24px; }
  .intro h1 { font-size: 42px; }
  .intro-copy { margin-top: 22px; font-size: 12px; }
  .viewer-card { padding: 7px; }
  .viewer { min-height: 0; }
  .viewer-empty { grid-template-columns: 1fr; padding: 24px; }
  .face-guide { width: 43%; min-width: 135px; }
  .empty-copy { padding: 14px 0 0; text-align: center; }
  .empty-copy::before { display: none; }
  .empty-copy h2 { margin: 7px 0 6px; font-size: 18px; }
  .empty-copy p { display: none; }
  .viewer-actions { flex-wrap: wrap; }
  .viewer-actions .primary-button { flex-basis: 100%; }
  .viewer-actions .secondary-button { width: 100%; }
  .control-panel { min-height: 550px; padding: 24px 20px 20px; }
  .how-card { grid-template-columns: 1fr; gap: 18px; padding: 24px; }
  .how-card > i { width: 100%; height: 1px; }
  footer { width: calc(100% - 24px); }
  footer span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
