:root {
  --bg: #f4f1ea;
  --ink: #1c1b19;
  --muted: #6b6560;
  --card: #fffdf8;
  --line: #e4ddd2;
  --accent: #0f6b5c;
  --accent-soft: #d8efe8;
  --danger: #a33b2d;
  --danger-soft: #f7e4df;
  --shadow: 0 10px 30px rgba(40, 32, 18, 0.08);
  --radius: 16px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(180, 120, 40, 0.08), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100%;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

.hero {
  margin-bottom: 28px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 14px;
  font-weight: 600;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

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

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

.status.ok { color: var(--accent); font-weight: 600; }
.status.bad { color: var(--danger); font-weight: 600; }

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.config-item {
  background: #faf7f0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.config-item .k {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.config-item .v {
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
  font-family: var(--mono);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  font-family: var(--mono);
  line-height: 1.5;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.12);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, background 0.12s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: #0c5a4d;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.ghost:hover {
  background: #f7f3eb;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 1.2em;
}

.hint.error { color: var(--danger); }

.tabs {
  display: flex;
  gap: 6px;
  background: #f7f3eb;
  padding: 4px;
  border-radius: 999px;
}

.tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.tab-panel.hidden,
.hidden {
  display: none !important;
}

.table-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.table-meta strong {
  color: var(--ink);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table.schedule {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}

table.schedule th,
table.schedule td {
  border: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 12px;
  vertical-align: top;
  text-align: center;
}

table.schedule th {
  background: #faf7f0;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
}

table.schedule td.course {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.45;
}

table.schedule td.course .loc {
  display: block;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

table.schedule td.course .weeks {
  display: block;
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
}

table.schedule td.node-col {
  background: #faf7f0;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

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

.course-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.course-item h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.course-item .meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.json-box {
  background: #1c1b19;
  color: #e8e4db;
  border-radius: 12px;
  padding: 16px;
  overflow: auto;
  max-height: 480px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-card {
  border-color: #efc8be;
  background: var(--danger-soft);
}

.error-card h2 { color: var(--danger); }

.error-card p {
  margin: 0 0 12px;
  color: var(--danger);
  line-height: 1.6;
}

.footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

.mode-tabs {
  margin-left: auto;
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 28px 16px;
  background: #faf7f0;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover,
.file-drop.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-icon { font-size: 28px; }

.file-text {
  font-size: 15px;
  font-weight: 600;
}

.file-sub {
  font-size: 12px;
  color: var(--muted);
}

.file-sub code {
  font-family: var(--mono);
  background: #eee8dc;
  padding: 1px 6px;
  border-radius: 4px;
}

.file-name {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

#tabXiaoai code {
  font-family: var(--mono);
  font-size: 12px;
}

.week-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.week-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding-top: 6px;
  flex-shrink: 0;
}

.week-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.week-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.week-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.week-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.trim-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.trim-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.trim-toggle span {
  line-height: 1.4;
}

@media (max-width: 640px) {
  .page { padding: 24px 14px 48px; }
  .card { padding: 16px; }
  .tabs { width: 100%; overflow: auto; }
  .card-head { flex-direction: column; align-items: flex-start; }
  .mode-tabs { margin-left: 0; }
}
