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

:root {
  --bg: #0a0b08;
  --bg2: #111210;
  --surface: rgba(18, 20, 16, 0.85);
  --glass: rgba(85, 95, 50, 0.08);
  --glass-heavy: rgba(18, 20, 16, 0.65);
  --glass-border: rgba(140, 160, 80, 0.14);
  --glass-hover: rgba(140, 160, 80, 0.22);
  --text: #e8e8e0;
  --text-dim: rgba(232, 232, 224, 0.35);
  --text-mid: rgba(232, 232, 224, 0.65);
  --olive: #8ba339;
  --olive-dim: #6b7d2e;
  --olive-bright: #b5d44e;
  --olive-glow: rgba(139, 163, 57, 0.2);
  --gradient: linear-gradient(135deg, #7a9230, #b5d44e);
  --gradient-glow: linear-gradient(135deg, rgba(122, 146, 48, 0.3), rgba(181, 212, 78, 0.15));
  --radius: 14px;
  --radius-sm: 9px;
  --blur: blur(20px);
  --elevate: 0 12px 40px -10px rgba(0, 0, 0, 0.5);
  --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column
}

/* Video Layer */
#videoWrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: #000
}

#webcam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  /* Mirror controlled dynamically via JS based on front/rear camera */
}

#webcam.mirrored {
  transform: scaleX(-1);
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none
}

#labelContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none
}

/* Loading Screen */
#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.6s ease
}

#loadingScreen.hidden {
  opacity: 0;
  pointer-events: none
}

.loader-logo {
  font-size: 36px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px
}

.loader-sub {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase
}

.loader-bar-track {
  width: 240px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 3px;
  transition: width 0.4s ease
}

.loader-status {
  color: var(--text-mid);
  font-size: 11px;
  min-height: 16px
}

.loader-nametag {
  position: absolute;
  bottom: 40px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0.8;
}

/* Header */
#header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(10, 11, 8, 0.96) 0%, rgba(10, 11, 8, 0.4) 60%, transparent 100%)
}

.logo {
  font-size: 22px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.logo span {
  font-weight: 300;
  opacity: 0.5;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  pointer-events: all;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.btn:hover {
  background: var(--glass-hover);
  border-color: rgba(140, 160, 80, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn.active {
  background: rgba(139, 163, 57, 0.2);
  border-color: rgba(139, 163, 57, 0.5);
  color: var(--olive-bright);
  box-shadow: 0 0 15px var(--olive-glow);
}

/* Camera Controls */
#controls {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}

.shutter-btn {
  width: 72px;
  height: 72px;
  background: none;
  border: 4px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.shutter-inner {
  width: 58px;
  height: 58px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.shutter-btn:hover {
  transform: scale(1.05);
}

.shutter-btn:active .shutter-inner {
  transform: scale(0.85);
  background: #f0f0f0;
}

#langSelector {
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: all;
  min-width: 110px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

#langSelector option {
  background: var(--bg2);
  color: var(--text)
}

/* Detection Shelf */
#detectedBar {
  position: absolute;
  bottom: 190px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 280px;
  max-width: 90vw;
  z-index: 10;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: 40px;
  padding: 8px 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: var(--elevate);
}

#detectedBar::-webkit-scrollbar {
  display: none
}

#detectedBar:empty::after {
  content: 'Identifying objects…';
  color: var(--text-dim);
  font-size: 11px;
  width: 100%;
  text-align: center;
  letter-spacing: 1px;
}

.detected-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  animation: chipIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.detected-chip:hover {
  background: rgba(139, 163, 57, 0.12);
  border-color: rgba(139, 163, 57, 0.25);
  transform: scale(1.05);
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9)
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1)
  }
}

.chip-emoji {
  font-size: 18px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chip-text {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.chip-foreign {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1
}

.chip-english {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
}

.chip-speak {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(139, 163, 57, 0.1);
  border: 1px solid rgba(139, 163, 57, 0.15);
  color: var(--olive);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0
}

.chip-speak:hover {
  background: var(--olive);
  color: #fff;
  transform: scale(1.1)
}

/* Stats & Credits */
#statsStrip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: linear-gradient(0deg, var(--bg) 0%, rgba(10, 11, 8, 0.8) 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 15px 30px 25px 30px;
  pointer-events: none;
}

.stat,
.credit-badge {
  pointer-events: all;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-dim)
}

.stat-value {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-label {
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.6;
}

/* Name Badge */
.credit-badge {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 4px 10px;
  background: linear-gradient(135deg, rgba(139, 163, 57, 0.12), rgba(181, 212, 78, 0.06));
  border: 1px solid rgba(139, 163, 57, 0.3);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s ease;
  text-decoration: none;
}

.credit-badge::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(139, 163, 57, 0.4), rgba(181, 212, 78, 0.1), rgba(139, 163, 57, 0.4));
  background-size: 200% 200%;
  animation: badgeShimmer 3s ease-in-out infinite;
  z-index: 0;
  opacity: 0.5;
}

