/* 共用基础样式：后台、登录页、学生作业页都用这一份 */
:root {
  --ink: #18212b;
  --muted: #687684;
  --line: #e3e8ee;
  --line-strong: #d3dbe3;
  --surface: #ffffff;
  --soft: #f5f7f9;
  --accent: #1f6feb;
  --accent-dark: #174ea6;
  --accent-soft: #e7f1fd;
  --success: #16865b;
  --danger: #b42318;
  --warning: #9a6700;
  --shadow: 0 1px 2px rgba(24, 33, 43, .04), 0 8px 24px rgba(24, 33, 43, .05);
  --radius: 12px;
  --radius-sm: 8px;
  --control-h: 36px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* 有些元素自带 display:flex，会盖掉 hidden 属性 */
body { margin: 0; color: var(--ink); background: #f2f5f8; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent-dark); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid #4b9af1; outline-offset: 2px; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0 0 6px; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 21px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; line-height: 1.6; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { color: var(--muted); margin: 0; font-size: 13px; }
.card { padding: 18px 20px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card > header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.card > header:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.card > header p { margin: 0; color: var(--muted); font-size: 13px; }

/* 次要内容默认收起，页面更清爽 */
details.card > summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin: 0; font-size: 15px; }
details.card > summary h2::before { content: "▸"; margin-right: 8px; color: #9aa7b3; font-size: 12px; }
details.card[open] > summary h2::before { content: "▾"; }
details.card > summary .summary-hint { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
details.card > summary .summary-hint::after { content: "展开"; color: #9aa7b3; margin-left: 6px; }
details.card[open] > summary .summary-hint::after { content: "收起"; }
/* 卡片内部的小折叠（例如班级成员、作品版本）用同一套展开/收起提示 */
.card details > summary { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; font-size: 12px; list-style: none; }
.card details > summary::-webkit-details-marker { display: none; }
.card details > summary::before { content: "▸"; color: #9aa7b3; font-size: 10px; }
.card details[open] > summary::before { content: "▾"; }
.card details > summary .summary-hint::after { content: "展开"; color: #9aa7b3; margin-left: 6px; }
.card details[open] > summary .summary-hint::after { content: "收起"; }
.card details > summary .summary-hint { margin-left: auto; color: var(--muted); white-space: nowrap; }
details.card[open] > summary { margin-bottom: 12px; }
details.card > summary + * { margin-top: 12px; }
.progress-inline { height: 6px; min-width: 90px; border-radius: 99px; background: #e8eef4; overflow: hidden; }
.progress-inline > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4b9af1, #1f6feb); transition: width .3s ease; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: block; padding: 15px 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 4px; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: var(--surface); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fafd; }
tbody td:first-child { color: #24313d; font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; line-height: 18px; white-space: nowrap; font-weight: 500; }
.pill.ok { color: #0f6848; background: #e3f5ed; }
.pill.draft { color: #8a5a00; background: #fdf1d8; }
.pill.off { color: #8a1f16; background: #fde7e4; }
.pill.role { color: #1c4f8a; background: #e7f1fd; }
.pill.legacy { color: #56606b; background: #eceff2; }
.pill.dataset { margin: 0 4px 4px 0; color: #1c4f8a; background: #eef4fd; }

form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field-hint, label.field small { max-width: 168px; color: #8b98a5; font-size: 11px; line-height: 1.4; white-space: normal; }
/* 一行里字段很多时，数字输入框别被拉得太宽 */
label.field input[type="number"] { min-width: 96px; }
label.field > span { font-weight: 600; color: #4a5763; }
label.field > span:has(+ input[required])::after,
label.field > span:has(+ textarea[required])::after,
label.field > span:has(+ select[required])::after { content: " *"; color: #d92d20; font-weight: 400; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  min-width: 160px; min-height: var(--control-h); padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: auto; }
input::placeholder, textarea::placeholder { color: #a7b2bd; }
input:focus, select:focus, textarea:focus { border-color: #8db8ee; box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); outline: 0; }
input:disabled, select:disabled, textarea:disabled { background: #f4f6f8; color: var(--muted); cursor: not-allowed; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fbfcfd; font-size: 13px; transition: all .15s ease; }
.checks label:hover { border-color: #b9d4ee; background: #f1f7fd; }
.checks label:has(input:checked) { border-color: #9ec4ee; background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: var(--control-h); padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); color: #fff; background: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
.button:hover { background: var(--accent-dark); }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.secondary { border-color: var(--line-strong); color: #35424e; background: #fff; }
.button.secondary:hover { border-color: #9ec4ee; color: var(--accent-dark); background: #f7fbff; }
.button.danger { background: #d92d20; }
.button.danger:hover { background: #b42318; }
.button.small { min-height: 30px; padding: 5px 11px; font-size: 12px; font-weight: 500; }

.flash { display: flex; align-items: flex-start; gap: 8px; padding: 11px 14px; margin-bottom: 12px; border-radius: 10px; font-size: 13px; animation: flash-in .18s ease-out; }
.flash::before { flex: 0 0 auto; font-size: 13px; line-height: 1.5; }
.flash.success { color: #0f6848; background: #e9f7f1; border: 1px solid #b7e4d0; }
.flash.success::before { content: "✓"; font-weight: 700; }
.flash.error { color: #8a1f16; background: #fdeceb; border: 1px solid #f3c4bd; }
.flash.error::before { content: "!"; font-weight: 700; }
.flash.fade { opacity: 0; transition: opacity .4s ease; }
.flash-link { margin-left: auto; font-weight: 600; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre { max-height: 380px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; font-size: 12px; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.summary-list { display: grid; gap: 10px; }
.summary-row { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.summary-row strong { font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 9px; border-radius: 999px; background: #eef4fd; color: #1c4f8a; font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.empty { padding: 26px 22px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); text-align: center; background: #fbfcfd; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* 复制按钮：贴在密钥/路径旁边 */
.copy { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); background: #fff; font-size: 11px; }
.copy:hover { border-color: #9ec4ee; color: var(--accent-dark); }
.copy.done { border-color: #b7e4d0; color: #0f6848; background: #e9f7f1; }

/* 提交中的按钮：仍然可提交，只是看起来"已经在处理" */
.button.busy, button.busy { opacity: .7; }

/* 上传预览 */
.upload-preview { display: flex; flex-direction: column; gap: 6px; flex-basis: 100%; margin-top: 4px; }
.upload-preview .upload-head { color: #4a5763; font-size: 12px; font-weight: 600; }
.upload-files { display: flex; flex-wrap: wrap; gap: 6px; }
.upload-files img { width: 56px; height: 56px; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 6px; background: #eef2f5; }

/* 长表单/长列表底部的操作条（吸底，别让人滚到底才找到按钮） */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 6;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 4px -20px -18px; padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
}
.work-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.work-gallery figure { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.work-gallery img { width: 100%; height: 170px; object-fit: cover; border-radius: 8px; background: #eef2f5; }
.work-gallery figcaption { margin-top: 8px; font-size: 12px; line-height: 1.5; }
