:root {
  --bg-deep: #0b1220;
  --bg-panel: #121b2e;
  --bg-panel-raised: #17233a;
  --line: #223252;
  --signal-cyan: #6ee7f0;
  --word-amber: #f5a623;
  --ink: #f3f1ec;
  --muted: #8695b0;

  --font-display: "Unbounded", sans-serif;
  --font-body: "Manrope", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(110, 231, 240, 0.07), transparent),
    radial-gradient(ellipse 50% 35% at 100% 100%, rgba(245, 166, 35, 0.06), transparent);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-size: 28px;
  color: var(--signal-cyan);
  text-shadow: 0 0 18px rgba(110, 231, 240, 0.55);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.01em;
  margin: 0;
}

.brand-text h1 .arrow {
  color: var(--word-amber);
  padding: 0 2px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.camera-toggle {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.camera-toggle:hover { border-color: var(--signal-cyan); }

.camera-toggle:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--signal-cyan);
  outline-offset: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px 7px 10px;
}

.status-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.status-pill[data-state="loading"] i { background: var(--word-amber); animation: pulse-dot 1.1s ease-in-out infinite; }
.status-pill[data-state="ready"] i { background: var(--signal-cyan); box-shadow: 0 0 8px rgba(110, 231, 240, 0.8); }
.status-pill[data-state="error"] i { background: #f0616e; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
  flex: 1;
}

/* ---------- Camera stage ---------- */

.stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: #060a13;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

.stage-frame video,
.stage-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* selfie ko'rinish uchun oyna effekti */
}

.stage-frame video { filter: saturate(0.9) brightness(0.92); }

.stage-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 14px;
  color: var(--muted);
  background: rgba(6, 10, 19, 0.72);
  transition: opacity 0.3s ease;
}

.stage-hint[hidden] { display: none; }

/* ---------- Subtitle card (signature element) ---------- */

.subtitle-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.subtitle-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.subtitle-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05;
  color: var(--ink);
  transition: color 0.2s ease;
}

.subtitle-card.locked .subtitle-word {
  color: var(--word-amber);
  animation: word-lock 0.6s ease;
}

@keyframes word-lock {
  0% { transform: scale(0.85); text-shadow: 0 0 0 rgba(245, 166, 35, 0); }
  35% { transform: scale(1.08); text-shadow: 0 0 34px rgba(245, 166, 35, 0.65); }
  100% { transform: scale(1); text-shadow: 0 0 0 rgba(245, 166, 35, 0); }
}

.confidence-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(280px, 100%);
}

.confidence-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-panel-raised);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--signal-cyan), var(--word-amber));
  transition: width 0.15s ease;
}

.confidence-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  min-width: 34px;
  text-align: right;
}

/* ---------- Sidebar ---------- */

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 20px;
}

.panel-grow { flex: 1; display: flex; flex-direction: column; }

.panel h2 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--signal-cyan);
  background: rgba(110, 231, 240, 0.1);
  border-radius: 999px;
  padding: 2px 8px;
}

.vocab-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.vocab-search {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 11px;
}

.vocab-search::placeholder { color: var(--muted); }
.vocab-search:focus { outline: none; border-color: var(--signal-cyan); }

.vocab-sort {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  cursor: pointer;
}

.vocab-sort:focus { outline: none; border-color: var(--signal-cyan); }

.vocab-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 2px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

.chip {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.chip:hover {
  border-color: var(--word-amber);
  color: var(--word-amber);
}

.panel-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 10px;
}

.chip.active {
  color: #0b1220;
  background: var(--signal-cyan);
  border-color: var(--signal-cyan);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 360px;
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.history-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--bg-panel-raised);
  animation: history-in 0.3s ease;
}

.history-item .h-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
}

.history-item .h-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

@keyframes history-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Footer ---------- */

.footnote {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- So'z animatsiya oynasi ---------- */

.anim-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: anim-fade-in 0.18s ease;
}

.anim-modal[hidden] { display: none; }

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

.anim-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.anim-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  color: var(--word-amber);
  margin-bottom: 8px;
}

.anim-canvas {
  width: 320px;
  height: 320px;
  max-width: 80vw;
  max-height: 60vh;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.anim-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.anim-close:hover { color: var(--ink); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: column; }
  .history-list { max-height: 220px; }
}

@media (max-width: 520px) {
  .app { padding: 16px 14px 28px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
