:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e0e8;
  --paper: #fbfcfd;
  --panel: #ffffff;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #147d64;
  --green-soft: #e6f5ef;
  --amber: #a15c07;
  --amber-soft: #fff4dc;
  --rose: #b42318;
  --shadow: 0 16px 40px rgba(31, 41, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef3f7;
  color: var(--ink);
  font-family:
    "DengXian", "Songti SC", "STSong", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  border-radius: 6px;
  min-height: 34px;
  padding: 6px 12px;
}

button:hover {
  border-color: #a8b4c5;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

button.ghost {
  background: transparent;
}

.shell {
  min-height: 100vh;
}

.topbar {
  background: #0f172a;
  color: #fff;
  padding: 16px 28px;
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 750;
}

.brand p {
  margin: 5px 0 0;
  color: #b8c2d3;
  font-size: 14px;
}

.account {
  color: #d7deea;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-logout {
  min-height: 28px;
  padding: 3px 8px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef4f8;
}

.auth-card {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-kicker {
  margin-bottom: 8px;
  color: #49627d;
  font-size: 15px;
  font-weight: 750;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.28;
}

.auth-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 16px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fa;
}

.auth-switch button {
  border-color: transparent;
  background: transparent;
}

.auth-switch button.active {
  background: #fff;
  border-color: #c7d2e0;
  box-shadow: 0 1px 4px rgba(31, 41, 51, 0.08);
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
  font-size: 15px;
}

.auth-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 16px;
}

.auth-message,
.auth-warning {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.auth-warning {
  color: var(--rose);
}

.permission-waiting {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f2d38b;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #694100;
  line-height: 1.55;
}

.permission-waiting span {
  color: #8a5b0a;
  font-size: 14px;
}

.permission-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 22px;
}

.layout.collections-layout {
  grid-template-columns: 1fr;
}

.collections-layout .sidebar {
  display: none;
}

.layout.catalog-layout {
  grid-template-columns: 1fr;
}

.catalog-layout .sidebar {
  display: none;
}

