:root {
  --ink: #171717;
  --muted: #66635f;
  --line: #ded8cc;
  --paper: #f7f1e7;
  --panel: #fffaf0;
  --white: #ffffff;
  --red: #c23b34;
  --amber: #c78318;
  --green: #28765a;
  --teal: #216b75;
  --violet: #5d4a8c;
  --shadow: 0 18px 55px rgba(58, 45, 28, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(194, 59, 52, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(33, 107, 117, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
select {
  font: inherit;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(194, 59, 52, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(33, 107, 117, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.login-gate.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.login-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
}

.login-message,
.sync-status {
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}

.login-message.bad,
.sync-status.bad {
  color: var(--red);
}

.sync-status.good {
  color: var(--green);
}

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

.sidebar {
  padding: 28px;
  background: #27231e;
  color: #f8efe1;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 2px solid #e7cc8a;
  color: #e7cc8a;
  font-size: 24px;
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.question-panel h3,
.mock-hero h3,
.list-head h3,
.plan-grid h3 {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
}

.brand p {
  color: #cfc4b3;
  margin-top: 4px;
}

.score-panel,
.today-panel {
  border: 1px solid rgba(231, 204, 138, 0.28);
  background: rgba(255, 250, 240, 0.07);
  padding: 18px;
}

.score-main {
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-bottom: 1px solid rgba(231, 204, 138, 0.22);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.score-main span {
  font-size: 54px;
  line-height: 0.9;
  font-weight: 900;
  color: #e7cc8a;
}

.score-main small {
  color: #cfc4b3;
}

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

.score-grid div {
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 3px solid rgba(231, 204, 138, 0.45);
  padding-left: 12px;
}

.score-grid strong {
  font-size: 25px;
}

.score-grid span,
.today-panel li {
  color: #cfc4b3;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.ghost-button,
.primary-button {
  min-height: 42px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-button {
  text-align: left;
  padding: 12px 14px;
  color: #f8efe1;
  background: transparent;
  border-color: rgba(231, 204, 138, 0.18);
}

.nav-button.active,
.nav-button:hover {
  background: #e7cc8a;
  color: #27231e;
}

.today-panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.today-panel ol {
  margin: 0;
  padding-left: 18px;
}

.today-panel li + li {
  margin-top: 8px;
}

.main {
  padding: 30px;
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.topbar h2 {
  font-size: 32px;
}

.top-actions,
.answer-bar,
.list-head,
.mock-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-shell {
  min-height: 100vh;
  padding: 30px;
}

.admin-card {
  margin: 8vh auto 0;
}

.admin-panel {
  max-width: 1180px;
  margin: 0 auto;
}

.admin-create,
.admin-table-wrap {
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.admin-create {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
}

.admin-create label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-create input {
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 0 10px;
  font: inherit;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-table small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
}

.primary-button {
  background: var(--ink);
  color: var(--white);
  padding: 0 18px;
}

.ghost-button {
  background: rgba(255, 250, 240, 0.72);
  color: var(--ink);
  border-color: var(--line);
  padding: 0 16px;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filters label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  margin-top: 6px;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 10px;
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.question-panel,
.insight-panel,
.mock-hero,
.mock-result,
.mistake-item,
.plan-grid article {
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.question-panel {
  padding: 26px;
  min-height: 610px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.question-meta span,
.chip {
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 9px;
  font-size: 12px;
  color: var(--muted);
}

.question-panel h3 {
  font-size: 23px;
  line-height: 1.62;
  margin-bottom: 20px;
  overflow-wrap: anywhere;
}

.options {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.attachment-box {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.attachment-box details {
  padding: 0;
}

.attachment-box summary {
  cursor: pointer;
  padding: 13px 14px;
  font-weight: 900;
  color: var(--teal);
}

.attachment-text {
  max-height: 360px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 13px;
  color: #2b2925;
  background: #fff;
}

.option {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 10px 14px 10px 10px;
  overflow-wrap: anywhere;
}

.option .letter {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: #eee2cf;
  font-weight: 900;
}

.option.selected {
  border-color: var(--teal);
  background: rgba(33, 107, 117, 0.1);
}

.option.correct {
  border-color: var(--green);
  background: rgba(40, 118, 90, 0.12);
}

.option.wrong {
  border-color: var(--red);
  background: rgba(194, 59, 52, 0.12);
}

.answer-bar {
  justify-content: space-between;
}

.feedback {
  margin-top: 18px;
  padding: 16px;
  border-left: 4px solid var(--green);
  background: #fff;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.feedback.bad {
  border-left-color: var(--red);
}

.hidden {
  display: none;
}

.insight-panel {
  padding: 20px;
}

.insight-panel h3 {
  margin: 0 0 8px;
}

.insight-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.meter-track {
  height: 12px;
  background: #eadfce;
}

.meter-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  transition: width 0.25s ease;
}

.chapter-bars {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.chapter-row {
  display: grid;
  gap: 6px;
}

.chapter-row header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.bar {
  height: 9px;
  background: #eadfce;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.mock-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
}

.mock-hero,
.mock-result {
  padding: 24px;
}

.mock-hero h3,
.list-head h3 {
  font-size: 28px;
}

.mock-hero p {
  color: var(--muted);
  line-height: 1.7;
}

.mock-actions {
  align-items: stretch;
  flex-direction: column;
}

.result-pass {
  color: var(--green);
}

.result-fail {
  color: var(--red);
}

.mock-result {
  min-height: 280px;
}

.mock-question {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.mock-question strong {
  display: block;
  margin-bottom: 8px;
}

.list-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.mistake-list {
  display: grid;
  gap: 12px;
}

.mistake-item {
  padding: 16px;
}

.mistake-item p {
  margin: 8px 0 0;
  color: var(--muted);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.plan-grid article {
  padding: 18px;
  min-height: 220px;
}

.plan-grid span {
  color: var(--red);
  font-weight: 900;
}

.plan-grid p {
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 1100px) {
  .app-shell,
  .workspace,
  .mock-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

@media (max-width: 680px) {
  body {
    background-size: 22px 22px;
  }

  .main,
  .sidebar,
  .login-card,
  .admin-shell {
    padding: 14px;
  }

  .sidebar {
    gap: 12px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 19px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    font-size: 12px;
  }

  .score-panel,
  .today-panel {
    padding: 12px;
  }

  .score-main {
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .score-main span {
    font-size: 38px;
  }

  .score-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .score-grid div {
    min-height: 54px;
    border-left-width: 2px;
    padding-left: 7px;
  }

  .score-grid strong {
    font-size: 18px;
  }

  .score-grid span {
    font-size: 11px;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .nav-button {
    min-height: 38px;
    text-align: center;
    padding: 8px 4px;
    font-size: 13px;
  }

  .today-panel {
    display: none;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar,
  .answer-bar,
  .list-head,
  .mock-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  select {
    min-height: 40px;
  }

  .question-panel,
  .insight-panel,
  .mock-hero,
  .mock-result,
  .plan-grid article {
    box-shadow: none;
  }

  .question-panel {
    min-height: auto;
    padding: 16px;
  }

  .question-panel h3 {
    font-size: 18px;
    line-height: 1.55;
  }

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

  .question-meta span,
  .chip {
    font-size: 11px;
    padding: 5px 7px;
  }

  .option {
    min-height: 52px;
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 9px 10px 9px 8px;
    line-height: 1.45;
  }

  .option .letter {
    width: 28px;
    height: 28px;
  }

  .answer-bar .ghost-button,
  .answer-bar .primary-button,
  .top-actions .ghost-button,
  .top-actions .primary-button {
    width: 100%;
  }

  .insight-panel {
    padding: 14px;
  }

  .plan-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .plan-grid article {
    min-height: auto;
  }

  .admin-create {
    grid-template-columns: 1fr;
    box-shadow: none;
  }

  .admin-table-wrap {
    box-shadow: none;
  }
}
