@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Premium Dashboard Light Theme */
  --bg-page: #fbfcfd;
  --bg-surface: #ffffff;
  --bg-hover: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  
  --accent-color: #2563eb; /* 專業深藍 */
  --accent-light: #eff6ff;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.04), 0 2px 6px -1px rgba(0,0,0,0.03);
  --shadow-hover: 0 16px 32px -4px rgba(0,0,0,0.08), 0 8px 16px -4px rgba(0,0,0,0.04);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-secondary);
  background-color: var(--bg-page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img, video { max-width: 100%; }

.container {
  width: min(1080px, 92%);
  margin: 0 auto;
}

/* =======================================
   Header
   ======================================= */
header {
  padding: 80px 0 48px;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 24px;
  font-size: 1.2rem;
  font-weight: 400;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-chip {
  padding: 6px 16px;
  border-radius: 99px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* =======================================
   Dashboard Layout
   ======================================= */
.dash-section {
  margin-bottom: 48px;
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Bento Grid (Main Lessons) */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.bento-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bento-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.bento-tag {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: 6px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bento-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.bento-card p {
  margin: 0 0 24px;
  font-size: 0.95rem;
  flex: 1;
}

.arrow-icon {
  position: absolute;
  bottom: 32px;
  right: 32px;
  opacity: 0;
  transform: translateX(-10px);
  color: var(--accent-color);
  font-weight: bold;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.bento-card:hover .arrow-icon {
  opacity: 1;
  transform: translateX(0);
}

.bento-primary {
  grid-column: span 2;
  background: linear-gradient(135deg, #ffffff 0%, #f4f8ff 100%);
  border-top: 3px solid var(--accent-color);
}
@media(max-width: 768px) { .bento-primary { grid-column: span 1; } }

/* Split Section (Bottom half) */
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
@media(max-width: 900px) { .dash-split { grid-template-columns: 1fr; } }

/* List View (Extra Resources) */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
}

.list-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateX(4px);
}

.list-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  background: var(--accent-light);
  color: var(--accent-color);
  border-radius: var(--radius-sm);
  margin-right: 16px;
  flex-shrink: 0;
}

.list-content h4 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.list-content p {
  margin: 0;
  font-size: 0.9rem;
}

.list-item .arrow-icon { right: 20px; top: 50%; bottom: auto; margin-top: -12px; }
.list-item:hover .arrow-icon { opacity: 1; transform: translateX(0); }

/* Action Center Banner */
.action-card {
  position: relative;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  height: 100%;
}

.action-content { position: relative; z-index: 2; }

.action-badge {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.2);
}

.action-card h2 {
  margin: 0 0 16px;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
}

.action-card p {
  margin: 0 0 32px;
  font-size: 1.05rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.6;
}

.btn-action {
  display: inline-block;
  background: #fff;
  color: var(--text-primary);
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-action:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.action-graphic {
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 200px;
  height: 200px;
  opacity: 0.5;
  pointer-events: none;
}
.action-graphic .circle {
  position: absolute; width: 120px; height: 120px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(59,130,246,0.5), rgba(37,99,235,0));
  top: 0; left: 0;
}
.action-graphic .square {
  position: absolute; width: 100px; height: 100px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(16,185,129,0.3), rgba(5,150,105,0));
  bottom: 20px; right: 20px; transform: rotate(15deg);
}

/* =======================================
   Article & Universal Styles
   ======================================= */
.reading-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  margin-top: 40px;
}

.toc-panel {
  position: sticky;
  top: 40px;
}

.toc-panel h3 { margin: 0 0 16px; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-strong); }
.toc-list a {
  display: block; padding: 8px 0 8px 16px; margin-left: -1px;
  border-left: 1px solid transparent; color: var(--text-secondary);
  font-size: 0.95rem; transition: all 0.2s;
}
.toc-list a:hover { color: var(--text-primary); border-left-color: var(--text-primary); }

.article-shell {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px;
  box-shadow: var(--shadow-md);
  font-size: var(--reader-font-size, 1.1rem);
  line-height: var(--reader-line-height, 1.6);
  transition: font-size 0.2s ease, line-height 0.2s ease;
}

/* Reader Toolbar States */
body.wide-mode .container {
  width: min(1400px, 95%);
  transition: width 0.3s ease;
}

body.focus-mode header,
body.focus-mode .toc-panel,
body.focus-mode .home-float {
  opacity: 0.2;
  pointer-events: none;
}
body.focus-mode header:hover,
body.focus-mode .home-float:hover {
  opacity: 1;
  pointer-events: auto;
}
body.focus-mode .reading-layout {
  grid-template-columns: 1fr;
}
body.focus-mode .toc-panel {
  display: none;
}

.article-shell h2 { font-size: 2rem; color: var(--text-primary); margin-top: 0; margin-bottom: 24px; font-weight: 700; }
.article-shell h3 { font-size: 1.25rem; color: var(--text-primary); margin-top: 40px; margin-bottom: 16px; font-weight: 600; }
.article-shell p { margin-bottom: 20px; }
.article-shell ul { padding-left: 24px; }
.article-shell li { margin-bottom: 8px; }

