* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

/* =====================
   ANIMATED BACKGROUND
===================== */
.animated-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, #e7f2ef, transparent 40%),
    radial-gradient(circle at 80% 30%, #a1c2bd, transparent 45%),
    radial-gradient(circle at 50% 80%, #708993, transparent 50%),
    linear-gradient(120deg, #e7f2ef, #a1c2bd, #708993);
  background-size: 300% 300%;
  animation: lightFlow 18s ease infinite;
  z-index: -1;
}

.animated-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 30% 40%, rgba(161, 194, 189, 0.4), transparent 35%),
    radial-gradient(circle at 70% 60%, rgba(112, 137, 147, 0.3), transparent 40%);
  animation: floatingOrbs 15s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes lightFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes floatingOrbs {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-30px, 20px) scale(0.95); }
}

/* =====================
   DARK MODE BACKGROUND
===================== */
body.dark .animated-bg {
  background:
    radial-gradient(circle at 15% 25%, rgba(59,193,168,0.15), transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(36,158,148,0.12), transparent 55%),
    radial-gradient(circle at 50% 80%, rgba(12,119,121,0.1), transparent 60%),
    linear-gradient(135deg, #0a1929, #0f2744, #1a3a52);
  background-size: 250% 250%;
  animation: darkFlow 20s ease-in-out infinite;
}

body.dark .animated-bg::before {
  background: 
    radial-gradient(circle at 40% 30%, rgba(59, 193, 168, 0.08), transparent 55%),
    radial-gradient(circle at 60% 70%, rgba(36, 158, 148, 0.06), transparent 60%);
}

@keyframes darkFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* =====================
   LAYOUT
===================== */
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.5s ease;
  overflow-x: hidden;
}

