:root {
  color-scheme: light;
  --bg: #edf6f7;
  --surface: #f7fbfa;
  --panel: #ffffff;
  --panel-soft: #f4f9f9;
  --text: #102033;
  --muted: #5f7184;
  --subtle: #8da0b2;
  --line: #cfdfe4;
  --line-strong: #b8ccd4;
  --brand: #126c8c;
  --brand-dark: #0b4d69;
  --brand-soft: #dff2f6;
  --accent: #b76e28;
  --accent-soft: #fff2df;
  --success: #11724e;
  --danger: #b42318;
  --warn: #a15c07;
  --shadow: 0 14px 34px rgba(24, 64, 83, 0.11);
  --shadow-soft: 0 5px 18px rgba(24, 64, 83, 0.075);
  --radius: 8px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(18, 108, 140, 0.13), transparent 28%),
    radial-gradient(circle at 82% 0%, rgba(183, 110, 40, 0.10), transparent 30%),
    linear-gradient(180deg, #f8fbfa 0%, #edf6f7 45%, #e8f1f4 100%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 60px 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(184, 204, 212, 0.72);
  background: rgba(252, 254, 253, 0.86);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
  letter-spacing: 0;
}

.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #20a08a 58%, var(--accent));
  box-shadow: 0 8px 18px rgba(18, 108, 140, 0.24);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

#currentUser {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: calc(100vh - 60px);
}

.sidebar {
  padding: 20px 14px;
  border-right: 1px solid rgba(184, 204, 212, 0.74);
  background: rgba(247, 251, 250, 0.70);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 7px;
  color: #344054;
  margin-bottom: 6px;
  font-weight: 560;
}

.nav-link::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--line-strong);
}

.nav-link.active,
.nav-link:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-decoration: none;
}

.nav-link.active::before,
.nav-link:hover::before {
  background: var(--brand);
}

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

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.22;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.grid {
  display: grid;
  gap: 14px;
}

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

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

.panel,
.item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel > h2,
.panel > h3 {
  color: #182230;
}

.item {
  padding: 16px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.item:hover {
  border-color: #9fc9d5;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.item h3,
.panel h2,
.panel h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
}

.course-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
}

.course-card .btn {
  align-self: end;
  justify-self: start;
}

.course-card p {
  margin: 0;
}

.task-card,
.material-card {
  display: grid;
  gap: 8px;
}

.record-card {
  border-left: 3px solid var(--brand);
}

.item p,
.panel p {
  line-height: 1.65;
}

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

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef7fb;
  color: var(--brand-dark);
  border: 1px solid #bfdae3;
  font-size: 12px;
  font-weight: 650;
}

.status.pass,
.status.active,
.status.success {
  background: #e6f6ee;
  color: var(--success);
  border-color: #a9e7c5;
}

.status.blocked,
.status.error,
.status.disabled {
  background: #fff1f0;
  color: var(--danger);
  border-color: #ffc7c2;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
  border-radius: 7px;
  min-height: 36px;
  padding: 0 13px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.btn:hover {
  border-color: #a8bfd2;
  background: #f9fbfd;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(18, 108, 140, 0.20);
}

.btn.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn.danger {
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

.form-row label {
  color: #475467;
  font-size: 13px;
  font-weight: 650;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  min-height: 40px;
  padding: 8px 11px;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 108, 140, 0.13);
}

.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.6;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

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

.table th {
  background: #eef6f7;
  color: #475467;
  font-weight: 720;
}

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

.table tbody tr:hover td {
  background: #f8fcfb;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(18, 108, 140, 0.18), transparent 32%),
    radial-gradient(circle at 80% 8%, rgba(183, 110, 40, 0.12), transparent 30%),
    linear-gradient(180deg, #f8fbfa 0%, #edf6f7 48%, #e8f1f4 100%);
}

.login-box {
  width: min(430px, 100%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-title {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.login-box .intro-link {
  width: 100%;
  margin-top: 12px;
}

.message {
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  margin-bottom: 12px;
}

.message.error {
  border-color: #fecdca;
  background: #fffbfa;
  color: var(--danger);
}

.message.success {
  border-color: #abefc6;
  background: #f6fef9;
  color: var(--success);
}

.chat-layout {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-height: calc(100vh - 116px);
  gap: 12px;
}

.chat-messages {
  overflow: auto;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.bubble {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 8px;
  margin-bottom: 10px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.bubble.student {
  margin-left: auto;
  background: #dff2f6;
  border: 1px solid #b9dce5;
}

.bubble.assistant {
  background: #fbfaf7;
  border: 1px solid #e8dfd2;
}

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

.bubble p:last-child,
.bubble ul:last-child,
.bubble ol:last-child,
.bubble pre:last-child {
  margin-bottom: 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 8px 0;
  line-height: 1.35;
  color: #101828;
}

.bubble h1 {
  font-size: 20px;
}

.bubble h2 {
  font-size: 18px;
}

.bubble h3 {
  font-size: 16px;
}

.bubble ul,
.bubble ol {
  margin: 6px 0 10px;
  padding-left: 22px;
}

.bubble li {
  margin: 3px 0;
}

.bubble code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #e7edf3;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.bubble pre {
  margin: 8px 0 10px;
  padding: 11px;
  border-radius: 7px;
  background: #101828;
  color: #f8fafc;
  overflow: auto;
}

.bubble pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.bubble blockquote {
  margin: 8px 0;
  padding: 7px 10px;
  border-left: 3px solid #9ecae3;
  color: var(--muted);
  background: #f9fbfd;
}

.bubble a {
  color: var(--brand-dark);
  text-decoration: underline;
}

.chat-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.suggestion-btn {
  border: 1px solid #b9dce5;
  background: rgba(255, 255, 255, 0.82);
  color: var(--brand-dark);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 3px 10px rgba(24, 64, 83, 0.06);
}

.suggestion-btn:hover {
  background: var(--brand-soft);
  border-color: #8fc6d4;
}

.chat-input .textarea {
  min-height: 54px;
}

.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

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

#configText {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: #101828;
  color: #e5edf5;
  border-color: #101828;
}

@media (max-width: 1000px) {
  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar {
    position: static;
    padding: 12px 16px;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    display: flex;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .nav-link {
    white-space: nowrap;
    margin-bottom: 0;
  }

  .grid.two,
  .grid.three,
  .split {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 16px;
  }

  .page-head {
    display: grid;
  }

  .bubble {
    max-width: 92%;
  }

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