@keyframes badgeShimmer {
  0% {
    background-position: 0% 50%
  }

  50% {
    background-position: 100% 50%
  }

  100% {
    background-position: 0% 50%
  }
}

.credit-badge:hover {
  border-color: rgba(139, 163, 57, 0.55);
  box-shadow: 0 0 20px rgba(139, 163, 57, 0.2), 0 0 40px rgba(139, 163, 57, 0.08);
  transform: translateY(-1px);
}

.credit-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--olive-bright);
  box-shadow: 0 0 6px var(--olive), 0 0 12px rgba(139, 163, 57, 0.3);
  animation: dotPulse 2s ease-in-out infinite;
  z-index: 1;
  flex-shrink: 0;
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.85)
  }

  50% {
    opacity: 1;
    transform: scale(1.2)
  }
}

.credit-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--olive-bright), #d4e87a, var(--olive-bright));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: nameGlow 4s linear infinite;
  z-index: 1;
  white-space: nowrap;
}

@keyframes nameGlow {
  0% {
    background-position: 0% center
  }

  100% {
    background-position: 200% center
  }
}

/* AR Labels */
.detection-label {
  position: absolute;
  pointer-events: all;
  cursor: pointer;
  transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1), top 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  will-change: left, top;
  transform-origin: top left;
  z-index: 4
}

.detection-label.entering {
  animation: labelIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards
}

.detection-label.exiting {
  animation: labelOut 0.3s ease forwards;
  pointer-events: none
}

@keyframes labelIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(5px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

@keyframes labelOut {
  from {
    opacity: 1;
    transform: scale(1)
  }

  to {
    opacity: 0;
    transform: scale(0.92) translateY(6px)
  }
}

.label-card {
  background: rgba(12, 14, 10, 0.78);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid rgba(139, 163, 57, 0.14);
  border-radius: 10px;
  padding: 9px 12px;
  min-width: 110px;
  max-width: 190px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(139, 163, 57, 0.05) inset;
  transition: background 0.2s, border-color 0.2s
}

.label-card:hover {
  background: rgba(12, 14, 10, 0.92);
  border-color: rgba(139, 163, 57, 0.3)
}

.label-foreign {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 1px
}

.label-phonetic {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--olive);
  font-weight: 400;
  margin-bottom: 2px;
  opacity: 0.85
}

.label-english {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 3px
}

.label-speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(139, 163, 57, 0.10);
  border: 1px solid rgba(139, 163, 57, 0.16);
  color: var(--olive);
  cursor: pointer;
  font-size: 9px;
  transition: var(--transition);
  flex-shrink: 0;
  margin-left: auto
}

.label-speak:hover {
  background: rgba(139, 163, 57, 0.28);
  transform: scale(1.1)
}

/* Sidebar Panel */
#sidePanel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  z-index: 20;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-left: 1px solid var(--glass-border);
  transform: translateX(100%);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidePanel.open {
  transform: translateX(0)
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--glass-border)
}

.panel-title {
  font-size: 16px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.panel-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: var(--transition)
}

.panel-close:hover {
  background: rgba(255, 80, 80, 0.1);
  border-color: rgba(255, 80, 80, 0.2);
  color: #ff8080;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px 20px
}

.vocab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 10px;
  transition: var(--transition);
  cursor: pointer
}

.vocab-item:hover {
  border-color: var(--glass-border);
  background: var(--glass-hover);
  transform: translateX(4px);
}

.vocab-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.vocab-info {
  flex: 1;
  min-width: 0
}

.vocab-foreign {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.vocab-english {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.vocab-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.7;
}

.setting-group {
  margin-bottom: 14px
}

.setting-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0
}

.setting-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--olive);
  font-weight: 500
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  outline: none;
  margin-top: 5px
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gradient);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--olive-glow)
}

/* Quiz */
.quiz-label .label-foreign {
  filter: blur(8px);
  transition: filter 0.3s ease;
  user-select: none
}

.quiz-label.revealed .label-foreign {
  filter: blur(0)
}

/* Toast */
.toast {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  white-space: nowrap
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0)
}

/* No Camera */
#noCameraMsg {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 28px
}

#noCameraMsg h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--olive-bright)
}

#noCameraMsg p {
  color: var(--text-dim);
  font-size: 12px;
  max-width: 340px;
  line-height: 1.5
}

