* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #0d0f13; }
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #0d0f13; }
button, input, select { font: inherit; }
button { border: 0; }
#webcam-video { position: absolute; inset: 0; width: 100vw; height: 100vh; object-fit: cover; z-index: 1; transform: scaleX(-1); background: #0d0f13; }
canvas { position: absolute; inset: 0; width: 100vw; height: 100vh; z-index: 2; pointer-events: none; }
#ui-overlay { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: center; align-items: center; padding: 24px; background: rgba(6, 8, 12, 0.88); backdrop-filter: blur(16px); transition: opacity 0.45s ease; }
.modal { width: min(460px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,0.08); border-radius: 22px; color: white; text-align: center; background: rgba(27, 30, 37, 0.96); box-shadow: 0 24px 80px rgba(0,0,0,0.45); }
.modal h1 { margin: 8px 0 10px; font-size: clamp(28px, 5vw, 38px); letter-spacing: -0.03em; }
.modal > p:not(.eyebrow) { margin: 0 0 26px; color: #aeb6c4; font-size: 14px; line-height: 1.6; }
.eyebrow { margin: 0; color: #55d8ff; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
#start-button, .primary-button { padding: 13px 20px; border-radius: 12px; color: #071018; background: #55d8ff; cursor: pointer; font-weight: 800; box-shadow: 0 8px 24px rgba(85,216,255,0.18); }
#start-button:hover, .primary-button:hover { filter: brightness(1.06); }
#start-button:disabled, .primary-button:disabled { cursor: wait; opacity: 0.65; }
#loading-indicator { display: none; margin-top: 18px; color: #55d8ff; font-size: 13px; font-weight: 700; }
#error-message { display: none; margin-top: 18px; color: #ff7777; font-size: 13px; line-height: 1.45; }
.status-chip { position: fixed; top: 16px; left: 50%; z-index: 8; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); padding: 8px 13px; border: 1px solid rgba(255,255,255,0.10); border-radius: 999px; color: #eef4fb; background: rgba(16, 20, 27, 0.78); backdrop-filter: blur(12px); font-size: 12px; font-weight: 700; text-align: center; pointer-events: none; }
.status-chip[data-state="ready"] { border-color: rgba(92, 230, 157, 0.34); }
.status-chip[data-state="loading"] { border-color: rgba(85,216,255,0.34); }
.status-chip[data-state="error"] { border-color: rgba(255,119,119,0.45); color: #ffd1d1; }
.control-panel[hidden], .profile-modal[hidden], .profile-results[hidden], .fit-result-card[hidden] { display: none !important; }
.control-panel { position: fixed; top: 56px; left: 16px; z-index: 7; width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 72px); overflow: auto; border: 1px solid rgba(255,255,255,0.10); border-radius: 18px; color: #eff4fa; background: rgba(14, 18, 24, 0.82); backdrop-filter: blur(18px); box-shadow: 0 16px 50px rgba(0,0,0,0.28); }
.control-brand, .control-section { padding: 14px 16px; }
.control-brand { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.control-brand strong { font-size: 15px; }
.control-brand span, .control-section small { color: #8d98a8; font-size: 11px; line-height: 1.45; }
.control-section + .control-section { border-top: 1px solid rgba(255,255,255,0.07); }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.control-row > div { min-width: 0; }
.control-row small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.control-label { display: block; margin-bottom: 7px; color: #dbe4ef; font-size: 12px; font-weight: 750; }
.compact-button, .secondary-button, .text-button { cursor: pointer; transition: 0.2s ease; }
.compact-button, .secondary-button { border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; color: #eff4fa; background: rgba(255,255,255,0.06); }
.compact-button { flex: 0 0 auto; padding: 8px 10px; font-size: 11px; font-weight: 750; }
.secondary-button { padding: 10px 12px; font-size: 12px; font-weight: 700; }
.compact-button:hover, .secondary-button:hover { background: rgba(255,255,255,0.11); }
.text-button { padding: 9px 6px; color: #aeb7c6; background: transparent; font-size: 12px; }
.text-button:hover { color: white; }
#garment-color { width: 100%; height: 34px; padding: 2px; border: 1px solid rgba(255,255,255,0.12); border-radius: 9px; background: transparent; cursor: pointer; }
#reset-garment { width: 100%; margin-top: 10px; }
.profile-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; }
.profile-backdrop { position: absolute; inset: 0; background: rgba(3,5,8,0.76); backdrop-filter: blur(14px); }
.profile-card { position: relative; z-index: 1; width: min(780px, 100%); max-height: min(900px, calc(100vh - 40px)); overflow: auto; padding: 30px; border: 1px solid rgba(255,255,255,0.10); border-radius: 22px; color: #edf3fa; background: #171b22; box-shadow: 0 28px 90px rgba(0,0,0,0.54); }
.profile-card.wide-card { width: min(1020px, 100%); }
.close-button { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; color: #d8e0ea; background: rgba(255,255,255,0.07); cursor: pointer; font-size: 24px; line-height: 1; }
.profile-heading { padding-right: 36px; }
.profile-heading h2 { margin: 7px 0 9px; font-size: clamp(24px, 4vw, 32px); letter-spacing: -0.03em; }
.profile-heading > p:not(.eyebrow) { max-width: 780px; margin: 0; color: #aab4c2; font-size: 13px; line-height: 1.6; }
.profile-form-grid, .garment-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.profile-form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full-field { grid-column: 1 / -1; }
.field > span, .capture-card strong { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.field small { display: block; margin-top: 6px; color: #8995a5; font-size: 11px; line-height: 1.45; }
.input-with-unit { display: flex; align-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; background: #0f1319; }
.input-with-unit input { flex: 1; min-width: 0; padding: 12px 13px; border: 0; outline: none; color: white; background: transparent; }
.input-with-unit span { padding: 0 13px; color: #8995a5; font-size: 12px; }
.field select, .field > input[type="file"], #front-photo, #side-photo, #back-photo { display: block; width: 100%; margin: 8px 0 0; padding: 10px 11px; border: 1px solid rgba(255,255,255,0.11); border-radius: 10px; color: #dce5ef; background: #0f1319; font-size: 12px; }
.capture-card { display: flex; flex-direction: column; gap: 7px; padding: 15px; border: 1px solid rgba(255,255,255,0.08); border-radius: 15px; background: rgba(255,255,255,0.025); }
.capture-card p { margin: 0; color: #8f9aaa; font-size: 11px; line-height: 1.5; }
.capture-card small { color: #74d9f7; font-size: 11px; line-height: 1.4; }
.profile-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.profile-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.measurement { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid rgba(255,255,255,0.07); border-radius: 11px; background: rgba(255,255,255,0.03); font-size: 12px; }
.measurement span { color: #9ba6b5; }
.measurement strong { color: #edf6fb; }
.profile-warning { grid-column: 1 / -1; margin: 4px 0 0; padding: 10px 12px; border-radius: 11px; color: #ffdca1; background: rgba(255, 183, 77, 0.08); font-size: 11px; line-height: 1.5; }
.accuracy-note { margin-top: 18px; padding: 12px 14px; border-left: 3px solid #55d8ff; border-radius: 8px; color: #9ba6b5; background: rgba(85,216,255,0.06); font-size: 11px; line-height: 1.55; }
.accuracy-note strong { color: #eaf6ff; }

.scan-stage { margin-top: 20px; padding: 14px; border: 1px solid rgba(85,216,255,0.15); border-radius: 16px; background: linear-gradient(180deg, rgba(85,216,255,0.05), rgba(255,255,255,0.015)); overflow: hidden; }
.scan-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 11px; }
.scan-stage-head span { color: #55d8ff; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; }
.scan-stage-head strong { color: #aeb8c6; font-size: 11px; text-align: right; }
.scan-progress { height: 4px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,0.07); }
.scan-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #55d8ff, #6ef0be); transition: width 0.35s ease; }
.scan-grid { display: grid; gap: 10px; margin-top: 12px; }
.scan-grid.three-views { grid-template-columns: repeat(3, 1fr); }
.scan-preview { position: relative; height: 126px; overflow: hidden; border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; background: radial-gradient(circle at 50% 50%, rgba(85,216,255,0.08), transparent 70%), #0e1218; }
.scan-preview > span { position: absolute; top: 8px; left: 9px; z-index: 3; color: #8995a5; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.silhouette-guide { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: 46px; height: 92px; border: 1px solid rgba(85,216,255,0.35); border-radius: 42% 42% 32% 32% / 26% 26% 55% 55%; opacity: 0.65; }
.side-guide { width: 27px; border-radius: 45% 55% 42% 45% / 26% 25% 56% 56%; }
.back-guide { border-style: dashed; }
.scan-line { position: absolute; z-index: 4; left: 0; right: 0; top: -8px; height: 2px; opacity: 0; background: #55d8ff; box-shadow: 0 0 18px 5px rgba(85,216,255,0.32); }
.is-scanning .scan-line { opacity: 1; animation: scanSweep 1.45s linear infinite; }
.scan-complete { border-color: rgba(92,230,157,0.32); }
.scan-error { border-color: rgba(255,119,119,0.42); }
@keyframes scanSweep { 0% { top: 5%; } 100% { top: 95%; } }
.garment-scan-visual { position: relative; height: 165px; margin-top: 12px; overflow: hidden; border-radius: 12px; background: radial-gradient(circle, rgba(85,216,255,0.07), transparent 68%), #0e1218; }
.garment-outline-guide { position: absolute; left: 50%; top: 18px; width: 126px; height: 130px; transform: translateX(-50%); clip-path: polygon(28% 0, 39% 8%, 61% 8%, 72% 0, 100% 22%, 86% 44%, 73% 35%, 70% 100%, 30% 100%, 27% 35%, 14% 44%, 0 22%); border: 1px solid rgba(85,216,255,0.3); background: rgba(85,216,255,0.04); }
.measurement-beam { position: absolute; opacity: 0.5; background: rgba(110,240,190,0.8); }
.measurement-beam.horizontal { left: 22%; right: 22%; top: 55%; height: 1px; }
.measurement-beam.vertical { top: 15%; bottom: 13%; left: 50%; width: 1px; }

.result-layout { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 14px; margin-top: 16px; }
.result-layout .profile-results { margin-top: 0; align-content: start; }
.avatar-panel { min-height: 260px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; background: radial-gradient(circle at 50% 45%, rgba(85,216,255,0.11), transparent 60%), #0f1319; }
.avatar-panel-head { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; color: #dfe9f2; font-size: 11px; font-weight: 800; }
.avatar-panel-head small { color: #7f8b9b; font-weight: 600; }
.avatar-preview { position: relative; min-height: 220px; }
.avatar-preview canvas { position: static; width: 100% !important; height: 220px !important; }
.avatar-preview p { display: grid; place-items: center; min-height: 220px; margin: 0; color: #7f8b9b; font-size: 11px; }
.fit-summary { padding: 10px 11px; border-radius: 10px; background: rgba(255,255,255,0.035); color: #dce5ee; font-size: 11px; line-height: 1.45; }
.fit-summary.empty-state { color: #7f8b9b; }
.fit-result-card { margin-top: 14px; padding: 14px; border: 1px solid rgba(110,240,190,0.18); border-radius: 13px; background: rgba(110,240,190,0.055); }
.fit-result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fit-badge { padding: 6px 9px; border-radius: 999px; color: #07150f; background: #6ef0be; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.fit-score { color: #dffcf0; font-size: 18px; font-weight: 900; }
.fit-result-card ul { margin: 12px 0 0; padding-left: 18px; color: #9eaaB7; font-size: 11px; line-height: 1.55; }

@media (max-width: 820px) {
    .status-chip { top: 10px; }
    .control-panel { top: auto; bottom: 12px; left: 12px; width: calc(100vw - 24px); max-height: 42vh; }
    .profile-card { max-height: calc(100vh - 20px); padding: 24px 18px; border-radius: 18px; }
    .profile-form-grid, .garment-form-grid, .profile-results, .profile-form-grid.three-columns, .result-layout { grid-template-columns: 1fr; }
    .full-field, .profile-warning { grid-column: 1; }
    .profile-actions { align-items: stretch; flex-direction: column; }
    .primary-button, .text-button { width: 100%; }
    .scan-grid.three-views { grid-template-columns: repeat(3, minmax(90px,1fr)); overflow-x: auto; }
    .scan-preview { min-width: 90px; }
}
