/* ---------------------------------------------------------------- 应用外壳 */

.shell {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh; width: 100%; max-width: 100%;
}
/* 任务 P1-003：移动浏览器地址栏收起/展开会改变 100vh，底部内容会被裁掉。
   dvh 是动态视口单位；不支持的浏览器沿用上面的 100vh，不会退化。 */
@supports (min-height: 100dvh) { .shell { min-height: 100dvh; } }

.rail {
  background: var(--ink);
  color: #cfd8d3;
  padding: var(--sp-5) var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand img { width: 34px; height: 34px; }
.brand-name { font-family: var(--font-display); font-weight: 700; color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: #7d8e88; letter-spacing: .08em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-top: var(--sp-4); }
.nav-group-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  color: #a9b7b2; padding: 0 var(--sp-3) var(--sp-2);
}
.nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3); border-radius: var(--radius);
  color: #cfd8d3; font-size: 14px; text-decoration: none;
  border-left: 2px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.is-active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #7fd4c2; font-weight: 600; }
.nav a img { width: 17px; height: 17px; opacity: .82; }
.nav a.is-active img { opacity: 1; }
.nav-badge {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--alarm); color: #fff; border-radius: 9px; padding: 1px 6px;
}

.rail-foot { margin-top: auto; font-size: 11px; color: #a9b7b2; font-family: var(--font-mono); line-height: 1.6; }

.main { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-4);
  position: sticky; top: 0; z-index: 20;
  /* 顶栏内容放不下时必须换行，不能靠压缩把标签/按钮挤成竖排 */
  flex-wrap: wrap; row-gap: var(--sp-2);
}
.topbar > * { min-width: 0; }

.identity {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 4px 4px 4px 10px;
}
/* 身份选择器、右侧 pills 与「退出」按钮按内容宽度占位，永不压缩（否则会逐字换行） */
.topbar > .tag, .topbar > .btn, .identity { flex: 0 0 auto; }
.topbar > .tag, .topbar > .btn { white-space: nowrap; }

