:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f3f4f7;
  --surface-hover: #eceef3;
  --text: #181a1f;
  --text-secondary: #5f6673;
  --text-muted: #939aa8;
  --border: #e6e8ee;
  --primary: #2563eb;
  --primary-soft: #ebf3ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #e11d48;
  --red-soft: #ffe4e6;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --shadow-card: 0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-sheet: 0 -8px 32px rgba(15, 23, 42, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #181c24;
  --surface-muted: #222733;
  --surface-hover: #2a303f;
  --text: #f1f5f9;
  --text-secondary: #a1abbd;
  --text-muted: #6c7689;
  --border: #2a303d;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.16);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Boot Loader */
.boot-loader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
}

.boot-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Common Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.94;
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-muted {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger-soft {
  background: var(--red-soft);
  color: var(--red);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s ease;
}

.icon-btn:hover,
.icon-btn:active {
  background: var(--surface-muted);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.tag-pill.primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.tag-pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag-pill.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag-pill.red {
  background: var(--red-soft);
  color: var(--red);
}

/* =========================================
   HOME / BOOKSHELF VIEW
   ========================================= */
.home-container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  max-width: 65%;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-pill-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.synced { background: var(--green); }
.sync-dot.syncing { background: var(--amber); animation: pulse 1s infinite; }
.sync-dot.local { background: var(--text-muted); }
.sync-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hero-summary {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 52%, #0284c7 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.22);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hero-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.hero-sub {
  margin: 3px 0 0;
  font-size: 12px;
  opacity: 0.88;
}

.hero-mode-chip {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
}

.hero-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-stat-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.hero-stat-lbl {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 2px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.books-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.book-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.book-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.book-desc {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.book-progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  display: flex;
}

.book-progress-mastered {
  background: var(--green);
  height: 100%;
  transition: width 0.3s ease;
}

.book-progress-review {
  background: var(--amber);
  height: 100%;
  transition: width 0.3s ease;
}

.book-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.book-meta-row strong {
  color: var(--text);
}

.book-limit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 11px;
  background: var(--surface-muted);
  font-size: 12px;
}

.book-card-actions {
  display: flex;
  gap: 8px;
}

.book-card-actions .btn-primary {
  flex: 1;
}

/* =========================================
   STUDY VIEW (Eudic Style)
   ========================================= */
.study-shell {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.study-topbar {
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.study-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.study-counters {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}

.counter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.counter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.counter-dot.green { background: var(--green); }
.counter-dot.red { background: var(--red); }
.counter-dot.gray { background: var(--text-muted); }

.counter-item.green { color: var(--green); }
.counter-item.red { color: var(--red); }

.prev-word-hint {
  color: var(--text-muted);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-progress-line {
  height: 3px;
  width: 100%;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.study-progress-done {
  background: var(--green);
  height: 100%;
  transition: width 0.25s ease;
}

.study-progress-pending {
  background: #cbd5e1;
  height: 100%;
}

.study-stage {
  flex: 1;
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
}

.study-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.card-dots-bar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-dots-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 11px;
  color: var(--text-muted);
}

.word-hero {
  text-align: center;
  padding: 8px 4px 4px;
}

.word-headword {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
  word-break: break-word;
}

.word-headword.zh-prompt {
  font-size: 22px;
  line-height: 1.45;
  padding: 10px 4px;
}

.phonetics-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.phonetic-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  transition: background 0.15s ease;
}

.phonetic-btn:hover,
.phonetic-btn:active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Example Box */
.example-block {
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.example-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.example-sentence {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
}

.word-highlight {
  color: var(--primary);
  font-weight: 700;
}

.example-trans-toggle {
  font-size: 12px;
  color: var(--text-muted);
  text-align: left;
  padding: 2px 0;
}

.example-trans-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 4 Choice Options */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  min-height: 54px;
  padding: 12px 15px;
  border-radius: 13px;
  background: var(--surface-muted);
  border: 1.5px solid transparent;
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.choice-btn.en-choice {
  font-size: 17px;
  font-weight: 600;
}

.choice-btn.correct {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

.choice-btn.wrong {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.choice-btn.dimmed {
  opacity: 0.58;
}

.choice-key-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 18px;
  text-align: center;
}

.dont-know-btn {
  align-self: center;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Listening Mode Big Speaker */
.listen-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0 8px;
}

.listen-circle-btn {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.14);
}

.listen-circle-btn:active {
  transform: scale(0.95);
}

/* Card Mode Bottom 3-Button Bar */
.card-mode-spacer {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.card-reveal-btn {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 14px;
}

.card-familiarity-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.fam-btn {
  min-height: 46px;
  border-radius: 12px;
  background: var(--surface-muted);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.fam-btn.unknown { color: var(--red); }
.fam-btn.fuzzy { color: var(--amber); }
.fam-btn.known { color: var(--green); }

/* Spelling Mode */
.spell-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 8px 0;
}

.spell-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--surface-muted);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.6px;
  outline: none;
}

.spell-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.spell-input.correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.spell-input.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

/* =========================================
   WORD DETAIL VIEW (Screenshot 2 Style)
   ========================================= */
.detail-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.detail-word {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.star-btn.active {
  color: #f59e0b;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.meaning-box {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
}

.poly-compare-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.poly-item {
  background: var(--surface-muted);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
}

.poly-item.highlight {
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.25);
}

/* Morpheme Tree (Screenshot 2 Style) */
.morpheme-tree {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.tree-root-node {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.tree-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-muted);
  font-size: 13px;
  font-weight: 600;
}

.tree-branch {
  margin-left: 12px;
  padding-left: 14px;
  border-left: 1.5px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.morpheme-note-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.55;
}

.morpheme-kind-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-next-wrap {
  margin-top: 6px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(transparent, var(--surface) 24%);
}

/* =========================================
   BOTTOM 5-ICON STUDY TOOLBAR
   ========================================= */
.study-bottom-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
}

.toolbar-btn {
  height: 44px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: 10px;
}

.toolbar-btn:active,
.toolbar-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.toolbar-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* =========================================
   MODALS & BOTTOM SHEET (Screenshot 4 Style)
   ========================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.16s ease;
}

@media (min-width: 640px) {
  .modal-backdrop.center-desktop {
    align-items: center;
    padding: 20px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  width: 100%;
  max-width: 540px;
  max-height: 88dvh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow-sheet);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

@media (min-width: 640px) {
  .modal-backdrop.center-desktop .bottom-sheet {
    border-radius: 22px;
    max-height: 84dvh;
  }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mode-option-btn {
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-option-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 14px;
  font-weight: 600;
}

.setting-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Toggle Switch */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.undo-danger-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-soft);
}

/* Forms & Inputs */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.text-input,
.text-area,
.select-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 14px;
  outline: none;
}

.text-input:focus,
.text-area:focus,
.select-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.text-area {
  min-height: 110px;
  resize: vertical;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.preset-chip.active {
  background: var(--primary);
  color: #fff;
}

/* Wordlist Browser Items */
.word-list-scroll {
  max-height: 52dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.word-list-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.word-list-main {
  min-width: 0;
  flex: 1;
}

.word-list-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.word-list-sub {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Profile / Settings Subpages */
.subpage-container {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 16px calc(30px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.subpage-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subpage-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.panel-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.guide-box {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-box code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 700;
  color: var(--primary);
}

/* Completion Card */
.complete-card {
  text-align: center;
  padding: 28px 20px;
  align-items: center;
  gap: 16px;
}

.complete-badge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast */
.toast-container {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 380px);
}

.toast-item {
  background: rgba(24, 26, 31, 0.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .toast-item {
  background: rgba(51, 65, 85, 0.96);
}
