:root {
  --canvas: #f6f7f5;
  --paper: #ffffff;
  --ink: #1d2b2a;
  --muted: #6d7a77;
  --line: #dbe1dc;
  --pine: #116149;
  --pine-dark: #0b4435;
  --mint: #dff1e8;
  --sun: #f4bd56;
  --coral: #c95e4b;
  --coral-pale: #fcedea;
  --blue: #3f6d96;
  --shadow: 0 18px 52px rgba(29, 43, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app-shell { display: grid; grid-template-columns: 255px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 36px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--pine); font-weight: 800; font-size: 17px; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 0; }
.brand p, .eyebrow, .panel-title, .section-heading > span { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.brand p, .eyebrow, .panel-title { letter-spacing: 0; }

.nav-tabs { display: grid; gap: 3px; }
.nav-tab { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border: 0; border-left: 3px solid transparent; color: var(--muted); background: transparent; text-align: left; font-weight: 700; }
.nav-tab:hover, .nav-tab.active { border-left-color: var(--pine); color: var(--pine-dark); background: #f1f7f3; }
.nav-index { color: #9aa59f; font-size: 11px; font-variant-numeric: tabular-nums; }

.daily-panel { margin-top: auto; padding-top: 28px; }
.daily-number { display: flex; align-items: baseline; gap: 4px; margin: 9px 0 11px; }
.daily-number strong { color: var(--pine-dark); font-size: 42px; line-height: 1; font-variant-numeric: tabular-nums; }
.daily-number span { color: var(--muted); font-size: 15px; }
.progress-track { height: 5px; overflow: hidden; background: #e6ebe7; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--sun); transition: width 180ms ease; }
.daily-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 19px; }
.daily-grid strong { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.daily-grid span { color: var(--muted); font-size: 12px; }

.content { width: min(1240px, 100%); margin: 0 auto; padding: 34px clamp(22px, 5vw, 68px) 52px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 32px; }
.topbar h2 { margin: 2px 0 0; font-size: 32px; line-height: 1.15; letter-spacing: 0; }
.topbar-actions { display: flex; gap: 7px; }
.account-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 0; color: var(--pine-dark); background: var(--paper); font-weight: 800; }
.account-button:hover { border-color: var(--pine); background: #f6fbf8; }
.icon-button, .sound-button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
.icon-button:hover, .sound-button:hover { border-color: var(--pine); color: var(--pine); }

.view { display: none; }
.view.active { display: block; }
.study-layout, .library-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, 0.65fr); gap: 36px; align-items: start; }

.study-stage { min-height: 535px; padding: 26px 0 0; border-top: 3px solid var(--pine); background: var(--paper); box-shadow: var(--shadow); }
.stage-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 0 32px; }
.card-meta { display: flex; gap: 7px; flex-wrap: wrap; }
.card-meta span { padding: 5px 8px; color: var(--pine-dark); background: var(--mint); font-size: 12px; font-weight: 800; }
.card-meta span + span { color: var(--blue); background: #eaf1f6; }
.word-focus { display: grid; align-content: center; min-height: 248px; padding: 30px 32px 22px; }
.word-focus h3 { max-width: 100%; margin: 0; overflow-wrap: anywhere; font-size: clamp(42px, 7vw, 74px); line-height: 1; letter-spacing: 0; }
#phoneticText { min-height: 26px; margin: 16px 0 0; color: var(--blue); font-size: 17px; font-weight: 700; }
.reveal-button { width: calc(100% - 64px); min-height: 54px; margin: 0 32px; border: 1px solid var(--pine); color: var(--pine-dark); background: #f6fbf8; font-weight: 800; }
.reveal-button:hover { background: var(--mint); }
.answer-panel { min-height: 128px; margin: 0 32px; padding: 22px 0 0; }
.definition { color: var(--ink); font-size: 24px; font-weight: 800; line-height: 1.45; }
.example { margin: 13px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 20px 32px 28px; }
.primary-button, .secondary-button { min-height: 50px; border: 1px solid transparent; border-radius: 0; font-weight: 800; }
.primary-button { color: white; background: var(--pine); }
.primary-button:hover:not(:disabled) { background: var(--pine-dark); }
.secondary-button { border-color: #efc4bd; color: var(--coral); background: var(--coral-pale); }
.secondary-button:hover:not(:disabled) { background: #f9dcd7; }
.primary-button:disabled, .secondary-button:disabled { opacity: 0.38; }

.queue-panel { padding: 18px 0 0; border-top: 3px solid var(--sun); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.section-heading h3 { margin: 3px 0 0; font-size: 19px; letter-spacing: 0; }
.queue-list, .word-list { display: grid; gap: 0; max-height: 513px; overflow: auto; border-top: 1px solid var(--line); }
.queue-item { padding: 15px 4px; border-bottom: 1px solid var(--line); background: transparent; transition: background 140ms ease, padding 140ms ease; }
.queue-item:hover { padding-left: 10px; background: #fbfcfa; cursor: pointer; }
.queue-item strong, .library-item strong { display: block; margin-bottom: 4px; }
.queue-item span, .library-item span { color: var(--muted); font-size: 13px; line-height: 1.4; }

.quiz-box { max-width: 790px; padding: 0; border-top: 3px solid var(--blue); background: var(--paper); box-shadow: var(--shadow); }
.quiz-box .section-heading { padding: 22px 28px 0; }
.quiz-prompt { padding: 38px 28px; background: #eef4f8; text-align: center; }
.quiz-prompt p { margin: 0 0 9px; color: var(--muted); font-size: 14px; }
.quiz-prompt strong { font-size: clamp(36px, 6vw, 58px); overflow-wrap: anywhere; }
.options { display: grid; gap: 8px; padding: 22px 28px 10px; }
.option-button { min-height: 52px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 0; background: #fff; color: var(--ink); text-align: left; }
.option-button:hover { border-color: var(--blue); background: #f8fbfd; }
.option-button.correct { border-color: var(--pine); background: var(--mint); }
.option-button.wrong { border-color: var(--coral); background: var(--coral-pale); }
.quiz-feedback { min-height: 27px; padding: 0 28px; color: var(--pine-dark); font-weight: 800; }
.next-button { width: calc(100% - 56px); margin: 11px 28px 28px; }

.add-form, .library-panel { padding: 24px; border-top: 3px solid var(--pine); background: var(--paper); box-shadow: var(--shadow); }
.add-form { display: grid; gap: 14px; }
.library-panel { border-top-color: var(--sun); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 12px; color: var(--ink); background: #fff; outline: none; }
input:focus, textarea:focus { border-color: var(--pine); box-shadow: 0 0 0 3px rgba(17, 97, 73, 0.12); }
.search-input { margin-bottom: 14px; }
.word-list { max-height: 610px; }
.library-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.delete-button { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #efc4bd; border-radius: 0; color: var(--coral); background: var(--coral-pale); }
.word-source { color: var(--muted); font-size: 12px; white-space: nowrap; }

.auth-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; background: var(--paper); color: var(--ink); box-shadow: 0 24px 78px rgba(29, 43, 42, 0.24); }
.auth-dialog::backdrop { background: rgba(15, 29, 25, 0.46); }
.auth-form { display: grid; gap: 15px; padding: 26px; }
.auth-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.auth-heading h2 { margin: 3px 0 0; font-size: 24px; }
.dialog-close { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 0; background: white; color: var(--muted); font-size: 20px; }
.auth-status { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.auth-status.error { color: var(--coral); }
.auth-status.success { color: var(--pine); }
.text-button { width: max-content; padding: 3px 0; border: 0; background: transparent; color: var(--blue); font-size: 14px; font-weight: 800; }
.danger-text { color: var(--coral); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 18px 22px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; }
  .nav-tabs { display: flex; justify-content: center; gap: 0; }
  .nav-tab { width: auto; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-tab:hover, .nav-tab.active { border-bottom-color: var(--pine); border-left-color: transparent; }
  .daily-panel { display: none; }
  .study-layout, .library-layout { grid-template-columns: 1fr; gap: 28px; }
  .content { padding-top: 28px; }
  .queue-list { max-height: 280px; }
}

@media (max-width: 600px) {
  .sidebar { grid-template-columns: 1fr; gap: 14px; }
  .nav-tabs { justify-content: flex-start; }
  .nav-index { display: none; }
  .content { padding: 24px 16px 38px; }
  .topbar { margin-bottom: 25px; }
  .topbar h2 { font-size: 28px; }
  .study-stage { min-height: 490px; }
  .stage-header, .word-focus { padding-left: 22px; padding-right: 22px; }
  .word-focus { min-height: 225px; }
  .reveal-button, .answer-panel { width: calc(100% - 44px); margin-left: 22px; margin-right: 22px; }
  .answer-panel { width: auto; }
  .card-actions { padding-left: 22px; padding-right: 22px; }
  .definition { font-size: 21px; }
  .add-form, .library-panel { padding: 20px; }
}
