:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
textarea,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(440px, 1.1fr);
  gap: 20px;
  align-items: start;
  min-height: 100vh;
  padding: 20px;
}

[hidden] {
  display: none !important;
}

.entry-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.entry-card {
  width: min(560px, 100%);
  border: 1px solid #d9e1e8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  padding: 28px;
}

.entry-card h1 {
  margin-bottom: 22px;
}

.entry-form {
  display: grid;
  gap: 16px;
}

.entry-form label {
  display: grid;
  gap: 8px;
  color: #52606d;
  font-weight: 700;
}

.answer-field {
  display: grid;
  gap: 8px;
  color: #52606d;
  font-weight: 700;
}

.answer-field textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid #cfd9e2;
  border-radius: 6px;
  padding: 10px 12px;
  color: #17202a;
  background: #ffffff;
}

.entry-form select,
.entry-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd9e2;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 0 12px;
}

.entry-error {
  margin: 14px 0 0;
  color: #b3261e;
}

.problem-panel,
.chat-panel,
.submit-panel {
  background: #ffffff;
  border: 1px solid #d9e1e8;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.submit-panel {
  grid-column: 1;
  padding: 24px;
}

.problem-panel {
  padding: 28px;
  overflow: auto;
}

.panel-header {
  border-bottom: 1px solid #e5ebf0;
  padding-bottom: 18px;
  margin-bottom: 22px;
}

.panel-header.compact {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #256c6a;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 12px;
  font-size: 22px;
}

h3 {
  margin: 22px 0 10px;
  font-size: 16px;
}

.problem-card {
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  padding: 20px;
  background: #fbfcfd;
}

.task-picker-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.task-picker-panel label {
  color: #52606d;
  font-size: 13px;
  font-weight: 700;
}

.task-picker-panel select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd9e2;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 0 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  margin-bottom: 14px;
  border-radius: 4px;
  background: #dff3ef;
  color: #17645d;
  font-size: 13px;
  font-weight: 700;
}

.problem-card p,
.rules li {
  font-size: 16px;
  line-height: 1.75;
}

.rules ul {
  padding-left: 20px;
  margin: 0;
}

.data-section {
  margin-top: 20px;
}

.calculation-panel {
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  padding: 18px;
  background: #fbfcfd;
}

.kv-grid {
  display: grid;
  gap: 10px;
}

.kv-item {
  display: grid;
  grid-template-columns: minmax(150px, 0.38fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid #e5ebf0;
}

.kv-item strong {
  color: #52606d;
  font-size: 13px;
}

.kv-item span {
  white-space: pre-wrap;
  line-height: 1.6;
}

.calculation-goal {
  margin-top: 14px;
  padding: 12px;
  border-left: 4px solid #256c6a;
  background: #eef7f4;
  line-height: 1.7;
}

.calculation-goal h3 {
  margin: 0 0 6px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title-row h3 {
  margin-bottom: 10px;
}

.small-button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: #256c6a;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e5ebf0;
  text-align: left;
  font-size: 14px;
}

th {
  background: #eef4f5;
  color: #24313d;
  font-weight: 700;
}

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

.test-ok {
  color: #137333;
  font-weight: 700;
}

.test-bad {
  color: #b3261e;
  font-weight: 700;
}

.test-pending {
  color: #8a5a00;
  font-weight: 700;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: calc(100vh - 40px);
  min-height: 620px;
  position: sticky;
  top: 20px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid #e5ebf0;
}

.chat-header h2 {
  margin-bottom: 0;
}

.secondary-button,
.quick-prompts button,
.chat-form button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.secondary-button {
  min-width: 72px;
  height: 36px;
  background: #edf2f5;
  color: #24313d;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  background: #f8fafb;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 38px;
}

.message.user .avatar {
  grid-column: 2;
  background: #1c5f9c;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: #e6f0fa;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #256c6a;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.bubble {
  max-width: 100%;
  padding: 12px 14px;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #ffffff;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul {
  margin: 4px 0 8px;
  padding-left: 20px;
}

.bubble li {
  margin: 4px 0;
}

.math-inline {
  display: inline-block;
  padding: 0 4px;
  border-radius: 4px;
  background: #eef7f4;
  color: #123b35;
  font-family: "Cambria Math", "Times New Roman", serif;
}

.math-block {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef7f4;
  color: #123b35;
  text-align: center;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 18px;
  overflow-x: auto;
}

.math-frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  margin: 0 3px;
  vertical-align: middle;
  line-height: 1.05;
}

