/* ── CSS Variables ── */
:root {
  --bg: #050505;
  --surface: #0d0d0d;
  --surface2: #131313;
  --border: #1e2e1e;
  --primary: #00cc6a;
  --primary-h: #00ff88;
  --primary-dim: rgba(0,204,106,0.12);
  --accent: #7c3aed;
  --accent-h: #a78bfa;
  --accent-dim: rgba(124,58,237,0.12);
  --success: #00ff88;
  --warning: #f59e0b;
  --error: #ef4444;
  --text: #e0eeff;
  --text-muted: #8899bb;
  --text-dim: #4a5570;
  --radius: 14px;
  --radius-sm: 8px;
  --nav-h: 72px;
  --header-h: 60px;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f4f7f4;
  --surface2: #eaf0ea;
  --border: #d4e8d4;
  --primary: #00875a;
  --primary-h: #00aa6e;
  --primary-dim: rgba(0,135,90,0.10);
  --accent: #6d28d9;
  --accent-h: #7c3aed;
  --accent-dim: rgba(109,40,217,0.10);
  --success: #00875a;
  --text: #1a2e1a;
  --text-muted: #4a6a52;
  --text-dim: #8aaa90;
}
[data-theme="light"] body {
  background: linear-gradient(135deg, rgba(124,58,237,0.10) 0%, #ffffff 45%, rgba(109,40,217,0.06) 100%);
}
[data-theme="light"] .app-header   { background: rgba(255,255,255,0.93); }
[data-theme="light"] .bottom-nav   { background: rgba(255,255,255,0.96); }
[data-theme="light"] .processing-overlay { background: rgba(250,255,250,0.90); }
[data-theme="light"] .toast        { background: #f0f7f0; }
[data-theme="light"] .btn-primary  { color: #fff; }
[data-theme="light"] .chat-msg.user .chat-bubble { color: #fff; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* ── Header ── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: rgba(5,5,5,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 16px; padding-right: 16px;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.app-logo { font-size: 24px; letter-spacing: -2px; }
.app-title { font-size: 22px; font-weight: 700; color: var(--text); }
.header-right { display: flex; gap: 8px; align-items: center; }

/* ── Main ── */
.app-main {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); left: 0; right: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

/* ── Views ── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:translateY(0) } }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
}

/* ── Input Tabs ── */
.input-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.tab-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 18px; font-weight: 700;
  padding: 20px 10px;
  cursor: pointer; transition: all 0.2s;
  text-align: center; white-space: nowrap;
}
.tab-btn:hover:not(.active) { border-color: var(--primary); color: var(--text); }
.tab-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary-h);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.15s ease; }

/* ── Fields ── */
.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.input-field {
  width: 100%; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 16px;
  padding: 11px 14px; outline: none; transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--text-dim); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* ── Buttons ── */
.btn-primary {
  width: 100%; background: var(--primary); color: #001a0d; border: none;
  border-radius: var(--radius-sm); font-size: 16px; font-weight: 700;
  padding: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  width: 100%; background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary); border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; padding: 11px; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--primary-dim); }

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-dim); }
.drop-icon { font-size: 40px; margin-bottom: 10px; }
.drop-text { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.drop-hint { font-size: 13px; color: var(--text-dim); }
.file-selected {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; margin-top: 10px;
}
.file-name-text { font-size: 13px; color: var(--text); font-weight: 600; }
.file-size-text { font-size: 12px; color: var(--text-muted); }

/* ── Record ── */
.record-center { display: flex; flex-direction: column; align-items: center; padding: 20px 0; }
.btn-record {
  width: 80px; height: 80px; border-radius: 50%; border: none;
  background: var(--primary); font-size: 32px; cursor: pointer;
  transition: all 0.2s; box-shadow: 0 0 0 0 rgba(0,204,106,0.4);
}
.btn-record.recording {
  background: var(--error);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  70% { box-shadow: 0 0 0 16px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.record-status { margin-top: 14px; font-size: 16px; color: var(--text-muted); font-weight: 600; }
.record-timer { font-size: 28px; font-weight: 700; color: var(--error); font-variant-numeric: tabular-nums; margin-top: 6px; }

/* ── Podcast Episodes ── */
.podcast-header { font-weight: 700; font-size: 14px; margin-bottom: 10px; color: var(--text); }
.episode-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: all 0.2s; display: flex; justify-content: space-between; align-items: center;
}
.episode-item:hover { border-color: var(--primary); background: var(--primary-dim); }
.episode-item.selected { border-color: var(--primary); background: var(--primary-dim); }
.episode-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; margin-right: 10px; }
.episode-meta { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ── Hint Box ── */
.hint-box {
  background: rgba(0,204,106,0.07); border: 1px solid rgba(0,204,106,0.18);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.hint-box p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── Source Bar ── */
.source-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px;
}
.source-icon { font-size: 18px; }
.source-info { flex: 1; min-width: 0; }
.source-title { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-meta { font-size: 11px; color: var(--text-muted); }

/* ── Note Sections ── */
.note-section { border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; border: 1px solid var(--border); }
.note-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; font-size: 16px; font-weight: 700;
}
.note-section-body { padding: 0 16px 16px; }

.note-section.summary .note-section-header { background: linear-gradient(135deg, rgba(0,204,106,0.18), rgba(0,255,136,0.08)); }
.note-section.learnings .note-section-header { background: linear-gradient(135deg, rgba(0,255,180,0.15), rgba(0,204,106,0.08)); }
.note-section.applications .note-section-header { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(6,182,212,0.1)); }
.note-section.counter .note-section-header { background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(167,139,250,0.08)); }

