/* ============================================================
   ROOT & DESIGN TOKENS
   ============================================================ */
:root {
  /* Palette */
  --bg:           #0d0e14;
  --bg-2:         #12141e;
  --surface:      rgba(255,255,255,0.038);
  --surface-2:    rgba(255,255,255,0.055);
  --surface-hover:rgba(255,255,255,0.07);
  --border:       rgba(255,255,255,0.07);
  --border-focus: rgba(250,189,0,0.45);

  /* Brand colors */
  --gold:         #f5bc00;
  --gold-dim:     rgba(245,188,0,0.12);
  --gold-glow:    rgba(245,188,0,0.22);
  --amber:        #fb923c;
  --indigo:       #6366f1;
  --indigo-dim:   rgba(99,102,241,0.15);

  /* Text */
  --fg:           #f0f2f8;
  --fg-2:         #9aa0b8;
  --fg-3:         #5c6380;

  /* Semantic */
  --danger:       #f87171;
  --success:      #34d399;

  /* Geometry */
  --radius-xl:    1.75rem;
  --radius-lg:    1.25rem;
  --radius-md:    0.875rem;
  --radius-sm:    0.5rem;

  /* Effects */
  --shadow-card:  0 32px 80px rgba(0,0,0,0.55), 0 8px 32px rgba(0,0,0,0.35);
  --shadow-sm:    0 4px 20px rgba(0,0,0,0.25);
  --blur:         blur(20px);
  --transition:   0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --spring:       0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body { height: 100%; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   ANIMATED BACKGROUND
   ============================================================ */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* Fine mesh grid */
.mesh {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 30%, transparent 80%);
}

/* Gradient orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
  animation: drift 28s ease-in-out infinite alternate;
}

.orb-1 {
  width: 55rem;
  height: 55rem;
  top: -22rem;
  left: -18rem;
  background: radial-gradient(circle at 35% 45%, rgba(99,102,241,0.28), transparent 65%);
  animation-duration: 32s;
}

.orb-2 {
  width: 40rem;
  height: 40rem;
  top: 10%;
  right: -15rem;
  background: radial-gradient(circle at 55% 35%, rgba(245,188,0,0.2), transparent 65%);
  animation-duration: 26s;
  animation-delay: -10s;
}

.orb-3 {
  width: 35rem;
  height: 35rem;
  bottom: -12rem;
  left: 30%;
  background: radial-gradient(circle at 50% 55%, rgba(251,146,60,0.15), transparent 65%);
  animation-duration: 36s;
  animation-delay: -18s;
}

@keyframes drift {
  0%   { transform: translate(0, 0)    scale(1); }
  33%  { transform: translate(40px,-35px) scale(1.06); }
  66%  { transform: translate(-30px, 45px) scale(0.94); }
  100% { transform: translate(20px, -15px) scale(1.02); }
}

/* Noise texture overlay */
.noise {
  position: absolute;
  inset: 0;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 2.75rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--indigo), #8b5cf6 50%, var(--gold));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 24px rgba(99,102,241,0.35);
  transition: transform var(--spring), box-shadow var(--transition);
  flex-shrink: 0;
  overflow: visible;
}

.brand:hover .brand-logo {
  transform: rotate(-8deg) scale(1.08);
  box-shadow: 0 8px 28px rgba(245,188,0,0.3);
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 30%, var(--gold) 75%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--fg-2);
  letter-spacing: 0.04em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(245,188,0,0.25);
  animation: pulse-dot 2.5s ease-in-out infinite;
  display: block;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 2rem 3rem;
  text-align: center;
  flex-shrink: 0;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(245,188,0,0.08);
  border: 1px solid rgba(245,188,0,0.18);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  margin-bottom: 1.5rem;
  animation: fade-up 0.7s ease both;
}

.eyebrow-icon {
  font-size: 0.6rem;
  opacity: 0.7;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--fg);
  animation: fade-up 0.7s ease 0.08s both;
}

.gradient-text {
  background: linear-gradient(125deg, var(--gold) 0%, var(--amber) 50%, var(--indigo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin-top: 1rem;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--fg-2);
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
  animation: fade-up 0.7s ease 0.16s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TRANSLATOR LAYOUT
   ============================================================ */
.translator {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 2rem 3rem;
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: rgba(18, 20, 30, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: scale-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.22s both;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: rgba(255,255,255,0.1);
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.97) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---- Language Bar ---- */
.lang-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  background: var(--surface);
}

.lang-slot {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
}

.lang-slot-right {
  justify-content: flex-end;
}

.lang-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  flex-shrink: 0;
}

.select-wrap {
  position: relative;
  flex: 1;
  max-width: 16rem;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 2.4rem 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.select-wrap select:hover {
  background: var(--surface-hover);
  border-color: rgba(255,255,255,0.13);
}

.select-wrap select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(245,188,0,0.1);
}

.select-wrap select option {
  background: #1a1c28;
  color: var(--fg);
}

.select-arrow {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--gold);
  display: flex;
}

/* ---- Swap button ---- */
.swap-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--spring);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.swap-btn:hover {
  background: var(--gold-dim);
  border-color: rgba(245,188,0,0.4);
  color: var(--gold);
  transform: rotate(180deg) scale(1.08);
  box-shadow: 0 0 20px var(--gold-glow);
}

.swap-btn:active {
  transform: rotate(180deg) scale(0.92);
}

/* ---- Card Divider ---- */
.card-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ---- Panels ---- */
.panels {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  min-height: 20rem;
}

