/* ==========================================================================
   Wordnest · Design System & Modern Stylesheet
   Theme: Calming Forest Sage & Literary Elegance
   ========================================================================== */

:root {
  /* Fonts */
  --font-serif: "Newsreader", "Charter", "Iowan Old Style", "Bitstream Charter", "Georgia", "Cambria", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Primary Emerald Palette */
  --green: #156349;
  --green-hover: #0e4b37;
  --green-active: #093829;
  --green-light: #eaf5ee;
  --green-surface: #f3f9f5;
  --green-border: #bde0cf;

  /* Surfaces & Canvas */
  --bg-body: #f7faf8;
  --bg-card: #ffffff;
  --bg-card-subtle: #f6f9f7;
  --bg-hover: #eff5f1;
  --line: #e3eae5;
  --line-strong: #c8d8d0;

  /* Text Hierarchy */
  --text-main: #173328;
  --text-secondary: #4d685d;
  --muted: #6f867b;
  --text-subtle: #96a9a0;

  /* Status & Accent Colors */
  --master-color: #10754e;
  --master-bg: #eaf6ef;
  --master-border: #bde5d1;
  --master-hover-bg: #156349;

  --learn-color: #b45309;
  --learn-bg: #fff8f0;
  --learn-border: #fedcb8;
  --learn-hover-bg: #fef2df;

  --danger-color: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  /* Elevation & Shadows */
  --shadow-xs: 0 1px 2px rgba(18, 52, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(18, 52, 40, 0.05), 0 3px 10px rgba(18, 52, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(18, 52, 40, 0.05), 0 12px 24px -4px rgba(18, 52, 40, 0.08);
  --shadow-lg: 0 10px 20px -3px rgba(18, 52, 40, 0.07), 0 20px 36px -5px rgba(18, 52, 40, 0.1);
  --shadow-modal: 0 24px 64px -12px rgba(14, 38, 30, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.05);

  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.15s var(--ease-spring);
  --transition-normal: 0.22s var(--ease-spring);
}

/* ==========================================================================
   CSS Reset & Base Elements
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-body);
  line-height: 1.65;
  min-height: 100vh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button, a, select {
  -webkit-tap-highlight-color: transparent;
}

/* Standard Button */
button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  background: var(--green);
  color: #ffffff;
  font-weight: 550;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all var(--transition-normal);
  line-height: 1.35;
}

button:hover:not(:disabled) {
  background: var(--green-hover);
  box-shadow: 0 2px 8px rgba(21, 99, 73, 0.25);
}

button:active:not(:disabled) {
  transform: scale(0.975);
  background: var(--green-active);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none !important;
  transform: none !important;
}

/* Focus Outline */
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2.5px solid var(--green);
  outline-offset: 2.5px;
}

/* Secondary Button */
.secondary {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: var(--text-secondary);
}

.secondary:hover:not(:disabled) {
  background: var(--bg-card-subtle);
  border-color: var(--green);
  color: var(--green);
  box-shadow: var(--shadow-xs);
}

/* Plain / Ghost Button */
.plain {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.plain:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--green);
  box-shadow: none;
}

/* ==========================================================================
   Main App Shell & Sticky Sidebar
   ========================================================================== */

.shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
aside {
  width: 270px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 32px 22px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

/* Brand */
.brand {
  color: var(--text-main);
  text-decoration: none;
  font-size: 24px;
  letter-spacing: -0.8px;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: opacity var(--transition-fast);
}

.brand:hover {
  opacity: 0.92;
}

.brand-icon {
  background: linear-gradient(135deg, #1b7a5a 0%, #10523d 100%);
  color: #ffffff;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(16, 82, 61, 0.28);
  flex-shrink: 0;
}

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

.brand-title {
  line-height: 1.1;
  font-size: 22px;
  font-family: var(--font-serif);
  font-weight: 700;
  color: #12382c;
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-top: 3px;
  font-family: var(--font-sans);
}

/* Navigation */
nav {
  margin-top: 36px;
  display: grid;
  gap: 8px;
}

nav button {
  text-align: left;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14.5px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  justify-content: flex-start;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

nav button:hover:not(.active) {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  box-shadow: none;
}

nav button.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
  border-color: rgba(21, 99, 73, 0.12);
}

nav .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.8;
  opacity: 0.85;
}

nav button.active .nav-icon {
  opacity: 1;
}

nav b {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 650;
  background: var(--green);
  color: #ffffff;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  min-width: 20px;
  text-align: center;
  transition: transform var(--transition-fast);
}

nav button.active b {
  background: var(--green);
  color: #ffffff;
}

/* Sidebar Note / Literary Card */
.sidebar-note {
  margin-top: auto;
  background: linear-gradient(180deg, #f3f8f5 0%, #ebf4ef 100%);
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid #dce8e1;
  font-size: 13px;
  line-height: 1.75;
  box-shadow: var(--shadow-xs);
}

.sidebar-note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--green);
}

.sidebar-note-header .leaf-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-note strong {
  display: block;
  font-size: 13px;
  color: var(--text-main);
  font-weight: 650;
}

.sidebar-note p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 12.5px;
}

.leaf {
  font-size: 24px;
  color: var(--green);
  display: inline-block;
  line-height: 1;
}

/* Local Note / Status */
.local-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  display: inline-block;
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   Workspace, Sticky Header & Footer
   ========================================================================== */

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

header {
  height: 72px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 44px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 15;
}

.breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb-icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
  flex-shrink: 0;
}

#breadcrumb {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.header-tools {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* Accent Selection Dropdown */
.accent-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  padding: 4px 12px 4px 10px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast);
}

.accent-wrap:hover {
  border-color: var(--green);
}

.accent-wrap .tool-icon {
  width: 16px;
  height: 16px;
  color: var(--green);
  flex-shrink: 0;
}

select {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 30px 7px 12px;
  background: #ffffff;
  color: var(--text-main);
  appearance: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%234d685d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all var(--transition-fast);
}

.accent-wrap select {
  border: 0;
  padding: 3px 22px 3px 2px;
  background-position: right 2px center;
  font-size: 13px;
  color: var(--text-secondary);
}

select:hover {
  border-color: var(--green);
}

/* Header Help Button */
.help-btn {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.help-btn .btn-icon {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  color: var(--muted);
}

.help-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-surface);
}

.help-btn:hover .btn-icon {
  color: var(--green);
}