.summary-text { font-size: 14px; color: var(--text); line-height: 1.8; white-space: pre-wrap; }

.note-list { list-style: none; }
.note-list li {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 15px; color: var(--text); line-height: 1.6;
}
.note-list li:last-child { border-bottom: none; }
.note-num {
  min-width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-dim); color: var(--primary-h);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.note-item-text { flex: 1; }
.timestamp-link {
  display: inline-block; font-size: 11px; color: var(--primary-h); background: var(--primary-dim);
  border-radius: 4px; padding: 1px 6px; margin-left: 6px; text-decoration: none; white-space: nowrap;
}
.timestamp-link:hover { background: var(--primary); color: #fff; }

/* ── Notes Actions ── */
.notes-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.btn-action {
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 600; padding: 10px 6px; cursor: pointer; transition: all 0.2s;
}
.btn-action:hover { border-color: var(--primary); color: var(--primary-h); }

/* ── Chat ── */
.chat-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.chat-header {
  padding: 12px 16px; font-size: 16px; font-weight: 700;
  border-bottom: 1px solid var(--border); background: var(--surface2);
  display: flex; align-items: center; gap: 8px;
}
.pro-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 4px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; vertical-align: middle; line-height: 1;
}
.chat-messages { padding: 12px 16px; min-height: 60px; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 80%; background: var(--surface2); border-radius: 12px;
  padding: 9px 13px; font-size: 16px; color: var(--text); line-height: 1.6;
}
.chat-msg.user .chat-bubble { background: var(--primary); color: #001a0d; }
.chat-avatar { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text); font-size: 16px; padding: 9px 14px; outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.btn-chat-send {
  background: var(--primary); color: #fff; border: none;
  border-radius: 20px; padding: 9px 18px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-chat-send:hover { background: var(--primary-h); }
.btn-chat-send:disabled { opacity: 0.5; }

/* ── History ── */
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: all 0.2s; display: flex; justify-content: space-between; align-items: flex-start;
}
.history-item:hover { border-color: var(--primary); }
.history-info { flex: 1; min-width: 0; }
.history-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 13px; color: var(--text-muted); }
.history-del {
  background: none; border: none; color: var(--text-dim); font-size: 16px;
  cursor: pointer; padding: 4px 6px; border-radius: 6px; flex-shrink: 0; margin-left: 8px;
}
.history-del:hover { background: rgba(239,68,68,0.1); color: var(--error); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 42px; margin-bottom: 10px; }

