/*
 * ATA Design System 1.0
 * ---------------------------------------------------------------------------
 * 目标：简洁、清晰、专业、温和。
 *   · 页面先回答「今天做什么」，再提供二级能力；
 *   · 一屏不超过一个主行动，指标只保留能驱动决策的数字；
 *   · 状态色只用于状态，不用彩色卡片堆装饰；
 *   · 桌面多任务、平板双栏、手机单任务，断点统一在 1200 / 1024 / 720。
 *
 * 本文件是增量设计系统：保留既有 base/app/time 样式，只统一令牌并新增
 * ds-* 组件。老页面无需重写即可继承更克制的底色、边框与字号。
 */

:root {
  /* 色彩：冷纸底、墨色字、松绿主色；风险色只做状态，不做大面积背景 */
  --ink: #1b2430;
  --ink-soft: #33404e;
  --paper: #f4f6f4;
  --paper-deep: #e9ede8;
  --surface: #ffffff;
  --surface-alt: #f8faf8;
  --seal: #175a52;
  --seal-soft: #e6f0ed;
  --seal-line: #b7d2cb;
  --alarm: #a4234f;
  --alarm-soft: #fbeaef;
  --pending: #8a5a00;
  --pending-soft: #fdf3e2;
  --slate: #5f6b76;
  --line: #e0e5df;
  --line-strong: #c4ccc3;
  --info: #245a86;
  --info-soft: #e9f1f8;
  --success: #22624b;
  --success-soft: #e7f2ed;

  /* 字体层级：28 / 20 / 16 / 14 / 13 / 12 */
  --font-display: "Inter Tight", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Consolas", monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;

  /* 间距：4 的倍数，页面纵向只使用 16/24/32 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --radius: 4px;
  --radius-lg: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(27, 36, 48, .05);
  --shadow: 0 2px 6px rgba(27, 36, 48, .06), 0 12px 32px -20px rgba(27, 36, 48, .28);
  --rail-w: 236px;
  --content-max: 1180px;
  --tap: 44px;
}

html { font-size: 15px; }
body {
  background: var(--paper);
  color: var(--ink);
  font-size: var(--text-md);
  line-height: 1.6;
}
h1 { font-size: var(--text-2xl); letter-spacing: -.02em; }
h2 { font-size: var(--text-xl); letter-spacing: -.01em; }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
small, .small { font-size: var(--text-sm); }
.tiny { font-size: var(--text-xs); }

/* ---------------------------------------------------------------- 页面骨架 */

.ds-page { max-width: var(--content-max); margin-inline: auto; }
.ds-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.ds-page-head-copy { min-width: 0; flex: 1 1 420px; }
.ds-page-head h1 { margin: 2px 0 var(--sp-2); }
.ds-page-head p { margin: 0; max-width: 68ch; color: var(--slate); }
.ds-page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.ds-eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--slate);
}

.ds-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.ds-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ds-grid-full { grid-column: 1 / -1; }
.ds-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: var(--sp-5); align-items: start; }

/* ---------------------------------------------------------------- 页头焦点 */

.ds-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--seal);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.ds-hero h2 { font-size: var(--text-2xl); margin-bottom: var(--sp-2); font-weight: 700; }
.ds-hero p { margin: 0; color: var(--slate); max-width: 62ch; }
.ds-hero.is-warning { border-left-color: var(--pending); }
.ds-hero.is-error { border-left-color: var(--alarm); }
.ds-hero-focus {
  border-left: 1px solid var(--line);
  padding-left: var(--sp-5);
  min-width: 0;
}
.ds-hero-focus-label { font-size: var(--text-xs); color: var(--slate); letter-spacing: .04em; }
.ds-hero-focus-title { font-weight: 650; font-size: var(--text-lg); margin: 2px 0 var(--sp-1); }
.ds-hero-focus-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--slate); font-size: var(--text-xs); }

/* ---------------------------------------------------------------- 指标 */

.ds-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: var(--sp-5);
}
.ds-metric {
  background: var(--surface); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  text-decoration: none; color: inherit;
}
a.ds-metric:hover { background: var(--surface-alt); text-decoration: none; }
.ds-metric-value {
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  line-height: 1.15; font-variant-numeric: tabular-nums;
}
.ds-metric-label { font-size: var(--text-xs); color: var(--slate); }
.ds-metric[data-tone="warning"] .ds-metric-value { color: var(--pending); }
.ds-metric[data-tone="error"] .ds-metric-value { color: var(--alarm); }
.ds-metric[data-tone="success"] .ds-metric-value { color: var(--success); }

/* ---------------------------------------------------------------- 分区与列表 */