.main,
.sidebar,
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.main {
  overflow: hidden;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

.tabs,
.segmented,
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab,
.segmented button {
  background: #f5f7fa;
}

.tab.active,
.segmented button.active {
  background: var(--blue-soft);
  border-color: #8fb2ff;
  color: #174ea6;
}

.font-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.font-control button {
  min-height: 28px;
  padding: 3px 8px;
}

.font-control span {
  color: var(--muted);
  font-size: 13px;
  min-width: 36px;
  text-align: center;
}

.content {
  padding: 22px;
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.article-meta h2 {
  margin: 0;
  font-size: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #0f684f;
  font-size: 13px;
  white-space: nowrap;
}

.catalog-page {
  display: grid;
  gap: 14px;
}

.catalog-subject-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-subject-tabs button {
  min-width: 88px;
  background: #f5f7fa;
}

.catalog-subject-tabs button.active {
  border-color: #8fb2ff;
  background: var(--blue-soft);
  color: #174ea6;
  font-weight: 700;
}

.year-directory {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  align-items: start;
}

.year-block {
  border-bottom: 1px solid #edf1f5;
}

.year-row {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #111827;
  font-size: 17px;
  font-weight: 700;
}

.year-row:hover {
  background: #f8fafc;
}

.year-arrow {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.text-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 10px 18px;
}

.text-link {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-color: transparent;
  background: transparent;
  font-family: "Times New Roman", Times, serif;
  font-size: 17px;
}

.text-link:hover {
  border-color: #d8e1eb;
  background: #f8fafc;
}

.text-link.active {
  color: #174ea6;
  font-weight: 700;
}

.text-link.active::before {
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 999px;
  background: var(--blue);
}

.text-link small {
  color: var(--muted);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.catalog-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 4px;
  color: var(--muted);
}

.article-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 14px;
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.article-switcher button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.paragraph {
  padding: 17px 0;
  border-top: 1px solid #edf1f5;
}

.paragraph:first-of-type {
  border-top: 0;
}

.para-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.english {
  font-family: "Times New Roman", Times, serif;
  font-size: 20px;
  line-height: 1.78;
}

.translation {
  margin-top: 10px;
  color: #344054;
  line-height: 1.75;
  background: #f8fafc;
  border-left: 3px solid #bad1f8;
  padding: 10px 12px;
}

.word {
  border-bottom: 1px dotted transparent;
  border-radius: 3px;
  padding: 1px 2px;
}

.word:hover {
  background: var(--amber-soft);
  border-bottom-color: #e4a744;
}

.sense-panel {
  position: relative;
  user-select: text;
}

.sense-paragraph {
  border-top: 1px solid #edf1f5;
  padding: 16px 0;
}

.sense-paragraph:first-child {
  border-top: 0;
}

.sense-stream {
  display: block;
  line-height: 1.78;
}

.sense {
  display: inline;
  margin: 0;
  padding: 0 1px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  line-height: inherit;
  cursor: pointer;
}

.sense.bilingual-token {
  display: inline-flex;
  flex-direction: column;
  vertical-align: top;
  margin: 0 4px 8px 0;
  padding: 0 2px 2px;
  max-width: 100%;
}

.sense:hover {
  background: rgba(37, 99, 235, 0.08);
}

.sense.pending {
  background: rgba(255, 236, 184, 0.72);
  box-shadow: inset 0 -2px 0 rgba(228, 167, 68, 0.7);
  color: #4a2d06;
}

.sense-en {
  font-family: "Times New Roman", Times, serif;
}

.sense-cn {
  color: var(--muted);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.68em;
  line-height: 1.28;
  margin-top: -2px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.confirm-popover {
  position: sticky;
  top: 10px;
  z-index: 5;
  width: min(520px, 100%);
  margin: 0 0 16px;
  border: 1px solid rgba(237, 195, 108, 0.85);
  background: rgba(255, 248, 230, 0.97);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.08);
}

.confirm-text {
  font-weight: 700;
}

.questions {
  display: grid;
  gap: 13px;
}

.questions-inline {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e8edf3;
}

.questions-meta {
  margin-bottom: 12px;
}

.question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
}

.question h3 {
  margin: 0 0 7px;
  font-size: 20px;
}

.question-sense-stream {
  line-height: 1.72;
}

.question-sense-stream .sense.bilingual-token {
  margin-bottom: 4px;
}

.option {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  margin: 3px 0;
  padding: 5px 7px;
  border-radius: 6px;
}

.option-content {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
  align-items: start;
}

.option-label {
  font-family: "Times New Roman", Times, serif;
  font-size: 20px;
  line-height: 1.72;
}

.option:hover {
  background: #f8fafc;
}

.option.correct {
  background: var(--green-soft);
  border: 1px solid #8fd5bf;
}

.option.wrong {
  background: #fff1f0;
  border: 1px solid #f4aaa4;
}

.option input {
  margin-top: 8px;
}

.answer-line {
  margin-top: 10px;
  color: var(--green);
  font-weight: 700;
}

.card-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  margin: 0;
  font-size: 18px;
}

.card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.word-card,
.notecard,
.filters {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.empty {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

.lookup-word {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.lookup-word h3 {
  margin: 0;
  font-size: 24px;
}

.source {
  color: var(--blue);
  font-size: 13px;
}

.definition {
  margin: 12px 0;
  line-height: 1.65;
}

.sense-ref {
  margin: 12px 0;
  padding: 13px;
  background: #f7f9fc;
  border: 1px solid #dce5f0;
  border-radius: 6px;
}

.sense-ref strong {
  display: block;
  margin-bottom: 4px;
  color: #344054;
}

.main-sense-text,
.main-sense-card strong {
  display: block;
  font-family: "Times New Roman", Times, serif;
  font-size: 19px;
  line-height: 1.4;
  color: #111827;
  margin-bottom: 7px;
}

.main-sense-card {
  margin: 10px 0 14px;
  padding: 14px;
  background: #fff8e7;
  border: 1px solid rgba(237, 195, 108, 0.75);
  border-radius: 8px;
}

.main-sense-card span {
  display: block;
  color: #4b5565;
  line-height: 1.65;
}

.side-label {
  color: var(--amber);
  font-weight: 700;
  margin-bottom: 8px;
}

.study-card {
  display: grid;
  gap: 4px;
}

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

.collection-control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  background: #fff;
  overflow: visible;
}

.collection-stat {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: #344054;
  font-weight: 700;
}

.control-row,
.bulk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid #edf1f5;
}

.bulk-row {
  border-bottom: 0;
}

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

.control-group > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented.compact button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 14px;
}