/* ── Settings ── */
.settings-section-title { font-size: 15px; font-weight: 700; color: var(--accent-h); margin-bottom: 12px; }
.link-hint { display: block; font-size: 13px; color: var(--primary-h); text-decoration: none; margin-top: 6px; }
.link-hint:hover { text-decoration: underline; }
.settings-status { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.settings-status.ok { background: rgba(16,185,129,0.15); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.settings-status.err { background: rgba(239,68,68,0.1); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }

/* ── Processing Overlay ── */
.processing-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,5,5,0.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.processing-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
  text-align: center; min-width: 220px;
}
.spinner {
  width: 44px; height: 44px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-step { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.processing-detail { font-size: 14px; color: var(--text-muted); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); left: 50%;
  transform: translateX(-50%); z-index: 300;
  background: #0a0f0a; border: 1px solid var(--border);
  color: var(--text); font-size: 15px; font-weight: 600;
  padding: 11px 20px; border-radius: 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(5,5,5,0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: none; border: none; cursor: pointer; padding: 6px 4px;
  transition: all 0.2s; position: relative;
}
.nav-btn.active .nav-icon { filter: none; }
.nav-btn.active .nav-label { color: var(--primary-h); }
.nav-btn.active::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 2px; background: var(--primary); border-radius: 0 0 2px 2px;
}
.nav-icon { font-size: 36px; }
.nav-label { font-size: 18px; color: var(--text-dim); font-weight: 600; transition: color 0.2s; }
.nav-btn.active .nav-label { color: var(--primary-h); }

/* ── Source Badge (notes view) ── */
.source-badge {
  display: inline-block; font-size: 13px; font-weight: 600;
  color: var(--primary-h); background: var(--primary-dim);
  padding: 3px 10px; border-radius: 12px; white-space: nowrap; flex-shrink: 0;
}
.source-bar .source-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}

/* ── Note Section Header Variants ── */
.note-header-summary { background: linear-gradient(135deg, rgba(0,204,106,0.18), rgba(0,255,136,0.08)); }
.note-header-learn   { background: linear-gradient(135deg, rgba(0,255,180,0.15), rgba(0,204,106,0.08)); }
.note-header-apply   { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(6,182,212,0.1)); }
.note-header-counter { background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(167,139,250,0.08)); }

/* ── Note Section Body ── */
.note-section-body {
  padding: 12px 16px; font-size: 16px; color: var(--text);
  line-height: 1.8; white-space: pre-wrap;
}
.note-section .note-list { padding: 0 16px 12px; }

