:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #5f6875;
  --line: #d9dee7;
  --blue: #2f67d8;
  --teal: #0f766e;
  --red: #c2413a;
  --amber: #a16207;
  --green-soft: #e8f7f1;
  --red-soft: #fdecec;
  --blue-soft: #eaf1ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.18;
}

.login-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.login-actions button {
  min-height: 42px;
  font-weight: 760;
}

.login-actions button:first-child {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

button,
input,
label.import-button {
  font: inherit;
}

button,
label.import-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover,
label.import-button:hover {
  border-color: #9aa9be;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 760;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.totals span {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.totals strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.controls,
.study,
.queue {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.controls,
.queue {
  padding: 16px;
}

.control-block {
  margin-bottom: 18px;
}

.control-block label,
.label,
.queue-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input[type="search"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 103, 216, 0.14);
}

.segments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segments button {
  height: 36px;
  padding: 0 8px;
}

.segments button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #184eaf;
  font-weight: 700;
}

.metrics {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.metric strong {
  color: var(--ink);
}

.utility {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.utility button,
.import-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 10px;
}

#importProgress {
  display: none;
}

.profile-tools {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

#profileText {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#copyProfileLink {
  min-height: 34px;
}

#switchProfileBtn {
  min-height: 34px;
}

.study {
  min-height: 590px;
  padding: clamp(22px, 4vw, 52px);
}

.study-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 42px;
}

.badge,
.source-badge,
.doc-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.badge {
  background: #fff7d6;
  color: var(--amber);
}

.source-badge {
  background: var(--blue-soft);
  color: #184eaf;
}

.word {
  min-height: 116px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  font-size: clamp(46px, 7vw, 86px);
  font-weight: 780;
  line-height: 1.06;
  letter-spacing: 0;
}

.answer-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 36px;
}

.answer-row button,
.next {
  min-height: 54px;
  font-size: 18px;
  font-weight: 760;
}

.know {
  background: var(--green-soft);
  border-color: #b7dece;
  color: var(--teal);
}

.dont {
  background: var(--red-soft);
  border-color: #efb7b3;
  color: var(--red);
}

.detail {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.hidden {
  display: none;
}

.phonetic {
  min-height: 28px;
  color: var(--blue);
  font-size: 20px;
  font-weight: 700;
}

.definition,
.example {
  margin: 14px 0 0;
  color: #252a31;
  font-size: 19px;
  line-height: 1.7;
}

.example {
  color: var(--muted);
}

.doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.doc-chip {
  background: #f1f4f8;
  color: #394250;
}

.doc-chip.high {
  background: #eaf7f4;
  color: var(--teal);
}

.next {
  width: 100%;
  margin-top: 24px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.queue-title {
  display: flex;
  justify-content: space-between;
}

#queueList {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

#queueList li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

#queueList .mini-word {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#queueList .mini-meta {
  color: var(--muted);
  font-size: 12px;
}

.panel-separator {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.history-panel {
  display: grid;
  gap: 10px;
}

.daily-list,
.mistake-timeline {
  display: grid;
  gap: 8px;
}

.review-mistakes {
  width: 100%;
  min-height: 38px;
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #184eaf;
  font-weight: 760;
}

.review-mistakes:disabled {
  border-color: var(--line);
  background: #f4f6f9;
  color: var(--muted);
  cursor: not-allowed;
}

.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.daily-row,
.mistake-day {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.daily-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
}

.daily-date,
.mistake-date {
  color: var(--ink);
  font-weight: 740;
}

.daily-meta,
.mistake-summary {
  color: var(--muted);
  font-size: 12px;
}

.mistake-day {
  padding: 10px;
}

.mistake-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mistake-items {
  display: grid;
  gap: 6px;
}

.mistake-word {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
  width: 100%;
  min-height: 38px;
  padding: 10px;
  text-align: left;
  line-height: 1.45;
  white-space: normal;
}

.mistake-word.repeat {
  border-color: #e3918c;
  background: #fff5f4;
}

.mistake-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.mistake-term {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 15px;
  font-weight: 780;
}

.mistake-count {
  color: var(--red);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.mistake-phonetic {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.mistake-definition,
.mistake-example,
.mistake-docs {
  overflow-wrap: anywhere;
  color: #252a31;
  font-size: 12px;
}

.mistake-example,
.mistake-docs {
  color: var(--muted);
}

.repeat-label {
  color: var(--red);
  font-size: 12px;
  font-weight: 760;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .queue {
    grid-column: 1 / -1;
  }

  #queueList,
  .daily-list,
  .mistake-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 640px);
    padding: 12px 0 20px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .totals {
    width: 100%;
    justify-content: stretch;
  }

  .totals span {
    flex: 1 1 30%;
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .study {
    min-height: 500px;
    padding: 22px;
  }

  .word {
    min-height: 92px;
    font-size: 44px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  #queueList,
  .daily-list,
  .mistake-timeline {
    grid-template-columns: 1fr;
  }
}