.identity-label { font-family: var(--font-mono); font-size: 11px; color: var(--slate); letter-spacing: .06em; white-space: nowrap; }
.identity select { border: 0; background: transparent; font-weight: 600; font-size: 13px; padding: 3px 4px; cursor: pointer; max-width: min(38vw, 18rem); }
/* 身份/范围说明独占顶栏第二行：第一行只放控件，说明文字整行排版，不再被挤成窄列 */
.identity-scope {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  min-width: 0; flex: 1 1 100%; order: 9;
}
.scope-note, .scope-diagnostics { position: relative; font-size: 12px; color: var(--slate); }
.scope-note > summary { cursor: pointer; white-space: nowrap; }
.scope-note > p, .scope-diagnostics .tech-details-body {
  position: absolute; top: 100%; left: 0; z-index: 30;
  width: min(360px, 80vw); max-height: 45vh; overflow: auto;
  padding: var(--sp-3); margin: 6px 0 0;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.scope-diagnostics .tech-details { margin: 0; }

.content { padding: var(--sp-6); max-width: 100%; width: min(100%, 1600px); min-width: 0; margin-inline: auto; }
.skip-link {
  position: fixed; top: var(--sp-3); left: var(--sp-3); z-index: 101;
  padding: var(--sp-2) var(--sp-3); background: var(--surface);
  border: 2px solid var(--seal); border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.content > *, .stack, .card, .page-head { min-width: 0; max-width: 100%; }
.content p, .content li, .content .mono { overflow-wrap: anywhere; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: var(--sp-5); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--line); }
.page-head h1 { margin-bottom: var(--sp-2); }
.page-head > p { max-width: 76ch; }
.workflow-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--line); overflow: hidden; }
.metric { min-width: 0; padding: var(--sp-3) var(--sp-4); background: var(--surface); }
.metric-label { font-size: 12px; color: var(--slate); }
.metric-value { font-family: var(--font-display); font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5); min-width: 0; max-width: 100%;
}
.card-tight { padding: var(--sp-4); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card.stack > .card-head { margin-bottom: 0; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--sp-4); }
.stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stat-label { font-size: 12px; color: var(--slate); margin-top: 6px; }
.stat.is-alarm { border-color: var(--alarm); background: var(--alarm-soft); }
.stat.is-alarm .stat-value { color: var(--alarm); }
.stat.is-pending { border-color: #e4c98d; background: var(--pending-soft); }
.stat.is-pending .stat-value { color: var(--pending); }
.stat.is-seal { border-color: var(--seal-line); background: var(--seal-soft); }
.stat.is-seal .stat-value { color: var(--seal); }
.stat-action { width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.stat-action:hover, .stat-action:focus-visible, .stat-action[aria-pressed="true"] {
  outline-offset: 2px; border-color: var(--seal); box-shadow: 0 0 0 2px var(--seal-soft);
}
.intervention-task { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.intervention-task:last-child { border-bottom: 0; }
.intervention-task-main { min-width: 0; display: grid; gap: 4px; }
.intervention-task-actions { flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 720px) {
  .intervention-task { flex-direction: column; }
  .intervention-task-actions { width: 100%; }
}

/* ---------------------------------------------------------------- 标记 */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 2px; border: 1px solid var(--line-strong);
  background: var(--surface-alt); color: var(--ink-soft); white-space: nowrap;
}
.tag-seal { background: var(--seal-soft); border-color: var(--seal-line); color: var(--seal); }
.tag-alarm { background: var(--alarm-soft); border-color: #e8b2ca; color: var(--alarm); }
.tag-pending { background: var(--pending-soft); border-color: #e4c98d; color: var(--pending); }
.tag-ink { background: var(--ink); border-color: var(--ink); color: #fff; }

/* AI 产出必须始终带标记（V1.2 §1.2） */
.ai-mark {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px;
  padding: 2px 7px; border-radius: 2px;
  background: repeating-linear-gradient(135deg, #eef1ec 0 6px, #e4e9e2 6px 12px);
  border: 1px dashed var(--line-strong); color: var(--ink-soft);
}

/* ---------------------------------------------------------------- 证据条带（签名元素） */

.ribbon { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; min-width: 0; max-width: 100%; }
.ribbon-head {
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  background: var(--surface-alt);
}
.ribbon-body { padding: var(--sp-4); overflow-x: auto; max-width: 100%; }
.ribbon-grid { display: grid; gap: 4px; min-width: max-content; }
.ribbon-row { display: grid; grid-template-columns: 92px repeat(var(--days), 24px); gap: 4px; align-items: center; }
.ribbon-label { font-size: 12px; font-weight: 600; padding-right: var(--sp-2); }
.ribbon-axis { font-family: var(--font-mono); font-size: 9px; color: var(--slate); text-align: center; }

.cell { width: 24px; height: 24px; border-radius: 2px; border: 1px solid transparent; position: relative; cursor: pointer; }
.cell-covered { background: var(--seal); border-color: var(--seal); }
.cell-partial { background: var(--pending); border-color: var(--pending); }
/* 缺失用斜纹实心洋红：结构上不可折叠、不可弱化 */
.cell-missing {
  background: repeating-linear-gradient(45deg, var(--alarm) 0 3px, #d4699a 3px 6px);
  border-color: var(--alarm);
}
.cell-none { background: var(--paper-deep); border-color: var(--line); }
.cell-future { background: transparent; border: 1px dashed var(--line); }

.ribbon-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: 12px; color: var(--slate); margin-top: var(--sp-3); }
.ribbon-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------------- 待办列表 */

.queue { display: flex; flex-direction: column; }
.queue-item {
  display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); align-items: center;
}
.queue-item:last-child { border-bottom: 0; }
.workbench-layout { display: grid; gap: var(--sp-4); }
.queue-content { min-width: 0; }
.queue-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; }
.queue-actions .tag, .queue-actions .btn {
  min-width: 84px; min-height: 36px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 10px; font-size: 13px; line-height: 1.2;
}
.queue-bar { width: 6px; height: 100%; min-height: 34px; border-radius: 3px; background: var(--line-strong); }
.queue-item[data-kind="safety"] .queue-bar,
.queue-item[data-kind="high_risk"] .queue-bar { background: var(--alarm); }
.queue-item[data-kind="overdue"] .queue-bar { background: var(--alarm); opacity: .7; }
.queue-item[data-kind="pending_verification"] .queue-bar,
.queue-item[data-kind="missing_record"] .queue-bar { background: var(--pending); }
.queue-item[data-kind="today_lesson"] .queue-bar { background: var(--seal); }
.queue-title { font-weight: 600; }
.queue-target { font-size: 13px; color: var(--slate); margin-top: 2px; }
.queue-sub { font-size: 13px; color: var(--slate); }

/* Large collections expose a bounded page, visible counts and direct actions. */
.collection-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.collection-tools input[type="search"] {
  flex: 1 1 220px; min-width: 0; max-width: 400px;
  padding: 8px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface);
}
.collection-filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.collection-filter[aria-pressed="true"] { border-color: var(--seal); background: var(--seal-soft); color: var(--seal); }
.collection-page { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-3); }

/* 用户管理的角色分栏：把「所有角色混排一张表」换成按角色分开看，并显示各角色真实人数。
   机构规模到几百上千个账号时，混排表既读不动，也让人以为只有这些账号。 */
.role-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.role-tabs .tab {
  font: inherit; font-size: 13px; line-height: 1.2;
  padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: #fff; color: var(--slate); cursor: pointer;
}
.role-tabs .tab:hover { border-color: var(--seal); color: var(--seal); }
.role-tabs .tab.is-active { background: var(--seal); border-color: var(--seal); color: #fff; font-weight: 600; }
.role-tabs .tab:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.role-tabs .tab[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }
.collection-page .row-wrap { justify-content: flex-end; }
.closure-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--sp-2); }
.closure-action {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 5px; min-height: 82px; padding: var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  color: var(--ink); background: var(--surface-alt); text-align: left;
  cursor: pointer; font: inherit;
}
.closure-action:hover, .closure-action:focus-visible { border-color: var(--seal); background: var(--seal-soft); }
.closure-action span { font-size: 13px; color: var(--slate); }
.closure-note { margin: var(--sp-2) 0 0; }
.student-summary-list, .student-directory { display: flex; flex-direction: column; }
.student-summary, .student-directory-row {
  display: grid; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line);
}
.student-summary { grid-template-columns: minmax(120px, 1fr) minmax(0, 3fr) minmax(130px, .9fr); }
.student-summary:last-child, .student-directory-row:last-child { border-bottom: 0; }
.student-summary-name { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; font-weight: 600; }
.student-summary-metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-3); font-size: 13px; }
.student-summary-metrics > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.student-directory-row { grid-template-columns: minmax(140px, 1fr) auto; }
.student-directory-row > div:first-child { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.student-directory-name { font-weight: 600; font-size: 16px; white-space: nowrap; }
.student-directory-actions { justify-content: flex-end; }
@media (max-width: 1000px) {
  .student-summary { grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); }
  .student-summary > :last-child { grid-column: 2; }
}