/* ── Timestamp Link ── */
.ts-link {
  display: inline-block; font-size: 11px; color: var(--primary-h);
  background: var(--primary-dim); border-radius: 4px; padding: 1px 6px;
  margin-left: 6px; text-decoration: none; white-space: nowrap;
}
.ts-link:hover { background: var(--primary); color: #fff; }

/* ── History Extras ── */
.history-icon { font-size: 22px; flex-shrink: 0; margin-right: 8px; }
.history-date { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Episode List ── */
.episode-search-wrap {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.episode-search-input { flex: 1; }
.episode-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.episode-list { margin-top: 4px; }

/* ── YouTube Mode Toggle ── */
.yt-mode-toggle {
  display: flex; gap: 6px; margin-bottom: 10px;
}
.yt-mode-btn {
  flex: 1; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
}
.yt-mode-btn.active {
  background: var(--primary-dim); border-color: var(--primary); color: var(--primary);
}
.yt-mode-btn:hover:not(.active) { border-color: var(--primary); color: var(--text); }

.yt-search-row {
  display: flex; gap: 8px; align-items: stretch;
}
.yt-search-row .input-field { flex: 1; min-width: 0; }
.yt-search-row .btn-secondary { flex: 0 0 auto; width: fit-content; min-width: 44px; padding: 10px 16px; }

/* ── Podcast Candidates (搜尋結果候選) ── */
.candidates-header {
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  padding: 8px 0 6px; margin-bottom: 4px;
}
.candidate-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; transition: all 0.2s;
}
.candidate-item:hover { border-color: var(--primary); background: var(--primary-dim); }
.candidate-art { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.candidate-art-placeholder { width: 48px; height: 48px; border-radius: 8px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.candidate-info { flex: 1; min-width: 0; }
.candidate-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.candidate-artist { font-size: 13px; color: var(--text-muted); }

/* ── Settings Guide ── */
.guide-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px 10px;
  margin-bottom: 12px;
}
.guide-title {
  font-size: 16px; font-weight: 700; color: var(--accent-h);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.guide-step { margin-bottom: 14px; }
.guide-step-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 7px;
}
.guide-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.guide-step-body { font-size: 13px; color: var(--text-muted); line-height: 1.7; padding-left: 30px; }
.guide-list { list-style: none; padding-left: 30px; display: flex; flex-direction: column; gap: 7px; }
.guide-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.guide-list li b { color: var(--text); }
.guide-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.guide-link { color: var(--primary-h); text-decoration: none; }
.guide-link:hover { text-decoration: underline; }

/* ── Keywords ── */
.notes-keywords { margin-bottom: 10px; }
.kw-label { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 6px; }
.kw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-chip {
  display: inline-block; font-size: 12px; color: var(--primary-h);
  background: var(--primary-dim); border: 1px solid var(--primary);
  border-radius: 20px; padding: 3px 10px; cursor: pointer; transition: all .15s;
}
.kw-chip:hover { background: var(--primary); color: #fff; }

/* ── Tags ── */
.notes-tags { margin-bottom: 12px; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text); background: var(--surface2);
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px;
}
.tag-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 0; line-height: 1; margin-left: 2px;
}
.tag-remove:hover { color: var(--error); }
.tag-add-wrap { display: flex; gap: 6px; align-items: center; }
.tag-input {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text); font-size: 13px;
  padding: 4px 12px; outline: none; width: 120px; transition: border-color .2s;
}
.tag-input:focus { border-color: var(--primary); }
.tag-add-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 20px; padding: 4px 12px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.tag-add-btn:hover { border-color: var(--primary); color: var(--primary-h); }

/* ── Star Button ── */
.btn-star {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px; padding: 4px 10px;
  font-size: 14px; cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.btn-star:hover, .btn-star.starred { color: #f59e0b; border-color: #f59e0b; }

/* ── History Filter Bar ── */
.history-filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.hf-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 20px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.hf-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.hf-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary-h); }

/* ── History Item extras ── */
.history-title-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.history-star { font-size: 14px; flex-shrink: 0; }
.history-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.history-tag { font-size: 11px; color: var(--primary-h); background: var(--primary-dim); border-radius: 10px; padding: 2px 7px; }

/* ── Sync ── */
.sync-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

/* ── Summary Level ── */
.summary-level-toggle { display: flex; gap: 8px; margin-top: 10px; }
.summary-level-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all .15s;
}
.summary-level-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.summary-level-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ── Helpers ── */
.hidden { display: none !important; }
.lang-toggle { display: flex; gap: 6px; margin-top: 0; }
.lang-btn { padding: 5px 13px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; font-weight: 600; transition: all .15s; }
.lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lang-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ── Edit Mode ── */
.btn-source-edit {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px; padding: 4px 10px;
  font-size: 13px; font-weight: 600; cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.btn-source-edit:hover { border-color: var(--primary); color: var(--primary-h); }
.notes-edit { margin-bottom: 16px; }
.edit-section { margin-bottom: 14px; }
.edit-label { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.edit-hint { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }
.edit-textarea {
  width: 100%; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  padding: 10px 12px; outline: none; resize: vertical; line-height: 1.7;
  font-family: inherit; transition: border-color 0.2s;
}
.edit-textarea:focus { border-color: var(--primary); }
.edit-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* ── Flash Cards ── */
.flashcard-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.flashcard-header-row {
  padding: 12px 16px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border); background: var(--surface2);
}
.flashcard-title { font-size: 15px; font-weight: 700; color: var(--text); }
.flashcard-controls { display: flex; align-items: center; gap: 8px; }
.flashcard-count-input {
  width: 52px; padding: 5px 6px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); text-align: center;
}
.flashcard-count-input:focus { outline: none; border-color: var(--primary); }
.btn-gen-cards {
  background: var(--primary-dim); color: var(--primary-h);
  border: 1px solid var(--primary); border-radius: 8px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-gen-cards:hover { background: var(--primary); color: #fff; }
.btn-gen-cards:disabled { opacity: 0.5; cursor: not-allowed; }
.flashcard-container { padding: 16px; }
.flashcard-card {
  height: 160px; cursor: pointer; margin-bottom: 14px;
  perspective: 1000px;
}
.flashcard-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 0.4s ease;
}
.flashcard-card.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute; width: 100%; height: 100%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 14px; font-size: 14px; text-align: center; line-height: 1.6; color: var(--text);
}
.flashcard-back { transform: rotateY(180deg); color: var(--accent-h); background: var(--accent-dim); border-color: var(--accent); }
.flashcard-nav { display: flex; justify-content: center; align-items: center; gap: 20px; }
.btn-card-nav {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 16px; font-size: 16px; cursor: pointer; color: var(--text); transition: all .15s;
}
.btn-card-nav:hover { border-color: var(--primary); color: var(--primary-h); }
.card-counter { font-size: 14px; font-weight: 700; color: var(--text-muted); min-width: 54px; text-align: center; }
.flashcard-hint { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 10px; }

