/* ==========================================================================
   Agent 训练营 · 学习任务与证书中心
   纯原生 CSS，无构建、无外部依赖。
   设计语言：Electric Blue / 浅色 / 卡片化 / 中等圆角 / 宽松间距
   ========================================================================== */

/* ------------------------------ 1. 设计令牌 ------------------------------ */
:root {
  --background: hsl(220 24% 97%);
  --card: hsl(0 0% 100%);
  --foreground: hsl(222 47% 11%);
  --muted-fg: hsl(215 16% 47%);
  --primary: hsl(221 83% 53%);
  --primary-fg: hsl(210 40% 98%);
  --border: hsl(214 32% 91%);
  --radius: 0.625rem;
  --success: hsl(142 71% 45%);

  /* 由主色派生的实用层级 */
  --primary-hover: hsl(221 83% 47%);
  --primary-active: hsl(221 83% 42%);
  --primary-soft: hsl(221 83% 53% / 0.08);
  --primary-soft-2: hsl(221 83% 53% / 0.14);
  --primary-ring: hsl(221 83% 53% / 0.45);
  --success-soft: hsl(142 71% 45% / 0.1);
  --danger: hsl(0 72% 51%);
  --danger-soft: hsl(0 72% 51% / 0.08);
  --warning: hsl(32 95% 44%);
  --warning-soft: hsl(32 95% 44% / 0.09);

  --muted-bg: hsl(215 25% 96%);
  --muted-bg-2: hsl(214 30% 93%);
  --surface-2: hsl(214 34% 98.5%);

  --shadow-xs: 0 1px 2px hsl(222 47% 11% / 0.04);
  --shadow-sm: 0 1px 3px hsl(222 47% 11% / 0.06), 0 1px 2px hsl(222 47% 11% / 0.04);
  --shadow-md: 0 8px 24px -8px hsl(222 47% 11% / 0.14), 0 2px 6px -2px hsl(222 47% 11% / 0.06);
  --shadow-lg: 0 24px 48px -16px hsl(222 47% 11% / 0.18), 0 8px 16px -8px hsl(222 47% 11% / 0.08);

  --sidebar-w: 16rem;
  --topbar-h: 3.75rem;
  --content-max: 68rem;

  --font-sans: "Outfit", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Consolas,
    "Liberation Mono", Menlo, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 180ms;

  color-scheme: light;
}

/* ------------------------------ 2. 基础重置 ------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--primary-soft-2);
  color: var(--foreground);
}

/* 全站可见焦点环 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 0.375rem;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.5rem 0.875rem;
  border-radius: 0.5rem;
  background: var(--foreground);
  color: #fff;
  font-size: 0.8125rem;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* ------------------------------ 3. 应用骨架 ------------------------------ */
.app-shell {
  display: flex;
  min-height: 100%;
  min-height: 100dvh;
}

/* 登录页：无侧栏、无顶栏 */
body.is-login .sidebar,
body.is-login .topbar {
  display: none;
}

body.is-login .app-shell {
  display: block;
}

body.is-login .content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  padding: clamp(1.25rem, 5vw, 3rem);
  min-height: 100dvh;
}

/* --- 侧栏 --- */
.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.125rem 0.875rem 1rem;
  background: var(--card);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.375rem 1.125rem;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 0.625rem;
  background: linear-gradient(140deg, hsl(221 83% 58%), hsl(217 91% 50%));
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 10px -4px hsl(221 83% 53% / 0.55);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-title {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin-top: 0.1875rem;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 0.25rem;
  overflow-y: auto;
}

.nav-label {
  margin: 0.75rem 0.625rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: hsl(215 16% 58%);
}

.nav-label:first-child {
  margin-top: 0.125rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5313rem 0.625rem;
  border-radius: 0.5rem;
  color: var(--muted-fg);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-item:hover {
  background: var(--muted-bg);
  color: var(--foreground);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: var(--muted-bg-2);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  flex: 0 0 auto;
  width: 1.0625rem;
  height: 1.0625rem;
  stroke-width: 1.75;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
}

.sidebar-tip {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted-fg);
  font-size: 0.75rem;
  line-height: 1.5;
}

