/* LexiLayer Studio — Flagship App Design System */
:root {
  --bg-primary: #070a13;
  --bg-secondary: #0d121f;
  --bg-surface: rgba(18, 24, 38, 0.7);
  --bg-surface-hover: rgba(28, 38, 58, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(99, 102, 241, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 35px rgba(99, 102, 241, 0.25);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.12) 0px, transparent 55%),
    radial-gradient(at 85% 85%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.6) 0px, transparent 80%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 1. Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 10, 19, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 28px;
}

.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: block;
}

.lang-selector-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.lang-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.lang-select {
  background: transparent;
  color: #fff;
  border: none;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.lang-select option {
  background: var(--bg-secondary);
  color: #fff;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-val {
  color: #e2e8f0;
}

/* 2. Tabs Navigation */
.app-tabs {
  max-width: 1300px;
  margin: 20px auto 0;
  padding: 0 28px;
  width: 100%;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: #818cf8;
  border-bottom-color: #6366f1;
}

/* 3. Main Content */
.app-main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px;
  width: 100%;
  flex: 1;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
  display: block;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* 4. Flashcard 3D Scene */
.flashcard-scene {
  perspective: 1200px;
  max-width: 620px;
  height: 380px;
  margin: 30px auto;
}

.flashcard-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.flashcard-3d.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, rgba(23, 37, 84, 0.85), rgba(15, 23, 42, 0.95));
  border-color: rgba(6, 182, 212, 0.35);
}

.card-category {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #818cf8;
}

.card-word {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
}

.card-part {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card-prompt {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.card-translation-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.card-translation {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: -0.02em;
}

.card-example {
  font-style: italic;
  color: #cbd5e1;
  font-size: 1.1rem;
}

.card-definition {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.srs-actions {
  display: flex;
  gap: 14px;
  max-width: 620px;
  margin: 0 auto;
}

.srs-btn {
  flex: 1;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.srs-btn:hover {
  transform: translateY(-2px);
}

.btn-again:hover { background: rgba(244, 63, 94, 0.2); border-color: var(--accent-rose); }
.btn-hard:hover { background: rgba(245, 158, 11, 0.2); border-color: var(--accent-amber); }
.btn-good:hover { background: rgba(99, 102, 241, 0.2); border-color: var(--accent-primary); }
.btn-easy:hover { background: rgba(16, 185, 129, 0.2); border-color: var(--accent-emerald); }

.srs-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.srs-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.shortcut-hints {
  text-align: center;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 5. Audio Button */
.audio-btn {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.audio-btn:hover {
  background: rgba(99, 102, 241, 0.35);
  transform: scale(1.08);
}

/* 6. Speed Drill */
.drill-arena {
  max-width: 680px;
  margin: 30px auto;
}

.card-glass {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.start-screen {
  text-align: center;
}

.hero-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.start-screen h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.start-screen p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.prompt-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.drill-prompt-word {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  margin: 16px 0 28px;
  color: #fff;
}

.drill-choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.choice-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.choice-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.choice-btn.correct {
  background: rgba(16, 185, 129, 0.25) !important;
  border-color: var(--accent-emerald) !important;
}

.choice-btn.wrong {
  background: rgba(244, 63, 94, 0.25) !important;
  border-color: var(--accent-rose) !important;
}

.drill-scoreboard {
  display: flex;
  gap: 12px;
}

.score-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* 7. LexiReader */
.reader-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.reader-input-pane textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  margin: 10px 0 16px;
}

.reader-output-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.reader-canvas {
  flex: 1;
  background: rgba(10, 14, 23, 0.5);
  border-radius: var(--radius-sm);
  padding: 16px;
  line-height: 1.8;
  font-size: 1.05rem;
  min-height: 220px;
}

.reader-canvas span.match {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border-bottom: 2px solid #6366f1;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.reader-canvas span.match:hover {
  background: #6366f1;
  color: #fff;
}

/* 8. Dictionary Table */
.dict-filter-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
}

.search-box input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 0.95rem;
  width: 320px;
  outline: none;
}

.dict-table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.dict-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.dict-table th {
  background: rgba(15, 23, 42, 0.9);
  padding: 14px 18px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.dict-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
}

.dict-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* 9. Buttons */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: #fff;
}

/* 10. Sync Grid */
.sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.sync-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.sync-icon {
  font-size: 2.5rem;
}

.store-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.store-badge {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-subtle);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
}

.store-badge:hover {
  background: #6366f1;
}

/* 11. Footer */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(7, 10, 19, 0.9);
  padding: 20px 28px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a, .footer-inner a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover, .footer-inner a:hover {
  color: #818cf8;
}

/* Responsive */
@media (max-width: 850px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .reader-layout { grid-template-columns: 1fr; }
  .drill-choices-grid { grid-template-columns: 1fr; }
  .flashcard-scene { height: 320px; }
  .card-word { font-size: 2.2rem; }
  .card-translation { font-size: 2rem; }
}