/* ---------------------------------------------------------------- 表格 */

.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.table-scroll:focus-visible { outline-offset: 1px; }
/* Q013：列有各自的最小可读宽度（min-width）时，若表格只写 width:100%，当卡片比
   列的总最小宽度还窄，浏览器会保持表格盒宽不变、让单元格内容溢出盒外并被
   .table-scroll 直接裁掉——第五列因此既看不到也滚不到。min-width:min-content 让
   表格至少撑到列的最小宽度，横向滚动交给 .table-scroll，内容不再消失。 */
.table { width: 100%; min-width: min-content; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--slate); font-weight: 500; white-space: nowrap;
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-strong);
}
.table td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: top; word-break: normal; overflow-wrap: break-word; }
/* 短字段不再缩成单个汉字；说明列保持可读宽度，空间不足时滚动表格本身。 */
.table th, .table td { min-width: 9ch; }
.table-cell-content { min-width: 9ch; }
.table-col-prose .table-cell-content { min-width: 28ch; max-width: 52ch; }
.table-col-actions .table-cell-content { min-width: 15ch; }
/* 日期、数量和操作控件按自然宽度占位；窄卡片由 .table-scroll 横向滚动。 */
.table td .mono, .table td .btn { white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }

/* 模型维护表默认卡片断点 1200px：1000–1200 的笔记本/平板宽度下，
   横向滚动会把启用/停用/删除推到视口外；这里改为带标签的卡片，
   操作按钮直接可见。其它表格布局不受影响。 */