.chapter-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-count {
  color: var(--muted);
  font-size: 13px;
}

.chapter-panel {
  position: absolute;
  z-index: 12;
  top: calc(100% + 8px);
  left: 0;
  width: min(520px, calc(100vw - 48px));
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.chapter-subject {
  padding: 4px 0 10px;
  border-bottom: 1px solid #edf1f5;
}

.chapter-subject:last-child {
  border-bottom: 0;
}

.chapter-year {
  display: grid;
  gap: 7px;
  margin: 8px 0 0 22px;
}

.chapter-texts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: 22px;
}

.check-line,
.check-chip,
.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #344054;
}

.check-line.strong {
  font-weight: 700;
  color: #111827;
}

.check-chip {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #d9e2ec;
  border-radius: 999px;
  background: #fbfcfd;
}

.switch-line {
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fbfcfd;
}

.switch-line small {
  color: var(--muted);
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.page-export {
  margin-left: auto;
}

.bulk-row .export-actions {
  border-top: 0;
  padding: 0;
}

.collection-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.collection-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.collection-table th,
.collection-table td {
  border-bottom: 1px solid #e9eef3;
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
}

.collection-table th {
  background: #f7f9fa;
  color: #667085;
  font-weight: 700;
}

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

.check-col {
  width: 64px;
  text-align: center !important;
}

.type-col {
  width: 82px;
}

.action-col {
  width: 76px;
  text-align: center !important;
}

.english-cell {
  width: 28%;
  font-family: "Times New Roman", Times, serif;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.repeat-count {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #667085;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  margin-bottom: 5px;
}

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

.text-danger {
  border: 1px solid #f0c8c8;
  background: #fff;
  color: #b42318;
  padding: 5px 9px;
}

.text-danger:hover {
  background: #fff5f5;
  border-color: #e89b9b;
}

.ghost-small,
.source-toggle {
  border: 1px solid #d8e1eb;
  background: #fff;
  color: #344054;
  padding: 5px 8px;
  margin: 0 4px 6px 0;
}

.source-toggle {
  display: inline-flex;
  margin-top: 8px;
  color: var(--blue);
}

.source-list {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #e0e7ef;
  border-radius: 6px;
  background: #fbfcfd;
  color: #667085;
  font-size: 13px;
}

.source-list div {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.28);
}

.confirm-dialog {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.confirm-dialog h3 {
  margin: 0 0 8px;
}

.confirm-dialog p {
  margin: 0 0 14px;
  color: #344054;
  line-height: 1.65;
}

.export-actions {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 1180px) {
  .topbar {
    padding: 14px 20px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    padding: 18px 20px 28px;
  }

  .content {
    padding: 18px;
  }

  .sidebar {
    top: 12px;
    max-height: calc(100vh - 24px);
  }

  .english {
    line-height: 1.72;
  }

  .sense.bilingual-token {
    margin-right: 3px;
  }

  .collection-table {
    min-width: 920px;
  }
}

@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: auto;
    bottom: 0;
    z-index: 8;
    max-height: 42vh;
  }

  .year-directory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar-inner,
  .toolbar,
  .article-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .year-directory {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }

  .english {
    font-size: 18px;
  }

  .sidebar {
    max-height: 50vh;
  }

  .collection-control-panel {
    position: sticky;
    top: 0;
    z-index: 9;
  }
}
