/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --a:      #29c49a;
  --a-dim:  rgba(41,196,154,.12);
  --a-glow: rgba(41,196,154,.22);

  --warn:   #c49029;
  --danger: #c44545;

  --t0: #f0f0f4;
  --t1: #9090a8;
  --t2: #404050;

  --ov-dark:   rgba(8,8,12,.78);
  --ov-mid:    rgba(8,8,12,.62);
  --ov-subtle: rgba(8,8,12,.42);
  --ov-border: rgba(255,255,255,.08);

  --f-sans: 'Outfit', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --r: 10px;
  --st: env(safe-area-inset-top,    0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left,   0px);
  --sr: env(safe-area-inset-right,  0px);

  --ctrl-hide-dur: .35s;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--f-sans);
  color: var(--t0);
  -webkit-tap-highlight-color: transparent;
}

#video {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  will-change: transform;
  z-index: 0;
}

#overlay {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
  will-change: transform;
  z-index: 1;
}

.start-screen {
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease-out;
}
.start-screen.gone { opacity: 0; pointer-events: none; }

.start-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 32px 28px;
  background: rgba(16,16,22,.9);
  border: 1px solid var(--ov-border);
  border-radius: 20px;
  max-width: 320px; width: 90%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.start-logo { font-size: 1.3rem; font-weight: 300; letter-spacing: -.01em; color: var(--t1); }
.start-logo strong { font-weight: 700; color: var(--t0); }

.start-hint { font-size: .82rem; color: var(--t2); text-align: center; line-height: 1.5; max-width: 220px; }

.start-btn {
  width: 100%; padding: 13px 0;
  background: var(--a); color: #000;
  border: none; border-radius: var(--r);
  font-family: var(--f-sans); font-weight: 600; font-size: .95rem;
  cursor: pointer; position: relative; overflow: hidden;
  transition: opacity .15s, transform .1s;
}
.start-btn:active { transform: scale(.97); }
.start-btn:disabled { opacity: .35; }

.start-status { display: flex; align-items: center; gap: 7px; font-family: var(--f-mono); font-size: .62rem; color: var(--t2); }

.sdot { width: 5px; height: 5px; border-radius: 50%; background: var(--t2); flex-shrink: 0; transition: background .3s; }
.sdot.ok    { background: var(--a);      }
.sdot.warn  { background: var(--warn);   }
.sdot.error { background: var(--danger); }

.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--st)) calc(16px + var(--sr)) 10px calc(16px + var(--sl));
  background: linear-gradient(to bottom, rgba(0,0,0,.72) 0%, transparent 100%);
  transition: opacity var(--ctrl-hide-dur) ease-out, transform var(--ctrl-hide-dur) ease-out;
}
.top-bar.hidden { opacity: 0; pointer-events: none; transform: translateY(-8px); }

.top-logo { font-size: .92rem; font-weight: 300; letter-spacing: .01em; color: rgba(255,255,255,.6); }
.top-logo strong { font-weight: 700; color: var(--t0); }
.top-logo span   { color: var(--a); }

.top-right { display: flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: .62rem; color: var(--t1); }

.icon-btn {
  width: 32px; height: 32px;
  background: var(--ov-mid); border: 1px solid var(--ov-border);
  border-radius: 8px; color: var(--t1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: color .15s, background .15s; flex-shrink: 0;
}
.icon-btn:hover { color: var(--t0); background: var(--ov-dark); }
.icon-btn:active { transform: scale(.92); }

.hand-ring {
  position: fixed;
  bottom: calc(80px + var(--sb)); right: calc(18px + var(--sr));
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--a); opacity: 0; z-index: 10;
  transition: opacity .3s; will-change: opacity;
}
.hand-ring.active { opacity: 1; animation: ringPulse 1.8s ease-out infinite; }
@keyframes ringPulse {
  0%   { transform: scale(1);   opacity: 1; }
  60%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(1);   opacity: 0; }
}

.sign-display {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 5; pointer-events: none;
}

.sign-word {
  font-family: var(--f-sans); font-weight: 700;
  font-size: clamp(4rem, 14vw, 9rem);
  letter-spacing: -.04em; color: var(--a); line-height: 1;
  text-shadow: 0 0 40px rgba(41,196,154,.3), 0 2px 20px rgba(0,0,0,.8);
  transition: color .15s, opacity .15s; min-height: 1em;
}
.sign-word.dim { color: rgba(255,255,255,.12); text-shadow: none; }
.sign-word.pop { animation: wordPop .2s ease-out; }
@keyframes wordPop {
  0%   { transform: scale(.88); opacity: 0; }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1);    opacity: 1; }
}

.sentence-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  padding: 20px calc(20px + var(--sr)) calc(16px + var(--sb)) calc(20px + var(--sl));
  background: linear-gradient(to top, rgba(0,0,0,.82) 0%, rgba(0,0,0,.5) 60%, transparent 100%);
  display: flex; flex-direction: column; gap: 8px;
}

.sentence-text {
  font-size: clamp(.95rem, 2.5vw, 1.2rem); font-weight: 500;
  color: var(--t0); line-height: 1.45; min-height: 1.5em; transition: opacity .2s;
}
.sentence-text.placeholder { color: var(--t2); font-weight: 400; font-style: italic; }

.sentence-chips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 22px; }
.s-chip {
  padding: 2px 9px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; font-family: var(--f-mono); font-size: .62rem; color: var(--t1);
  animation: chipIn .18s cubic-bezier(.34,1.4,.64,1);
}
.s-chip.new { background: var(--a-dim); border-color: rgba(41,196,154,.25); color: var(--a); }
@keyframes chipIn { from { opacity: 0; transform: scale(.75); } to { opacity: 1; transform: scale(1); } }