/* ── Desktop Optimizations ── */
@media(min-width: 1025px) {
  #app {
    flex-direction: row;
    padding: 20px;
    gap: 20px;
    background: radial-gradient(circle at top left, #1a1c14, #0a0b08);
  }

  #videoWrap {
    border-radius: 24px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    flex: 2;
  }

  #sidePanel {
    position: static;
    width: 380px;
    transform: none;
    background: var(--glass-heavy);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--elevate);
  }

  .panel-close {
    display: none;
  }

  #header {
    top: 20px;
    left: 20px;
    right: 20px;
    border-radius: 20px 20px 0 0;
    padding: 20px 24px;
  }

  #detectedBar {
    min-width: 400px;
  }

  #statsStrip {
    position: absolute;
    bottom: 30px;
    left: 40px;
    right: 40px;
    width: auto;
    padding: 12px 24px;
    background: var(--glass-heavy);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    justify-content: space-between;
    z-index: 100;
  }

  #controls {
    bottom: 100px;
  }

  .credit-badge {
    margin-left: 0;
  }
}

@media(max-width: 1024px) {
  #sidePanel {
    width: 100%;
    border-left: none;
    border-radius: 0;
  }
}

@media(max-width: 768px) {
  #header {
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(10, 11, 8, 0.98) 0%, rgba(10, 11, 8, 0.6) 70%, transparent 100%);
  }

  .logo {
    font-size: 17px;
    flex-shrink: 0;
  }

  .header-actions {
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .header-actions::-webkit-scrollbar {
    display: none;
  }

  .btn {
    padding: 6px 10px;
    font-size: 10px;
    flex-shrink: 0;
  }

  #langSelector {
    min-width: 85px;
    font-size: 10px;
    flex-shrink: 0;
  }

  /* Stacking: Stats(bottom:0) -> Controls(bottom:80px) -> DetectedBar(above controls) */
  #statsStrip {
    padding: 10px 16px 20px 16px;
    gap: 16px;
    z-index: 10;
  }

  #controls {
    bottom: 80px;
  }

  #detectedBar {
    bottom: 170px;
    min-height: 48px;
    padding: 6px 12px;
    min-width: 200px;
    max-width: 92vw;
    border-radius: 28px;
  }

  .detected-chip {
    padding: 6px 10px;
    gap: 7px;
  }

  .chip-emoji {
    font-size: 16px;
  }

  .chip-foreign {
    font-size: 12px;
  }

  .stat-value {
    font-size: 12px;
  }

  .stat-label {
    font-size: 6px;
  }

  .credit-badge {
    scale: 0.85;
  }

  .shutter-btn {
    width: 64px;
    height: 64px;
  }

  .shutter-inner {
    width: 52px;
    height: 52px;
  }

  .label-card {
    min-width: 95px;
    max-width: 160px;
    padding: 7px 10px;
  }

  .label-foreign {
    font-size: 12px;
  }

  .label-english {
    font-size: 8px;
  }

  .toast {
    bottom: 250px;
    font-size: 10px;
    padding: 7px 14px;
  }
}

@media(max-width: 480px) {
  #header {
    padding: 8px 10px;
  }

  .logo {
    font-size: 15px;
  }

  .header-actions {
    gap: 3px;
  }

  .btn {
    padding: 5px 7px;
    font-size: 9px;
  }

  #langSelector {
    min-width: 75px;
    padding: 6px 8px;
    font-size: 9px;
  }

  #controls {
    bottom: 70px;
  }

  #detectedBar {
    bottom: 150px;
    width: 94vw;
    min-width: unset;
    border-radius: 22px;
    padding: 5px 10px;
    min-height: 44px;
    gap: 5px;
  }

  .detected-chip {
    padding: 5px 8px;
    gap: 6px;
    border-radius: 10px;
  }

  .chip-foreign {
    font-size: 11px;
  }

  .chip-english {
    font-size: 7px;
  }

  .chip-speak {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  #statsStrip {
    gap: 12px;
    padding: 8px 12px 18px 12px;
  }

  .stat-value {
    font-size: 11px;
  }

  .credit-badge {
    margin-left: 0;
    scale: 0.8;
  }

  .shutter-btn {
    width: 58px;
    height: 58px;
  }

  .shutter-inner {
    width: 46px;
    height: 46px;
  }

  .toast {
    bottom: 230px;
  }

  .label-card {
    min-width: 85px;
    max-width: 140px;
    padding: 6px 8px;
  }

  .label-foreign {
    font-size: 11px;
  }

  .label-phonetic {
    font-size: 8px;
  }

  .label-english {
    font-size: 7px;
  }
}

@media(max-width: 360px) {
  .logo {
    font-size: 14px;
  }

  .header-actions {
    gap: 2px;
  }

  .btn {
    padding: 4px 6px;
    font-size: 8px;
  }

  #langSelector {
    min-width: 65px;
    font-size: 8px;
  }

  .label-card {
    max-width: 110px;
    min-width: 75px;
  }

  #detectedBar {
    bottom: 142px;
  }

  .credit-badge {
    scale: 0.75;
  }
}