.ds-section {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5);
  min-width: 0;
}
.ds-section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-2);
}
.ds-section-head h2 { font-size: var(--text-lg); margin: 0; }
.ds-section-head p { margin: 2px 0 0; color: var(--slate); font-size: var(--text-xs); }
.ds-section-head .ds-btn, .ds-page-actions .ds-btn { white-space: nowrap; flex: 0 0 auto; }
.ds-list { display: flex; flex-direction: column; }
.ds-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.ds-row:first-child { border-top: 0; }
.ds-row-main { min-width: 0; }
.ds-row-title {
  font-weight: 600; color: var(--ink); overflow-wrap: anywhere;
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.ds-row-sub { color: var(--slate); font-size: var(--text-xs); overflow-wrap: anywhere; margin-top: 2px; }
.ds-row-fields {
  display: flex; flex-wrap: wrap; gap: 2px 14px;
  margin-top: 6px; color: var(--slate); font-size: var(--text-xs);
}
.ds-row-fields b { color: var(--ink-soft); font-weight: 600; }
.ds-row-action { display: flex; align-items: center; gap: var(--sp-2); padding-top: 2px; }
.ds-row-action .btn, .ds-row-action .ds-btn { white-space: nowrap; }
.ds-row.is-done .ds-row-title { color: var(--slate); }

.ds-row-fields .ds-criteria { flex-basis: 100%; }
.ds-criteria {
  color: var(--slate); font-size: var(--text-xs);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.ds-criteria b { color: var(--ink-soft); }

/* 状态徽标：只做状态，不承载装饰 */
.ds-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: var(--radius-pill); padding: 1px 8px;
  font-size: 11px; line-height: 1.7; font-weight: 600;
  background: var(--surface-alt); color: var(--slate);
  border: 1px solid var(--line); white-space: nowrap;
}
.ds-badge[data-tone="info"] { background: var(--info-soft); color: var(--info); border-color: #c5d9e9; }
.ds-badge[data-tone="success"] { background: var(--success-soft); color: var(--success); border-color: #bfdccc; }
.ds-badge[data-tone="warning"] { background: var(--pending-soft); color: var(--pending); border-color: #ecd6ae; }
.ds-badge[data-tone="error"] { background: var(--alarm-soft); color: var(--alarm); border-color: #efc3d1; }

.ds-empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: var(--sp-5); text-align: center; color: var(--slate);
  background: var(--surface-alt); font-size: var(--text-sm);
}
.ds-empty strong { display: block; color: var(--ink); margin-bottom: 2px; }

.ds-loading { display: grid; gap: var(--sp-3); }
.ds-skeleton {
  height: 54px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-alt) 0%, var(--paper-deep) 50%, var(--surface-alt) 100%);
  background-size: 200% 100%; animation: ds-shimmer 1.2s linear infinite;
}
@keyframes ds-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ds-skeleton { animation: none; } }

.ds-alert {
  border: 1px solid var(--line); border-left: 4px solid var(--info);
  background: var(--surface); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); font-size: var(--text-sm);
}
.ds-alert[data-tone="error"] { border-left-color: var(--alarm); background: var(--alarm-soft); }
.ds-alert[data-tone="warning"] { border-left-color: var(--pending); background: var(--pending-soft); }
.ds-alert[data-tone="success"] { border-left-color: var(--success); background: var(--success-soft); }

/* ---------------------------------------------------------------- 流程步骤 */

.ds-stepper { display: flex; gap: 0; overflow-x: auto; padding: var(--sp-2) 0; }
.ds-step {
  flex: 1 0 120px; min-width: 120px; position: relative;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 0;
  border-top: 2px solid var(--line);
  font-size: var(--text-xs); color: var(--slate);
}
.ds-step::before {
  content: ""; position: absolute; top: -5px; left: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line-strong);
}
.ds-step[data-status="done"] { border-top-color: var(--success); color: var(--ink); }
.ds-step[data-status="done"]::before { background: var(--success); }
.ds-step[data-status="current"] { border-top-color: var(--seal); color: var(--ink); font-weight: 650; }
.ds-step[data-status="current"]::before { background: var(--seal); box-shadow: 0 0 0 3px var(--seal-soft); }
.ds-step-label { display: block; margin-top: var(--sp-2); font-weight: 600; color: inherit; }
.ds-step-detail { display: block; margin-top: 1px; color: var(--slate); font-weight: 400; }

/* ---------------------------------------------------------------- 工具条与表格 */

.ds-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--sp-3); margin-bottom: var(--sp-3);
}
.ds-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-field > span { font-size: 11px; color: var(--slate); letter-spacing: .02em; }
.ds-input, .ds-select {
  height: 36px; min-width: 0; padding: 0 var(--sp-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: var(--text-sm);
}
.ds-input:focus, .ds-select:focus { border-color: var(--seal); outline: 2px solid var(--seal-soft); }
.ds-search { min-width: 220px; }
.ds-toolbar-actions { display: flex; gap: var(--sp-2); margin-left: auto; }

.ds-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.ds-table-scroll { overflow-x: auto; }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.ds-table th {
  text-align: left; font-size: 11px; letter-spacing: .04em; color: var(--slate);
  font-weight: 600; background: var(--surface-alt);
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.ds-table td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr:hover { background: var(--surface-alt); }
.ds-table .ds-person { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.ds-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--seal-soft);
  color: var(--seal); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex: 0 0 auto;
}
.ds-table .ds-next { color: var(--ink-soft); }
.ds-table .ds-sub { color: var(--slate); font-size: var(--text-xs); }

.ds-pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line);
  font-size: var(--text-xs); color: var(--slate); flex-wrap: wrap;
}
.ds-pager-pages { display: flex; gap: var(--sp-2); align-items: center; }
.ds-pager button { min-height: 32px; }