/* Footer */
footer {
  font-size: 13px;
  color: var(--muted);
  margin: 40px 44px 0;
  padding: 24px 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-dot {
  color: var(--text-subtle);
}

.footer-tag {
  background: var(--bg-hover);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Main Content Area & Typography
   ========================================================================== */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 44px 30px;
  width: 100%;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 2.2px;
  color: var(--green);
  font-weight: 700;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

h1 {
  font-family: var(--font-serif);
  font-size: 34px;
  letter-spacing: -0.8px;
  margin: 4px 0 8px;
  font-weight: 700;
  color: #123528;
  line-height: 1.25;
}

h2 {
  font-size: 20px;
  letter-spacing: -0.3px;
  margin: 0 0 10px;
  font-weight: 650;
  color: var(--text-main);
}

p {
  line-height: 1.75;
  margin: 0 0 12px;
}

.intro {
  color: var(--text-secondary);
  font-size: 14.5px;
  margin: 0;
}

.sub {
  color: var(--muted);
  font-size: 13.5px;
  margin: 6px 0;
}

/* Pill badge */
.pill {
  font-size: 12.5px;
  font-weight: 550;
  background: var(--green-light);
  color: var(--green);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--green-border);
  flex-shrink: 0;
}

.pill-spark {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* ==========================================================================
   Stages Selector Grid (初中 / 高中 / 四级 / 六级)
   ========================================================================== */

.stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 28px 0 24px;
}

.stage {
  background: #ffffff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: left;
  padding: 18px 16px;
  color: var(--text-main);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.stage:hover:not(.active) {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  background: #ffffff;
}

.stage.active {
  border-color: var(--green);
  background: linear-gradient(180deg, #ffffff 0%, var(--green-surface) 100%);
  color: var(--green);
  box-shadow: 0 0 0 1px var(--green), var(--shadow-sm);
}

.stage-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 8px;
}

.stage .number {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--bg-hover);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.stage.active .number {
  background: var(--green);
  color: #ffffff;
}

.stage-pct {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.stage.active .stage-pct {
  color: var(--green);
}

.stage-title,
.stage strong {
  font-size: 15.5px;
  font-weight: 650;
  display: block;
  line-height: 1.3;
}

.stage-meter {
  height: 4px;
  background: #e9f0ec;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 10px 0 8px;
  width: 100%;
}

.stage-meter-fill {
  height: 100%;
  background: #a3cbb8;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.stage.active .stage-meter-fill {
  background: var(--green);
}

.stage-sub,
.stage small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.stage.active small {
  color: var(--text-secondary);
}

/* ==========================================================================
   Statistics Metrics Grid (总词数 / 已筛选 / 已掌握 / 待学习)
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  padding: 20px 0;
  box-shadow: var(--shadow-xs);
}

.stat {
  padding: 0 28px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.stat:last-child {
  border-right: 0;
}

.stat small {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat strong {
  font-size: 28px;
  display: block;
  margin: 6px 0 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  color: var(--text-main);
  line-height: 1.2;
}

.stat strong.green {
  color: var(--master-color);
}

.stat strong.orange {
  color: var(--learn-color);
}

/* ==========================================================================
   Card Panel & Batch Screening Controls
   ========================================================================== */

.panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-xs);
}

.batch-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.batch-head h2 {
  font-size: 21px;
  margin: 0;
  font-family: var(--font-serif);
}

/* Animated Progress Bar */
.progress {
  height: 8px;
  background: #edf4f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 20px 0 14px;
  position: relative;
}

.progress > span {
  height: 100%;
  display: block;
  background: linear-gradient(90deg, #156349 0%, #299e74 100%);
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 4px rgba(21, 99, 73, 0.35);
}

.batch-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  gap: 12px;
}

/* Toolbar & Action Controls */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 26px 0 18px;
  gap: 16px;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Search Input */
input[type=search] {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  padding: 9px 16px 9px 38px;
  min-width: 200px;
  width: 260px;
  color: var(--text-main);
  background: #ffffff;
  font-size: 13.5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f867b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: all var(--transition-fast);
}

input[type=search]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 99, 73, 0.15);
  width: 300px;
}

/* ==========================================================================
   Word Grid & Word Flashcards
   ========================================================================== */

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.word-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  position: relative;
}

.word-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.word-card.marked {
  opacity: 0.65;
  background: #fafcfb;
  border-style: dashed;
}

.word-card.marked:hover {
  opacity: 0.95;
}