@media (max-width: 1200px) {
  .model-registry-table { display: block; overflow: visible; }
  .model-registry-table thead,
  .model-registry-table tbody,
  .model-registry-table tr,
  .model-registry-table th,
  .model-registry-table td { display: block; }
  .model-registry-table thead { display: none; }
  .model-registry-table tbody tr {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: var(--sp-3); margin-bottom: var(--sp-3); background: var(--surface);
  }
  .model-registry-table tbody td {
    min-width: 0; border: 0; padding: var(--sp-2) 0;
  }
  .model-registry-table tbody td::before {
    content: attr(data-label); display: block; margin-bottom: 4px;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
    text-transform: uppercase; color: var(--slate);
  }
  .model-registry-table tbody td.table-col-actions .table-cell-content {
    min-width: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2);
  }
}

/* 学习群页的五列记录表需要整行宽度；消息与录入表单仍可并排阅读。 */
.group-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.group-layout > .group-records { grid-column: 1 / -1; }

/* 学习空间：信息密度由总览、学科脉搏与可折叠明细分层，首屏保持聚焦。 */
.learning-workspace-page { max-width: 1480px; margin: 0 auto; }
.workspace-command-band {
  display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(360px, 2fr);
  gap: var(--sp-4); align-items: stretch; padding: var(--sp-4);
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface-alt);
}
.workspace-focus-copy { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.workspace-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 1px; background: var(--line); overflow: hidden; border-radius: var(--radius); }
.workspace-student-head { display: grid; grid-template-columns: minmax(360px, 1fr) auto; align-items: center; gap: var(--sp-4); }
.workspace-focus-strip { padding: var(--sp-3) var(--sp-4); border-left: 4px solid var(--pending); background: var(--pending-soft); }
.workspace-focus-strip > * + * { margin-top: 4px; }
.workspace-section > h3 { margin: 0 0 var(--sp-2); font-size: 15px; }
.workspace-subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: var(--sp-2); }
.workspace-subject-row { min-width: 0; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-alt); }
.workspace-subject-row > * + * { margin-top: var(--sp-2); }
.workspace-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.workspace-detail { min-width: 0; border-top: 1px solid var(--line); }
.workspace-detail summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) 0; cursor: pointer; }
.workspace-detail-body { display: grid; gap: 1px; background: var(--line); }
.workspace-list-row { display: grid; grid-template-columns: minmax(64px, .35fr) minmax(140px, 1fr) auto; gap: var(--sp-3); align-items: start; padding: var(--sp-2) var(--sp-3); background: var(--surface); min-width: 0; }
.workspace-list-row > * { overflow-wrap: anywhere; }
.workspace-agent-state { padding-top: var(--sp-2); border-top: 1px dashed var(--line-strong); }

