/* ═══════════════════════════════════════════════════════════════════════════════
   Pocket Dictionary – Global Styles
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────────────────────── */
:root {
  --sand:      #efe1d3;
  --shell:     #f8f2eb;
  --blush:     #d8b8a6;
  --rose:      #b78978;
  --clay:      #8f6659;
  --ink:       #332926;
  --muted:     #7b6960;
  --line:      rgba(96,72,62,.15);
  --bg:        #f8f2eb;
  --surface:   #fff;
  --surface2:  #f4ede4;
  --text:      #332926;
  --text-muted:#7b6960;
  --accent:    #8f6659;
  --accent-h:  #7a5548;
  --success:   #4a8c5c;
  --error:     #c0392b;
  --warn:      #c87941;
  --shadow-sm: 0 2px 8px rgba(75,49,38,.08);
  --shadow:    0 6px 24px rgba(75,49,38,.12);
  --shadow-lg: 0 16px 48px rgba(75,49,38,.18);
  --radius:    12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
  --transition: 200ms ease;

  /* Heatmap */
  --hm-0: #ede5dc;
  --hm-1: #cba892;
  --hm-2: #b78978;
  --hm-3: #9a6b5a;
  --hm-4: #7a4f3c;
}

[data-theme="dark"] {
  --bg:        #1c1714;
  --surface:   #261e1a;
  --surface2:  #302620;
  --text:      #f0e8e0;
  --text-muted:#9e8b80;
  --line:      rgba(255,200,170,.1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
  --shadow:    0 6px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
  --hm-0: #2a2220;
  --hm-1: #5a3e35;
  --hm-2: #7a5548;
  --hm-3: #9a6b5a;
  --hm-4: #c0876a;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

h1,h2,h3,h4 { font-weight: 700; line-height: 1.25; }
p { line-height: 1.65; }

a { color: var(--accent); }

img { max-width: 100%; }

button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-root {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform var(--transition);
  z-index: 100;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 36px; height: 36px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 13px;
  flex-shrink: 0;
}

[data-theme="dark"] .brand-mark { background: var(--clay); }

.brand-name { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.2; }
.brand-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { list-style: none; padding: 10px 8px; flex: 1; }
.sidebar-nav li + li { margin-top: 2px; }

.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: none; background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover   { background: var(--surface2); color: var(--text); }
.nav-item.nav-active { background: var(--sand); color: var(--accent); font-weight: 700; }
[data-theme="dark"] .nav-item.nav-active { background: var(--surface2); }

.nav-icon  { font-size: 16px; width: 20px; text-align: center; }
.nav-label { font-size: 14px; }

.sidebar-footer {
  padding: 12px 8px 16px;
  border-top: 1px solid var(--line);
}

.theme-btn {
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.theme-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Mobile header ──────────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky; top: 0; z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-logo { font-weight: 700; font-size: 15px; }

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* ── Views ─────────────────────────────────────────────────────────────────── */
.view { display: none; padding: 28px 32px 60px; max-width: 900px; }
.view-active { display: block; }

.view-header { margin-bottom: 24px; }
.view-title  { font-size: 26px; color: var(--text); margin-bottom: 4px; }
.view-sub    { color: var(--text-muted); font-size: 15px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 80ms;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--sand); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: var(--error); }
.btn-danger:hover { background: #fef0ee; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-large { padding: 12px 24px; font-size: 16px; width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 16px; background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.btn-icon:hover { background: var(--sand); }
.btn-icon.saved { background: var(--rose); color: #fff; border-color: var(--rose); }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ── Word Card ──────────────────────────────────────────────────────────────── */
.word-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp .25s ease;
}

.word-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}
.word-main {}
.word-title { font-size: 36px; color: var(--ink); }
[data-theme="dark"] .word-title { color: var(--text); }

.phonetic { color: var(--rose); font-size: 17px; margin-top: 2px; font-style: italic; }

.word-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.example-highlight {
  font-style: italic; color: var(--muted);
  border-left: 3px solid var(--blush);
  padding-left: 14px;
  margin-bottom: 20px;
  font-size: 15px;
}

.meaning-block { margin-bottom: 16px; }
.pos-tag {
  display: inline-block;
  background: var(--sand); color: var(--clay);
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  margin-bottom: 6px; text-transform: capitalize;
}
[data-theme="dark"] .pos-tag { background: var(--surface2); color: var(--rose); }

.def-list { list-style: disc; padding-left: 20px; }
.def-list li { margin-bottom: 6px; font-size: 15px; }
.def-list .example { color: var(--text-muted); font-style: italic; font-size: 13px; margin-top: 3px; }

.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }

.synonyms-section, .meanings-section { margin-top: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; border-radius: 20px; font-size: 13px;
  background: var(--sand); color: var(--clay);
  border: 1px solid var(--blush);
  cursor: pointer; transition: background var(--transition);
}
.chip:hover { background: var(--blush); color: var(--ink); }
.chip-static { cursor: default; }
[data-theme="dark"] .chip { background: var(--surface2); color: var(--rose); border-color: transparent; }

.error-card { border-color: var(--error); }
.error-title { font-weight: 700; font-size: 16px; }
.muted-note { color: var(--text-muted); font-size: 14px; }

/* ── Search ─────────────────────────────────────────────────────────────────── */
.search-bar-wrap { margin-bottom: 24px; }

.search-form-row {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.search-form-row input {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 15px;
  transition: border-color var(--transition);
}
.search-form-row input:focus { outline: none; border-color: var(--rose); }

.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Dashboard ──────────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex; gap: 14px; align-items: flex-start;
}

.dash-card-accent { border-color: var(--rose); }
.dash-card-clickable { cursor: pointer; transition: box-shadow var(--transition); }
.dash-card-clickable:hover { box-shadow: var(--shadow); }

.dash-card-icon { font-size: 28px; }
.dash-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 4px; }
.dash-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.dash-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.xp-bar-wrap, .progress-bar-wrap {
  height: 4px; background: var(--line); border-radius: 2px; margin: 8px 0 4px; overflow: hidden;
}
.xp-bar, .progress-bar {
  height: 100%; background: var(--rose); border-radius: 2px;
  transition: width .4s ease;
}

