:root {
  --ink: #172033;
  --muted: #667085;
  --paper: rgba(255, 255, 255, .9);
  --cream: #eef2f8;
  --line: #dce3ee;
  --green: #2563eb;
  --green-dark: #173f91;
  --accent: #ec6a5c;
  --good: #168468;
  --bad: #cf4b57;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #fff;
  --surface-muted: #f6f8fc;
  --ring: rgba(37, 99, 235, .2);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .04);
  --shadow-md: 0 12px 36px rgba(31, 48, 77, .1);
  --shadow-lg: 0 28px 80px rgba(31, 48, 77, .18);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  color-scheme: light;
}

html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 10% 0%, rgba(123, 167, 255, .24), transparent 31rem),
    radial-gradient(circle at 92% 18%, rgba(242, 159, 151, .18), transparent 27rem),
    linear-gradient(180deg, #f8faff 0, var(--cream) 58%, #e9eef7 100%);
}
body::before {
  opacity: .09;
  mix-blend-mode: multiply;
}

button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}
button:not(:disabled) { transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease; }
button:not(:disabled):active { transform: translateY(1px) scale(.985); }

#uiEnhancementRoot { position: fixed; inset: 0; z-index: 140; pointer-events: none; }
.app-presence-accent {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(780px, 72vw);
  height: 3px;
  transform-origin: center;
  translate: -50% 0;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, transparent, #4f7ff0 18%, #7c65d7 50%, #ef7d6e 82%, transparent);
  box-shadow: 0 2px 18px rgba(79, 127, 240, .3);
}
.lucide-icon-wrap { display: inline-grid; place-items: center; width: 100%; height: 100%; }
.button-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: 0 0 18px; }
.muted-icon { opacity: .62; }