.math-frac span:first-child {
  width: 100%;
  padding: 0 3px 2px;
  border-bottom: 1px solid currentColor;
}

.math-frac span:last-child {
  padding: 2px 3px 0;
}

.analysis-image {
  display: block;
  max-width: 100%;
  margin-top: 12px;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #ffffff;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid #e5ebf0;
  background: #ffffff;
}

.quick-prompts button {
  min-height: 34px;
  padding: 0 12px;
  background: #eef7f4;
  color: #17645d;
  font-weight: 700;
}

.code-panel {
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.inline-code-panel {
  margin-top: 20px;
}

.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.code-panel h3 {
  margin: 0;
  font-size: 15px;
}

.code-panel span {
  color: #667085;
  font-size: 13px;
}

.code-panel pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
}

.code-panel code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.mode-switch-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 16px 22px 0;
  background: #ffffff;
  color: #4b5563;
  font-size: 16px;
  font-weight: 700;
}

.mode-toggle {
  position: relative;
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid #3f756b;
  border-radius: 999px;
  background: #123b35;
  cursor: pointer;
  transition: background 0.18s ease;
}

.mode-toggle.active {
  background: #0f2f2b;
}

.mode-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  transition: transform 0.18s ease;
}

.mode-toggle.active .mode-toggle-thumb {
  transform: translateX(28px);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
  padding: 14px 22px 22px;
}

.chat-form textarea {
  width: 100%;
  resize: none;
  border: 1px solid #cfd9e2;
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

.chat-form textarea:focus {
  border-color: #256c6a;
  box-shadow: 0 0 0 3px rgba(37, 108, 106, 0.14);
}

.chat-form button {
  background: #256c6a;
  color: #ffffff;
  font-weight: 700;
}

.chat-form button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.submission-form {
  display: grid;
  gap: 16px;
}

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

.submission-form input,
.submission-form textarea,
.submission-form select {
  width: 100%;
  border: 1px solid #cfd9e2;
  border-radius: 8px;
  padding: 10px 11px;
  color: #17202a;
  background: #ffffff;
  outline: none;
}

.submission-form textarea {
  resize: vertical;
}

.submission-form input:focus,
.submission-form textarea:focus,
.submission-form select:focus {
  border-color: #256c6a;
  box-shadow: 0 0 0 3px rgba(37, 108, 106, 0.14);
}

.primary-button {
  justify-self: start;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: #256c6a;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.grade-result {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #cfd9e2;
  border-radius: 8px;
  background: #f8fafb;
  line-height: 1.7;
}

.grade-result h3 {
  margin: 14px 0 8px;
}

.grade-result p {
  margin: 0 0 8px;
}

.grade-result ul {
  margin: 4px 0 12px;
  padding-left: 20px;
}

.grading-page .problem-panel,
.grading-page .chat-panel,
.grading-page .submission-form,
.grading-page .submit-panel .panel-header {
  display: none;
}

.grading-page .app {
  display: block;
  min-height: auto;
  max-width: 960px;
  margin: 0 auto;
}

.grading-page .submit-panel {
  display: block;
  padding: 28px;
}

.grading-page .grade-result {
  margin-top: 0;
  background: #ffffff;
}

.review-app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}

.review-header,
.review-toolbar,
.review-card,
.empty-state {
  border: 1px solid #d9e1e8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 18px;
}

.review-header h1 {
  font-size: 28px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: #edf2f5;
  color: #24313d;
  font-weight: 700;
  text-decoration: none;
}

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

.review-toolbar p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.review-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-filters button,
.review-actions button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.review-filters button {
  background: #eef7f4;
  color: #17645d;
}

.review-filters button.active {
  background: #256c6a;
  color: #ffffff;
}

.review-list {
  display: grid;
  gap: 16px;
}

.review-card {
  padding: 20px;
}

.review-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5ebf0;
}

.review-card-header h2 {
  margin: 10px 0 6px;
}