.panel-divider {
  width: 1px;
  background: var(--border);
  margin: 0;
  align-self: stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem 1rem;
  position: relative;
  transition: background var(--transition);
}

.panel:focus-within {
  background: rgba(245,188,0,0.02);
}

.panel-src:focus-within::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--indigo), var(--gold));
  border-radius: 0 2px 2px 0;
}

.panel-tgt:focus-within::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--gold), var(--amber));
  border-radius: 2px 0 0 2px;
}

/* ---- Textarea ---- */
.panel textarea {
  flex: 1;
  width: 100%;
  resize: none;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  font-size: 1.08rem;
  line-height: 1.7;
  font-family: inherit;
  font-weight: 400;
  padding: 0;
  min-height: 11rem;
}

.panel textarea::placeholder {
  color: var(--fg-3);
  font-weight: 400;
}

.panel textarea[readonly] {
  cursor: default;
  color: rgba(240,242,248,0.85);
}

/* ---- Output wrap & loader ---- */
.output-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

.output-wrap textarea {
  min-height: 11rem;
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.loader.hidden { display: none; }

.loader-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(13,14,20,0.88);
  border: 1px solid var(--border);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.loader-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  display: block;
  animation: bounce-dot 0.8s ease-in-out infinite;
}

.loader-dots span:nth-child(2) { animation-delay: 0.16s; }
.loader-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1.1); opacity: 1; }
}

/* ---- Panel footer ---- */
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  gap: 0.5rem;
}

.tgt-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* ---- Icon buttons ---- */
.icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--fg);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.9);
}

.icon-btn.success {
  color: var(--success);
  background: rgba(52,211,153,0.1);
  border-color: rgba(52,211,153,0.2);
}

/* ---- Counter & error ---- */
.counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--fg-3);
  letter-spacing: 0.04em;
}

.error {
  font-size: 0.72rem;
  color: var(--danger);
  font-weight: 500;
}

/* ============================================================
   QUICK PHRASES / CHIPS
   ============================================================ */
.chips-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.chips-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.chip {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg-2);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  letter-spacing: 0.01em;
}

.chip:hover {
  color: var(--fg);
  border-color: rgba(245,188,0,0.35);
  background: var(--gold-dim);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(245,188,0,0.1);
}

.chip:active {
  transform: scale(0.96) translateY(0);
}

/* ============================================================
   STATUS
   ============================================================ */
.status {
  text-align: center;
  font-size: 0.72rem;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  min-height: 1.1rem;
  flex-shrink: 0;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: 2rem 2rem 1.75rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, transparent, rgba(245,188,0,0.012));
  flex-shrink: 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--fg-2);
  opacity: 0.7;
}

.footer-logo {
  color: var(--gold);
  opacity: 0.7;
  display: flex;
}

.footer-copy {
  font-size: 0.7rem;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  opacity: 0.55;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .panels {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .panel-divider {
    width: auto;
    height: 1px;
    align-self: auto;
    background: var(--border);
  }

  .panel-src:focus-within::after,
  .panel-tgt:focus-within::after {
    inset: unset;
    width: 100%;
    height: 3px;
    left: 0;
    top: 0;
    border-radius: 0 0 2px 2px;
  }

  .panel-tgt:focus-within::after {
    top: unset;
    bottom: 0;
    border-radius: 2px 2px 0 0;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 1.1rem 1.25rem;
  }

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

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

  .live-badge span:not(.live-dot) { display: none; }
  .live-badge { padding: 0.45rem 0.7rem; }

  .hero {
    padding: 0.5rem 1.25rem 2rem;
  }

  .hero-sub { font-size: 0.92rem; }

  .translator {
    padding: 0 1.25rem 2.5rem;
    gap: 1rem;
  }

  .lang-bar {
    padding: 0.9rem 1rem;
    gap: 0.5rem;
  }

  .select-wrap select {
    font-size: 0.78rem;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
  }

  .panel {
    padding: 1rem 1.1rem 0.85rem;
  }

  .panel textarea {
    font-size: 0.95rem;
    min-height: 8rem;
  }

  .output-wrap textarea {
    min-height: 8rem;
  }

  .chip {
    font-size: 0.74rem;
    padding: 0.38rem 0.85rem;
  }

  .swap-btn {
    width: 2.4rem;
    height: 2.4rem;
  }
}

@media (max-width: 400px) {
  .hero-title { font-size: 2rem; }

  .lang-slot { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
  .lang-slot-right { align-items: flex-end; }

  .select-wrap { max-width: 100%; }
}

/* ============================================================
   UTILITY
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ============================================================
   LIGHT THEME
   ============================================================ */
[data-theme="light"] {
  --bg:           #f4f6fa;
  --bg-2:         #ffffff;
  --surface:      rgba(255,255,255,0.7);
  --surface-2:    #ffffff;
  --surface-hover:rgba(0,0,0,0.05);
  --border:       rgba(0,0,0,0.1);
  --border-focus: rgba(245,188,0,0.5);

  --fg:           #1e293b;
  --fg-2:         #475569;
  --fg-3:         #64748b;

  --shadow-card:  0 32px 80px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.04);
}

[data-theme="light"] .mesh {
  background-image:
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
}

[data-theme="light"] .card {
  background: rgba(255, 255, 255, 0.65);
}

[data-theme="light"] .select-wrap select option {
  background: #ffffff;
  color: var(--fg);
}

[data-theme="light"] .loader-dots {
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .swap-btn,
[data-theme="light"] .chip {
  background: #ffffff;
}

[data-theme="light"] .panel textarea[readonly] {
  color: rgba(30,41,59,0.85);
}