/* ============================================================
   LaoTalk — Global Styles
   Purple gradient theme · Mobile-first · Dark/Light mode
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease; }

/* ── Apple Haptic Touch — 全局点击缩放动画 ────────────────── */
:root {
  /* Apple 风格交互变量 */
  --tap-scale:       0.965;
  --tap-shadow:      0 1px 2px rgba(0,0,0,0.06);
  --tap-duration:    0.12s;
  --tap-timing:      cubic-bezier(0.32, 0.72, 0, 1);
  --spring-bounce:    cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 所有可点击的交互元素默认按压效果 */
button,
[role="button"],
a,
[role="tab"],
[role="listitem"],
.tab-btn,
.learn-tab-btn,
.phrase-card,
.word-row,
.nav-item,
.pack-sel-btn,
.guide-btn,
.card-play-btn,
.card-fav-btn,
.card-expand-btn,
.card-copy-btn,
.know-btn,
.unknown-btn,
.fab,
.fc-target-option,
.dict-item,
.check-btn,
.icon-btn {
  transition:
    transform           var(--tap-duration) var(--tap-timing),
    box-shadow         var(--tap-duration) var(--tap-timing),
    background-color   0.15s ease,
    opacity            0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* 苹果风格 — 按下缩放 + 阴影压缩 */
button:active,
[role="button"]:active,
a:active,
[role="tab"][aria-selected="true"],
.phrase-card:active,
.word-row:active,
.pack-sel-btn:active,
.guide-btn:active,
.card-play-btn:active,
.card-fav-btn:active,
.card-expand-btn:active,
.card-copy-btn:active,
.know-btn:active,
.unknown-btn:active,
.fc-target-option:active,
.dict-item:active,
.check-btn:active,
.icon-btn:active {
  transform: scale(var(--tap-scale));
  box-shadow: var(--tap-shadow);
}

/* 输入框聚焦苹果风格 */
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
  border-color: var(--primary) !important;
}

/* ── Apple Haptic Touch — Utility Classes ──────────────────── */
.tap-animate {
  transition:
    transform           var(--tap-duration) var(--tap-timing),
    box-shadow         var(--tap-duration) var(--tap-timing),
    background-color   0.15s ease,
    opacity            0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
}

.tap-scale:active {
  transform: scale(var(--tap-scale));
  box-shadow: var(--tap-shadow);
}

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary:       #007AFF;
  --primary-dark:  #0056CC;
  --primary-glow: rgba(0, 122, 255, 0.25);
  --primary-soft: rgba(0, 122, 255, 0.10);
  --accent:        #667eff;
  --accent-dark:   #4f97ff;
  --page-gutter:   1rem;
  --bg:            #F2F2F7;
  --bg-secondary:  #E5E5EA;
  --surface:       #ffffff;
  --surface-hover: #F5F5FA;
  --text:          #000000;
  --text-secondary:#3C3C43;
  --text-muted:    #8E8E93;
  --border:        rgba(60, 60, 67, 0.18);
  --border-light:  rgba(60, 60, 67, 0.12);
  --success:       #34C759;
  --warning:       #FF9500;
  --danger:        #FF3B30;
  --radius:        20px;
  --radius-sm:     16px;
  --radius-xs:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:     0 10px 30px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.06);
  --hdr-h:         64px;
  --fav-color:     #f43f5e;
  
  --hero-grad: linear-gradient(135deg, #6b7dff 0%, #3d9bff 42%, #8b5cff 100%);
  --hero-grad-soft: linear-gradient(180deg, rgba(107,125,255,0.14), rgba(61,155,255,0.08) 45%, rgba(139,92,255,0.06) 100%);
  --surface-strong: rgba(255,255,255,0.92);
  --surface-soft: rgba(248,250,255,0.9);
  --line-strong: rgba(107,125,255,0.16);
  --page-bg-layer-1: #f7f8ff;
  --page-bg-layer-2: #eef1ff;
  --page-bg-layer-3: #f5f2ff;
  --card-grad: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
}

