:root {
  --brand: #0099bb;
  --brand-deep: #00758f;
  --orange: #ff6b35;
  --ink: #1c1c1e;
  --muted: #636366;
  --line: #e5e5ea;
  --soft: #f5f5f7;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(18, 41, 47, 0.12);
  font-family: "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--white);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100%; background: var(--white); }
html[lang="zh-Hans"] { font-family: "Noto Sans SC", sans-serif; }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.setup-view {
  min-height: 100vh;
  background:
    radial-gradient(circle at 5% 15%, rgba(0,153,187,.08), transparent 22rem),
    linear-gradient(180deg, #fff 0%, #fff 64%, #f7fbfc 100%);
  overflow: hidden;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  height: 88px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(229,229,234,.8);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; font: 800 18px/1 "JetBrains Mono", monospace; background: var(--brand); border-radius: 11px 3px 11px 3px; box-shadow: 0 8px 20px rgba(0,153,187,.22); }
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font: 600 9px/1.2 "JetBrains Mono", monospace; letter-spacing: .15em; }
.privacy-pill { display: flex; align-items: center; gap: 8px; padding: 9px 13px; color: var(--muted); background: var(--soft); border-radius: 999px; font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #28a745; box-shadow: 0 0 0 4px rgba(40,167,69,.12); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.language-picker { position: relative; }
.language-picker::after { content: "⌄"; position: absolute; right: 11px; top: 50%; transform: translateY(-55%); color: var(--brand-deep); pointer-events: none; font-size: 12px; }
.language-picker select { min-height: 36px; padding: 0 30px 0 12px; appearance: none; color: var(--brand-deep); background: #fff; border: 1px solid var(--line); border-radius: 999px; outline: none; font-size: 12px; font-weight: 700; cursor: pointer; }
.language-picker select:focus-visible { border-color: var(--brand-deep); box-shadow: 0 0 0 3px rgba(0,112,138,.12); }

.hero { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 76px 0 92px; display: grid; grid-template-columns: 1fr 500px; gap: 9vw; align-items: center; }
.hero-copy { position: relative; }
.hero-copy::after { content: ""; position: absolute; left: -54px; top: 80px; width: 5px; height: 118px; background: linear-gradient(var(--brand), var(--orange)); border-radius: 10px; }
.eyebrow, .section-kicker { margin: 0 0 18px; color: var(--brand-deep); font: 600 12px/1.2 "JetBrains Mono", monospace; letter-spacing: .17em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(47px, 5.2vw, 76px); line-height: 1.08; letter-spacing: -.055em; }
.hero h1 em { color: var(--brand); font-style: normal; }
.hero-lead { max-width: 540px; margin: 28px 0 0; color: var(--muted); font-size: 18px; line-height: 1.85; }
.feature-strip { display: flex; gap: 18px; margin-top: 44px; }
.feature-strip span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.feature-strip b { color: var(--brand); font: 600 11px/1 "JetBrains Mono", monospace; }

.script-card { position: relative; padding: 34px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 26px 7px 26px 7px; box-shadow: var(--shadow); }
.script-card::before { content: ""; position: absolute; inset: 12px -12px -12px 12px; z-index: -1; border: 1px solid rgba(0,153,187,.18); border-radius: 26px 7px 26px 7px; }
.card-heading, .settings-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.step-tag { display: inline-block; color: var(--brand-deep); font: 600 10px/1 "JetBrains Mono", monospace; letter-spacing: .14em; }
.card-heading h2, .settings-heading h2 { margin: 7px 0 0; font-size: 24px; letter-spacing: -.03em; }
.text-button { padding: 5px; color: var(--muted); background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; }
#scriptInput { width: 100%; min-height: 260px; margin-top: 24px; padding: 20px; resize: vertical; color: var(--ink); background: var(--soft); border: 1px solid transparent; border-radius: 14px 4px 14px 4px; outline: none; font-size: 16px; line-height: 1.8; transition: .2s ease; }
#scriptInput:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,153,187,.09); }
.script-meta { display: flex; justify-content: space-between; margin: 10px 3px 20px; color: var(--muted); font: 500 11px/1.3 "JetBrains Mono", monospace; }
.primary-button, .secondary-button { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 14px; border-radius: 12px 3px 12px 3px; font-weight: 700; text-decoration: none; border: 0; }
.primary-button { width: 100%; padding: 0 20px; color: #fff; background: var(--brand); box-shadow: 0 12px 24px rgba(0,153,187,.2); }
.primary-button:hover { background: var(--brand-deep); transform: translateY(-1px); }
.primary-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; }
.secondary-button { padding: 0 20px; color: var(--ink); background: #fff; border: 1px solid var(--line); }
.secondary-button.full { width: 100%; }
.permission-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.how-it-works { padding: 90px max(20px, calc((100vw - 1180px)/2)); background: var(--soft); }
.how-it-works > h2 { margin: 0 0 42px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.045em; }
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.steps-grid article { position: relative; min-height: 190px; padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 18px 5px 18px 5px; overflow: hidden; }
.steps-grid article > span { position: absolute; right: 18px; top: 8px; color: rgba(0,153,187,.1); font: 600 70px/1 "JetBrains Mono", monospace; }
.steps-grid h3 { position: relative; margin: 35px 0 12px; font-size: 20px; }
.steps-grid p { position: relative; margin: 0; color: var(--muted); line-height: 1.75; }

.studio-view { position: fixed; inset: 0; z-index: 10; min-height: 100dvh; overflow: hidden; background: #111; color: #fff; }
#cameraPreview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #111; transform: scaleX(-1) scale(var(--camera-zoom, 1)); transform-origin: center; transition: transform .18s ease; }
#cameraPreview.unmirrored { transform: scale(var(--camera-zoom, 1)); }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 30px; text-align: center; color: #fff; background: radial-gradient(circle at center, #23323a 0%, #0b0f12 70%); }
.camera-placeholder[hidden] { display: none; }
.placeholder-icon { width: 66px; height: 66px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; font-size: 32px; }
.camera-placeholder h2 { margin: 20px 0 8px; }
.camera-placeholder p { max-width: 350px; margin: 0 0 20px; color: rgba(255,255,255,.65); }
.studio-topbar { position: absolute; z-index: 4; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 20px 18px; background: linear-gradient(rgba(0,0,0,.62), transparent); }
.round-button, .close-button { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: rgba(12,16,18,.56); border: 1px solid rgba(255,255,255,.18); border-radius: 50%; backdrop-filter: blur(12px); }
.round-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; }
.round-button.active { color: #72e7ff; border-color: rgba(114,231,255,.6); }
.round-button.zoom-reset { font: 700 12px/1 "JetBrains Mono", monospace; }
.top-actions { display: flex; gap: 10px; }
.record-status { min-width: 128px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; background: rgba(12,16,18,.56); border: 1px solid rgba(255,255,255,.15); border-radius: 999px; backdrop-filter: blur(12px); }
.record-status > span { width: 8px; height: 8px; background: #aaa; border-radius: 50%; }
.record-status b { font-size: 12px; }
.record-status time { color: rgba(255,255,255,.7); font: 500 12px/1 "JetBrains Mono", monospace; }
.record-status.recording > span { background: #ff3b30; animation: blink 1.1s infinite; }
.record-status.recording b { color: #ff8c85; }
@keyframes blink { 50% { opacity: .25; } }

.prompter-panel { position: absolute; z-index: 3; left: 50%; top: 16%; width: min(680px, calc(100vw - 36px)); height: min(320px, 40vh); min-width: 280px; min-height: 160px; transform: translateX(-50%); color: #fff; background: rgba(6,9,11,.7); border: 1px solid rgba(255,255,255,.19); border-radius: 18px 5px 18px 5px; box-shadow: 0 24px 80px rgba(0,0,0,.35); backdrop-filter: blur(8px); resize: both; overflow: hidden; touch-action: none; }
.drag-handle { position: absolute; z-index: 2; left: 8px; top: 8px; width: 38px; height: 38px; display: grid; place-items: center; color: rgba(255,255,255,.75); background: rgba(255,255,255,.08); border: 0; border-radius: 50%; cursor: move; touch-action: none; }
.drag-handle svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.prompter-label { position: absolute; z-index: 2; top: 14px; left: 54px; right: 16px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.prompter-label span { padding: 5px 8px; color: #fff; background: var(--brand); border-radius: 5px; font-size: 10px; font-weight: 700; }
.prompter-label small { color: rgba(255,255,255,.58); font-size: 10px; }
.chapter-nav { position: absolute; z-index: 3; top: 47px; left: 50%; max-width: calc(100% - 80px); display: flex; gap: 6px; overflow-x: auto; transform: translateX(-50%); scrollbar-width: none; }
.chapter-nav::-webkit-scrollbar { display: none; }
.chapter-nav button { flex: 0 0 auto; width: 25px; height: 25px; padding: 0; color: rgba(255,255,255,.72); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); border-radius: 50%; font: 600 10px/1 "JetBrains Mono", monospace; }
.chapter-nav button.active { color: #061014; background: #72e7ff; }
.prompter-viewport { position: absolute; inset: 0; overflow-y: auto; padding: 82px 46px 70px; scroll-behavior: smooth; mask-image: linear-gradient(transparent 0%, #000 12%, #000 84%, transparent 100%); scrollbar-width: none; }
.prompter-viewport::-webkit-scrollbar { display: none; }
.prompter-text { white-space: pre-wrap; font-size: 32px; font-weight: 700; line-height: 1.65; letter-spacing: .02em; }
.script-section { margin: 0 0 1.05em; }
.resize-hint { position: absolute; right: 5px; bottom: 5px; width: 17px; height: 17px; border-right: 2px solid rgba(255,255,255,.55); border-bottom: 2px solid rgba(255,255,255,.55); pointer-events: none; }

.studio-controls { position: absolute; z-index: 4; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: 90px 82px 90px; align-items: center; gap: 22px; padding: 12px 20px; background: rgba(9,12,14,.68); border: 1px solid rgba(255,255,255,.16); border-radius: 26px 8px 26px 8px; backdrop-filter: blur(16px); }
.control-button { display: grid; justify-items: center; gap: 6px; color: #fff; background: none; border: 0; font-size: 11px; }
.control-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.control-button.active { color: #72e7ff; }
.record-button { width: 72px; height: 72px; padding: 6px; background: transparent; border: 3px solid #fff; border-radius: 50%; }
.record-button span { width: 100%; height: 100%; display: block; background: #ff3b30; border-radius: 50%; transition: .2s; }
.record-button.recording span { width: 28px; height: 28px; margin: 13px; border-radius: 6px; }
.pause-recording { position: absolute; z-index: 5; left: 50%; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 116px); transform: translateX(-50%); padding: 9px 15px; color: #fff; background: rgba(9,12,14,.72); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; backdrop-filter: blur(12px); font-size: 12px; font-weight: 700; }

.quick-edit-panel { position: absolute; z-index: 8; inset: 50% auto auto 50%; width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 64px); padding: 26px; transform: translate(-50%, -50%); color: var(--ink); background: rgba(255,255,255,.98); border: 1px solid var(--line); border-radius: 22px 6px 22px 6px; box-shadow: 0 24px 100px rgba(0,0,0,.5); }
#quickEditInput { width: 100%; min-height: min(46vh, 430px); margin: 20px 0 14px; padding: 18px; resize: vertical; color: var(--ink); background: var(--soft); border: 1px solid var(--line); border-radius: 12px 4px 12px 4px; outline: none; line-height: 1.8; }
#quickEditInput:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,153,187,.09); }

.settings-panel { position: absolute; z-index: 7; right: 22px; bottom: 22px; width: min(390px, calc(100vw - 32px)); max-height: calc(100dvh - 44px); overflow-y: auto; padding: 26px; color: var(--ink); background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 22px 6px 22px 6px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.settings-heading h2 { font-size: 21px; }
.close-button { color: var(--ink); background: var(--soft); border-color: var(--line); font-size: 24px; }
.color-setting { margin: 24px 0; padding: 0; border: 0; }
.color-setting legend { margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.color-setting input { position: absolute; opacity: 0; pointer-events: none; }
.range-setting { margin: 20px 0; }
.range-setting label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.range-setting output { color: var(--ink); font-family: "JetBrains Mono", monospace; }
.range-setting input { width: 100%; accent-color: var(--brand); }
.range-ends { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; color: #8e8e93; font-size: 10px; }
.range-ends span:nth-child(2):not(:last-child) { color: var(--brand-deep); text-align: center; }
.camera-zoom-setting { padding: 14px; background: rgba(0,153,187,.07); border: 1px solid rgba(0,153,187,.14); border-radius: 12px 4px 12px 4px; }
.color-setting { display: flex; gap: 12px; align-items: center; }
.color-setting legend { width: 100%; }
.color-dot { position: relative; width: 34px; height: 34px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; font-size: 0; }
.color-dot::after { content: ""; position: absolute; inset: 4px; background: #fff; border: 1px solid #ccc; border-radius: 50%; }
.color-dot.yellow::after { background: #ffe66d; border: 0; }
.color-dot.cyan::after { background: #72e7ff; border: 0; }
.color-dot.green::after { background: #9cffb5; border: 0; }
.color-dot:has(input:checked) { border-color: var(--brand); }

.countdown { position: absolute; z-index: 9; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.48); backdrop-filter: blur(4px); }
.countdown span { font: 700 clamp(100px, 25vw, 220px)/1 "JetBrains Mono", monospace; text-shadow: 0 12px 50px rgba(0,0,0,.5); animation: count .8s ease both; }
@keyframes count { from { opacity: 0; transform: scale(1.5); } to { opacity: 1; transform: scale(1); } }

.result-view { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: radial-gradient(circle at top, rgba(0,153,187,.12), transparent 34rem), var(--soft); }
.result-card { width: min(700px, 100%); padding: 40px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 26px 7px 26px 7px; box-shadow: var(--shadow); }
.success-mark { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 20px; color: #fff; background: var(--brand); border-radius: 50%; font-size: 26px; }
.result-card h1 { margin: 0; font-size: clamp(36px, 6vw, 62px); letter-spacing: -.055em; }
.result-card > p:not(.eyebrow) { color: var(--muted); }
#recordingPreview { width: 100%; max-height: 52vh; margin: 22px 0; background: #111; border-radius: 16px 4px 16px 4px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-card > .text-button { margin-top: 18px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); transform: translate(-50%, 30px); padding: 12px 18px; color: #fff; background: rgba(28,28,30,.92); border-radius: 999px; opacity: 0; pointer-events: none; transition: .25s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 52px; padding-top: 50px; }
  .hero-copy { max-width: 680px; }
  .hero-copy::after { display: none; }
  .script-card { width: min(620px, 100%); }
}

@media (max-width: 640px) {
  .site-header { width: calc(100% - 32px); height: 74px; }
  .privacy-pill { width: 10px; height: 10px; padding: 0; background: #28a745; font-size: 0; box-shadow: 0 0 0 4px rgba(40,167,69,.12); }
  .privacy-dot { display: none; }
  .header-actions { gap: 12px; }
  .language-picker select { min-height: 34px; max-width: 112px; padding-left: 10px; }
  .hero { width: calc(100% - 32px); padding: 42px 0 70px; }
  .hero h1 { font-size: 46px; }
  .hero-lead { font-size: 16px; }
  .feature-strip { flex-wrap: wrap; gap: 12px 18px; margin-top: 32px; }
  .script-card { padding: 24px 20px; border-radius: 20px 5px 20px 5px; }
  #scriptInput { min-height: 240px; }
  .how-it-works { padding-top: 68px; padding-bottom: 68px; }
  .steps-grid { grid-template-columns: 1fr; }
  .prompter-panel { top: 14%; height: 36vh; min-width: 0; }
  .prompter-viewport { padding: 82px 24px 60px; }
  .prompter-text { font-size: 28px; }
  .studio-controls { bottom: max(16px, env(safe-area-inset-bottom)); grid-template-columns: 68px 66px 68px; gap: 13px; padding: 10px 14px; }
  .record-button { width: 62px; height: 62px; }
  .record-button.recording span { margin: 10px; }
  .pause-recording { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 98px); }
  .settings-panel { left: 16px; right: 16px; bottom: 16px; width: auto; max-height: 78dvh; }
  .record-status { min-width: auto; }
  .record-status b { display: none; }
  .result-card { padding: 30px 20px; }
  .result-actions { grid-template-columns: 1fr; }
}

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