.container {
  width: 100%;
  padding: 20px;
  animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =====================
   GLASS CARD
===================== */
.card {
  max-width: 720px;
  margin: auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-radius: 26px;
  padding: 36px;
  box-shadow: 
    0 30px 80px rgba(25, 24, 59, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset,
    0 10px 40px rgba(161, 194, 189, 0.2);
  transition: all 0.5s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(161, 194, 189, 0.15),
    transparent
  );
  animation: shimmer 8s linear infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 40px 100px rgba(25, 24, 59, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset,
    0 15px 50px rgba(161, 194, 189, 0.3);
}

body.dark .card {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 0 0 1px rgba(59,193,168,0.15),
    0 30px 90px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 20px 60px rgba(10, 25, 41, 0.4);
}

body.dark .card::before {
  background: linear-gradient(
    45deg,
    transparent,
    rgba(59, 193, 168, 0.06),
    transparent
  );
}

body.dark .card:hover {
  box-shadow:
    0 0 0 1px rgba(59,193,168,0.25),
    0 40px 100px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 25px 70px rgba(10, 25, 41, 0.5);
  transform: translateY(-4px);
}

/* =====================
   TEXT
===================== */
header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 2rem;
  color: #19183b;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 10px rgba(25, 24, 59, 0.1);
  transition: all 0.3s ease;
}

header h1:hover {
  transform: scale(1.02);
  text-shadow: 0 4px 20px rgba(25, 24, 59, 0.15);
}

header p {
  font-size: 0.9rem;
  margin-top: 6px;
  color: #708993;
  font-weight: 400;
  opacity: 0.9;
  transition: all 0.3s ease;
}

body.dark header h1,
body.dark header p,
body.dark label {
  color: #f1f5f9;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.dark header h1:hover {
  text-shadow: 0 4px 16px rgba(59, 193, 168, 0.3);
}

/* =====================
   THEME BUTTON
===================== */
#themeToggle {
  margin-top: 14px;
  background: linear-gradient(135deg, #249e94, #3bc1a8);
  color: #ffffff;
  border-radius: 18px;
  padding: 8px 22px;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 4px 15px rgba(36, 158, 148, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

#themeToggle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

#themeToggle:hover::before {
  width: 300px;
  height: 300px;
}

#themeToggle:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 25px rgba(36, 158, 148, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

#themeToggle:active {
  transform: translateY(0);
}

/* =====================
   INPUTS
===================== */
label {
  font-size: 0.85rem;
  margin-bottom: 6px;
  display: block;
  font-weight: 500;
  letter-spacing: 0.3px;
  position: relative;
  z-index: 1;
}

textarea {
  width: 100%;
  min-height: 110px;
  border-radius: 16px;
  padding: 14px;
  border: none;
  background: #e7f2ef;
  color: #19183b;
  resize: none;
  font-size: 0.95rem;
  line-height: 1.6;
  transition: all 0.3s ease;
  box-shadow: 
    0 2px 10px rgba(112, 137, 147, 0.1),
    inset 0 1px 3px rgba(25, 24, 59, 0.05);
  position: relative;
  z-index: 1;
}

textarea:focus {
  outline: none;
  background: #ffffff;
  box-shadow: 
    0 4px 20px rgba(36, 158, 148, 0.15),
    0 0 0 2px rgba(36, 158, 148, 0.3),
    inset 0 1px 3px rgba(25, 24, 59, 0.05);
  transform: translateY(-2px);
}

textarea::placeholder {
  color: rgba(112, 137, 147, 0.6);
  transition: color 0.3s ease;
}

textarea:focus::placeholder {
  color: rgba(112, 137, 147, 0.4);
}

body.dark textarea {
  background: rgba(30, 41, 59, 0.6);
  color: #f1f5f9;
  box-shadow: 
    0 2px 10px rgba(0, 0, 0, 0.4),
    inset 0 1px 3px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(59, 193, 168, 0.1);
}

body.dark textarea:focus {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(59, 193, 168, 0.4);
  box-shadow: 
    0 4px 20px rgba(59, 193, 168, 0.15),
    0 0 0 2px rgba(59, 193, 168, 0.3),
    inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark textarea::placeholder {
  color: rgba(203, 213, 225, 0.4);
}

/* =====================
   BUTTONS
===================== */
button {
  border: none;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 16px;
  transition: all 0.25s ease;
  font-weight: 500;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

button:hover::after {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

button:active {
  transform: translateY(-1px);
}

#speechBtn {
  background: linear-gradient(135deg, #0c7779, #249e94);
  color: white;
  margin-top: 10px;
  box-shadow: 
    0 4px 15px rgba(12, 119, 121, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

#speechBtn:hover {
  box-shadow: 
    0 8px 25px rgba(12, 119, 121, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

#translateBtn {
  background: linear-gradient(135deg, #3bc1a8, #249e94);
  color: white;
  box-shadow: 
    0 4px 15px rgba(59, 193, 168, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

#translateBtn:hover {
  box-shadow: 
    0 8px 25px rgba(59, 193, 168, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

#copyBtn {
  background: linear-gradient(135deg, #708993, #5a6d76);
  color: white;
  box-shadow: 
    0 4px 15px rgba(112, 137, 147, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

#copyBtn:hover {
  box-shadow: 
    0 8px 25px rgba(112, 137, 147, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

#speakOutput {
  background: linear-gradient(135deg, #249e94, #3bc1a8);
  color: white;
  margin-top: 10px;
  box-shadow: 
    0 4px 15px rgba(36, 158, 148, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

#speakOutput:hover {
  box-shadow: 
    0 8px 25px rgba(36, 158, 148, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* =====================
   LANGUAGE SELECT
===================== */
.language-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  margin: 22px 0;
  align-items: center;
  position: relative;
  z-index: 1;
}

select {
  padding: 10px 14px;
  border-radius: 16px;
  border: none;
  background: #e7f2ef;
  color: #19183b;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 
    0 2px 10px rgba(112, 137, 147, 0.1),
    inset 0 1px 3px rgba(25, 24, 59, 0.05);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2319183b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
  min-width: 150px;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

select option {
  background: #ffffff;
  color: #19183b;
  padding: 10px;
  font-weight: 500;
}

select:hover {
  background-color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 
    0 4px 15px rgba(36, 158, 148, 0.15),
    inset 0 1px 3px rgba(25, 24, 59, 0.05);
}

select:focus {
  outline: none;
  box-shadow: 
    0 4px 20px rgba(36, 158, 148, 0.2),
    0 0 0 2px rgba(36, 158, 148, 0.3);
}

body.dark select {
  background: rgba(30, 41, 59, 0.6);
  color: #f1f5f9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f1f5f9' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  box-shadow: 
    0 2px 10px rgba(0, 0, 0, 0.4),
    inset 0 1px 3px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(59, 193, 168, 0.1);
}

body.dark select option {
  background: #1e293b;
  color: #f1f5f9;
}

body.dark select:hover {
  background-color: rgba(30, 41, 59, 0.8);
  border-color: rgba(59, 193, 168, 0.2);
  box-shadow: 
    0 4px 15px rgba(59, 193, 168, 0.15),
    inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark select:focus {
  border-color: rgba(59, 193, 168, 0.4);
  box-shadow: 
    0 4px 20px rgba(59, 193, 168, 0.2),
    0 0 0 2px rgba(59, 193, 168, 0.3);
}

/* =====================
   FOOTER STATUS
===================== */
#status {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 8px;
  text-align: center;
  font-weight: 400;
  letter-spacing: 0.2px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

#status:not(:empty) {
  animation: statusPulse 0.5s ease-out;
}

@keyframes statusPulse {
  0% { transform: scale(0.95); opacity: 0; }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 0.85; }
}

/* =====================
   SWAP ICON STYLING
===================== */
.language-section > :nth-child(2) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3bc1a8, #249e94);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 
    0 4px 12px rgba(36, 158, 148, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.language-section > :nth-child(2):hover {
  transform: rotate(180deg) scale(1.1);
  box-shadow: 
    0 6px 20px rgba(36, 158, 148, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.language-section > :nth-child(2):active {
  transform: rotate(180deg) scale(0.95);
}

/* =====================
   RESPONSIVE DESIGN
===================== */
@media (max-width: 768px) {
  .card {
    padding: 24px;
    border-radius: 20px;
  }

  header h1 {
    font-size: 1.6rem;
  }

  .language-section {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .language-section > :nth-child(2) {
    transform: rotate(90deg);
  }

  .language-section > :nth-child(2):hover {
    transform: rotate(270deg) scale(1.1);
  }
}

/* =====================
   ACCESSIBILITY
===================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}