.profile-gate {
  background:
    radial-gradient(circle at 20% 10%, rgba(135, 174, 255, .3), transparent 36rem),
    radial-gradient(circle at 88% 82%, rgba(245, 165, 157, .2), transparent 30rem),
    #eef2f8;
}
.profile-gate-card {
  width: min(470px, 100%);
  padding: clamp(30px, 6vw, 52px);
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(130%);
}
.profile-gate-logo, .brand-mark, .dashboard-z {
  border-radius: 18px;
  background: linear-gradient(145deg, #336ee7, #204bac 68%, #17367e);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 13px 32px rgba(35, 79, 175, .24);
  transform: none;
}
.profile-gate-card h1, .dashboard-intro h1, .dashboard-action strong, .study-word-card h2,
.study-complete h2, .brand b { font-family: ui-serif, "Songti SC", "Noto Serif SC", Georgia, serif; }
.profile-gate-card > p:first-of-type, .eyebrow, .dashboard-action small, .study-kicker { color: #5573bb; }
.auth-tabs {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f4f7fc;
}
.auth-tabs button { border: 0; border-radius: 10px; }
.auth-tabs button.active { border: 0; background: #fff; color: var(--green-dark); box-shadow: var(--shadow-sm); }
.auth-form label { color: #344054; }
.auth-form input, .import-modal input, .import-modal textarea {
  min-height: 46px;
  border: 1px solid #d7deea;
  border-radius: 12px;
  background: rgba(255,255,255,.92);
}
.auth-form input:focus { border-color: #6991ed; box-shadow: 0 0 0 4px var(--ring); }
.auth-submit, .primary-button, .learned-button {
  border-radius: 12px;
  background: linear-gradient(135deg, #2f6be4, #204fb9);
  box-shadow: 0 8px 22px rgba(37, 99, 235, .22);
}
.auth-submit:hover, .primary-button:hover, .learned-button:hover { background: linear-gradient(135deg, #255fd4, #183f9a); transform: translateY(-1px); }
.forgot-password-button { color: #315db6; text-decoration: none; }
.forgot-password-button:hover { text-decoration: underline; }

.shell { width: min(1180px, calc(100% - 48px)); padding-top: 22px; }
.topbar {
  position: sticky;
  z-index: 20;
  top: 14px;
  min-height: 68px;
  padding: 11px 14px;
  border: 1px solid rgba(220, 227, 238, .82);
  border-radius: 20px;
  background: rgba(250, 252, 255, .8);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px) saturate(140%);
}
.brand { gap: 10px; }
.brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 13px; }
.z-glyph { transform: none; text-shadow: none; }
.brand b { font-size: 18px; letter-spacing: .02em; }
.brand small { color: #8490a4; }
.top-actions { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.profile-button, .history-button, .vocabulary-button, .mastered-button, .level-button,
.study-entry-button, .dictation-entry-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #d9e0ec;
  border-radius: 11px;
  background: rgba(255,255,255,.72);
  color: #344054;
  box-shadow: none;
}
.top-actions > .study-entry-button, .top-actions > .dictation-entry-button, .top-actions > .level-button { display: inline-flex; }
.profile-button:hover, .history-button:hover, .vocabulary-button:hover, .mastered-button:hover, .level-button:hover {
  border-color: #b8c8e7;
  background: #fff;
  color: var(--green-dark);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.mastered-button > #masteredCount { background: #e7efff; color: #2455b7; }
.level-dot { background: #4f7ff0; box-shadow: 0 0 0 4px rgba(79,127,240,.12); }
.level-menu {
  top: 64px;
  width: 240px;
  padding: 8px;
  border-color: rgba(214,223,237,.95);
  border-radius: 16px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}
.level-menu button { min-height: 44px; border-radius: 11px; }
.level-menu button:hover, .level-menu button.active { background: #edf3ff; color: #244b9c; }

.dashboard { padding-top: 68px; }
.dashboard-intro { align-items: center; }
.dashboard-intro h1 { color: #172033; font-size: clamp(42px, 5.5vw, 68px); letter-spacing: -.055em; }
.dashboard-z { width: 82px; height: 82px; flex-basis: 82px; border-radius: 24px; }
.dashboard-stats {
  overflow: hidden;
  border-color: rgba(217,225,237,.9);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}
.dashboard-stats article { position: relative; min-height: 146px; padding: 27px 30px; }
.dashboard-stats article::after { content: ""; position: absolute; left: 30px; right: 30px; bottom: 0; height: 3px; border-radius: 999px; background: linear-gradient(90deg, #3973e6, #7f8fea); opacity: .72; }
.dashboard-stats strong, .dashboard-detail-stats strong { color: #214fae; font-family: ui-serif, Georgia, serif; }
.dashboard-detail-stats {
  overflow: hidden;
  border-color: rgba(217,225,237,.9);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: rgba(247,249,253,.88);
  box-shadow: 0 16px 36px rgba(31,48,77,.06);
}
.dashboard-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.dashboard-action {
  position: relative;
  min-height: 124px;
  grid-template-columns: 52px 1fr 20px;
  gap: 17px;
  padding: 22px;
  overflow: hidden;
  border-color: rgba(215,224,237,.92);
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}
.dashboard-action::after { content: ""; position: absolute; inset: auto -20% -70% 35%; height: 130px; border-radius: 50%; background: radial-gradient(circle, rgba(91,134,231,.12), transparent 70%); pointer-events: none; }
.dashboard-action:hover { transform: translateY(-4px); border-color: #b8c9e9; box-shadow: 0 18px 38px rgba(31,48,77,.12); }
.dashboard-action .action-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: linear-gradient(145deg, #3c77ea, #2455ba);
  box-shadow: 0 9px 22px rgba(37,99,235,.2);
}
.dashboard-action .action-icon .lucide-icon-wrap { color: #fff; }
.dashboard-action strong { color: #1f293d; font-size: 21px; }
.dashboard-action em { color: #758197; font-size: 11px; line-height: 1.5; }
.dashboard-action > b { width: 20px; height: 20px; color: #7890bf; }
.wrong-learn-action .action-icon, .wrong-test-action .action-icon, .cloze-wrong-action .action-icon { background: linear-gradient(145deg, #ef8177, #cf5360); }
.error-analysis-action .action-icon { background: linear-gradient(145deg, #f19a4b, #d66a35); }
.choose-group-action .action-icon, .choose-dictation-action .action-icon { background: linear-gradient(145deg, #42a88b, #247e68); }
.cloze-action .action-icon, .choose-cloze-action .action-icon { background: linear-gradient(145deg, #987bd5, #6e52af); }
.dashboard-note { color: #7b879b; }

.modal-backdrop {
  background: rgba(15, 24, 42, .54);
  backdrop-filter: blur(10px);
}
.modal-backdrop:not([hidden]) { animation: modern-backdrop-in .18s ease-out; }
.modal-backdrop:not([hidden]) > section { animation: modern-dialog-in .28s cubic-bezier(.2,.8,.2,1); }
.import-modal, .study-modal {
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 22px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-lg);
}
.modal-head, .study-head { border-color: var(--line); background: #f7f9fd; }
.modal-head > button, .study-head > button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.modal-head > button:hover, .study-head > button:hover { background: #e9eef8; color: #1f4b9f; }
.group-selection-summary, .dictation-filter-option, .history-summary { border-radius: 12px; background: var(--surface-muted); }
.group-choice, .study-word-card, .history-list, .word-list { border-radius: 14px; }
.group-choice:hover { border-color: #a9bde5; background: #f2f6ff; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.study-progress-track i { background: linear-gradient(90deg, #3470e5, #8d74d5); }
.study-sound-button { border-radius: 12px; background: #f1f5fd; color: #2857b5; }
.completion-mark { background: #e8f7f2; color: #14775e; }

.error-analysis-modal { width: min(900px, 100%); }
.error-analysis-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.error-analysis-summary article {
  min-height: 84px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
}
.error-analysis-summary small, .error-analysis-summary span { display: block; color: var(--muted); font-size: 9px; }
.error-analysis-summary strong { display: inline-block; margin: 5px 4px 0 0; color: var(--green-dark); font: 600 24px/1.2 ui-serif, Georgia, serif; }
.error-analysis-summary article:last-child strong { font-family: inherit; font-size: 17px; }
.error-analysis-head, .error-analysis-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(150px, .8fr) minmax(110px, .55fr);
  align-items: center;
  gap: 18px;
}
.error-analysis-head { padding: 0 17px 8px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; }
.error-analysis-head span:last-child { text-align: right; }
.error-analysis-list { max-height: min(520px, 54vh); overflow-y: auto; border: 1px solid var(--line); }
.error-analysis-row { min-height: 82px; padding: 13px 17px; background: #fff; }
.error-analysis-row + .error-analysis-row { border-top: 1px solid var(--line); }
.error-analysis-identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.error-analysis-rank { display: grid; place-items: center; width: 39px; height: 32px; flex: 0 0 39px; border-radius: 10px; background: #edf3ff; color: #315db6; font-size: 10px; font-weight: 800; }
.error-analysis-identity > div { min-width: 0; }
.error-analysis-identity strong, .error-analysis-identity span { display: block; }
.error-analysis-identity strong { color: var(--ink); font: 600 18px/1.25 ui-serif, Georgia, serif; }
.error-analysis-identity span { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.error-analysis-counts strong { color: var(--bad); font: 700 20px/1 ui-serif, Georgia, serif; }
.error-analysis-counts > span { display: inline; margin-left: 4px; color: var(--bad); font-size: 10px; }
.error-analysis-counts small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; }
.error-analysis-rate { text-align: right; }
.error-analysis-rate > strong { display: block; margin-bottom: 7px; color: #ba4653; font: 700 17px/1 ui-serif, Georgia, serif; }
.error-analysis-rate > span { display: block; height: 5px; overflow: hidden; border-radius: 999px; background: #f2dfe2; }
.error-analysis-rate i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ef8177, #c94755); }

@keyframes modern-backdrop-in { from { opacity: 0; } }
@keyframes modern-dialog-in { from { opacity: 0; transform: translateY(18px) scale(.975); } }

@media (max-width: 1040px) {
  .topbar { align-items: flex-start; }
  .top-actions { max-width: 72%; }
  .top-actions .profile-button:first-child { order: 10; }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 680px); padding-top: 12px; }
  .topbar { top: 8px; padding: 10px 12px; border-radius: 16px; }
  .brand small { display: none; }
  .top-actions { max-width: none; }
  .top-actions > button:not(#levelButton):not(#openHistoryButton):not(#openVocabularyButton) { display: none; }
  .top-actions button { min-width: 38px; justify-content: center; }
  .history-button, .vocabulary-button { font-size: 0; gap: 0; }
  .history-button .button-icon, .vocabulary-button .button-icon { width: 20px; height: 20px; }
  .dashboard { padding-top: 42px; }
  .dashboard-intro { align-items: flex-end; }
  .dashboard-z { width: 58px; height: 58px; flex-basis: 58px; border-radius: 17px; font-size: 28px; }
  .dashboard-stats { grid-template-columns: repeat(3, 1fr); }
  .dashboard-stats article { min-height: 112px; padding: 18px 14px; }
  .dashboard-stats article::after { left: 14px; right: 14px; }
  .dashboard-stats strong { font-size: 36px; }
  .dashboard-detail-stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-detail-stats article:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .dashboard-detail-stats article:nth-child(4) { border-top: 1px solid var(--line); }
  .dashboard-actions { grid-template-columns: 1fr; }
  .dashboard-action { min-height: 108px; }
  .error-analysis-summary { grid-template-columns: 1fr 1fr; }
  .error-analysis-summary article:last-child { grid-column: 1 / -1; min-height: 66px; }
  .error-analysis-head { display: none; }
  .error-analysis-row { grid-template-columns: minmax(0, 1fr) 105px; gap: 12px; }
  .error-analysis-rate { grid-column: 1 / -1; display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px; text-align: left; }
  .error-analysis-rate > strong { margin: 0; }
}
@media (max-width: 460px) {
  .profile-gate { padding: 12px; }
  .profile-gate-card { padding: 28px 20px; border-radius: 22px; }
  .brand b { font-size: 16px; }
  .dashboard-intro h1 { font-size: 39px; }
  .dashboard-z { display: none; }
  .dashboard-stats article { padding: 16px 10px; }
  .dashboard-stats small { letter-spacing: .03em; }
  .dashboard-stats strong { font-size: 31px; }
  .dashboard-action { grid-template-columns: 46px 1fr 18px; padding: 18px 16px; gap: 13px; border-radius: 15px; }
  .dashboard-action .action-icon { width: 46px; height: 46px; border-radius: 13px; }
  .dashboard-action strong { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
