:root {
  --bg: #060913;
  --bg-elevated: rgba(18, 24, 43, 0.65);
  --bg-card: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f0f4f9;
  --text-muted: #8b9cb3;
  --accent: #5b9fd4;
  --accent-hover: #7ab3e0;
  --accent-soft: rgba(91, 159, 212, 0.15);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.12);
  --success: #05ffd5;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-x: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(2rem + var(--safe-bottom));
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Effects */
.app-background-effects {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
}

.glow-sphere-1 {
  top: -10%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, #5b9fd4 0%, transparent 70%);
}

.glow-sphere-2 {
  bottom: -10%;
  left: -10%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, #9d5bd4 0%, transparent 70%);
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(2rem + var(--safe-top)) max(1.2rem, var(--safe-x)) 2rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Header & Logo styling */
.header {
  margin-bottom: 2rem;
  animation: fadeIn 0.6s ease-out;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #5b9fd4, #9d5bd4);
  color: #060913;
  box-shadow: 0 4px 20px rgba(91, 159, 212, 0.35);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.header h1 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #a2bccc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  flex-direction: column;
}

.header .subtitle {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  -webkit-text-fill-color: initial;
  margin-top: 0.1rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* Search Section & Glowing input */
.search-section {
  margin-bottom: 1rem;
  animation: fadeInUp 0.5s ease-out 0.1s both;
}

.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.3s;
}

.search-form input {
  width: 100%;
  height: 52px;
  padding: 0 1rem 0 3.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
  backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.search-form input:focus {
  border-color: rgba(91, 159, 212, 0.6);
  background: rgba(22, 30, 54, 0.8);
  box-shadow: 0 0 25px rgba(91, 159, 212, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.search-form input:focus + .search-input-icon {
  color: var(--accent);
}

.search-form input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* Button & spinner */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #5b9fd4, #448cc4);
  color: #060913;
  box-shadow: 0 4px 15px rgba(91, 159, 212, 0.3);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  width: 52px;
  height: 52px;
  min-width: 52px;
  padding: 0;
  border-radius: var(--radius);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(91, 159, 212, 0.45);
  background: linear-gradient(135deg, #6cb2e8, #5b9fd4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
  transition: transform 0.3s;
}

.btn-primary:hover .btn-icon {
  transform: translateX(2px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2.5px solid rgba(6, 9, 19, 0.25);
  border-top-color: #060913;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Accent Selection Capsule */
.accent-toggle-wrapper {
  background: rgba(18, 24, 43, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 15px;
  backdrop-filter: blur(8px);
}

.accent-toggle {
  display: flex;
  width: 100%;
  gap: 4px;
}

.accent-option {
  flex: 1;
  height: 38px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.accent-option span {
  transition: transform 0.25s;
}

.accent-option:hover span {
  transform: scale(1.03);
}

.accent-option[data-accent="us"][aria-pressed="true"] {
  background: rgba(91, 159, 212, 0.12);
  color: var(--accent);
  border-color: rgba(91, 159, 212, 0.25);
  box-shadow: 0 2px 10px rgba(91, 159, 212, 0.08);
}

.accent-option[data-accent="uk"][aria-pressed="true"] {
  background: rgba(177, 139, 251, 0.12);
  color: #b18bfb;
  border-color: rgba(177, 139, 251, 0.25);
  box-shadow: 0 2px 10px rgba(177, 139, 251, 0.08);
}

/* Recent Searches Glassmorphism */
.history-section {
  margin: 1.5rem 0 1.25rem;
  padding: 1.1rem;
  background: rgba(18, 24, 43, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  animation: fadeIn 0.4s ease-out;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.1rem;
}

.history-header h2 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn:hover {
  color: var(--error);
  background: rgba(248, 113, 113, 0.1);
}

.clear-btn svg {
  width: 14px;
  height: 14px;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.history-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-chip:hover {
  background: rgba(91, 159, 212, 0.1);
  border-color: rgba(91, 159, 212, 0.3);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Status Notifications styling */
.status {
  padding: 1rem 1.25rem;
  border-radius: 16px;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(12px);
  border: 1px solid transparent;
  animation: fadeIn 0.3s ease-out;
}

.status-info {
  background: rgba(91, 159, 212, 0.1);
  border-color: rgba(91, 159, 212, 0.2);
  color: #a3d2f7;
}

.status-warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.2);
  color: #ffe082;
}

.status-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
  color: #ff9e9e;
}

/* Results Premium Cards layout */
.result-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.5rem;
  backdrop-filter: blur(15px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.15rem;
}

.result-word {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #5b9fd4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  word-break: break-all;
}

.play-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.play-btn:hover {
  background: rgba(91, 159, 212, 0.12);
  border-color: rgba(91, 159, 212, 0.35);
  color: var(--accent);
  transform: scale(1.08);
}

.play-btn:active {
  transform: scale(0.95);
}

.play-btn svg {
  width: 20px;
  height: 20px;
}

.play-btn .stop-icon {
  display: none;
}

.play-btn.is-playing {
  background: rgba(91, 159, 212, 0.2) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  animation: pulseGlow 1.5s infinite;
}

.play-btn.is-playing .play-icon {
  display: none;
}

.play-btn.is-playing .stop-icon {
  display: block;
}

.ipa {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 1.5rem;
  letter-spacing: 0.5px;
}

/* Part of Speech Badges */
.pos-header {
  margin-top: 1.4rem;
  margin-bottom: 0.75rem;
  display: flex;
}

.pos-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
}

.pos-noun {
  background: rgba(91, 159, 212, 0.1);
  color: #5b9fd4;
  border: 1px solid rgba(91, 159, 212, 0.2);
}

.pos-verb {
  background: rgba(177, 139, 251, 0.1);
  color: #b18bfb;
  border: 1px solid rgba(177, 139, 251, 0.2);
}

.pos-adjective, .pos-adj {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.pos-adverb, .pos-adv {
  background: rgba(74, 222, 128, 0.1);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.pos-unknown {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Senses & Translations chips styling */
.sense-item {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 1.1rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sense-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.sense-item:first-of-type {
  margin-top: 0;
}

.mandarin-translations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.mandarin-chip {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  background: linear-gradient(135deg, rgba(5, 255, 213, 0.12), rgba(5, 255, 213, 0.06));
  border: 1px solid rgba(5, 255, 213, 0.22);
  border-radius: 9px;
  color: #05ffd5;
  text-shadow: 0 0 10px rgba(5, 255, 213, 0.15);
  box-shadow: 0 2px 8px rgba(5, 255, 213, 0.04);
}

.sense-definition {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.55;
  font-weight: 450;
}

.example {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-style: normal;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid rgba(91, 159, 212, 0.35);
  padding: 0.4rem 0.75rem;
  border-radius: 0 8px 8px 0;
  margin-top: 0.65rem;
  line-height: 1.45;
}

/* Animations declarations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(91, 159, 212, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(91, 159, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 159, 212, 0); }
}