/* Word Card Header */
.word-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.word {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  overflow-wrap: anywhere;
  color: #12382c;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

/* Audio Pronunciation Button */
.speak {
  border: 1px solid var(--line);
  background: var(--green-surface);
  color: var(--green);
  border-radius: var(--radius-full);
  padding: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.speak:hover:not(:disabled) {
  background: var(--green-light);
  border-color: var(--green-border);
  color: var(--green-hover);
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(21, 99, 73, 0.2);
}

.speak:active:not(:disabled) {
  transform: scale(0.95);
}

.speak.playing {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
  animation: soundWave 1.2s infinite ease-in-out;
}

@keyframes soundWave {
  0% { box-shadow: 0 0 0 0 rgba(21, 99, 73, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(21, 99, 73, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 99, 73, 0); }
}

.speak svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

/* Phonetic & Part of Speech */
.word-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 14px;
}

.phonetic {
  color: var(--muted);
  font-size: 13.5px;
  font-family: var(--font-serif);
  letter-spacing: 0.2px;
  margin: 0;
}

.pos-badge {
  font-size: 11px;
  font-weight: 650;
  color: var(--green);
  background: var(--green-light);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   Tactile Meaning Region (Accordion Details & Reveal Card)
   ========================================================================== */

.meaning-region {
  margin: 0 0 12px;
  min-height: 64px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #f8faf9 0%, #f3f7f5 100%);
  border: 1.5px dashed var(--line-strong);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.meaning-region:hover {
  background: #eef6f1;
  border-color: #a8cfbd;
}

.meaning-region summary {
  padding: 14px 16px;
  min-height: 60px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  width: 100%;
}

.meaning-region summary::-webkit-details-marker {
  display: none;
}

.meaning-region summary::marker {
  content: '';
}

.meaning-region summary:focus-visible {
  outline: 2.5px solid var(--green);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.meaning-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: center;
  user-select: none;
}

.meaning-hint .hint-icon {
  width: 16px;
  height: 16px;
  opacity: 0.75;
}

.meaning-value {
  display: none;
  width: 100%;
}

.meaning-region[open] {
  border-style: solid;
  border-color: #cce5d7;
  background: #ffffff;
  box-shadow: inset 0 1px 3px rgba(18, 52, 40, 0.03);
}

.meaning-region[open] .meaning-hint {
  display: none;
}

.meaning-region[open] .meaning-value,
.meaning-value .meaning,
.meaning-value .example {
  display: block;
}

.meaning,
.meaning-text {
  font-size: 14.5px;
  color: var(--text-main);
  line-height: 1.75;
  white-space: pre-line;
  font-weight: 500;
}

.example,
.example-box {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--green-surface);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.6;
}

.example-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-light);
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 6px;
  font-style: normal;
  text-transform: uppercase;
}

/* Audio Source Tag & Credit Link */
.audio-label {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.audio-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.audio-badge.synth .audio-dot {
  background: #94a3b8;
}

.credit-btn,
.credit-link {
  font-size: 11.5px !important;
  color: var(--green) !important;
  padding: 1px 6px !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Card Decision Buttons & Status Badges
   ========================================================================== */

.actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  align-items: center;
}

.actions button {
  flex: 1;
  font-size: 13.5px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
}

/* Learn Button (Need to Learn) */
.learn-btn {
  background: var(--learn-bg);
  color: var(--learn-color);
  border: 1.5px solid var(--learn-border);
}

.learn-btn:hover:not(:disabled) {
  background: var(--learn-hover-bg);
  border-color: #f59e0b;
  color: #92400e;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.15);
}

/* Master Button (Familiar / Mastered) */
.master-btn {
  background: var(--master-bg);
  color: var(--master-color);
  border: 1.5px solid var(--master-border);
}

.master-btn:hover:not(:disabled) {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(21, 99, 73, 0.25);
}

/* Marked Status Tag */
.tag,
.marked-tag {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--master-color);
  background: var(--master-bg);
  border: 1px solid var(--master-border);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag.learning,
.marked-tag.learning {
  color: var(--learn-color);
  background: var(--learn-bg);
  border-color: var(--learn-border);
}

.reset-btn {
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 12px;
}

.reset-btn:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty {
  text-align: center;
  padding: 56px 24px;
  border-radius: var(--radius-lg);
}

.empty h2 {
  font-size: 22px;
  font-family: var(--font-serif);
  margin: 12px 0 8px;
  color: var(--text-main);
}

.empty p {
  font-size: 14.5px;
  color: var(--muted);
  max-width: 420px;
  margin: 0 auto 20px;
}

.empty .leaf {
  font-size: 36px;
  margin-bottom: 6px;
}

/* ==========================================================================
   Library & Progress Section
   ========================================================================== */

.library-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.library-grid .wide {
  grid-column: 1 / -1;
}

.backup-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* Modern Data Table */
.stage-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  margin-top: 14px;
}

.stage-table th {
  text-align: left;
  border-bottom: 2px solid var(--line);
  padding: 12px 14px;
  font-weight: 650;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stage-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 16px 14px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.stage-table tr:hover td {
  background: var(--bg-hover);
}

.stage-table tr:last-child td {
  border-bottom: 0;
}

.stage-table button.plain {
  font-weight: 650;
  color: var(--green);
  padding: 0;
  font-size: 14.5px;
}

.source-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.6;
}

/* ==========================================================================
   Dialog Modals (Help, Sources, Audio Credits, Import Preview)
   ========================================================================== */

dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  max-width: 720px;
  width: calc(100% - 32px);
  padding: 32px;
  color: var(--text-main);
  max-height: 85vh;
  box-shadow: var(--shadow-modal);
  background: #ffffff;
  position: fixed;
  inset: 0;
  margin: auto;
  animation: dialogFadeIn 0.24s var(--ease-spring);
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

dialog::backdrop {
  background: rgba(14, 38, 30, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  color: var(--text-main);
}

.dialog-close-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.dialog-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

dialog h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  margin-top: 0;
  color: #12382c;
}

dialog p,
dialog li {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-secondary);
}