/* ---------------------------------------------------------------- 按钮与表单 */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 14px; font-weight: 550;
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn-primary:hover { background: #10443e; }
.btn-danger { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.btn-danger:hover { background: #8d1a4e; }
/* R85 / F-004：负向动作降为警示描边，正向动作保留主色填充。 */
.btn-danger-outline { background: transparent; border-color: var(--alarm); color: var(--alarm); }
.btn-danger-outline:hover { background: rgba(141, 26, 78, 0.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--seal); padding: 4px 8px; }
.btn-ghost:hover { background: var(--seal-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child, .field > label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); min-width: 0; max-width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; font-family: var(--font-body); }

/* ------------------------------------------------- 科目×老师矩阵（一站式建档 / 老师库） */
/* Q023：建档页的核心操作面。每门科目一块，块内可挂多位老师；窄屏自动换行，
   不允许把科目名压成单字竖排（Q013 的教训）。 */
.matrix-subject {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3); background: var(--surface-alt);
}
.matrix-subject + .matrix-subject { margin-top: var(--sp-2); }
.matrix-subject .row-wrap > .strong { min-width: 5ch; }
.matrix-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.matrix-row select { min-width: 12ch; max-width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; background: var(--surface); cursor: pointer;
}
.chip input { margin: 0; }
.chip:has(input:checked) { border-color: var(--seal-line); background: var(--surface-alt); font-weight: 600; }

/* ---------------------------------------------------------------- 证据卡 */

.evidence {
  border: 1px solid var(--seal-line); background: var(--surface-alt);
  padding: var(--sp-3); border-radius: var(--radius); font-size: 13px;
}
.evidence-missing { border-color: var(--alarm); background: var(--alarm-soft); }
.evidence-head { display: flex; gap: var(--sp-2); align-items: center; margin-bottom: 4px; flex-wrap: wrap; }

.notice {
  border: 1px solid var(--pending);
  background: var(--pending-soft); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius); font-size: 13.5px;
}
.notice-alarm { border-color: var(--alarm); background: var(--alarm-soft); }
.notice-seal { border-color: var(--seal); background: var(--seal-soft); }

.empty { text-align: center; padding: var(--sp-5) var(--sp-4); color: var(--slate); }
.empty img { width: 64px; opacity: .7; margin-bottom: var(--sp-2); }
.empty p { margin: var(--sp-2) 0 0; }

/* 沉淀等级刻度 */
.sed-scale { display: flex; gap: 2px; align-items: center; }
.sed-step { width: 16px; height: 5px; border-radius: 1px; background: var(--paper-deep); }
.sed-step.on { background: var(--seal); }
.sed-step.on.warn { background: var(--pending); }

/* 登录 */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5); background: var(--paper); }
.login-card { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.login-aside { background: var(--ink); color: #cfd8d3; padding: var(--sp-7) var(--sp-6); }
.login-aside h2 { color: #fff; margin-bottom: var(--sp-3); font-size: 22px; }
.login-form { padding: var(--sp-7) var(--sp-6); }
.login-accounts { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.9; color: #8fa39c; }
@media (max-width: 860px) { .login-card { grid-template-columns: 1fr; } .login-aside { display: none; } }

/* ------------------------------------------------- 移动端导航（任务 P1-003）
 *
 * 此前 ≤900px 的做法是把侧栏摊平成静态块置于内容之上 —— 手机上要先滚过
 * 品牌区 + 11 个导航项 + 页脚才能看到正文，而助教在课后用手机录入时，
 * 每一次进入页面都要付这笔滚动成本。
 *
 * 改为**抽屉式**：侧栏移出视口，由 topbar 的汉堡按钮唤出，遮罩点击或 Esc 关闭。
 * 桌面端（>900px）完全不受影响 —— 下面所有规则都在媒体查询里。
 */
.nav-toggle { display: none; }
.rail-scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  /* 汉堡按钮：放进 sticky topbar，任何滚动位置都够得着 */
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex: 0 0 44px;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; padding: 0;
  }
  .nav-toggle:hover { background: var(--surface-alt); }
  .nav-toggle-bars { display: block; width: 18px; height: 12px; position: relative; }
  .nav-toggle-bars::before,
  .nav-toggle-bars::after,
  .nav-toggle-bars span {
    content: ""; position: absolute; left: 0; right: 0; height: 2px;
    background: var(--ink); border-radius: 1px;
  }
  .nav-toggle-bars::before { top: 0; }
  .nav-toggle-bars span { top: 5px; }
  .nav-toggle-bars::after { bottom: 0; }

  /* 抽屉本体 */
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(84vw, 300px); height: 100vh; height: 100dvh;
    transform: translateX(-100%);
    transition: transform .2s ease-out;
    overflow-y: auto; overscroll-behavior: contain;
    padding-top: max(var(--sp-5), env(safe-area-inset-top));
    padding-bottom: max(var(--sp-5), env(safe-area-inset-bottom));
    padding-left: max(var(--sp-4), env(safe-area-inset-left));
    box-shadow: 0 0 40px rgba(22, 32, 43, .35);
  }
  .shell.is-nav-open .rail { transform: translateX(0); }

  /* 遮罩：抽屉打开时才参与命中测试 */
  .rail-scrim {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(22, 32, 43, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s ease-out;
  }
  .shell.is-nav-open .rail-scrim { opacity: 1; pointer-events: auto; }

  /* 抽屉打开时锁背景滚动，避免"滑动穿透" */
  .shell.is-nav-open { overflow: hidden; max-height: 100vh; max-height: 100dvh; }

  .content { padding: var(--sp-4); }
  .topbar {
    padding: var(--sp-2) var(--sp-4);
    padding-top: max(var(--sp-2), env(safe-area-inset-top));
    flex-wrap: wrap; gap: var(--sp-2);
  }
  .content .grid { grid-template-columns: minmax(0, 1fr) !important; }
  .workspace-command-band, .workspace-student-head, .workspace-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace-list-row { grid-template-columns: minmax(70px, .35fr) minmax(0, 1fr); }
  .workspace-list-row > :last-child { grid-column: 2; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row, .spread, .card-head, .ribbon-head { flex-wrap: wrap; }
  .field, .identity { min-width: 0; max-width: 100%; }

  /* 触控目标：WCAG 2.2 AA 要求 ≥24px，此处取移动端惯例 44px */
  .nav a { min-height: 44px; padding: 10px var(--sp-3); }
  .btn, .btn-sm, .btn-ghost { min-height: 44px; }

  /* iOS Safari 对 font-size<16px 的输入框会自动放大页面并打断录入。
     这是移动端录入体验里最容易被忽略、也最影响连续输入的一处。 */
  .field input, .field select, .field textarea, .identity select { font-size: 16px; }
  .field input, .field select { min-height: 44px; }
  .identity select { max-width: none; min-height: 36px; }

  /* 横向可滚动的表格与条带：给出可滑动的视觉提示 */
  .table-scroll, .ribbon-body {
    -webkit-overflow-scrolling: touch;
    background:
      linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left center / 24px 100% no-repeat,
      linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right center / 24px 100% no-repeat,
      radial-gradient(farthest-side at 0 50%, rgba(22, 32, 43, .12), transparent) left center / 10px 100% no-repeat,
      radial-gradient(farthest-side at 100% 50%, rgba(22, 32, 43, .12), transparent) right center / 10px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
  }
}

@media (max-width: 520px) {
  .content, .topbar { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .rail { width: min(88vw, 300px); }
  .brand { flex-wrap: wrap; }
  .nav-group, .nav { min-width: 0; max-width: 100%; }
  .queue-item { grid-template-columns: 6px minmax(0, 1fr); }
  .queue-actions { grid-column: 2; justify-content: flex-start; }
  .student-summary, .student-directory-row { grid-template-columns: minmax(0, 1fr); }
  .student-summary > :last-child { grid-column: auto; }
  .student-directory-actions { justify-content: flex-start; }
  .card { padding: var(--sp-4); }
  .toast-host {
    left: var(--sp-3); right: var(--sp-3);
    bottom: max(var(--sp-3), env(safe-area-inset-bottom));
  }
  .toast { max-width: 100%; }
  /* 窄屏下身份区独占一行，避免"当前工作身份"标签与下拉挤成两截 */
  .identity { width: 100%; }
  .identity select { flex: 1; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
}

/* 无指针精度的设备（触屏）统一放大命中区，不依赖视口宽度 —— 平板横屏同样受益 */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-ghost { min-height: 44px; }
  .nav a { min-height: 44px; }
  .table td, .table th { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
}

.toast-host { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius);
  font-size: 13.5px; max-width: 400px; box-shadow: var(--shadow); animation: rise .18s ease-out;
}
.toast.err { background: var(--alarm); }
.toast.ok { background: var(--seal); }

/* ------------------------------------------------------------------ 技术详情
   B2A：机器表示（编号、原始 JSON、内部版本、IANA 时区名）默认折叠在这里。
   用原生 <details>：键盘可达、无需 JS 状态，且未展开的内容不参与 innerText
   —— 「默认不可见」因此是机器可验证的，而不是靠约定。
   注意：data-technical-details 是渲染审计的契约属性（见 presentation.mjs），
   样式可以改，这个属性不能改。 */
.tech-details { display: block; margin-top: 4px; font-size: 11px; }
.tech-details > summary {
  cursor: pointer; color: var(--slate); font-family: var(--font-mono);
  font-size: 10px; letter-spacing: .06em; list-style: none; display: inline-flex; align-items: center; gap: 4px;
}
.tech-details > summary::-webkit-details-marker { display: none; }
.tech-details > summary::before { content: '▸'; font-size: 9px; }
.tech-details[open] > summary::before { content: '▾'; }
.tech-details > summary:hover { color: var(--ink); }
.tech-details-body {
  margin-top: 4px; padding: 6px 8px; border: 1px solid var(--line, #e2e8e6);
  background: #f7f9f8; border-radius: var(--radius); color: var(--slate);
  word-break: normal; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.5;
}
.tech-details-body .mono { font-family: var(--font-mono); }
/* 技术详情不能塌到只有一个字宽；在窄屏仍由表格容器负责滚动。 */
.table .tech-details { min-width: 18ch; max-width: 34ch; }
.table .tech-details-body .mono { white-space: normal; overflow-wrap: anywhere; }

.form-dialog {
  width: min(92vw, 560px); border: 1px solid var(--line, #d9e2df); border-radius: 12px;
  padding: 0; color: var(--ink); background: var(--paper, #fff);
  box-shadow: 0 18px 60px rgba(18, 43, 36, .22);
}
.form-dialog::backdrop { background: rgba(15, 31, 27, .38); }
.form-dialog > form { padding: 24px; }
.form-dialog h2 { margin: 0; font-size: 1.1rem; }
.form-dialog textarea, .form-dialog input { width: 100%; box-sizing: border-box; }
.form-error { color: #a62c2c; font-size: .85rem; }
.justify-end { justify-content: flex-end; }

.management-advanced { margin-top: var(--sp-5); }
.management-advanced > summary, .management-secondary > summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); color: var(--seal); font-weight: 700; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-alt); }
.management-advanced[open] > summary, .management-secondary[open] > summary { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.management-advanced > .grid, .management-secondary > .card { padding-top: var(--sp-4); }

/* ------------------------------------------------------------------ 统一附件交互
   ATA-URGENT-CORE-USABILITY：附件是核心业务对象（作业提交、订正、提问、讲解、
   计划作答都依赖它）。这里只定义**一处**外观，避免每个视图各写一套。

   关键点：文件选择必须由真实 <input type="file"> 触发，但原生 input 在各浏览器
   里外观差异极大、在手机上还会被压成一个小方块。因此 label 包住 input 并把它
   视觉隐藏（而不是 display:none —— 那样在 iOS Safari 上点不动）。 */
.attach-picker { gap: var(--sp-2); }
.attach-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* 键盘用户必须能看到「按钮」上的焦点环：input 被视觉隐藏后焦点仍落在它上面。 */
.attach-picker label.btn:focus-within { outline: 2px solid var(--seal); outline-offset: 2px; }
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line, #dde5e2); border-radius: var(--radius);
  padding: 6px 10px; background: var(--surface-alt, #f7faf9);
}
.attach-kind {
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  background: var(--seal-soft, #e6f0ed); color: var(--seal, #145a50);
  border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}
.attach-name {
  flex: 1 1 12ch; min-width: 8ch; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-size { font-size: 11px; color: var(--slate, #667); white-space: nowrap; }
/* 窄屏（手机/平板竖屏）：一行放不下时让文件名独占一行，按钮不换行错位。 */
@media (max-width: 520px) {
  .attach-row { gap: 6px; }
  .attach-name { flex-basis: 100%; order: -1; }
  .attach-row .btn-sm { min-height: 36px; }
}

/* ------------------------------------------------------------------ 我的学习空间 · 列表行
   ATA-URGENT-CORE-USABILITY（R104 热修）：
   上一实现错误复用了 `.workspace-list-row`（grid-template-columns:
   minmax(64px,.35fr) minmax(140px,1fr) auto，为「引导词|摘要|元信息」
   三列设计）。学习空间的行只有一个子元素，于是整行被挤进 64px 列，
   中文逐字换行、按钮被压成竖条 —— Owner 真人试看直接复现。
   这里单独定义一套 flex 行：主内容自适应 + 右侧动作固定，自动换行。 */
.row-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-alt, #f7faf9);
  border: 1px solid var(--line, #dde5e2);
  border-radius: var(--radius);
  min-width: 0;
}
.row-card > * { min-width: 0; }
.row-card-main {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 16ch; min-width: 0;
}
.row-card-main > .strong, .row-card-main > .small { overflow-wrap: break-word; }
.row-card-side { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* 错题与资料：长题干可自然换行，不复用三列 workspace-list-row。 */
.notebook-page { min-width: 0; }
.notebook-page .card, .notebook-page .evidence { min-width: 0; }
.notebook-prose { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.notebook-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--sp-3); }
.notebook-fields > *, .notebook-page .field > * { min-width: 0; }
.notebook-page input, .notebook-page select, .notebook-page textarea { max-width: 100%; }
.notebook-page textarea { width: 100%; box-sizing: border-box; }
.notebook-action { align-items: flex-start; max-width: 100%; }
.notebook-action .form-error { white-space: normal; overflow-wrap: anywhere; }
.notebook-page .btn, .learning-space-page .btn { min-height: 44px; white-space: normal; }
.notebook-page .ds-tabs { flex-wrap: wrap; }
/* 窄屏：右侧动作区独占一行，按钮 ≥44px */
@media (max-width: 520px), (pointer: coarse) {
  .row-card { gap: var(--sp-2); }
  .row-card-side { flex-basis: 100%; }
  .row-card-side .btn { min-height: 44px; }
}

/* R126 · AI 流式回答 */
.ai-answer {
  white-space: pre-wrap;
  line-height: 1.65;
  word-break: break-word;
}
.ai-answer .ai-p { margin: 0 0 6px; }
.ai-answer .ai-h { font-weight: 700; margin: 10px 0 4px; }
.ai-answer .ai-list { margin: 2px 0 8px 20px; padding: 0; }
.ai-answer .ai-list li { margin: 2px 0; }
.ai-answer .ai-code {
  background: var(--code-bg, rgba(127, 127, 127, 0.12));
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  font-size: 0.85em;
  white-space: pre-wrap;
}
.ai-stream-status { min-height: 1.4em; }