.controls {
  position: fixed; bottom: calc(72px + var(--sb)); right: calc(16px + var(--sr));
  z-index: 15; display: flex; flex-direction: column; gap: 8px;
  transition: opacity var(--ctrl-hide-dur) ease-out, transform var(--ctrl-hide-dur) ease-out;
}
.controls.hidden { opacity: 0; pointer-events: none; transform: translateX(12px); }

.ctrl-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 14px; background: var(--ov-dark);
  border: 1px solid var(--ov-border); border-radius: var(--r);
  color: var(--t1); font-family: var(--f-sans); font-size: .8rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: color .15s, border-color .15s, transform .1s;
}
.ctrl-btn:hover { color: var(--t0); border-color: rgba(255,255,255,.15); }
.ctrl-btn:active { transform: scale(.95); }
.ctrl-btn:disabled { opacity: .25; cursor: not-allowed; }
.ctrl-btn--clear:hover { color: var(--danger); border-color: rgba(196,69,69,.3); }

.settings-panel {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.settings-panel.open { opacity: 1; pointer-events: auto; }

.settings-inner {
  width: 100%; max-width: 480px; background: #111118;
  border: 1px solid var(--ov-border); border-radius: 20px 20px 0 0;
  padding: 20px 22px calc(20px + var(--sb));
  display: flex; flex-direction: column; gap: 16px;
  transform: translateY(20px); transition: transform .25s;
}
.settings-panel.open .settings-inner { transform: translateY(0); }

.settings-title { font-size: .72rem; font-family: var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--t2); }

.setting-row { display: flex; align-items: center; gap: 12px; }
.setting-label { font-size: .8rem; color: var(--t1); width: 78px; flex-shrink: 0; }
.setting-row input[type=range] { flex: 1; accent-color: var(--a); cursor: pointer; }
.setting-val { font-family: var(--f-mono); font-size: .68rem; color: var(--a); min-width: 36px; text-align: right; }

.setting-row--url { flex-direction: column; align-items: stretch; gap: 6px; }
.setting-row--url .setting-label { width: auto; }
.url-input {
  width: 100%; background: #0d0d10;
  border: 1px solid rgba(255,255,255,.1); border-radius: 7px;
  color: var(--t0); font-family: var(--f-mono); font-size: .78rem;
  padding: 9px 12px; outline: none; transition: border-color .15s;
}
.url-input:focus { border-color: rgba(41,196,154,.35); }

.model-info { font-family: var(--f-mono); font-size: .66rem; color: var(--t2); line-height: 1.8; white-space: pre-line; }

.settings-close {
  width: 100%; padding: 12px; background: var(--a); color: #000;
  border: none; border-radius: var(--r);
  font-family: var(--f-sans); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: opacity .15s;
}
.settings-close:active { opacity: .8; }

.history-panel {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.history-panel.open { opacity: 1; pointer-events: auto; }

.history-inner {
  width: 100%; max-width: 480px; max-height: 70vh; background: #111118;
  border: 1px solid var(--ov-border); border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(18px + var(--sb));
  display: flex; flex-direction: column; gap: 14px;
  transform: translateY(20px); transition: transform .25s;
}
.history-panel.open .history-inner { transform: translateY(0); }

.history-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; font-family: var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--t2);
}

.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.history-list::-webkit-scrollbar { width: 2px; }
.history-list::-webkit-scrollbar-thumb { background: var(--t2); border-radius: 1px; }
.history-empty { font-size: .8rem; color: var(--t2); font-style: italic; text-align: center; padding: 20px 0; }

.h-card {
  background: rgba(255,255,255,.04); border: 1px solid var(--ov-border);
  border-left: 1px solid var(--a); border-radius: 8px; padding: 10px 12px;
  animation: cardIn .22s ease-out;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.h-card-text { font-size: .9rem; font-weight: 500; line-height: 1.4; }
.h-card-meta { margin-top: 4px; font-family: var(--f-mono); font-size: .58rem; color: var(--t2); }
.h-card-gloss { color: rgba(41,196,154,.5); }

.toast {
  position: fixed; bottom: calc(140px + var(--sb));
  left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(20,20,28,.92); border: 1px solid var(--ov-border);
  color: var(--t0); padding: 8px 16px; border-radius: 20px; font-size: .8rem;
  opacity: 0; transition: opacity .2s ease-out, transform .2s ease-out;
  pointer-events: none; z-index: 99;
  white-space: nowrap; max-width: calc(100vw - 32px); text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(0,0,0,.18); transform: scale(0);
  animation: ripple .45s ease-out forwards; pointer-events: none;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }


@media (prefers-reduced-motion: reduce) {
  .sign-word.pop, .hand-ring.active, .s-chip, .h-card { animation: none; }
  .hand-ring.active { opacity: 1; }
}

@media (min-width: 768px) {
  .controls {
    flex-direction: row; bottom: calc(80px + var(--sb));
    right: auto; left: 50%; transform: translateX(-50%);
  }
  .controls.hidden { transform: translateX(-50%) translateY(12px); }
  .sign-word { font-size: clamp(5rem, 10vw, 11rem); }
}


/* ── Top Navigation Links – Strong & Visible over camera ───────────────────── */
.top-bar {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.65) 50%,
    rgba(0, 0, 0, 0.25) 100%
  ) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.nav-link.active {
  color: #29c49a;
  background: rgba(41, 196, 154, 0.22);
  font-weight: 700;
}

/* Mobile friendly */
@media (max-width: 680px) {
  .nav-links { gap: 4px; }
  .nav-link { padding: 6px 14px; font-size: 13px; }
}

/* Mobile performance — disable GPU-heavy effects */
@media (max-width: 768px) {
  .start-inner,
  .ctrl-btn,
  .settings-inner,
  .history-inner,
  .sign-display,
  .sentence-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}