[data-theme="dark"] {
  --card-grad: linear-gradient(135deg, #1a1e3a 0%, #202448 100%);
  --bg:            #1C1C1E;
  --bg-secondary:  #2C2C2E;
  --surface:       #2C2C2E;
  --surface-hover: #3A3A3C;
  --text:          #FFFFFF;
  --text-secondary:#EBEBF5;
  --text-muted:    #8E8E93;
  --border:        rgba(84, 84, 88, 0.65);
  --border-light:  rgba(84, 84, 88, 0.4);
  --primary:       #0A84FF;
  --primary-dark:  #409CFF;
  --primary-glow:  rgba(10, 132, 255, 0.25);
  --primary-soft:  rgba(10, 132, 255, 0.15);
  --accent:        #5E5CE6;
  --accent-dark:   #BF5AF2;
  --shadow:        0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg:     0 16px 48px rgba(0, 0, 0, 0.6);
  --surface-strong: rgba(20,24,46,0.9);
  --surface-soft: rgba(26,31,58,0.88);
  --line-strong: rgba(145,156,255,0.18);
  --page-bg-layer-1: #0d1025;
  --page-bg-layer-2: #131935;
  --page-bg-layer-3: #15112d;
}

/* ── Base ──────────────────────────────────────────────────── */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Noto Sans Lao', 'Noto Sans', 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(circle at top center, rgba(126, 108, 255, 0.14), transparent 36%),
              radial-gradient(circle at 100% 10%, rgba(0, 122, 255, 0.12), transparent 32%),
              linear-gradient(180deg, var(--page-bg-layer-1) 0%, var(--page-bg-layer-2) 45%, var(--page-bg-layer-3) 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Layout ───────────────────────────────────────────── */
.app-container, .app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

[data-theme="dark"] .app-container, [data-theme="dark"] .app {
  background: #1C1C1E;
}

.main-content {
  flex: 1;
  width: 100%;
  position: relative;
}

/* ── Utility Classes ────────────────────────────────────────── */
.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  padding: 0.5rem 0 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 480px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.page {
  width: 100%;
  padding: 1rem var(--page-gutter) calc(100px + env(safe-area-inset-bottom, 0px));
  min-height: calc(100vh - 64px);
  animation: pageSlideIn 0.2s ease-out;
  box-sizing: border-box;
}

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

/* ── Splash Screen ───────────────────────────────────────────── */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  gap: 20px;
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: splash-pulse 1.6s ease-in-out infinite;
}

.splash-logo-img {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.splash-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.splash-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.splash-dots { display: flex; gap: 8px; margin-top: 4px; }
.splash-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); opacity: 0.35; animation: splash-dot-bounce 1.2s ease-in-out infinite; }
.splash-dot:nth-child(2) { animation-delay: 0.2s; }
.splash-dot:nth-child(3) { animation-delay: 0.4s; }

.splash-bar { width: 140px; height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 8px; }
.splash-bar-fill { height: 100%; border-radius: 2px; background: var(--primary); animation: splash-progress 2.5s ease-out forwards; }

@keyframes splash-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.04); opacity: 0.88; } }
@keyframes splash-dot-bounce { 0%, 100% { transform: translateY(0); opacity: 0.35; } 50% { transform: translateY(-6px); opacity: 1; } }
@keyframes splash-progress { 0% { width: 0%; } 60% { width: 85%; } 100% { width: 100%; } }

/* ── Common Components (Utility) ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-secondary);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 0.85rem; opacity: 0.5; filter: grayscale(0.3); }

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

mark {
  background: rgba(102,126,234,0.2); 
  color: var(--primary); 
  border-radius: 2px; 
  padding: 0 1px;
}

[data-theme="dark"] mark {
  background: rgba(129, 140, 248, 0.25);
  color: var(--primary);
}

/* ── Range slider ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--primary-glow);
  transition: transform 0.12s var(--tap-timing);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(0.9); }

/* ── Responsive ── */
@media (max-width: 480px) {
  :root { --page-gutter: 0.75rem; --hdr-h: 58px; }
  .app-container { max-width: 100%; }
}