.tip-icon {
  flex: 0 0 auto;
  width: 0.9375rem;
  height: 0.9375rem;
  margin-top: 0.125rem;
  color: var(--primary);
}

/* --- 主列 --- */
.main-column {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--topbar-h);
  padding: 0.5rem clamp(1rem, 3vw, 2rem);
  background: hsl(220 24% 97% / 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-crumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-fg);
}

.crumb-icon {
  display: grid;
  place-items: center;
  color: var(--primary);
}

.crumb-icon svg {
  width: 1.0625rem;
  height: 1.0625rem;
}

.crumb-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: hsl(222 30% 32%);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.topbar-tabs {
  display: flex;
  gap: 0.125rem;
  padding: 0.1875rem;
  border-radius: 0.5rem;
  background: var(--muted-bg-2);
}

.topbar-tabs a {
  padding: 0.2813rem 0.625rem;
  border-radius: 0.375rem;
  color: var(--muted-fg);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.topbar-tabs a:hover {
  color: var(--foreground);
  text-decoration: none;
}

.topbar-tabs a[aria-current="page"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

/* 用户菜单 */
.user-menu {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.user-trigger:hover {
  background: var(--card);
  border-color: var(--border);
}

.avatar {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 999px;
  background: linear-gradient(140deg, hsl(221 83% 60%), hsl(217 91% 52%));
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
}

.user-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 500;
}

.chev {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--muted-fg);
  transition: transform var(--dur) var(--ease);
}

.user-trigger[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.user-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  width: 14rem;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: pop-in 140ms var(--ease);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.popover-head {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem;
}

.popover-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.popover-mail {
  font-size: 0.75rem;
  color: var(--muted-fg);
  overflow: hidden;
  text-overflow: ellipsis;
}

.popover-sep {
  margin: 0.375rem 0.25rem;
}

.popover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  transition: background var(--dur) var(--ease);
}

.popover-item svg {
  width: 0.9375rem;
  height: 0.9375rem;
}

.popover-item:hover {
  background: var(--muted-bg);
}

.popover-item.danger {
  color: var(--danger);
}

.popover-item.danger:hover {
  background: var(--danger-soft);
}

.mobile-nav-toggle {
  display: none;
}

/* 桌面端隐藏移动端菜单按钮（需在 .icon-btn 之后声明并提高优先级） */
@media (min-width: 1025px) {
  .topbar .mobile-nav-toggle {
    display: none;
  }
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: hsl(222 47% 11% / 0.4);
  backdrop-filter: blur(2px);
  animation: fade-in 160ms var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- 内容区 --- */
.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem) 4rem;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: page-in 260ms var(--ease);
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ 4. 通用组件 ------------------------------ */
/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4375rem;
  min-height: 2.375rem;
  padding: 0.5rem 0.9375rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.15;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
    border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 1.9;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: 0 1px 2px hsl(221 83% 43% / 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
}

.btn-secondary {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--muted-bg);
}

.btn-ghost {
  color: var(--muted-fg);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--muted-bg);
  color: var(--foreground);
}

.btn-sm {
  min-height: 2rem;
  padding: 0.3125rem 0.6875rem;
  font-size: 0.8125rem;
  border-radius: 0.4375rem;
}

.btn-block {
  width: 100%;
}

.btn .spinner {
  width: 0.875rem;
  height: 0.875rem;
  border-width: 1.75px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 0.5rem;
  color: var(--muted-fg);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--muted-bg);
  color: var(--foreground);
}

.icon-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* 加载指示：克制的小圆环 */
.spinner {
  display: inline-block;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid hsl(221 83% 53% / 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 640ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.6s;
  }
}

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.4375rem;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-soft {
  background: var(--muted-bg-2);
  color: var(--muted-fg);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-success {
  background: var(--success-soft);
  color: hsl(142 66% 32%);
}

.badge-outline {
  border: 1px solid var(--border);
  color: var(--muted-fg);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.1563rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-fg);
  font-size: 0.6875rem;
  font-weight: 500;
}

.chip svg {
  width: 0.75rem;
  height: 0.75rem;
  stroke-width: 2;
}

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: hsl(214 32% 86%);
}