/* 移动端卡片：同一行数据，不丢字段 */
.ds-cards { display: none; }
.ds-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4); display: block; color: inherit; text-decoration: none;
}
.ds-card + .ds-card { margin-top: var(--sp-2); }
.ds-card:active { background: var(--surface-alt); }

/* ---------------------------------------------------------------- 按钮 */

.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer; text-decoration: none;
}
.ds-btn:hover { background: var(--surface-alt); text-decoration: none; }
.ds-btn[data-variant="primary"] { background: var(--seal); border-color: var(--seal); color: #fff; }
.ds-btn[data-variant="primary"]:hover { filter: brightness(1.06); }
.ds-btn[data-variant="ghost"] { border-color: transparent; background: transparent; color: var(--seal); }
.ds-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- 移动底栏 */

.ds-bottom-nav { display: none; }

/* ---------------------------------------------------------------- 断点 */

@media (max-width: 1200px) {
  .ds-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/*
 * Pad（721–1024）：保留双栏，而不是把电脑页面缩窄成单栏。
 * 左栏放「今日待办/问题队列」，右栏放「课程/跟进」；批改与讲解可并排操作，
 * 单屏内不必来回滚动。手机断点（≤720）才降为单栏 + 底部导航。
 */
@media (max-width: 1024px) and (min-width: 721px) {
  .ds-split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .ds-hero { grid-template-columns: minmax(0, 1fr); }
  .ds-hero-focus { border-left: 0; border-top: 1px solid var(--line); padding: var(--sp-3) 0 0; }
  .ds-grid, .ds-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-row { grid-template-columns: auto minmax(0, 1fr) auto; }
}

@media (max-width: 720px) {
  .ds-split, .ds-grid, .ds-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .ds-hero { grid-template-columns: minmax(0, 1fr); }
  .ds-hero-focus { border-left: 0; border-top: 1px solid var(--line); padding: var(--sp-3) 0 0; }
  html { font-size: 15px; }
  .ds-page-head { align-items: flex-start; }
  .ds-page-head h1 { font-size: 22px; }
  .ds-hero { padding: var(--sp-4); }
  .ds-hero h2 { font-size: 21px; }
  .ds-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-metric { padding: var(--sp-3); }
  .ds-metric-value { font-size: 20px; }
  .ds-section { padding: var(--sp-3) var(--sp-4); }
  .ds-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ds-row > .ds-badge:first-child { grid-column: 1 / -1; justify-self: start; }
  .ds-row-fields { gap: 2px 10px; }
  .ds-toolbar { padding: var(--sp-2); }
  .ds-toolbar > .ds-field { flex: 1 1 45%; }
  .ds-toolbar > .ds-field:first-child { flex-basis: 100%; }
  .ds-search { min-width: 0; width: 100%; }
  .ds-toolbar-actions { margin-left: 0; width: 100%; }
  .ds-table-wrap { display: none; }
  .ds-cards { display: block; }
  .ds-bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px max(4px, env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(27, 36, 48, .06);
  }
  .ds-bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-height: 48px; color: var(--slate); font-size: 12px;
    text-decoration: none; border-radius: var(--radius);
  }
  .ds-bottom-nav a img { width: 18px; height: 18px; opacity: .7; }
  .ds-bottom-nav a.is-active { color: var(--seal); font-weight: 700; background: var(--seal-soft); }
  .ds-bottom-nav a.is-active img { opacity: 1; }
  .content { padding-bottom: 88px !important; }
  .ds-btn { min-height: 44px; }
  /* 提示条不要盖住底部导航：抬到导航上方 */
  .toast-host { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .ds-criteria { -webkit-line-clamp: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-skeleton { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* 打印：列表页只留数据 */
@media print {
  .ds-toolbar, .ds-pager, .ds-bottom-nav, .rail, .topbar { display: none !important; }
  .ds-table-wrap, .ds-section { border-color: #999; }
}

/* R79 · 学习空间分区标签：只渲染当前分区，避免二级页无限增长。 */
.ds-tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: var(--sp-1); }
.ds-tab { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--sp-3); border-radius: var(--radius-md) var(--radius-md) 0 0; color: var(--ink-soft); text-decoration: none; font-size: var(--text-sm); }
.ds-tab:hover { background: var(--surface-alt); color: var(--ink); }
.ds-tab[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.ds-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