.back {
  display: inline-block; margin-top: 40px; padding: 10px 20px;
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text-secondary); font-weight: 500;
  transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.back:hover { background: var(--bg-hover); color: var(--text-primary); }

.reader-toolbar {
  position: fixed; right: 24px; bottom: 24px; display: flex; gap: 8px;
  background: var(--bg-surface); padding: 8px; border-radius: 99px;
  border: 1px solid var(--border-subtle); box-shadow: var(--shadow-hover);
}
.home-float {
  position: fixed; left: 24px; bottom: 24px; background: var(--bg-surface);
  color: var(--text-primary); padding: 10px 20px; border-radius: 99px;
  border: 1px solid var(--border-subtle); box-shadow: var(--shadow-hover);
  font-weight: 500; font-size: 0.9rem; transition: all 0.2s;
}
.home-float:hover { transform: translateY(-2px); }

.reader-btn {
  background: transparent; color: var(--text-secondary); border: none;
  padding: 8px 16px; border-radius: 99px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.reader-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

/* Practice Modals & Components */
.practice-shell { max-width: 800px; margin: 40px auto; }
.practice-topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-surface); padding: 16px 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle); box-shadow: var(--shadow-md); margin-bottom: 40px; gap: 16px; flex-wrap: wrap;
}
.mode-group { display: flex; background: var(--bg-hover); padding: 4px; border-radius: var(--radius-sm); }
.mode-btn { border: none; background: transparent; padding: 8px 16px; font-weight: 500; border-radius: 6px; cursor: pointer; color: var(--text-muted); transition: all 0.2s; }
.mode-btn.is-active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.filter-group { display: flex; gap: 12px; align-items: center; font-weight: 500; }
.filter-group select { border: 1px solid var(--border-strong); background: transparent; padding: 6px 12px; border-radius: 6px; outline: none; }

.status-line { display: flex; justify-content: space-between; margin-bottom: 24px; font-size: 0.9rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.quiz-question { font-size: 1.6rem; font-weight: 600; color: var(--text-primary); margin-bottom: 32px; }

.quiz-options { display: grid; gap: 12px; }
.option-btn {
  text-align: left; padding: 20px 24px; background: var(--bg-surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: 1.1rem;
  font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent-color); background: var(--accent-light); transform: translateX(2px); }
.option-btn.correct { border-color: #10b981; background: #ecfdf5; color: #065f46; }
.option-btn.wrong { border-color: #ef4444; background: #fef2f2; color: #991b1b; }

.quiz-typing-area { display: flex; gap: 16px; width: 100%; }
.quiz-input {
  flex: 1; padding: 16px 0; font-size: 1.5rem; background: transparent; border: none;
  border-bottom: 2px solid var(--border-strong); outline: none; font-weight: 500; color: var(--text-primary); transition: all 0.2s;
}
.quiz-input:focus { border-color: var(--accent-color); }
.quiz-feedback { margin-top: 24px; font-weight: 500; font-size: 1.1rem; }
.actions-row { display: flex; gap: 12px; margin-top: 32px; }
.actions-row .reader-btn { background: var(--bg-surface); border: 1px solid var(--border-strong); }
.actions-row .reader-btn:hover { border-color: var(--text-primary); }

.flash-card {
  width: 100%; aspect-ratio: 16/9; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); display: flex; flex-direction: column; justify-content: center; align-items: center;
  box-shadow: var(--shadow-md); cursor: pointer; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.flash-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.flash-card:active { transform: scale(0.98); }
.flash-side { font-size: 3rem; font-weight: 600; color: var(--text-primary); }
.flash-hint { margin-top: 24px; padding: 6px 16px; background: var(--bg-hover); border-radius: 99px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }

.translator-popover { position: absolute; width: 320px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-hover); padding: 24px; z-index: 2000; }
.translator-hidden { display: none; }
.translator-popover-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.translator-title { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.translator-close { background: var(--bg-hover); border: none; width: 28px; height: 28px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; color: var(--text-muted); transition: all 0.2s; }
.translator-close:hover { background: var(--text-secondary); color: white; }
.translator-original { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 12px; }
.translator-result { font-size: 1.1rem; font-weight: 500; color: var(--text-primary); padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 16px;}
.translator-link { color: var(--accent-color); font-size: 0.9rem; font-weight: 500; }

footer { text-align: center; padding: 40px 0; color: var(--text-muted); font-size: 0.9rem; margin-top: 60px; }

@media (max-width: 980px) {
  .reading-layout { grid-template-columns: 1fr; }
  .toc-panel { position: static; }
  .reader-toolbar { bottom: 20px; left: 50%; transform: translateX(-50%); width: max-content; }
  .home-float { bottom: auto; top: 20px; border-radius: 8px; }
}
@media (max-width: 700px) {
  .dash-split { grid-template-columns: 1fr; gap: 32px; }
  .article-shell { padding: 32px 24px; }
  header { padding: 40px 0; }
  .translator-popover { position: fixed !important; bottom: 80px !important; left: 16px !important; right: 16px !important; width: auto !important; top: auto !important; }
}
