:root {
  --ink: #173e40;
  --ink-soft: #587273;
  --teal: #176267;
  --teal-deep: #0d4d51;
  --blue: #6c8fb2;
  --paper: #f7f8f6;
  --line: rgba(24, 65, 67, .13);
  --white: #fff;
  --shadow: 0 22px 70px rgba(33, 70, 78, .14);
  --serif: Iowan Old Style, Baskerville, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); font-family: var(--sans); background: #edf3f5; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(44, 118, 124, .35); outline-offset: 3px; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.background { position: fixed; inset: 0; z-index: -2; background: linear-gradient(90deg, rgba(243,247,248,.78), rgba(249,248,245,.68)), url("assets/background.png") center 39% / cover no-repeat; }
.background::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 72% 20%, rgba(255,255,255,.76), transparent 34%), linear-gradient(180deg, rgba(255,255,255,.16), rgba(221,234,237,.38)); backdrop-filter: blur(1px); }

.app-shell { width: min(1440px, 100%); min-height: 100vh; margin: auto; padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 58px) max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.topbar { height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 30px; }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid rgba(23,62,64,.18); border-radius: 13px; background: rgba(255,255,255,.56); box-shadow: 0 8px 24px rgba(36,72,77,.08); }
.brand-mark svg { width: 28px; height: 28px; stroke-width: 1.3; }
.brand > span:last-child { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.brand strong { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; letter-spacing: -.04em; }
.brand em { font-family: var(--serif); font-size: .92rem; font-weight: 400; }

.progress { display: flex; align-items: center; gap: 11px; color: rgba(23,62,64,.43); font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.progress-item { display: flex; align-items: center; gap: 7px; transition: color .25s; }
.progress-item b { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid currentColor; border-radius: 50%; font-size: .66rem; }
.progress-item.is-active, .progress-item.is-complete { color: var(--teal); }
.progress-item.is-complete b { color: white; border-color: var(--teal); background: var(--teal); }
.progress i { width: 34px; height: 1px; background: currentColor; opacity: .35; }

.icon-button, .close-button { display: grid; place-items: center; border: 1px solid rgba(23,62,64,.13); background: rgba(255,255,255,.6); cursor: pointer; box-shadow: 0 10px 30px rgba(30,69,75,.08); backdrop-filter: blur(16px); }
.icon-button { justify-self: end; width: 43px; height: 43px; border-radius: 50%; }
.icon-button:hover, .close-button:hover { background: white; transform: translateY(-1px); }

.workspace { flex: 1; width: min(1080px, 100%); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; padding: 22px 0 14px; min-height: 0; }
.glass-card { border: 1px solid rgba(255,255,255,.72); border-radius: 28px; background: rgba(249,251,250,.68); box-shadow: var(--shadow); backdrop-filter: blur(26px) saturate(115%); }
.visual-panel { padding: clamp(18px, 2.3vw, 30px); display: flex; min-height: 610px; flex-direction: column; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.eyebrow { display: block; margin-bottom: 4px; color: #668184; font-size: .67rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: var(--serif); font-size: clamp(2rem, 3vw, 3rem); font-weight: 400; letter-spacing: -.045em; line-height: 1; }
h2 { font-family: var(--serif); font-size: 2rem; font-weight: 400; letter-spacing: -.035em; line-height: 1.05; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid rgba(26,77,79,.1); border-radius: 99px; background: rgba(255,255,255,.6); color: #6b8585; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #a6b3b1; }
.live-pill.is-live i { background: #4aa17b; box-shadow: 0 0 0 4px rgba(74,161,123,.13); }

.camera-frame { position: relative; flex: 1; min-height: 390px; overflow: hidden; border-radius: 19px; background: #dbe3e2; box-shadow: inset 0 0 0 1px rgba(255,255,255,.7); }
.camera-frame video, .camera-frame > img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.camera-frame > img { display: none; }
.camera-frame.has-photo > img { display: block; }
.camera-frame.has-photo video, .camera-frame.has-photo .camera-placeholder { display: none; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #567072; text-align: center; background: linear-gradient(145deg, rgba(216,229,230,.93), rgba(236,240,237,.93)); }
.camera-placeholder small { max-width: 300px; color: #779091; }
.placeholder-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 5px; border-radius: 50%; color: var(--teal); background: rgba(255,255,255,.68); box-shadow: 0 12px 28px rgba(42,84,87,.12); }
.placeholder-icon svg { width: 27px; height: 27px; }
.frame-corners { position: absolute; inset: 16px; border: 1px solid rgba(255,255,255,.4); border-radius: 12px; pointer-events: none; mask: linear-gradient(#000 0 0) top left / 45px 1px no-repeat, linear-gradient(#000 0 0) top left / 1px 45px no-repeat, linear-gradient(#000 0 0) top right / 45px 1px no-repeat, linear-gradient(#000 0 0) top right / 1px 45px no-repeat, linear-gradient(#000 0 0) bottom left / 45px 1px no-repeat, linear-gradient(#000 0 0) bottom left / 1px 45px no-repeat, linear-gradient(#000 0 0) bottom right / 45px 1px no-repeat, linear-gradient(#000 0 0) bottom right / 1px 45px no-repeat; background: white; }
.retake-button { position: absolute; right: 18px; bottom: 18px; display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.7); border-radius: 99px; color: white; background: rgba(15,52,55,.65); backdrop-filter: blur(10px); cursor: pointer; }
.retake-button[hidden] { display: none; }
.retake-button svg { width: 17px; }

.action-dock { position: relative; z-index: 2; width: min(560px, 92%); margin: -27px auto 0; padding: 6px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; border: 1px solid rgba(255,255,255,.7); border-radius: 99px; background: rgba(247,250,249,.76); box-shadow: 0 14px 42px rgba(23,65,70,.18); backdrop-filter: blur(24px); }
.dock-action { min-width: 0; padding: 9px 8px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 99px; color: #658082; background: transparent; cursor: pointer; transition: .22s ease; }
.dock-action span { font-size: .73rem; font-weight: 750; }
.dock-action svg { width: 19px; height: 19px; }
.dock-action:hover { color: var(--ink); background: rgba(255,255,255,.55); }
.dock-action.is-active { color: white; background: var(--teal); box-shadow: 0 7px 17px rgba(23,98,103,.25); }

.selection-panel { padding: clamp(22px, 2.8vw, 34px); display: flex; flex-direction: column; }
.composition-popup { position: relative; width: min(540px, calc(100% - 34px)); min-height: min(650px, calc(100vh - 34px)); max-height: calc(100vh - 34px); overflow: auto; border: 1px solid rgba(255,255,255,.82); border-radius: 26px; background: rgba(247,249,247,.98); box-shadow: 0 28px 90px rgba(9,45,48,.25); }
.composition-popup .selection-intro { padding-right: 54px; }
.composition-popup .fusion-area { margin-top: 32px; }
.selection-intro { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.selection-intro h2 { margin: 0 0 11px; font-size: clamp(1.7rem, 2.4vw, 2.25rem); }
.selection-intro p { margin-bottom: 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.55; }
.selection-list { display: grid; gap: 12px; padding: 22px 0; }
.selection-card { position: relative; width: 100%; min-width: 0; padding: 12px 34px 12px 0; display: grid; grid-template-columns: 26px 66px 1fr; align-items: center; gap: 11px; border: 0; border-bottom: 1px solid var(--line); text-align: left; background: transparent; cursor: pointer; }
.selection-card:hover .selection-thumb { transform: scale(1.025); }
.selection-number { align-self: start; padding-top: 4px; color: #91a3a4; font-size: .65rem; font-weight: 800; }
.selection-thumb { width: 66px; height: 66px; overflow: hidden; display: grid; place-items: center; border-radius: 12px; background: #e2e8e6; transition: transform .2s; }
.selection-thumb img { width: 100%; height: 100%; object-fit: cover; }
.selection-thumb.placeholder { color: #72898a; }
.selection-thumb.placeholder svg { width: 26px; height: 26px; }
.selection-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.selection-copy small { color: #759092; font-size: .61rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.selection-copy strong { overflow: hidden; color: var(--ink); font-family: var(--serif); font-size: 1.05rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.selection-copy em { overflow: hidden; color: #819395; font-size: .68rem; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.chevron { position: absolute; right: 3px; width: 18px; color: #819496; }
.fusion-area { margin-top: auto; }
.fusion-note { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; color: #758a8b; font-size: .72rem; line-height: 1.45; }
.fusion-note svg { flex: 0 0 auto; width: 17px; color: #9670a0; }
.fusion-note.is-ready { color: var(--teal); }
.fusion-button { width: 100%; padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 14px; color: white; background: linear-gradient(135deg, var(--teal), var(--teal-deep)); box-shadow: 0 14px 28px rgba(16,84,88,.24); cursor: pointer; transition: .2s; }
.fusion-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(16,84,88,.3); }
.fusion-button:disabled { color: #819092; background: #dbe2e1; box-shadow: none; cursor: not-allowed; }
.fusion-button span { font-weight: 750; }

.utility-bar { min-height: 38px; display: flex; align-items: center; justify-content: space-between; color: rgba(23,62,64,.57); font-size: .67rem; }
.utility-bar button { display: inline-flex; align-items: center; gap: 6px; border: 0; color: inherit; background: none; cursor: pointer; }
.utility-bar button:hover { color: var(--teal); }
.utility-bar svg { width: 16px; }
.utility-actions { display: flex; align-items: center; gap: 10px; }
.utility-bar .utility-help { width: 30px; height: 30px; justify-content: center; padding: 0; border: 1px solid rgba(23,62,64,.16); border-radius: 50%; background: rgba(255,255,255,.42); transition: .2s ease; }
.utility-bar .utility-help:hover { border-color: rgba(23,98,103,.3); background: rgba(255,255,255,.8); transform: translateY(-1px); }
.utility-bar .utility-help svg { width: 17px; height: 17px; }

.modal { width: 100%; max-width: none; height: 100%; max-height: none; padding: 0; border: 0; color: var(--ink); background: transparent; }
.modal::backdrop { background: rgba(14,43,47,.38); backdrop-filter: blur(13px); }
.modal[open] { display: grid; place-items: center; animation: fade-in .2s both; }
.modal-shell { width: min(1040px, calc(100% - 34px)); max-height: min(780px, calc(100vh - 34px)); overflow: auto; padding: 28px; border: 1px solid rgba(255,255,255,.8); border-radius: 26px; background: rgba(247,249,247,.96); box-shadow: 0 28px 90px rgba(9,45,48,.25); }
.modal-header { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: start; margin-bottom: 24px; }
.modal-header h2 { margin: 0; }
.close-button { width: 41px; height: 41px; border-radius: 50%; transition: .2s; }
.close-button.floating { position: absolute; top: 22px; right: 22px; }
.back-button { position: absolute; top: 52px; left: 0; display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: #718787; background: transparent; cursor: pointer; }
.back-button[hidden] { display: none; }
.catalog-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.catalog-card { overflow: hidden; padding: 0; border: 1px solid rgba(25,65,67,.09); border-radius: 16px; text-align: left; background: white; box-shadow: 0 8px 22px rgba(24,61,66,.07); cursor: pointer; transition: .2s; }
.catalog-card:hover { transform: translateY(-4px); box-shadow: 0 15px 30px rgba(24,61,66,.13); }
.catalog-card-image { position: relative; height: 145px; overflow: hidden; display: block; background: #e5eae8; }
.catalog-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.catalog-card:hover img { transform: scale(1.035); }
.catalog-card-copy { padding: 13px 14px 15px; display: block; }
.catalog-card-copy strong { display: block; min-height: 2.4em; font-family: var(--serif); font-size: 1rem; line-height: 1.18; }
.catalog-card-copy small { display: block; margin-top: 5px; color: #7b8d8e; font-size: .67rem; }
.catalog-card.is-selected { box-shadow: 0 0 0 3px var(--teal); }

.modal-shell.compact { position: relative; width: min(560px, calc(100% - 34px)); padding: 40px; }
.modal-symbol { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 22px; border-radius: 15px; color: #805c8b; background: #ede5ef; }
.modal-symbol svg { width: 27px; height: 27px; }
.compact h2 { font-size: 2.5rem; margin-bottom: 24px; }
.help-steps { margin: 0 0 27px; padding: 0; display: grid; gap: 15px; list-style: none; }
.help-steps li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; color: #6a8182; font-size: .82rem; line-height: 1.4; }
.help-steps li > b { color: #9aa9aa; font-size: .65rem; letter-spacing: .08em; }
.help-steps span { display: flex; flex-direction: column; }
.help-steps strong { margin-bottom: 2px; color: var(--ink); font-size: .91rem; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 17px; border: 0; border-radius: 13px; color: white; font-weight: 750; background: var(--teal); cursor: pointer; }
.primary-button:hover { background: var(--teal-deep); }
.media-shell { width: min(980px, calc(100% - 34px)); }
.media-shell video { display: block; width: 100%; max-height: 65vh; border-radius: 16px; background: #101818; }
.result-shell { width: min(1120px, calc(100% - 34px)); }
.result-shell canvas { display: block; width: 100%; height: auto; border-radius: 17px; background: #dce6e5; box-shadow: 0 14px 38px rgba(17,59,62,.12); }
.result-footer { padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.result-footer p { margin: 0; display: flex; flex-direction: column; }
.result-footer p span { margin-top: 4px; color: #748989; font-size: .75rem; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 99px; color: white; font-size: .78rem; background: rgba(14,56,59,.9); box-shadow: 0 10px 30px rgba(15,50,53,.22); transform: translate(-50%, 130%); opacity: 0; transition: .25s; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .progress { display: none; }
  .visual-panel { min-height: 600px; }
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .app-shell { padding-inline: 12px; }
  .brand > span:last-child { display: none; }
  .workspace { padding-top: 10px; gap: 13px; }
  .glass-card { border-radius: 21px; }
  .visual-panel { min-height: 550px; padding: 15px; }
  .section-heading { margin: 4px 3px 14px; }
  .section-heading h1 { font-size: 2rem; }
  .camera-frame { min-height: 370px; }
  .action-dock { width: 96%; }
  .dock-action { flex-direction: column; gap: 2px; padding: 7px 4px; }
  .dock-action span { font-size: .62rem; }
  .selection-panel { padding: 22px 18px; }
  .composition-popup { width: calc(100% - 18px); min-height: auto; max-height: calc(100vh - 18px); padding: 28px 20px 22px; border-radius: 20px; }
  .utility-bar > span { display: none; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .catalog-card-image { height: 120px; }
  .modal-shell { width: calc(100% - 18px); max-height: calc(100vh - 18px); padding: 20px; border-radius: 20px; }
  .back-button { position: static; grid-row: 2; margin-top: 13px; }
  .result-footer { align-items: stretch; flex-direction: column; }
  .result-footer .primary-button { width: 100%; }
}

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