.dash-quick-actions { grid-column: span 2; flex-direction: column; gap: 10px; }
.quick-action-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.dash-activity { grid-column: span 2; flex-direction: column; gap: 8px; }
.dash-recent-words { grid-column: span 2; flex-direction: column; gap: 8px; }

.activity-list { display: flex; flex-direction: column; gap: 6px; }
.activity-row  { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.activity-date { width: 110px; color: var(--text-muted); }
.activity-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.activity-dot.active { background: var(--rose); }
.activity-count { color: var(--text-muted); }

.recent-words-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.recent-word-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.recent-word-text { font-weight: 600; }
.recent-word-pos { color: var(--text-muted); font-size: 12px; }
.mastered-badge { background: var(--success); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 20px; }

/* ── Word of the Day ────────────────────────────────────────────────────────── */
.wotd-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  animation: fadeUp .3s ease;
  margin-bottom: 32px;
}

.wotd-badge {
  display: inline-block;
  background: var(--rose); color: #fff;
  font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px;
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em;
}
.wotd-date { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.wotd-word-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.wotd-word { font-size: 42px; color: var(--ink); line-height: 1; }
[data-theme="dark"] .wotd-word { color: var(--text); }
.wotd-actions { display: flex; gap: 8px; }
.wotd-meta { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.wotd-example {
  background: var(--sand); border-left: 3px solid var(--rose);
  padding: 12px 16px; border-radius: 0 8px 8px 0;
  font-style: italic; color: var(--muted); font-size: 15px;
  margin-bottom: 20px;
}
[data-theme="dark"] .wotd-example { background: var(--surface2); }
.wotd-meanings { margin-bottom: 20px; }
.wotd-synonyms {}

.section-heading { font-size: 18px; margin-bottom: 14px; }
.wotd-history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.wotd-history-item {
  background: var(--surface2); border-radius: var(--radius-sm); padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.wotd-history-word { font-weight: 700; font-size: 15px; }
.wotd-history-date { font-size: 12px; color: var(--text-muted); }

/* ── Difficulty & topic badges ─────────────────────────────────────────────── */
.difficulty-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  text-transform: capitalize;
}
.difficulty-beginner     { background: #d4edda; color: #155724; }
.difficulty-intermediate { background: #fff3cd; color: #856404; }
.difficulty-advanced     { background: #f8d7da; color: #721c24; }
[data-theme="dark"] .difficulty-beginner     { background: #1d3d28; color: #7ecf97; }
[data-theme="dark"] .difficulty-intermediate { background: #3d3010; color: #e8c470; }
[data-theme="dark"] .difficulty-advanced     { background: #3d1010; color: #e07070; }

.topic-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  background: var(--sand); color: var(--clay); text-transform: capitalize;
}
[data-theme="dark"] .topic-badge { background: var(--surface2); color: var(--rose); }

/* ── Random Word ────────────────────────────────────────────────────────────── */
.random-filters {
  margin-bottom: 24px;
}
.filter-row {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.filter-row label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--text-muted); font-weight: 600;
}
.filter-row select, select {
  padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit;
}
.filter-row select:focus, select:focus { outline: none; border-color: var(--rose); }

.random-result-area { min-height: 200px; position: relative; }
.random-meta-row { display: flex; gap: 8px; margin-bottom: 12px; }

.result-slide-out { opacity: 0; transform: translateY(-12px); transition: opacity .2s, transform .2s; }
.result-slide-in  { opacity: 0; transform: translateY(12px); }
.result-visible   { opacity: 1; transform: translateY(0); transition: opacity .3s, transform .3s; }

/* ── Heatmap ────────────────────────────────────────────────────────────────── */
.heatmap-stats-row {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.stat-chip {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 16px;
  display: flex; flex-direction: column; align-items: center; min-width: 90px;
}
.stat-chip-val { font-size: 22px; font-weight: 700; }
.stat-chip-lbl { font-size: 11px; color: var(--text-muted); text-align: center; }

.heatmap-wrap {
  overflow-x: auto; padding-bottom: 16px; position: relative;
}
.heatmap-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 3px;
  padding-left: 0;
  margin-bottom: 4px;
  height: 18px;
  position: relative;
}
.month-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.heatmap-grid {
  display: flex; gap: 3px;
}
.heatmap-col {
  display: flex; flex-direction: column; gap: 3px;
}
.heatmap-cell {
  width: 13px; height: 13px; border-radius: 2px;
  cursor: pointer; transition: transform .1s;
}
.heatmap-cell:hover { transform: scale(1.4); }
.heatmap-cell.future { opacity: .25; }

.heatmap-cell.intensity-0 { background: var(--hm-0); }
.heatmap-cell.intensity-1 { background: var(--hm-1); }
.heatmap-cell.intensity-2 { background: var(--hm-2); }
.heatmap-cell.intensity-3 { background: var(--hm-3); }
.heatmap-cell.intensity-4 { background: var(--hm-4); }

.heatmap-legend {
  display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 12px;
}
.legend-cell { width: 13px; height: 13px; border-radius: 2px; }
.legend-cell[data-intensity="0"] { background: var(--hm-0); }
.legend-cell[data-intensity="1"] { background: var(--hm-1); }
.legend-cell[data-intensity="2"] { background: var(--hm-2); }
.legend-cell[data-intensity="3"] { background: var(--hm-3); }
.legend-cell[data-intensity="4"] { background: var(--hm-4); }

.heatmap-tooltip {
  position: absolute; z-index: 50;
  background: var(--ink); color: #fff;
  font-size: 12px; line-height: 1.5;
  padding: 8px 12px; border-radius: 6px;
  pointer-events: none; max-width: 200px;
  box-shadow: var(--shadow);
}
.heatmap-tooltip.hidden { display: none; }
[data-theme="dark"] .heatmap-tooltip { background: #0d0b0a; }

/* ── Achievements ───────────────────────────────────────────────────────────── */
.achievements-summary { margin-bottom: 24px; }
.ach-summary-card {
  display: flex; gap: 20px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.ach-summary-item { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.ach-summary-val { font-size: 28px; font-weight: 700; }
.ach-summary-lbl { font-size: 12px; color: var(--text-muted); }

.achievements-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}

.achievement-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: box-shadow var(--transition);
}
.achievement-card.unlocked { border-color: var(--rose); box-shadow: 0 0 0 1px var(--rose); }
.achievement-card.locked { opacity: .7; }
.achievement-card:hover { box-shadow: var(--shadow); }

.ach-icon { font-size: 28px; flex-shrink: 0; }
.ach-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.ach-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.ach-unlocked-badge { font-size: 12px; color: var(--success); font-weight: 700; }
.ach-progress-wrap { height: 4px; background: var(--line); border-radius: 2px; margin-bottom: 4px; overflow: hidden; }
.ach-progress-bar { height: 100%; background: var(--rose); border-radius: 2px; transition: width .4s; }
.ach-progress-label { font-size: 12px; color: var(--text-muted); }

/* ── Vocabulary ─────────────────────────────────────────────────────────────── */
.vocab-toolbar { margin-bottom: 12px; }
.vocab-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.vocab-search-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 14px; }
.vocab-search-row input:focus { outline: none; border-color: var(--rose); }

.vocab-filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.vocab-filter-row select { padding: 6px 10px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

.vocab-io-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.vocab-count { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.vocab-list { display: flex; flex-direction: column; gap: 10px; }
.vocab-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.vocab-card:hover { box-shadow: var(--shadow); }
.vocab-card.mastered { border-color: var(--success); }
.vocab-card.bookmarked { border-color: var(--rose); }

.vocab-card-main { flex: 1; min-width: 0; }
.vocab-word-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.vocab-word { font-weight: 700; font-size: 17px; }
.bookmark-icon { color: var(--rose); }
.vocab-def { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vocab-note-preview { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 3px; }

.vocab-card-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* Note panel */
.note-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 360px; z-index: 300;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideInRight .2s ease;
}
.note-panel.hidden { display: none; }

.note-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 15px;
}
.note-toolbar {
  display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.note-editor {
  flex: 1; padding: 16px; overflow-y: auto;
  font-size: 14px; line-height: 1.65;
  outline: none;
}
.note-editor:empty::before {
  content: 'Write notes about this word…';
  color: var(--text-muted); pointer-events: none;
}
.note-footer {
  padding: 12px 16px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}

/* Import modal */
.modal {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px; max-width: 380px; width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: 16px; }

.import-row { font-size: 15px; margin-bottom: 8px; }
.import-row.success { color: var(--success); }
.import-row.warn    { color: var(--warn); }
.import-row.error   { color: var(--error); }

/* ── Reading Mode ───────────────────────────────────────────────────────────── */
.reading-layout { display: flex; gap: 20px; align-items: flex-start; }
.reading-main { flex: 1; min-width: 0; }
.reading-input-wrap { margin-bottom: 16px; }

.reading-input-wrap textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); font-size: 15px; line-height: 1.65;
  resize: vertical; font-family: inherit;
}
.reading-input-wrap textarea:focus { outline: none; border-color: var(--rose); }
.reading-input-actions { display: flex; gap: 8px; margin-top: 10px; }

.reading-stats {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 14px; padding: 10px 14px;
  background: var(--surface2); border-radius: var(--radius-sm);
}
.reading-legend { margin-left: auto; }

.reading-output {
  line-height: 1.9; font-size: 16px;
}
.hl-word {
  background: rgba(183, 137, 120, .28); color: var(--ink);
  border-bottom: 2px solid var(--rose);
  cursor: pointer; border-radius: 2px; padding: 0 1px;
  transition: background var(--transition);
}
.hl-word:hover, .hl-word:focus { background: rgba(183, 137, 120, .5); outline: none; }
[data-theme="dark"] .hl-word { color: var(--text); }

.reading-side {
  width: 280px; flex-shrink: 0;
  position: sticky; top: 20px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow);
  max-height: 80vh; overflow-y: auto;
}
.reading-side.hidden { display: none; }

.side-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.side-word { font-size: 20px; font-weight: 700; }
.side-panel-body { padding: 16px; }
.side-phonetic { color: var(--rose); font-size: 15px; margin-bottom: 8px; font-style: italic; }
.side-def { font-size: 14px; line-height: 1.6; margin: 10px 0; }
.side-note-section { margin-top: 12px; }
.side-note { font-size: 13px; color: var(--text-muted); font-style: italic; }

/* ── Skeleton ───────────────────────────────────────────────────────────────── */
@keyframes shimmer { 0%{background-position:-400px 0} 100%{background-position:400px 0} }

.skeleton-card { background: var(--surface); border-radius: var(--radius); padding: 28px; border: 1px solid var(--line); }
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--sand) 50%, var(--surface2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  margin-bottom: 12px;
}
.skeleton-title { height: 40px; width: 60%; }
.skeleton-line  { height: 14px; width: 90%; }
.skeleton-line.short { width: 55%; }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, var(--surface2) 25%, #3a2d28 50%, var(--surface2) 75%); background-size: 800px 100%; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  max-width: 320px;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: #2d6a4f; color: #fff; }
.toast-error   { background: var(--error); color: #fff; }
.toast-info    { background: var(--surface); color: var(--text); border: 1px solid var(--line); }

/* ── Achievement Popup ──────────────────────────────────────────────────────── */
.achievement-popup {
  position: fixed; top: 24px; right: 24px; z-index: 600;
  background: var(--ink); color: #fff;
  border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateX(120%);
  transition: opacity .3s, transform .3s;
  max-width: 280px;
}
.achievement-popup.hidden { display: none; }
.achievement-popup.visible { opacity: 1; transform: translateX(0); }

.achievement-popup-inner { padding: 20px; text-align: center; }
.achievement-popup-icon { font-size: 40px; margin-bottom: 8px; }
.achievement-popup-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.achievement-popup-name { font-size: 18px; font-weight: 700; margin: 4px 0; }
.achievement-popup-desc { font-size: 13px; opacity: .8; margin-bottom: 8px; }
.achievement-popup-xp { background: var(--rose); display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
[data-theme="dark"] .achievement-popup { background: #0d0b0a; border: 1px solid var(--line); }

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--rose);
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ──────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    width: 240px;
    padding-top: 56px; /* mobile header height */
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  .app-root { display: block; }
  .main-content { padding-top: 56px; }

  .view { padding: 20px 16px 60px; }
  .view-title { font-size: 22px; }

  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dash-activity, .dash-recent-words, .dash-quick-actions { grid-column: 1 / -1; }

  .word-title { font-size: 26px; }
  .wotd-word  { font-size: 32px; }

  .reading-layout { flex-direction: column; }
  .reading-side { width: 100%; position: static; max-height: none; }

  .note-panel { width: 100%; }

  .achievements-grid { grid-template-columns: 1fr; }

  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .vocab-card { flex-direction: column; align-items: flex-start; }
  .vocab-card-actions { justify-content: flex-start; }
  .filter-row { flex-direction: column; }
}