/* 进度条 */
.progress {
  position: relative;
  width: 100%;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--muted-bg-2);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(221 83% 58%), hsl(217 91% 50%));
  transition: width 520ms var(--ease);
}

.progress-bar.is-complete {
  background: linear-gradient(90deg, hsl(142 71% 48%), hsl(142 66% 40%));
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.progress-meta strong {
  color: var(--foreground);
  font-weight: 600;
}

/* 骨架屏 */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--muted-bg-2);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, hsl(0 0% 100% / 0.65), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.25s ease-in-out infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after {
    animation: none;
  }
}

.boot-screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.5rem;
}

.skeleton-title { width: 14rem; height: 1.75rem; }
.skeleton-hero { width: 100%; height: 11rem; border-radius: var(--radius); }
.skeleton-row { width: 100%; height: 5.25rem; border-radius: var(--radius); }
.skeleton-card { width: 100%; height: 15rem; border-radius: var(--radius); }
.skeleton-line { width: 100%; height: 2.75rem; border-radius: var(--radius); }

/* 空状态 / 错误状态 */
.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: clamp(2.5rem, 8vw, 4.5rem) 1.5rem;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-icon,
.error-icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.375rem;
  border-radius: 1rem;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-icon svg,
.error-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 1.6;
}

.error-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-title,
.error-title {
  font-size: 1rem;
  font-weight: 600;
}

.empty-desc,
.error-desc {
  max-width: 26rem;
  font-size: 0.8125rem;
  color: var(--muted-fg);
}

.empty-state .btn,
.error-state .btn {
  margin-top: 0.75rem;
}

/* ------------------------------ 5. 登录 / 注册 ------------------------------ */
.auth-page {
  position: relative;
  width: 100%;
  max-width: 26.5rem;
  margin: 0 auto;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(48rem 28rem at 12% -8%, hsl(221 83% 53% / 0.1), transparent 62%),
    radial-gradient(40rem 24rem at 92% 108%, hsl(199 89% 48% / 0.09), transparent 60%),
    var(--background);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.9375rem;
  background: linear-gradient(140deg, hsl(221 83% 58%), hsl(217 91% 50%));
  color: #fff;
  font-size: 1.375rem;
  font-weight: 700;
  box-shadow: 0 10px 24px -10px hsl(221 83% 53% / 0.75);
}

.auth-title {
  font-size: 1.1875rem;
  font-weight: 650;
}

.auth-sub {
  font-size: 0.8125rem;
  color: var(--muted-fg);
}

.auth-card {
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  box-shadow: var(--shadow-md);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
  border-radius: 0.5rem;
  background: var(--muted-bg);
}

