/* ==========================================================================
   申论 AI 批改系统 · 设计系统 v3
   主色靛蓝 · 层次灰 · 4px 间距基准 · 圆角/阴影/过渡统一
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-deep: #312e81;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;

  --text-1: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --bg: #f7f8fa;
  --surface: #ffffff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 28px rgba(16,24,40,.12);
  --transition: all .18s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ============ 顶部导航 ============ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .container { display: flex; align-items: center; height: 60px; }
.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 9px;
  letter-spacing: .2px;
}
.brand::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  flex-shrink: 0;
}
.nav { margin-left: 28px; display: flex; gap: 2px; min-width: 0; }
.nav a {
  padding: 7px 15px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}
.nav a:hover { background: var(--bg); color: var(--text-1); }
.nav a.active { background: var(--primary-light); color: var(--primary); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--text-2); }
.topbar .right .uname { font-weight: 500; color: var(--text-1); }
.topbar .right a { color: var(--text-2); font-size: 13px; }
.topbar .right a:hover { color: var(--primary); }

/* ============ 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 18px 0;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text-1); }
.card .sub { color: var(--text-3); font-size: 13px; }

/* ============ 区块（首页） ============ */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.sec-title { font-size: 18px; font-weight: 700; }
.sec-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
  margin-right: 9px;
  vertical-align: -2px;
}

/* ============ 首页欢迎条 ============ */
.welcome { display: flex; align-items: center; justify-content: space-between; }
.welcome-text .hi { font-size: 15px; color: var(--text-2); }
.welcome-text .hi b { color: var(--text-1); font-size: 17px; }
.welcome-text .welcome-tip { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.welcome-stat {
  font-size: 14px;
  color: var(--text-2);
  background: var(--primary-light);
  padding: 10px 18px;
  border-radius: 10px;
}
.welcome-stat b { color: var(--primary); font-size: 20px; font-weight: 700; }

/* ============ 省份宫格 ============ */
.grid-prov { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.prov-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  text-decoration: none;
  color: var(--text-1);
  transition: var(--transition);
  display: block;
  min-height: 76px;
  position: relative;
}
.prov-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  color: var(--text-1);
}
.prov-name { font-size: 15px; font-weight: 600; margin-bottom: 7px; }
.prov-meta { font-size: 12px; color: var(--text-3); }

/* ============ 题型宫格 ============ */
.grid-type { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.type-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent, var(--primary));
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  text-decoration: none;
  color: var(--text-1);
  transition: var(--transition);
  display: block;
  min-height: 84px;
}
.type-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); color: var(--text-1); }
.type-name { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.type-meta { font-size: 12px; color: var(--text-3); }
.type-count { font-size: 12px; color: var(--text-3); margin-top: 9px; }

/* ============ 子类筛选标签 ============ */
.subtype-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.sub-tab {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: var(--transition);
}
.sub-tab:hover { background: var(--border-light); color: var(--text-1); }
.sub-tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }

/* ============ 列表 ============ */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); border-radius: 8px; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-size: 15px; color: var(--text-1); font-weight: 500; }
.list-item .meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ============ 标签 ============ */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  line-height: 1.5;
}
.tag.plain { background: #eef0f4; color: var(--text-2); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.ghost:hover { background: var(--primary-light); box-shadow: none; }
.btn.gray { background: #eef0f4; color: var(--text-2); }
.btn.gray:hover { background: #e2e5ec; box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 6px 13px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============ 表单 ============ */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 500; color: var(--text-1); margin-bottom: 7px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  background: #fff;
  transition: var(--transition);
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }

/* ============ 提示 ============ */
.alert { padding: 13px 16px; border-radius: 10px; margin: 14px 0; font-size: 14px; border: 1px solid transparent; }
.alert.err { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert.ok { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert.info { background: var(--primary-light); color: var(--primary-deep); border-color: #c7d2fe; }

/* ============ 统计 ============ */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-box .num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-box .lbl { font-size: 13px; color: var(--text-3); margin-top: 5px; }
.student-account-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.student-account-stats .stat-box { min-width: 0; }
.student-account-stats .expiry-num { font-size: 20px; white-space: nowrap; }

/* ============ 表格 ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-light); }
th {
  background: var(--bg);
  color: var(--text-2);
  font-weight: 600;
  font-size: 13px;
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--primary-light); }
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 8px 8px 0; }

/* ============ 材料/内容 ============ */
.doc-content {
  background: #fbfbfd;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-1);
}
.material-block { margin-bottom: 16px; }
.material-block .m-title { font-weight: 600; color: var(--primary); margin-bottom: 5px; }

/* ============ 批改结果 ============ */
.grade-head { text-align: center; padding: 24px; }
.grade-head .score { font-size: 54px; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.grade-head .score small { font-size: 20px; color: var(--text-3); font-weight: 500; }
.ai-output {
  background: #fbfbfd;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-output h1, .ai-output h2, .ai-output h3 { font-size: 15px; margin: 14px 0 7px; }
.ai-output h3 { color: var(--primary); }

/* ============ 登录页 ============ */
.login-page { min-height: 100vh; min-height: 100dvh; padding: 20px 12px; display: flex; align-items: center; }
.login-wrap { width: 100%; max-width: 400px; margin: 0 auto; }
.login-wrap .card { padding: 40px 36px; }
.login-wrap h1 { font-size: 23px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-wrap .sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 26px; }
.login-wrap .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-wrap input { min-height: 48px; font-size: 16px; position: relative; z-index: 1; }

/* ============ 账号退出 ============ */
.account-logout { margin: 20px 0 8px; text-align: center; }
.account-logout form { margin: 0; }
.account-logout .btn { min-width: 180px; }

/* ============ 页脚 ============ */
.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 34px 0; }

/* ============ 工具类 ============ */
.muted { color: var(--text-3); font-size: 13px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* 整套批改 */
.batch-head,.batch-q-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.batch-head{justify-content:space-between}
.batch-status{margin-left:auto}
.batch-question{border-left:4px solid var(--primary)}
.batch-stem{background:var(--bg);border-radius:8px;padding:12px;margin:14px 0}
.batch-answer{width:100%;min-height:150px;padding:12px;border:1px solid var(--border);border-radius:9px;font:inherit;line-height:1.7;resize:vertical}
.batch-answer:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px rgba(79,70,229,.12)}
.batch-tools{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:8px}
.batch-ocr-status{min-height:20px}
.batch-count{margin-top:6px}
.batch-working{color:#b45309}
.batch-done{color:#15803d}
.batch-failed{color:#b91c1c}
.batch-total{font-size:18px;margin-top:10px;color:var(--text-1)}
.batch-submit-card{position:sticky;bottom:10px;z-index:10}

/* 批改等待提示 */
.grading-overlay { display:none; position:fixed; z-index:99999; inset:0; background:rgba(17,24,39,.52); align-items:center; justify-content:center; padding:20px; }
.grading-overlay.show { display:flex; }
.grading-modal { width:min(360px,100%); padding:30px 24px; border-radius:16px; background:#fff; text-align:center; box-shadow:0 12px 40px rgba(0,0,0,.2); }
.grading-spinner { width:34px; height:34px; margin:0 auto 16px; border:4px solid #e4e7f2; border-top-color:var(--primary); border-radius:50%; animation:grading-spin .8s linear infinite; }
.grading-title { color:var(--text-1); font-size:18px; font-weight:600; }
.grading-tip { color:var(--text-2); font-size:14px; margin-top:8px; }
@keyframes grading-spin { to { transform:rotate(360deg); } }

/* ============ 搜索框 ============ */
.search-bar { margin: 18px 0 0; }
.search-form { display: flex; gap: 10px; }
.search-form input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  background: #fff;
  transition: var(--transition);
}
.search-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .grid-prov, .grid-type { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  :root {
    --mobile-body-size: clamp(15.5px, calc(11px + 1.4vw), 17px);
    --mobile-small-size: clamp(12.5px, calc(8.1px + 1.4vw), 14px);
    --mobile-menu-size: clamp(12.5px, calc(8.5px + 1.25vw), 14px);
    --mobile-input-size: clamp(16px, calc(13.1px + .9vw), 17px);
    --mobile-title-size: clamp(18px, calc(9.3px + 2.7vw), 21px);
    --mobile-number-size: clamp(21px, calc(6.5px + 4.5vw), 26px);
  }
  body { font-size: var(--mobile-body-size); }
  .container { padding: 0 12px; }
  .topbar .container { height: auto; display: block; }
  .topbar .brand { height: 44px; justify-content: center; font-size: clamp(16px, calc(10.2px + 1.8vw), 18px); border-bottom: 1px solid var(--border-light); }
  .nav { width: 100%; margin: 0; padding: 6px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  .nav a { padding: 7px 2px; font-size: var(--mobile-menu-size); white-space: nowrap; text-align: center; }
  .topbar .right { display: none; }
  .grade-head .score { font-size: clamp(38px, 11vw, 46px); }
  .grid-prov, .grid-type { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .prov-card, .type-card { padding: 14px 12px; min-height: 60px; }
  .prov-name, .type-name { font-size: var(--mobile-body-size); }
  .prov-meta, .type-meta, .type-count, .list-item .meta, .muted, .tag, .footer { font-size: var(--mobile-small-size); }
  .card, .section { padding: 16px 14px; }
  .card h2 { font-size: clamp(16.5px, calc(10.7px + 1.8vw), 18.5px); }
  .sec-title { font-size: var(--mobile-title-size); }
  .sec-head { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .search-form { flex-direction: column; }
  .search-form .btn { width: 100%; }
  table { display: block; overflow-x: auto; white-space: nowrap; font-size: clamp(13.5px, calc(9.1px + 1.4vw), 15px); }
  .list-item { padding: 12px 4px; }
  .list-item .title { font-size: var(--mobile-body-size); }
  .welcome { flex-direction: column; align-items: flex-start; gap: 12px; }
  .welcome-text .welcome-tip { font-size: var(--mobile-body-size); }
  .field label { font-size: var(--mobile-body-size); }
  .field input, .field textarea, .field select, .search-form input { min-height: 46px; font-size: var(--mobile-input-size); }
  .btn { min-height: 44px; font-size: var(--mobile-body-size); }
  .btn.sm { font-size: var(--mobile-small-size); }
  .doc-content, .ai-output { padding: 14px 13px; font-size: var(--mobile-body-size); }
  details summary { min-height: 44px; display: flex; align-items: center; }
  .batch-submit-card { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .student-account-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .student-account-stats .stat-box { padding: 12px 4px; }
  .student-account-stats .stat-box .num { font-size: var(--mobile-number-size); line-height: 1.25; }
  .student-account-stats .stat-box .expiry-num { font-size: var(--mobile-small-size); }
  .student-account-stats .stat-box .lbl { font-size: clamp(11.5px, calc(7.1px + 1.4vw), 13px); line-height: 1.35; }
  .login-page { align-items: flex-start; padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .login-wrap { max-width: 440px; }
  .login-wrap .card { margin: 0; padding: 28px 20px; }
  .login-wrap h1 { font-size: clamp(22px, calc(10.4px + 3.6vw), 26px); }
  .login-wrap .sub { font-size: var(--mobile-small-size); }
  .account-logout .btn { width: 100%; min-width: 0; }
}
button.link-button{border:0;background:none;padding:0;color:inherit;font:inherit;cursor:pointer;text-decoration:none}
button.link-button:hover{text-decoration:underline}
