:root {
  --bg-primary: #090d16;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-primary: #38bdf8;
  --accent-gradient: linear-gradient(135deg, #0284c7, #38bdf8);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-hanzi: "Noto Serif TC", "KaiTi", "BiauKai", "DFKai-SB", "Microsoft JhengHei", serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* App Layout Grid */
.app-layout {
  display: flex;
  min-height: 82vh;
  position: relative;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.06) 0px, transparent 50%);
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  margin: 20px 0;
  width: 100%;
}

/* Left Sidebar Navigation */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.brand-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 8px rgba(34, 197, 94, 0.4));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.brand-tag {
  background: var(--accent-gradient);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
  margin-top: 2px;
}

/* Top Right Account Auth Container */
.top-right-account {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.btn-open-auth-modal {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  transition: all 0.2s;
}

.btn-open-auth-modal:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.6);
}

.account-top-right-box {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.user-status {
  font-size: 10.5px;
  color: var(--success);
  font-weight: 600;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #ef4444;
  color: white;
}

/* Auto Read Toggle Switch in Controls Bar */
.auto-read-group {
  padding: 8px 14px;
}

.auto-read-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  user-select: none;
}

.auto-read-toggle-label input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: #334155;
  border-radius: 20px;
  position: relative;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.auto-read-toggle-label input:checked + .toggle-slider {
  background: #22c55e;
}

.auto-read-toggle-label input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* Audio Player Control Bar in Flashcard */
.card-audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px 0;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 14px;
}

.read-word-btn {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
  transition: transform 0.15s;
}

.read-word-btn:hover {
  transform: scale(1.04);
}

.speed-select {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  outline: none;
}

/* Auth Modal Popup */
.auth-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  padding: 32px 28px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  animation: modalFadeIn 0.25s ease-out;
  text-align: left;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.auth-modal-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
}

.auth-modal-close:hover {
  color: #ffffff;
}

.auth-modal-logo {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 16px;
  text-align: center;
}

.auth-modal-tabs {
  display: flex;
  background: #0f172a;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab-btn.active {
  background: var(--accent-gradient);
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-input {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #ffffff;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.form-error {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  color: #fee2e2;
  padding: 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

.auth-submit-btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
}

.auth-submit-btn.btn-register-color {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
}

.form-footer-link {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

.form-footer-link a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 700;
}

/* Sidebar Bottom Account Box */
.sidebar-account-bottom {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 10px;
}

/* Menu Section */
.menu-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.menu-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 6px;
  padding-left: 8px;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item:hover .nav-icon {
  color: var(--accent-primary);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent-primary);
  font-weight: 700;
}

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

/* Sidebar FSRS Stats Widget */
.sidebar-stats-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0;
}

.stats-header {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
}

.stat-val {
  font-weight: 800;
  color: var(--accent-primary);
}