.tab {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  color: var(--muted-fg);
  font-size: 0.875rem;
  font-weight: 550;
  text-align: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.tab:hover {
  color: var(--foreground);
}

.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.9375rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.label {
  font-size: 0.8125rem;
  font-weight: 550;
  color: hsl(222 30% 26%);
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.hint {
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

.input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  font-size: 0.875rem;
  color: var(--foreground);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.input::placeholder {
  color: hsl(215 16% 62%);
}

.input:hover {
  border-color: hsl(214 32% 84%);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft-2);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-error {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.75rem;
  color: var(--danger);
}

.field-error svg {
  flex: 0 0 auto;
  width: 0.8125rem;
  height: 0.8125rem;
  stroke-width: 2.2;
}

.form-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid hsl(0 72% 51% / 0.22);
  border-radius: 0.5rem;
  background: var(--danger-soft);
  color: hsl(0 65% 38%);
  font-size: 0.8125rem;
}

.form-alert svg {
  flex: 0 0 auto;
  width: 0.9375rem;
  height: 0.9375rem;
  margin-top: 0.125rem;
  stroke-width: 2;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.125rem 0;
  color: hsl(215 16% 60%);
  font-size: 0.6875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.demo-box {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-2);
}

.demo-head {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(222 30% 30%);
}

.demo-head svg {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--primary);
}

.demo-rows {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.demo-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.4375rem 0.5625rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--card);
  font-size: 0.75rem;
  text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.demo-btn:hover:not(:disabled) {
  border-color: hsl(221 83% 53% / 0.45);
  background: var(--primary-soft);
}

.demo-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.demo-btn .demo-label {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  min-width: 0;
}

.demo-btn strong {
  font-size: 0.75rem;
  font-weight: 600;
}

.demo-btn code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

.demo-btn .demo-arrow {
  flex: 0 0 auto;
  color: var(--primary);
}

.demo-btn .demo-arrow svg {
  width: 0.875rem;
  height: 0.875rem;
}

.auth-foot {
  margin-top: 1.125rem;
  text-align: center;
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

/* ------------------------------ 6. 任务页 ------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border-radius: var(--radius);
  border: 1px solid hsl(221 83% 53% / 0.14);
  background:
    radial-gradient(32rem 16rem at 100% 0%, hsl(221 83% 53% / 0.09), transparent 70%),
    linear-gradient(180deg, hsl(0 0% 100%), hsl(220 40% 99%));
  box-shadow: var(--shadow-sm);
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hero-main {
  flex: 1 1 20rem;
  min-width: 0;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.hero-eyebrow svg {
  width: 0.875rem;
  height: 0.875rem;
}

.hero-title {
  font-size: clamp(1.375rem, 3.4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.hero-sub {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted-fg);
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.875rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* 窄屏时 hero 操作按钮独占一行并等分（放在 .hero-top 之后避免被 flex-wrap 撑高） */
@media (max-width: 720px) {
  .hero-actions {
    width: 100%;
  }

  .hero-actions .btn {
    flex: 1 1 0;
    min-width: 0;
  }
}

.hero-progress {
  margin-top: 1.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.625rem;
  margin-top: 1.25rem;
}

.stat {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
}

.stat-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted-fg);
}

.stat-value {
  display: block;
  margin-top: 0.1875rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-value small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-fg);
}

.stat-value.accent {
  color: var(--primary);
}

.stat-value.success {
  color: hsl(142 66% 34%);
}

/* 已获证书横幅 */
.cert-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
  padding: 0.9375rem 1.125rem;
  border: 1px solid hsl(142 71% 45% / 0.28);
  border-radius: var(--radius);
  background: linear-gradient(100deg, hsl(142 71% 45% / 0.1), hsl(142 71% 45% / 0.04));
  animation: banner-in 320ms var(--ease);
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.cert-banner-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.375rem;
  height: 2.375rem;
  border-radius: 0.625rem;
  background: var(--card);
  color: hsl(142 66% 36%);
  box-shadow: var(--shadow-xs);
}

.cert-banner-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 1.7;
}

.cert-banner-text {
  flex: 1 1 14rem;
  min-width: 0;
}

.cert-banner-title {
  font-size: 0.875rem;
  font-weight: 650;
}

.cert-banner-desc {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: hsl(142 40% 28%);
}

.cert-banner code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 0.0625rem 0.3125rem;
  border-radius: 0.25rem;
  background: hsl(0 0% 100% / 0.7);
}

/* 列表区头 */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 650;
}

.section-title svg {
  width: 1.0625rem;
  height: 1.0625rem;
  color: var(--primary);
}

.section-desc {
  margin-top: 0.1875rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted-fg);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.task-card {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.9375rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.task-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: hsl(214 32% 86%);
}

.task-card.is-completed {
  background: linear-gradient(180deg, hsl(142 71% 45% / 0.035), transparent 60%);
}

.task-card.is-pending {
  opacity: 0.92;
}

.task-card.is-busy {
  pointer-events: none;
}

.task-day {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-top: 0.0625rem;
  border-radius: 0.5rem;
  background: var(--muted-bg-2);
  color: hsl(222 30% 34%);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.task-card.is-completed .task-day {
  background: var(--success-soft);
  color: hsl(142 66% 32%);
}

.task-main {
  flex: 1 1 auto;
  min-width: 0;
}

.task-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.task-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.task-card.is-completed .task-title {
  color: hsl(222 24% 30%);
}

.task-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted-fg);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.task-aside {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.375rem;
  margin-left: 0.25rem;
}

.task-time {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  color: var(--muted-fg);
  white-space: nowrap;
}

