/* ==========================================================================
   LinguaFlow (語流) - Ultimate Complete Edition 🌊 (Colors + Physics)
   ========================================================================== */

:root {
  --primary: #2c3e50;

  /* 🌊 絕美海洋藍綠漸層回歸 (Oklch 高光澤色彩空間) */
  --ocean-start: oklch(0.6 0.15 250);
  --ocean-mid: oklch(0.65 0.18 220);
  --ocean-end: oklch(0.7 0.15 190);
  --ocean-grad: linear-gradient(135deg, var(--ocean-start), var(--ocean-end));
  --ocean-grad-x: linear-gradient(
    90deg,
    var(--ocean-start),
    var(--ocean-mid),
    var(--ocean-end)
  );

  --secondary: #3498db; /* 保留作為一般文字高亮 */
  --accent: #e67e22;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text-main: #2c3e50;
  --text-sub: #7f8c8d;
  --border: #edf2f7;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 🛡️ SVG 尺寸絕對鎖死 (專治哥吉拉) */
svg {
  display: block;
  flex-shrink: 0;
}
.search-icon {
  width: 20px !important;
  height: 20px !important;
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-sub);
}
.inline-icon {
  width: 18px !important;
  height: 18px !important;
  vertical-align: -3px;
  display: inline-block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.btn-icon {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  margin-right: 4px;
}
.nav-icon {
  width: 24px !important;
  height: 24px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.action-icon {
  width: 24px !important;
  height: 24px !important;
  cursor: pointer;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: transform 0.2s;
}
.action-icon:active {
  transform: scale(0.85);
}
.play-icon {
  width: 28px !important;
  height: 28px !important;
  fill: currentColor;
}
.modal-icon {
  width: 24px !important;
  height: 24px !important;
  margin-right: 8px;
  vertical-align: middle;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.chip-icon {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.gear-icon {
  width: 24px !important;
  height: 24px !important;
  transition: transform 0.3s ease;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.tutorial-icon {
  width: 24px !important;
  height: 24px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  margin-top: 2px;
}

/* 💎 Header & Logo */
header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 20px 20px 15px;
  border-bottom: 1px solid var(--border);
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.logo-area {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: default;
}
.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.brand-name {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.brand-zh {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: 0.05em;
}
.brand-logo {
  width: 75px !important;
  height: 38px !important;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.logo-area:hover .brand-logo {
  transform: scale(1.05) translateX(2px);
}

.setting-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-sub);
  transition: 0.3s;
}
.setting-trigger:hover {
  color: var(--primary);
  background: var(--bg);
}
.setting-trigger:hover .gear-icon {
  transform: rotate(30deg);
}

/* Progress (🌊 3色平滑海洋漸層) */
.progress-wrapper {
  background: var(--card-bg);
  padding: 15px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
}
.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-sub);
  margin-bottom: 8px;
}
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--ocean-grad-x);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Search & Action Buttons */
.search-container {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-input-wrapper {
  position: relative;
  flex: 1;
}
.search-input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  background: #f8f9fa;
  transition: 0.3s;
}
.search-input:focus {
  outline: none;
  border-color: var(--secondary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  font-size: 0.9rem;
}
/* 🌊 漸層主按鈕回歸 */
.btn-primary {
  background: var(--ocean-grad);
  color: white;
  box-shadow: 0 4px 12px
    color-mix(in oklch, var(--ocean-start) 30%, transparent);
}
.btn-primary:active {
  transform: scale(0.96);
}
.btn-ghost {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-ghost:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}
#btn-focus.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(230, 126, 34, 0.3);
}

/* Categories (🌊 選中時套用海洋漸層) */
.category-nav {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar {
  display: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--card-bg);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-sub);
  cursor: pointer;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: 0.3s;
}
.chip.active {
  background: var(--ocean-grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 10px
    color-mix(in oklch, var(--ocean-start) 25%, transparent);
}

/* Cards & 🚀 物理級滾動動畫 */
main {
  padding: 15px 20px 100px;
  max-width: 600px;
  margin: 0 auto;
}
.unit-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin: 20px 0 10px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
  position: relative;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.3s,
    opacity 0.3s,
    border 0.3s;
  border: 1px solid transparent;
  scroll-margin-top: 180px;
}
.card.playing {
  background: #f0f8ff;
  transform: scale(1.02);
  border: 1px solid var(--secondary);
  box-shadow: 0 8px 24px rgba(52, 152, 219, 0.15);
}
.card h2 {
  margin: 0 0 5px;
  font-size: 1.4rem;
  color: var(--primary);
  font-weight: 800;
}
.card p {
  margin: 0;
  color: var(--text-sub);
  font-size: 0.95rem;
}
.card-actions {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 15px;
}

/* 卡片消滅動畫 */
.card.mastered-anim {
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  pointer-events: none;
  border-color: transparent;
  box-shadow: none;
}

/* 滾動浮現特效 */
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@supports (animation-timeline: view()) {
  .card {
    animation: reveal both;
    animation-timeline: view();
    animation-range: entry 5% cover 20%;
  }
}

/* 例句排版專區 */
.eg-box {
  margin-top: 15px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  border-left: 3px solid var(--secondary);
}
.eg-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
}
.eg-cn {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-top: 4px;
  padding-left: 26px;
}
.volume-icon {
  color: var(--secondary);
  margin-top: 2px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.volume-icon.speaking {
  color: var(--accent);
  transform: scale(1.2);
}

.note-area {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: bold;
}

/* Action Icons */
.action-icon.star.active {
  fill: #f1c40f;
  stroke: #f1c40f;
}
.action-icon.check-icon {
  stroke: #27ae60;
}
.action-icon.undo-icon {
  stroke: var(--accent);
}

/* Bottom Bar (🌊 播放鍵專屬海洋漸層) */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 200;
}
.control-btn {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-sub);
  cursor: pointer;
  font-weight: bold;
  font-size: 0.7rem;
  transition: color 0.3s;
}
.control-btn.active {
  color: var(--secondary);
}
.play-btn {
  width: 56px;
  height: 56px;
  background: var(--ocean-grad);
  border-radius: 50%;
  border: none;
  color: white;
  margin-top: -25px;
  cursor: pointer;
  box-shadow: 0 6px 16px
    color-mix(in oklch, var(--ocean-start) 40%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.play-btn:active {
  transform: scale(0.92);
}
.play-btn.playing {
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(230, 126, 34, 0.4);
}

/* Modals & Toast */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}
.modal-overlay.open {
  display: flex;
  opacity: 1;
}
.modal-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 25px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal-card {
  transform: translateY(0);
}
.modal-title {
  margin: 0 0 15px;
  color: var(--primary);
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.note-target-text {
  font-size: 1.1rem;
  color: var(--secondary);
  font-weight: 800;
  margin-bottom: 15px;
  text-align: center;
  background: #f0f8ff;
  padding: 8px;
  border-radius: 8px;
}

.modal-card textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  resize: none;
  margin-top: 5px;
  font-family: inherit;
  font-size: 1rem;
}
.modal-card textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn {
  flex: 1;
}

.setting-item {
  margin-bottom: 20px;
}
.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-main);
  color: white;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: bold;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
  pointer-events: none;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.danger-btn {
  border: 1px solid #e74c3c !important;
  color: #e74c3c !important;
  background: transparent;
}
.danger-btn:hover {
  background: #fff0f0 !important;
}

/* 廣告防跑版預留區 */
.ad-wrapper {
  margin: 15px 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 16px;
  min-height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px dashed var(--border);
}

.empty-search {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-sub);
  font-weight: bold;
  font-size: 1.1rem;
}
.app-footer {
  text-align: center;
  padding: 20px 15px 100px;
  font-size: 0.8rem;
  color: var(--text-sub);
  line-height: 1.8;
}
.app-footer a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
}