dialog a {
  color: var(--green);
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 3px;
}

dialog table {
  width: 100%;
  font-size: 13.5px;
  border-collapse: collapse;
  margin: 16px 0;
}

dialog th {
  padding: 10px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

dialog td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

dialog .scroll {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px 14px;
  margin: 16px 0;
  background: var(--bg-card-subtle);
}

#close-dialog {
  margin-top: 22px;
}

/* ==========================================================================
   Toasts & Error Banners
   ========================================================================== */

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 52, 40, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: 0 10px 32px rgba(10, 30, 23, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 100;
  max-width: 90vw;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  animation: toastSlideUp 0.25s var(--ease-spring);
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

#toast.error {
  background: rgba(153, 27, 27, 0.95);
  box-shadow: 0 10px 32px rgba(153, 27, 27, 0.3);
}

.error-banner {
  padding: 16px 20px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-color);
  font-size: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ==========================================================================
   Responsive Breakpoints & Media Queries
   ========================================================================== */

/* Large Screens */
@media (min-width: 1450px) {
  main {
    max-width: 1340px;
    padding-top: 48px;
  }
  .word-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }
}

/* Tablets & Small Laptops */
@media (max-width: 1024px) {
  aside {
    width: 230px;
    padding: 26px 16px;
  }
  header {
    padding: 0 24px;
  }
  main {
    padding: 30px 24px;
  }
  .stats {
    padding: 16px 0;
  }
  .stat {
    padding: 0 16px;
  }
  .word-card {
    padding: 20px;
  }
  footer {
    margin: 30px 24px 0;
  }
}

/* Mobile Devices */
@media (max-width: 768px) {
  .shell {
    display: block;
  }
  aside {
    position: static;
    width: 100%;
    height: auto;
    padding: 16px 18px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    font-size: 21px;
  }
  .brand-sub,
  .sidebar-note,
  .local-note {
    display: none;
  }
  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 19px;
  }
  nav {
    margin-top: 14px;
    display: flex;
    gap: 6px;
  }
  nav button {
    flex: 1;
    justify-content: center;
    font-size: 13px;
    padding: 10px 6px;
    gap: 6px;
  }
  nav .nav-icon {
    width: 16px;
    height: 16px;
  }
  nav b {
    margin: 0;
  }
  header {
    height: 60px;
    padding: 0 18px;
  }
  #breadcrumb,
  .breadcrumb-wrap {
    display: none;
  }
  .header-tools {
    justify-content: space-between;
    width: 100%;
  }
  main {
    padding: 24px 16px;
  }
  h1 {
    font-size: 26px;
  }
  .heading {
    align-items: flex-start;
    gap: 12px;
  }
  .heading .pill {
    display: none;
  }
  .stages {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 18px 0;
  }
  .stage {
    padding: 14px 12px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 16px;
  }
  .stat {
    padding: 0 8px;
    border-right: 0;
  }
  .stat strong {
    font-size: 24px;
  }
  .word-grid,
  .library-grid {
    grid-template-columns: 1fr;
  }
  .word-card {
    padding: 20px;
  }
  .word {
    font-size: 28px;
  }
  .toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  input[type=search] {
    width: 100%;
  }
  footer {
    margin: 24px 16px 0;
    padding: 18px 0;
    font-size: 11px;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
