:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border: rgba(110, 118, 129, 0.25);
  --border2: rgba(110, 118, 129, 0.45);
  --text: #e6edf3;
  --muted: #7d8590;
  --accent: #3fb950;
  --accent2: #2ea043;
  --blue: #388bfd;
  --font-d: 'Syne', sans-serif;
  --font-b: 'DM Sans', sans-serif;
  --r: 12px;
  --rl: 18px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  opacity: 0.4;
}

* {
  box-sizing: border-box;
}

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 1.1rem;
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
  text-align: left;
}

.brand-icon {
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
}

.brand-logo {
  width: 2.45rem;
  height: 2.45rem;
  object-fit: cover;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  line-height: 1.05;
}

.brand-kicker {
  font-family: var(--font-b);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.brand-name {
  font-family: var(--font-d);
  font-size: 1.24rem;
  letter-spacing: 0.2em;
  font-weight: 800;
  color: var(--text);
}

.brand-subtitle {
  font-family: var(--font-b);
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
}

.nav-brand:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.hidden {
  display: none !important;
}

.brand-name em {
  color: var(--accent);
  font-style: normal;
}

.footer-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-note a {
  color: inherit;
  text-decoration: none;
}

.footer-note a:hover,
.footer-note a:focus {
  color: var(--text);
  text-decoration: underline;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-pill {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
}

button {
  font-family: var(--font-b);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  padding: 0.75rem 1.6rem;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  padding: 0.75rem 1.6rem;
  border-radius: var(--r);
  font-size: 0.9rem;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-accent {
  background: var(--blue);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 0.84rem;
}

.btn-accent:hover:not(:disabled) {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.55rem 1.1rem;
  font-size: 0.82rem;
}

.btn-speak {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--accent);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-speak:hover:not(:disabled) {
  background: rgba(63, 185, 80, 0.2);
}

.btn-speak:disabled {
  opacity: 0.35;
}

.btn-install {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(63, 185, 80, 0.4);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-install:hover {
  background: rgba(63, 185, 80, 0.1);
}

.btn-help {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.btn-help:hover,
.btn-help:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(63, 185, 80, 0.12);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3rem;
  padding: 5rem 2rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-inner {
  flex: 1;
  max-width: 560px;
}

.hero-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(63, 185, 80, 0.25);
  background: rgba(63, 185, 80, 0.07);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1.4rem;
}

.hero h1 {
  font-family: var(--font-d);
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.2rem;
}

.hero h1 span {
  color: var(--accent);
}

.hero-sub {
  font-size: 0.97rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 46ch;
  margin-bottom: 2rem;
  font-weight: 300;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-visual {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lens-ring {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1px solid rgba(63, 185, 80, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: slow-spin 20s linear infinite;
}

.lens-ring-inner {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 1px solid rgba(63, 185, 80, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: slow-spin 15s linear infinite reverse;
}

.lens-core {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 185, 80, 0.15), rgba(63, 185, 80, 0.03));
  border: 1px solid rgba(63, 185, 80, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lens-icon {
  font-size: 2.5rem;
}

@keyframes slow-spin {
  to {
    transform: rotate(360deg);
  }
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  z-index: 1;
}

.app-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 1.5rem;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card-head-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-head-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-icon {
  font-size: 1.3rem;
  margin-top: 0.1rem;
}

.card h2 {
  font-family: var(--font-d);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.card-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.video-wrap {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 1rem;
  background: var(--surface2);
  min-height: 200px;
}

#cameraPreview {
  width: 100%;
  border-radius: var(--r);
  min-height: 200px;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.video-overlay.hidden {
  display: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
  margin-top: 0.35rem;
}

.status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.camera-picker {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.camera-picker select {
  min-width: 0;
  width: 100%;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.camera-actions {
  align-items: center;
}

.camera-tuning {
  margin-top: 0.75rem;
  gap: 0.6rem;
}

.camera-tuning .option-label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.camera-tuning .output-select {
  min-width: 0;
  flex: 1;
}

.clarity-indicator {
  flex: 1 1 160px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface2);
  color: var(--muted);
  transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.clarity-override-btn {
  flex: 0 1 auto;
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
}

.clarity-override-btn.active {
  border-color: rgba(245, 166, 35, 0.45);
  color: #f5a623;
  background: rgba(245, 166, 35, 0.18);
}

.clarity-indicator::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.clarity-indicator.clarity-ok {
  background: rgba(63, 185, 80, 0.12);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(63, 185, 80, 0.35);
}

.clarity-indicator.clarity-ok::before {
  background: var(--accent);
}

.clarity-indicator.clarity-warn {
  background: rgba(245, 166, 35, 0.12);
  color: #dd8a00;
  box-shadow: inset 0 0 0 1px rgba(245, 166, 35, 0.35);
}

.clarity-indicator.clarity-warn::before {
  background: #f5a623;
}

.clarity-indicator.clarity-idle {
  background: rgba(110, 118, 129, 0.14);
  color: var(--muted);
}

.clarity-indicator.clarity-idle::before {
  background: var(--muted);
}

.clarity-indicator.clarity-error {
  background: rgba(220, 82, 72, 0.16);
  color: #dc5248;
  box-shadow: inset 0 0 0 1px rgba(220, 82, 72, 0.35);
}

.clarity-indicator.clarity-error::before {
  background: #dc5248;
}

.mobile-result-toggle {
  display: none;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.result-tab {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.result-tab.active {
  background: rgba(63, 185, 80, 0.14);
  color: var(--text);
}

.dropzone {
  display: block;
  cursor: pointer;
  border: 1.5px dashed var(--border2);
  border-radius: var(--r);
  margin-bottom: 1.25rem;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.active {
  border-color: var(--accent);
  background: rgba(63, 185, 80, 0.04);
}

.dropzone input {
  display: none;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 0.4rem;
  text-align: center;
}

.dropzone-icon {
  font-size: 1.6rem;
  opacity: 0.5;
}

.dropzone-text {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.dropzone-hint {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.6;
  letter-spacing: 0.06em;
}

.options-panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.option-row-stack {
  flex-direction: column;
  align-items: flex-start;
}

.option-row-inline {
  align-items: center;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.option-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.mode-note {
  margin: -0.25rem 0 0.6rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.output-select {
  min-width: 0;
  max-width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 0.45rem 0.8rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  appearance: none;
  outline: none;
}

.output-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.2);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  gap: 0.5rem;
}

.mode-switch input {
  display: none;
}

.mode-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.mode-switch input:checked + .mode-pill {
  background: rgba(63, 185, 80, 0.15);
  color: var(--text);
  border-color: var(--accent);
}

.output-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: rgba(63, 185, 80, 0.1);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.8rem;
  font-family: var(--font-b);
  font-size: 0.85rem;
  max-width: 100%;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-row input {
  display: none;
}

.toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.2s;
}

.toggle-row input:checked ~ .toggle-track {
  background: rgba(63, 185, 80, 0.25);
  border-color: var(--accent);
}

.toggle-row input:checked ~ .toggle-track .toggle-thumb {
  background: var(--accent);
  left: 21px;
}

.toggle-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.result-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.rbadge {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rbadge.dim {
  border-color: var(--border2);
  color: var(--muted);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.result-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.result-block h3 {
  font-family: var(--font-d);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 140px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.9rem;
  resize: vertical;
  color: var(--text);
  font-family: var(--font-b);
  font-size: 0.88rem;
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  border-color: var(--border2);
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.processing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(13, 17, 23, 0.72);
  color: var(--text);
  font-size: 0.85rem;
  backdrop-filter: blur(3px);
  border-radius: var(--r);
  z-index: 10;
}

.processing-overlay.hidden { display: none; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(63, 185, 80, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-block-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border-radius: 7px;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
}

.btn-retry {
  color: #f5a623;
  border-color: rgba(245, 166, 35, 0.45);
}

.btn-retry:hover,
.btn-retry:focus-visible {
  background: rgba(245, 166, 35, 0.18);
  color: #f5a623;
}

.btn-copy#copyBtn,
.btn-copy#exportBtn {
  font-size: 0.82rem;
  font-weight: 600;
}

.btn-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.paste-actions {
  margin-top: 0.75rem;
}

.card-paste textarea {
  min-height: 100px;
  border-color: var(--border2);
}

.card-paste textarea:focus {
  border-color: var(--accent);
}

.metric-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-radius: var(--r);
  border: 1px solid var(--border);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.metric-value {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.metric-value.small {
  font-size: 0.82rem;
}

.how-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  counter-reset: how;
}

.how-list li {
  counter-increment: how;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.how-list li::before {
  content: counter(how);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.25);
  color: var(--accent);
  font-family: var(--font-d);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.how-list li strong {
  color: var(--text);
}

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  opacity: 0.8;
}

.install-help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 997;
  background: rgba(6, 9, 14, 0.55);
  backdrop-filter: blur(3px);
}

.install-help-panel {
  position: fixed;
  z-index: 998;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 2rem));
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.install-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.install-help-title {
  font-family: var(--font-d);
  font-size: 0.95rem;
  font-weight: 700;
}

.install-help-body {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-line;
  margin-bottom: 1rem;
}

.install-help-foot {
  display: flex;
  justify-content: flex-end;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(6, 9, 14, 0.72);
  backdrop-filter: blur(4px);
}

.brand-modal {
  position: fixed;
  z-index: 999;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 2rem));
  max-height: min(84vh, 760px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(13, 17, 23, 0.98));
  border: 1px solid var(--border2);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  padding: 1.25rem;
}

.brand-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-modal h2 {
  margin: 0;
  font-family: var(--font-d);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.modal-close {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  flex-shrink: 0;
}

.brand-modal-body {
  display: grid;
  gap: 1rem;
}

.brand-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.brand-modal-logo {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--border2);
}

.brand-summary p,
.detail-card p {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.detail-card {
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.detail-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-d);
  font-size: 0.9rem;
  color: var(--text);
}

.detail-note {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.detail-card a {
  color: var(--accent);
  text-decoration: none;
}

.detail-card a:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0.7rem 1.4rem;
  font-size: 0.84rem;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  white-space: pre-wrap;
}

.service-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.9rem 2rem;
  background: rgba(210, 120, 0, 0.13);
  border-bottom: 1px solid rgba(210, 120, 0, 0.38);
  color: #f0b429;
  font-size: 0.88rem;
  line-height: 1.5;
}

.service-banner strong { color: #f5c842; }

.service-banner-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.service-banner-text { flex: 1; }

.service-banner-close {
  background: transparent;
  border: none;
  color: #f0b429;
  opacity: 0.65;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}

.service-banner-close:hover { opacity: 1; }

.camera-perm-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: var(--r);
  background: rgba(220, 82, 72, 0.1);
  border: 1px solid rgba(220, 82, 72, 0.3);
  margin-bottom: 0.85rem;
}

.camera-perm-alert.hidden { display: none; }

.perm-icon {
  font-size: 1rem;
  line-height: 1.4;
  color: #dc5248;
  flex-shrink: 0;
}

.perm-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #dc5248;
  margin-bottom: 0.25rem;
}

.perm-detail {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.mobile-action-bar {
  position: fixed;
  bottom: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  background: rgba(13, 17, 23, 0.93);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 0.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: stretch;
  z-index: 998;
  box-sizing: border-box;
  overflow: hidden;
}

.mobile-action-bar button {
  min-height: 52px;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.55rem 0.25rem;
  border-radius: 11px;
  width: 100%;
}

.mobile-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-action-btn:active:not(:disabled) {
  transform: scale(0.91);
  transition: transform 0.07s ease;
}

.mobile-action-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.mobile-action-label {
  font-size: 0.76rem;
  line-height: 1;
}

.mobile-action-primary {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 8px 18px rgba(22, 163, 74, 0.22);
}

.mobile-action-primary .mobile-action-icon {
  font-size: 1.2rem;
}

.mobile-action-bar .btn-ghost {
  border-color: var(--border2);
}

.mobile-action-bar button:disabled {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 1024px) {
  nav {
    padding: calc(1rem + env(safe-area-inset-top)) 1.5rem 1rem;
  }

  .hero {
    padding: 3.25rem 1.5rem 2.25rem;
    gap: 2rem;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 4vw, 3.2rem);
    line-height: 1.05;
  }

  .hero-sub {
    max-width: 28rem;
  }

  main {
    padding: 0 1.5rem calc(4rem + env(safe-area-inset-bottom));
  }

  .card {
    padding: 1.25rem;
  }

  .card-head {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

@media (max-width: 960px) {
  .hero {
    flex-direction: column;
    padding: 2rem 1rem 1.5rem;
  }

  .hero-visual {
    display: none;
  }

  .hero-tag {
    font-size: 0.66rem;
    margin-bottom: 1rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 10vw, 2.4rem);
    margin-bottom: 0.95rem;
  }

  .hero-sub {
    margin-bottom: 1.25rem;
  }

  .hero-actions {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }

  .hero-actions .btn-primary,
  .hero-actions .btn-ghost {
    width: 100%;
    min-height: 46px;
  }

  .app-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .results-grid {
    display: flex;
    flex-direction: column;
  }

  .results-grid .result-block:first-child {
    order: 2;
  }

  .results-grid .result-block:last-child {
    order: 1;
  }

  main {
    padding: 0 0.9rem calc(7rem + env(safe-area-inset-bottom));
  }

  nav {
    padding: calc(0.8rem + env(safe-area-inset-top)) 1rem 0.8rem;
  }

  .nav-pill {
    display: none;
  }

  .nav-right {
    gap: 0.35rem;
  }

  .btn-install {
    padding: 0.45rem 0.7rem;
    font-size: 0.72rem;
  }

  .nav-brand {
    gap: 0.5rem;
  }

  .brand-logo {
    width: 2rem;
    height: 2rem;
  }

  .brand-text-group {
    gap: 0.14rem;
  }

  .brand-kicker {
    font-size: 0.56rem;
    letter-spacing: 0.28em;
  }

  .brand-name {
    font-size: 1.04rem;
  }

  .brand-subtitle {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
  }

  .brand-modal {
    width: calc(100% - 1rem);
    padding: 1rem;
    border-radius: 18px;
  }

  .brand-modal-head {
    flex-direction: column;
  }

  .brand-summary {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .brand-modal-logo {
    margin: 0 auto;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 0.95rem;
    border-radius: 20px;
  }

  .card-head {
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
  }

  .card-sub {
    font-size: 0.78rem;
  }

  .card-camera .card-head-right {
    width: 100%;
    justify-content: space-between;
  }

  .result-block-actions {
    width: 100%;
  }

  .result-block-actions .btn-copy,
  .result-block-actions .btn-speak {
    flex: 1 1 auto;
    min-height: 42px;
  }

  .card-actions button,
  .paste-actions button {
    flex: 1 1 100%;
    min-height: 48px;
  }

  .clarity-indicator {
    flex: 1 1 auto;
  }

  .clarity-override-btn {
    flex: 0 1 auto;
  }

  .camera-tuning {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .camera-tuning .output-select {
    flex: 1 1 100%;
  }

  .mobile-result-toggle {
    display: flex;
  }

  .results-grid {
    gap: 0.75rem;
  }

  .result-block.mobile-hidden {
    display: none;
  }

  .result-badges {
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }

  .rbadge {
    white-space: nowrap;
  }

  .camera-picker {
    width: 100%;
  }

  .camera-picker select {
    width: 100%;
    min-width: 0;
  }

  .card-how {
    display: none;
  }

  .card-metrics {
    display: none;
  }

  .card-upload .dropzone {
    min-height: 140px;
  }

  .dropzone-inner {
    padding: 1.25rem 1rem;
  }

  /* Stack label above select on all inline option rows */
  .option-row-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .option-row-inline select,
  .option-row-inline .output-select {
    width: 100%;
    min-width: 0;
  }

  /* Service banner: tighter on mobile */
  .service-banner {
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    gap: 0.6rem;
  }

  #cameraPreview,
  .video-wrap {
    min-height: 220px;
  }

  .card-paste textarea:focus {
    scroll-margin-top: 1rem;
    scroll-margin-bottom: 6rem;
  }

  textarea {
    min-height: 100px;
  }

  .mobile-action-bar {
    display: grid;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }

  .mobile-action-btn {
    padding: 0.5rem 0.2rem;
    gap: 0.18rem;
  }

  .mobile-action-label {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
  }

  footer {
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero {
    padding-top: 1.6rem;
  }

  .hero-sub {
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 1.35rem;
  }

  .card-head-left {
    gap: 0.6rem;
  }

  .card-icon {
    font-size: 1.15rem;
  }

  .result-tab {
    min-height: 38px;
    font-size: 0.75rem;
  }

  .mobile-action-bar {
    left: 0.4rem;
    right: 0.4rem;
    bottom: max(0.4rem, env(safe-area-inset-bottom));
    padding: 0.4rem;
    padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
    gap: 0.28rem;
    border-radius: 13px;
  }

  .nav-brand {
    align-items: flex-start;
  }

  .brand-kicker {
    font-size: 0.46rem;
    letter-spacing: 0.18em;
  }

  .brand-name {
    font-size: 0.88rem;
  }

  .brand-subtitle {
    font-size: 0.52rem;
    letter-spacing: 0.04em;
  }

  .mobile-action-btn {
    padding: 0.6rem 0.4rem;
  }

  .mobile-action-label {
    font-size: 0.58rem;
    letter-spacing: 0.01em;
  }

  .mobile-action-icon {
    font-size: 0.95rem;
  }

  .mobile-action-primary .mobile-action-icon {
    font-size: 1.05rem;
  }
}

/* Small phones — 360px and under (old iPhone SE, budget Android) */
@media (max-width: 360px) {
  nav {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  main {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .card {
    padding: 0.7rem;
    border-radius: 14px;
  }

  .card-head {
    gap: 0.5rem;
    margin-bottom: 0.65rem;
  }

  .card-icon {
    font-size: 1rem;
  }

  .card h2 {
    font-size: 0.92rem;
  }

  .card-sub {
    font-size: 0.72rem;
  }

  .options-panel {
    gap: 0.7rem;
  }

  .mode-note {
    font-size: 0.72rem;
  }

  .result-badges {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .mobile-action-bar {
    left: 0.25rem;
    right: 0.25rem;
    gap: 0.2rem;
    padding: 0.35rem;
    border-radius: 12px;
  }

  .mobile-action-bar button {
    min-height: 48px;
    border-radius: 9px;
  }
}

/* Prevent iOS Safari from zooming on input focus — must be ≥16px */
@media (max-width: 960px) {
  select,
  .output-select,
  textarea,
  input[type="text"],
  input[type="search"] {
    font-size: 1rem;
  }

  .toast {
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
    right: 1rem;
    left: 1rem;
    text-align: center;
  }
}

/* Camera button: lit when stream is active */
#mobileStartCamera.camera-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(63, 185, 80, 0.12);
}

/* Capture button: pulse ring when clarity is met and capture is ready */
#mobileCapture.capture-ready {
  animation: capture-pulse 2.4s ease-in-out infinite;
}

@keyframes capture-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 139, 253, 0.55), 0 8px 18px rgba(22, 163, 74, 0.22); }
  55%       { box-shadow: 0 0 0 8px rgba(56, 139, 253, 0),  0 8px 18px rgba(22, 163, 74, 0.22); }
}

/* Offline state */
.mobile-action-bar.offline {
  border-color: rgba(220, 82, 72, 0.5);
}

.mobile-action-bar.offline::before {
  content: 'Offline';
  position: absolute;
  top: -1.8rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(220, 82, 72, 0.92);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.72rem;
  border-radius: 999px;
  text-transform: uppercase;
  pointer-events: none;
}

/* Large screens — give the layout more breathing room */
@media (min-width: 1280px) {
  main {
    padding: 0 3rem 5rem;
  }

  .hero {
    padding: 6rem 3rem 5rem;
    max-width: 1200px;
  }

  .card {
    padding: 1.75rem;
  }
}

/* PWA standalone — skip the marketing hero, start at the app */
@media (display-mode: standalone) {
  .hero {
    display: none;
  }

  nav {
    padding-top: max(0.9rem, env(safe-area-inset-top));
    padding-bottom: 0.9rem;
  }

  main {
    padding-top: 1rem;
  }

  #cameraPreview,
  .video-wrap {
    min-height: 280px;
  }
}