@media (min-width: 768px) {
  .app-container { max-width: 520px; }
}
.hdr {
  background:
    linear-gradient(135deg, rgba(116, 92, 255, 0.98) 0%, rgba(72, 138, 255, 0.96) 55%, rgba(126, 88, 214, 0.98) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0));
  box-shadow:
    0 18px 40px rgba(78, 95, 214, 0.24),
    0 3px 10px rgba(35, 43, 93, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.26);
  border: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 0 1rem;
  transition: background 0.3s ease;
}

.hdr::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 55%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0));
  pointer-events: none;
}

.hdr-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--hdr-h);
}

.hdr-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hdr-logo-img {
  height: 36px;
  object-fit: contain;
  border-radius: 20%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.hdr-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.hdr-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.hdr-icon-btn:active { transform: scale(var(--tap-scale, 0.965)); }
.hdr-icon-btn.active {
  background: #fff;
  color: var(--primary);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  z-index: 9999;
  min-width: 140px;
  overflow: hidden;
  animation: dropdownIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  font-weight: 600;
  transition: transform var(--tap-duration) var(--tap-timing),
              background-color 0.15s ease;
}

.lang-option:hover { background: var(--surface-soft); }
.lang-option:active { transform: scale(var(--tap-scale, 0.965)); }
.lang-option.active { background: var(--hero-grad); color: #fff; }

@media (max-width: 480px) {
  .hdr { border-radius: 0 0 22px 22px; margin-bottom: 0.25rem; }
  .hdr-logo-img { height: 32px; }
  .hdr-icon-btn { width: 40px; height: 40px; }
}

[data-theme="dark"] .hdr-icon-btn {
  background: rgba(255,255,255,0.08);
}
.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 480px;
  height: 68px;
  z-index: 500;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 8px;
  box-sizing: border-box;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.nav-hidden { transform: translate(-50%, calc(100% + 20px)); }
.nav-visible { transform: translate(-50%, 0); }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  height: 100%;
  user-select: none;
}

.nav-item:active {
  transform: scale(0.9);
  opacity: 0.7;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.nav-item span {
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  transform: scale(1.1) translateY(-2px);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(30, 30, 34, 0.95);
  border-color: rgba(255, 255, 255, 0.08);
}
/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

[data-theme="dark"] .toast {
  background: rgba(60, 60, 60, 0.92);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.login-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: overlayIn 0.3s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.login-modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  padding: 2.2rem 1.8rem;
  width: 100%;
  max-width: 360px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.login-modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--bg-secondary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.login-modal-close:hover { background: var(--border); color: var(--text); }

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-input {
  width: 100%;
  min-height: 54px;
  padding: 0 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  box-sizing: border-box;
  transition: all 0.25s;
}

.login-input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.login-error-msg {
  color: #ef4444;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  background: rgba(239, 68, 68, 0.1);
  padding: 8px;
  border-radius: 10px;
  margin: -0.5rem 0;
}

.login-submit-btn {
  width: 100%;
  min-height: 56px;
  background: var(--hero-grad);
  color: #fff;
  border: none;
  border-radius: 18px;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.35);
  transition: all 0.2s;
}

.login-submit-btn:active {
  transform: scale(0.965) translateY(1px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.28);
  opacity: 0.88;
}

.login-submit-btn {
  width: 100%;
  min-height: 56px;
  background: var(--hero-grad);
  color: #fff;
  border: none;
  border-radius: 18px;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.35);
  transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1),
              box-shadow 0.18s ease,
              opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.login-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: var(--border-light);
}

.social-login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.social-btn:active { transform: scale(0.96); }

.social-btn {
  min-height: 50px;
  border-radius: 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  transition: all 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.social-btn:hover { background: var(--surface-hover); border-color: var(--text-muted); }

.login-footer {
  margin-top: 1.8rem;
  text-align: center;
}

.toggle-mode-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 16px;
  transition: opacity 0.2s;
}

.toggle-mode-btn:hover { opacity: 0.8; text-decoration: underline; }

[data-theme="dark"] .login-modal {
  background: #1c1c1e;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .login-input, [data-theme="dark"] .social-btn {
  background: #2c2c2e;
  border-color: rgba(255, 255, 255, 0.1);
}