.task-time svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* 自定义勾选按钮 */
.check {
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border: 1.5px solid hsl(214 32% 84%);
  border-radius: 0.4375rem;
  background: var(--card);
  color: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.check:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.check svg {
  width: 0.9375rem;
  height: 0.9375rem;
  stroke-width: 2.6;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}

.check[aria-checked="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
  box-shadow: 0 1px 2px hsl(221 83% 43% / 0.3);
}

.check[aria-checked="true"] svg {
  opacity: 1;
  transform: none;
}

.check:disabled {
  cursor: progress;
  opacity: 0.65;
}

.check.is-loading {
  border-color: var(--primary);
  background: var(--card);
}

.check.is-loading .spinner {
  width: 0.8125rem;
  height: 0.8125rem;
  border-width: 1.5px;
}

/* ------------------------------ 7. 证书中心 ------------------------------ */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-sub {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted-fg);
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1rem;
}

.cert-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.cert-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: hsl(214 32% 86%);
}

.cert-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.125rem 1.125rem 0;
}

.cert-medal {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  background: linear-gradient(140deg, hsl(221 83% 58%), hsl(217 91% 50%));
  color: #fff;
  box-shadow: 0 6px 14px -6px hsl(221 83% 53% / 0.6);
}

.cert-medal svg {
  width: 1.375rem;
  height: 1.375rem;
  stroke-width: 1.7;
}

.cert-course {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

.cert-course-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.cert-no {
  display: inline-block;
  margin-top: 0.3125rem;
  padding: 0.125rem 0.4375rem;
  border-radius: 0.3125rem;
  background: var(--muted-bg);
  color: var(--muted-fg);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: -0.01em;
  word-break: break-all;
}

.cert-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1.125rem 1rem;
}

.cert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.cert-row dt {
  color: var(--muted-fg);
  font-size: 0.75rem;
}

.cert-row dd {
  margin: 0;
  font-weight: 550;
  text-align: right;
}

.cert-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1.125rem 1.125rem;
  margin-top: auto;
}

.cert-actions .btn {
  flex: 1 1 0;
}

/* 证书列表顶部摘要 */
.cert-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1.125rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--muted-fg);
}

.cert-summary > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
}

.cert-summary svg {
  width: 0.875rem;
  height: 0.875rem;
  stroke-width: 1.8;
  color: var(--primary);
}

.cert-summary strong {
  color: var(--foreground);
  font-weight: 650;
}

/* ------------------------------ 8. 证书预览 ------------------------------ */
.preview-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.preview-head-main {
  flex: 1 1 16rem;
  min-width: 0;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 650;
}

.preview-title svg {
  flex: 0 0 auto;
  width: 1.0625rem;
  height: 1.0625rem;
  color: var(--primary);
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.preview-meta code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: hsl(222 30% 34%);
  word-break: break-all;
}

.preview-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.preview-meta svg {
  width: 0.8125rem;
  height: 0.8125rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pdf-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pdf-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: none;
  background: hsl(210 20% 96%);
}

.pdf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  background: hsl(210 20% 96%);
  color: var(--muted-fg);
  font-size: 0.8125rem;
  transition: opacity 200ms var(--ease);
}

.pdf-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.pdf-tip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  color: hsl(215 16% 55%);
}

.pdf-tip svg {
  width: 0.8125rem;
  height: 0.8125rem;
}

/* ------------------------------ 9. Toast ------------------------------ */
.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 0.5rem;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 200ms var(--ease);
}

.toast.is-leaving {
  animation: toast-out 180ms var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px) scale(0.99); }
}

.toast-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.0625rem;
}

.toast-icon svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 2;
}

.toast-body {
  flex: 1 1 auto;
  min-width: 0;
}

.toast-title {
  font-size: 0.8125rem;
  font-weight: 600;
}

.toast-desc {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.toast-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.25rem;
  color: var(--muted-fg);
}

.toast-close:hover {
  background: var(--muted-bg);
}

.toast-close svg {
  width: 0.8125rem;
  height: 0.8125rem;
}