.sidebar-footer {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Header & Filters */
.top-header {
  margin-bottom: 24px;
}

.controls-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.control-group:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.control-icon {
  color: var(--text-muted);
  font-size: 14px;
  margin-right: 10px;
}

.select-control {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  min-width: 180px;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.select-control option {
  background: #0f172a;
  color: #f8fafc;
}

.search-group {
  flex: 1;
  min-width: 240px;
}

.search-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 12px 0;
  font-size: 14px;
  outline: none;
  width: 100%;
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* Flashcard Area */
.flashcard-section {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.flashcard-wrapper {
  max-width: 680px;
  width: 100%;
}

.flashcard-wrapper.worksheet-mode, .flashcard-wrapper.dataview-mode {
  max-width: 100%;
}

.flashcard {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 36px 30px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  align-self: center;
}

.card-hanzi {
  font-family: var(--font-hanzi);
  font-size: 68px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 4px 16px rgba(56, 189, 248, 0.2);
  margin: 16px 0 6px 0;
  line-height: 1.2;
}

.card-pinyin {
  font-size: 22px;
  color: var(--accent-primary);
  font-weight: 700;
  margin-bottom: 12px;
}

.card-def {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.5;
  margin: 12px 0;
}

.card-pos {
  display: inline-block;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  color: var(--text-muted);
}

.card-hanviet {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.audio-btn {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  margin: 10px auto;
  transition: all 0.2s;
}

.audio-btn:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

/* High Contrast Boxes */
.explanation-box {
  text-align: left;
  background: #1e293b;
  border-left: 4px solid var(--accent-primary);
  padding: 14px 18px;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 15px;
  line-height: 1.6;
  color: #f1f5f9;
}

.structure-box {
  text-align: left;
  background: #3b2d04;
  border: 1.5px solid #f59e0b;
  color: #fef08a;
  padding: 14px 18px;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

/* Examples Box */
.examples-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  margin-top: 16px;
}

.example-item {
  margin-bottom: 10px;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 8px;
}

.example-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.ex-hz { font-weight: 700; color: #ffffff; font-size: 17px; }
.ex-py { color: var(--accent-primary); font-size: 14px; margin-top: 2px; }
.ex-tr { color: var(--text-muted); font-style: italic; font-size: 14px; margin-top: 2px; }

/* Action Button */
.show-ans-btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 340px;
  margin: 18px auto 0 auto;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
  transition: all 0.2s;
}

.show-ans-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

/* Card Navigation Bar: Prev / Counter / Next */
.card-nav-bar {
  display: none; /* Hidden by default, shown by JS for flashcard modes */
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding: 10px 0;
}

.card-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  background: rgba(30, 41, 59, 0.85);
  color: #94a3b8;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.card-nav-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.card-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.card-nav-counter {
  font-size: 15px;
  font-weight: 800;
  color: #e2e8f0;
  min-width: 120px;
  text-align: center;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-nav-counter .nav-current {
  color: #38bdf8;
  font-size: 20px;
}

.card-nav-counter .nav-total {
  color: #64748b;
}

.card-nav-counter .nav-due-badge {
  display: inline-block;
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 8px;
}

/* FSRS Rating Buttons */
.fsrs-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.fsrs-btn {
  flex: 1;
  max-width: 140px;
  padding: 12px 8px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fsrs-btn.btn-again { background: #991b1b; color: #fecaca; }
.fsrs-btn.btn-again:hover { background: #dc2626; color: white; transform: translateY(-2px); }

.fsrs-btn.btn-hard { background: #854d0e; color: #fef08a; }
.fsrs-btn.btn-hard:hover { background: #ca8a04; color: white; transform: translateY(-2px); }

.fsrs-btn.btn-good { background: #166534; color: #bbf7d0; }
.fsrs-btn.btn-good:hover { background: #16a34a; color: white; transform: translateY(-2px); }

.fsrs-btn.btn-easy { background: #075985; color: #bae6fd; }
.fsrs-btn.btn-easy:hover { background: #0284c7; color: white; transform: translateY(-2px); }

.btn-time { font-size: 11px; opacity: 0.85; }

/* Vector Stroke Box */
.stroke-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  margin: 14px auto;
  display: inline-block;
}

.stroke-target {
  width: 140px;
  height: 140px;
  margin: 0 auto;
}

.replay-stroke-btn {
  background: #0284c7;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* ==========================================================================
   QUIZ OPTIONS REDESIGN
   ========================================================================== */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
  text-align: left;
  width: 100%;
}

.opt-btn {
  background: #1e293b;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.opt-btn:hover {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.12);
  transform: translateX(4px);
}

.opt-label {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.35);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.opt-btn.correct {
  background: #14532d !important;
  border-color: #22c55e !important;
  color: #dcfce7 !important;
}

.opt-btn.correct .opt-label {
  background: #22c55e !important;
  color: #052e16 !important;
  border-color: #4ade80 !important;
}

.opt-btn.wrong {
  background: #7f1d1d !important;
  border-color: #ef4444 !important;
  color: #fee2e2 !important;
}

.opt-btn.wrong .opt-label {
  background: #ef4444 !important;
  color: #450a0a !important;
  border-color: #fca5a5 !important;
}

/* Type Input */
.type-input {
  background: var(--bg-primary);
  border: 2px solid var(--accent-primary);
  color: #ffffff;
  font-family: var(--font-hanzi);
  font-size: 26px;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  width: 100%;
  max-width: 320px;
  margin: 16px auto;
  outline: none;
}

/* ==========================================================================
   07. DYNAMIC EX GENERATOR
   ========================================================================== */
.ezitie-workspace {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
}

@media (max-width: 1024px) {
  .ezitie-workspace { flex-direction: column-reverse; }
}

.ezitie-preview-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ezitie-a4-sheet {
  background: #ffffff !important;
  color: #000000 !important;
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 12mm;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  box-sizing: border-box;
  text-align: left;
}

.ez-page-header {
  border-bottom: 2px solid #ef4444;
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.ez-page-title {
  font-size: 20px;
  font-weight: 900;
  color: #b91c1c;
  font-family: var(--font-hanzi);
}

.ez-page-meta {
  font-size: 11px;
  color: #374151;
  display: flex;
  gap: 16px;
}

.ez-rows-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ez-char-row {
  border: 1px solid #fecaca;
  padding: 6px 8px;
  border-radius: 4px;
  background: #fff;
}

.ez-row-meta-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #374151;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px dashed #fca5a5;
  flex-wrap: wrap;
}

.ez-row-py {
  font-size: 13px;
  font-weight: 800;
  color: #b91c1c;
}

.ez-row-stroke-count {
  font-size: 11px;
  background: #fef2f2;
  color: #991b1b;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #fca5a5;
  font-weight: 700;
}

.ez-row-stroke-diagram {
  font-family: var(--font-hanzi);
  font-size: 12px;
  color: #475569;
}

.ez-cells-grid {
  display: flex;
  gap: 0;
}

.ez-cell {
  width: 14mm;
  height: 14mm;
  border: 1px solid #ef4444;
  position: relative;
  box-sizing: border-box;
}

.ez-cell-char {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hanzi);
  font-size: 10.5mm;
  line-height: 1;
  user-select: none;
}

.ez-cell-char.solid { color: #000000; font-weight: 800; }
.ez-cell-char.tracing { color: #fca5a5; font-weight: 400; }
.ez-cell-char.hollow { -webkit-text-stroke: 0.8px #475569; color: transparent; }

.ezitie-controls-col {
  width: 320px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.ez-panel-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.ez-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ez-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.ez-textarea {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #ffffff;
  padding: 10px;
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font-hanzi);
  resize: vertical;
  min-height: 80px;
  outline: none;
}

.ez-textarea:focus, .ez-select:focus, .ez-input:focus {
  border-color: var(--accent-primary);
}

.ez-select, .ez-input {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #ffffff;
  padding: 10px;
  border-radius: 10px;
  font-size: 13.5px;
  outline: none;
}

.ez-btn-generate {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(202, 138, 4, 0.4);
  transition: transform 0.2s;
}

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

.ez-btn-print {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4);
  transition: transform 0.2s;
}

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

/* ==========================================================================
   08. DATAVIEW DASHBOARD & ANKI/GITHUB HEATMAP CALENDAR
   ========================================================================== */
.dataview-workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  text-align: left;
}

/* Anki / GitHub Style Heatmap Activity Card */
.dv-heatmap-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.dv-heatmap-header {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.dv-heatmap-grid-wrapper {
  overflow-x: auto;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.dv-heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
}

.dv-heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #1e293b;
  transition: transform 0.1s;
}

.dv-heatmap-cell:hover {
  transform: scale(1.4);
  z-index: 10;
}

.dv-heatmap-cell.lvl-1 { background: #14532d; }
.dv-heatmap-cell.lvl-2 { background: #16a34a; }
.dv-heatmap-cell.lvl-3 { background: #22c55e; }
.dv-heatmap-cell.lvl-4 { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }

.dv-heatmap-stats {
  display: flex;
  gap: 24px;
  font-size: 13.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

.dv-heatmap-stats span b {
  color: #22c55e;
}

.dataview-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.dv-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dv-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dv-card-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-primary);
}

.dataview-table-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 20px;
  overflow-x: auto;
}

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

.dv-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.dv-table th {
  background: #0f172a;
  color: var(--accent-primary);
  padding: 12px 14px;
  font-weight: 800;
  border-bottom: 2px solid var(--border-color);
}

.dv-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.dv-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dv-hanzi {
  font-family: var(--font-hanzi);
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

.dv-status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 800;
}

.dv-status-tag.new { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.dv-status-tag.review { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.dv-status-tag.mastered { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

/* Mobile elements hidden on desktop */
.mobile-header { display: none; }
.mobile-overlay { display: none; }

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  /* iOS Safari Font-Size Zoom Bug Fix */
  input, select, textarea, .select-control, .form-input, .ez-select, .ez-textarea, .ez-input {
    font-size: 16px !important;
  }

  .mobile-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    min-height: calc(56px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: rgba(9, 13, 22, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
  }
  
  .mobile-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .mobile-menu-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
  }
  
  .mobile-brand {
    color: white;
    font-weight: 800;
    font-size: 17px;
  }
  
  .mobile-header-right {
    margin-left: auto;
  }

  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    height: 100vh;
    height: -webkit-fill-available;
    width: 280px;
    z-index: 1001;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar.mobile-open {
    left: 0;
  }
  
  .mobile-overlay {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .app-layout {
    flex-direction: column;
    margin: 0;
    border-radius: 0;
    border: none;
    min-height: 100vh;
    box-shadow: none;
  }

  .main-content {
    padding: 12px;
    padding-top: calc(68px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .controls-bar {
    flex-direction: column;
    gap: 10px;
  }

  .control-group {
    width: 100%;
  }

  .search-group {
    width: 100%;
    min-width: unset;
  }
  
  .select-control {
    width: 100%;
    min-width: unset;
    font-size: 16px !important;
  }
  
  .auto-read-group {
    width: 100%;
    justify-content: center;
  }
  
  .top-right-account {
    width: 100%;
    justify-content: center;
  }

  .flashcard {
    padding: 24px 18px;
    min-height: 320px;
    border-radius: 16px;
  }

  .card-hanzi { font-size: 52px; }
  .card-pinyin { font-size: 18px; }
  .card-def { font-size: 17px; }
  .badge-tag { font-size: 11.5px; padding: 4px 12px; }

  .card-nav-bar {
    gap: 8px;
    padding: 8px 0;
  }
  
  .card-nav-btn {
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .card-nav-counter {
    font-size: 13px;
    min-width: unset;
    padding: 6px 10px;
  }
  
  .card-nav-counter .nav-current {
    font-size: 17px;
  }

  .fsrs-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .fsrs-btn {
    min-width: calc(50% - 4px);
    max-width: unset;
    padding: 14px 8px;
  }

  .opt-btn {
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 12px;
  }
  
  .opt-label {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .card-audio-controls {
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }
  
  .read-word-btn {
    width: 100%;
    justify-content: center;
    font-size: 13px;
  }
  
  .speed-select {
    width: 100%;
  }

  .examples-box { padding: 12px; }
  .ex-hz { font-size: 15px; }

  .explanation-box, .structure-box {
    padding: 12px 14px;
    font-size: 14px;
  }

  .show-ans-btn {
    max-width: 100%;
    font-size: 15px;
    padding: 14px 20px;
  }

  .type-input {
    font-size: 22px;
    max-width: 100%;
  }

  .dataview-summary-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .dv-card { padding: 14px; }
  .dv-card-num { font-size: 22px; }
  .dv-heatmap-card { padding: 14px; }
  .dv-heatmap-grid-wrapper { justify-content: flex-start; overflow-x: auto; }
  .dv-heatmap-stats { gap: 12px; font-size: 12px; }
  
  .dv-table { font-size: 12px; }
  .dv-table th, .dv-table td { padding: 8px 10px; }
  .dv-hanzi { font-size: 17px; }
  .dv-title { font-size: 15px; }

  .ezitie-workspace {
    flex-direction: column-reverse;
  }
  .ezitie-controls-col { width: 100%; }
  .ezitie-a4-sheet {
    width: 100%;
    min-height: auto;
    padding: 8mm;
  }

  .auth-modal-card {
    max-width: 100%;
    padding: 24px 20px;
    border-radius: 18px;
    margin: 0 10px;
  }
}

/* Print CSS Styles */
@media print {
  body { background: white !important; color: black !important; }
  .sidebar, .top-header, .ezitie-controls-col, .navbar, footer, #fsrs-bar { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; width: 100% !important; }
  .flashcard-section { padding: 0 !important; }
  .flashcard-wrapper { max-width: 100% !important; }
  .ezitie-workspace { display: block !important; }
  .ezitie-preview-col { width: 100% !important; }
  .ezitie-a4-sheet { box-shadow: none !important; margin: 0 !important; padding: 10mm !important; width: 100% !important; }
}