.review-card-header p {
  margin: 0;
  color: #667085;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  margin-left: 6px;
  border-radius: 999px;
  background: #eef4f5;
  color: #24313d;
  font-size: 12px;
  font-weight: 700;
}

.status-pending {
  background: #fff4d6;
  color: #8a5a00;
}

.status-approved {
  background: #dff3ef;
  color: #17645d;
}

.status-rejected {
  background: #fde7e7;
  color: #b3261e;
}

.review-score {
  display: grid;
  justify-items: center;
  min-width: 72px;
  padding: 10px;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #f8fafb;
}

.review-score strong {
  color: #256c6a;
  font-size: 28px;
  line-height: 1;
}

.review-score span {
  margin-top: 4px;
  color: #667085;
  font-size: 13px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.review-grid section {
  min-width: 0;
}

.review-grid .review-wide {
  grid-column: 1 / -1;
}

.review-grid h3,
.review-detail h3 {
  margin: 0 0 8px;
}

.review-grid p {
  margin: 0;
  line-height: 1.75;
}

.review-card details {
  margin-top: 16px;
}

.review-card summary {
  cursor: pointer;
  color: #256c6a;
  font-weight: 700;
}

.review-detail {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  background: #f8fafb;
}

.review-detail pre {
  max-height: 260px;
  overflow: auto;
  margin: 0 0 14px;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.55;
}

.review-actions {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
  margin-top: 16px;
}

.review-actions.readonly-note {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef7f4;
  color: #17645d;
  font-weight: 700;
}

.review-actions input {
  min-height: 38px;
  border: 1px solid #cfd9e2;
  border-radius: 8px;
  padding: 0 11px;
}

.review-actions [data-action="reject"] {
  background: #fde7e7;
  color: #b3261e;
}

.review-actions [data-action="approve"] {
  background: #256c6a;
  color: #ffffff;
}

.review-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.empty-state {
  padding: 22px;
  color: #667085;
}

.admin-app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.admin-toolbar,
.admin-summary,
.submission-card {
  background: #ffffff;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.admin-toolbar {
  padding: 18px;
}

.admin-login,
.admin-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.admin-login {
  grid-template-columns: minmax(220px, 320px) auto;
}

.admin-login label,
.admin-filters label {
  display: grid;
  gap: 7px;
  color: #52606d;
  font-weight: 700;
}

.admin-login input,
.admin-filters select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd9e2;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 0 11px;
  font: inherit;
}

.admin-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  padding: 14px 16px;
  color: #344054;
}

.submission-list {
  display: grid;
  gap: 14px;
}

.submission-card {
  padding: 18px;
}

.submission-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.submission-card h2 {
  margin: 10px 0 4px;
  color: #17202a;
  font-size: 22px;
}

.submission-card p {
  margin: 0;
  color: #52606d;
  line-height: 1.7;
}

.submission-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.submission-meta span {
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef7f4;
  color: #17645d;
  font-size: 13px;
  font-weight: 700;
}

.submission-answer {
  margin-top: 14px;
  padding: 12px;
  border-left: 4px solid #256c6a;
  background: #f8fafb;
}

.submission-detail {
  display: grid;
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #dbe4ea;
}

.submission-detail h3 {
  margin: 0 0 8px;
}

.submission-detail pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.admin-chat-log {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.admin-chat-message {
  padding: 11px 12px;
  border-radius: 8px;
  background: #f8fafb;
  border: 1px solid #dbe4ea;
}

.admin-chat-message.assistant {
  background: #eef7f4;
}

.admin-chat-message strong {
  display: block;
  margin-bottom: 5px;
  color: #17202a;
}

.admin-test-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.admin-test-table th,
.admin-test-table td {
  padding: 9px;
  border: 1px solid #dbe4ea;
  text-align: left;
  vertical-align: top;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .chat-panel {
    height: 680px;
    position: static;
  }

  .submit-panel {
    grid-column: auto;
  }

  .review-toolbar,
  .review-header,
  .review-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .review-grid,
  .review-actions,
  .admin-login,
  .admin-filters {
    grid-template-columns: 1fr;
  }

  .submission-card-header,
  .admin-summary {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 10px;
  }

  .problem-panel {
    padding: 20px;
  }

  h1 {
    font-size: 24px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    height: 42px;
  }
}