.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info { border-left-color: var(--primary); }
.toast.info .toast-icon { color: var(--primary); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .toast-icon { color: var(--warning); }

/* ------------------------------ 10. 庆祝弹层 ------------------------------ */
.modal-root:empty {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: hsl(222 47% 11% / 0.45);
  backdrop-filter: blur(3px);
  animation: fade-in 180ms var(--ease);
}

.modal {
  position: relative;
  width: min(24rem, 100%);
  padding: 1.75rem 1.5rem 1.375rem;
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modal-in 240ms var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.modal-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 0.875rem;
  border-radius: 1.25rem;
  background: linear-gradient(140deg, hsl(221 83% 58%), hsl(217 91% 50%));
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 14px 30px -12px hsl(221 83% 53% / 0.8);
}

.modal-badge::after {
  content: "";
  position: absolute;
  inset: -0.5rem;
  border-radius: 1.6rem;
  border: 2px solid hsl(221 83% 53% / 0.18);
  animation: badge-pulse 2s var(--ease) infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-badge::after { animation: none; }
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-desc {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted-fg);
}

.modal-cert {
  display: flex;
  flex-direction: column;
  gap: 0.1875rem;
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-2);
  text-align: left;
}

.modal-cert-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
}

.modal-cert-row span {
  color: var(--muted-fg);
}

.modal-cert-row strong {
  font-weight: 600;
  text-align: right;
}

.modal-cert-row code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  word-break: break-all;
  text-align: right;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.125rem;
}

.modal-actions .btn {
  min-height: 2.5rem;
}

/* 结业横幅内的庆祝动画（轻微） */
.confetti-dot {
  position: absolute;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  pointer-events: none;
  animation: confetti-fall 1100ms var(--ease) forwards;
}

@keyframes confetti-fall {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  to { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 40px)) rotate(180deg); }
}

/* ------------------------------ 11. 其他 ------------------------------ */
.boot-screen {
  animation: fade-in 200ms var(--ease);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--background);
  color: var(--foreground);
  font-size: 0.9375rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------ 12. 响应式 ------------------------------ */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 240ms var(--ease);
    box-shadow: var(--shadow-lg);
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .mobile-nav-toggle {
    display: grid;
  }

  .topbar {
    padding-left: 0.5rem;
  }

  body.is-login .sidebar {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --topbar-h: 3.25rem;
  }

  .topbar-tabs {
    display: none;
  }

  .crumb-title {
    max-width: 12rem;
  }

  .content {
    padding-bottom: 3rem;
  }

  .page {
    gap: 1.125rem;
  }

  .cert-grid {
    grid-template-columns: 1fr;
  }

  .cert-actions .btn {
    min-height: 2.25rem;
  }

  .preview-head {
    padding: 0.75rem;
  }

  .preview-actions {
    width: 100%;
  }

  .preview-actions .btn {
    flex: 1 1 auto;
  }

  .pdf-frame-wrap,
  .pdf-frame {
    min-height: 62vh;
  }

  .toast-stack {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    width: auto;
  }
}

@media (max-width: 480px) {
  .task-card {
    flex-wrap: wrap;
    padding: 0.875rem;
  }

  .task-aside {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border);
  }

  .task-day {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.8125rem;
  }

  .hero-top {
    flex-direction: column;
  }

  /* hero-top 变为纵向排列后，flex-basis 会作用于高度，需重置避免出现大片空白 */
  .hero-main {
    flex: 0 1 auto;
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-card {
    padding: 1.125rem;
  }

  .user-name {
    display: none;
  }

  .modal {
    padding: 1.5rem 1.125rem 1.125rem;
  }

  .page-title {
    font-size: 1.3125rem;
  }
}

/* 390px 及以下：保证任何元素不撑破视口 */
@media (max-width: 400px) {
  .content {
    padding-left: 0.875rem;
    padding-right: 0.875rem;
  }

  .topbar {
    padding-right: 0.625rem;
  }

  .cert-no,
  .preview-meta code {
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .btn {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 深色环境兜底：保持浅色（原站为固定浅色主题） */
@media print {
  .sidebar,
  .topbar,
  .toast-stack,
  .sidebar-scrim {
    display: none !important;
  }

  .content {
    max-width: none;
    padding: 0;
  }
}