/* ── Theme Toggle Button ── */
.btn-theme {
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 9px; font-size: 17px;
  cursor: pointer; color: var(--text-muted); transition: all 0.2s; line-height: 1;
}
.btn-theme:hover { border-color: var(--primary); }

/* ── Auth / Account UI ── */
.auth-tabs { display: flex; gap: 8px; margin-bottom: 4px; }
.auth-tab {
  flex: 1; padding: 8px; border-radius: 8px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 14px; cursor: pointer;
  transition: all .15s;
}
.auth-tab.active {
  background: var(--primary-dim); border-color: var(--primary); color: var(--primary); font-weight: 600;
}
.auth-error {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  background: rgba(239,68,68,0.12); color: #f87171; font-size: 13px;
}
.account-email { font-size: 14px; color: var(--text); font-weight: 500; margin-bottom: 6px; }
.account-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.badge-free { background: var(--surface2); color: var(--text-muted); }
.badge-pro  { background: linear-gradient(135deg,#7c3aed,#6366f1); color: #fff; }
.usage-section { margin-top: 4px; }
.usage-label {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted); margin-bottom: 6px;
}
.usage-bar-track { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .4s; }
.usage-fill.usage-warn { background: #f59e0b; }
.usage-fill.usage-full { background: #ef4444; }
.field-prompt-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.fp-locked { opacity: 0.5; pointer-events: none; }
.fp-locked input { cursor: not-allowed; }
.upgrade-section { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.upgrade-btn { width: 100%; text-align: center; text-decoration: none; }
.upgrade-hint { font-size: 12px; color: var(--text-muted); text-align: center; }
.upgrade-divider { text-align: center; font-size: 12px; color: var(--text-muted); margin: 2px 0; }

/* ── Plan Info ── */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.plan-col {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .2s, box-shadow .2s;
}
.plan-col.plan-current {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-dim);
}
.plan-name { font-size: 13px; font-weight: 700; color: var(--text); }
.plan-price { font-size: 16px; font-weight: 800; color: var(--primary-h); }
.plan-per { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.plan-quota { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 3px; }
.plan-features li { font-size: 11px; padding-left: 14px; position: relative; color: var(--text-muted); }
.feat-yes::before { content: '✓'; position: absolute; left: 0; color: #22c55e; font-weight: 700; }
.feat-no::before { content: '✗'; position: absolute; left: 0; color: var(--border); }
.feat-no { color: var(--border); }
.plan-note { font-size: 11px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }

/* ── Developer Info ── */
.dev-info-row { font-size: 18px; color: var(--text-muted); margin-top: 6px; }
.dev-email { color: var(--primary); text-decoration: none; }
.dev-email:hover { text-decoration: underline; }

/* ── Header Usage Badge ── */
.header-usage {
  display: flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  background: var(--primary-dim); border: 1px solid var(--primary);
  font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap;
}
.header-usage.usage-warn { background: rgba(245,158,11,0.15); border-color: #f59e0b; color: #f59e0b; }
.header-usage.usage-full { background: rgba(239,68,68,0.15); border-color: #ef4444; color: #ef4444; }

/* ── Quota Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; max-width: 340px; width: 100%;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-body { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.7; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }
