/* ============================================================
   暖砂 Warm Sand · 组件样式 v1.2
   依赖 tokens.css（必须先于本文件引入）
   ------------------------------------------------------------
   命名约定：BEM 简化版 —— .component / .component--variant
   ============================================================ */

/* ---------------- 基础重置与元素 ---------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--text-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  color: var(--text-1);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}

p { margin: 0; }

a {
  color: var(--link);
  text-decoration: none;
  transition: var(--transition-ui);
}
a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

::selection { background: var(--selection-bg); color: var(--text-1); }

/* 键盘可达性：仅键盘聚焦时显示描边（描边自动跟随元素自身圆角） */
:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* ---------------- 布局原语 ---------------- */
.container {
  width: min(100% - var(--space-sm) * 2, var(--container));
  margin-inline: auto;
}
.container--wide {
  width: min(100% - var(--space-sm) * 2, var(--container-wide));
}

.section { padding-block: var(--space-2xl); }
.section--tight { padding-block: var(--space-xl); }

.section-head { max-width: 36rem; margin-bottom: var(--space-lg); }
.section-head--center { margin-inline: auto; text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  color: var(--text-brand);
}
.eyebrow::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-full);
  background: var(--clay-500);
}

.section-head h2 { font-size: var(--text-2xl); margin-bottom: var(--space-2xs); }
.section-head .lead { color: var(--text-3); font-size: var(--text-lg); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: 0.8125rem 1.375rem;          /* ≥44px 可点击高度 */
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-ui);
}
.btn:hover { text-decoration: none; }

.btn--primary { background: var(--action); color: var(--action-text); }
.btn--primary:hover {
  background: var(--action-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn--primary:active {
  background: var(--action-active);
  transform: scale(0.97);
  box-shadow: none;
}

.btn--secondary {
  background: var(--surface-raised);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn--secondary:hover {
  border-color: var(--clay-400);
  background: var(--surface-hover);
  color: var(--text-brand);
}
.btn--secondary:active { background: var(--action-soft); }

.btn--ghost { background: transparent; color: var(--text-brand); }
.btn--ghost:hover { background: var(--action-soft); }
.btn--ghost:active { background: var(--action-soft-hover); }

.btn--danger { background: var(--error); color: var(--text-inverse); }
.btn--danger:hover { background: var(--berry-700); }

/* 统一按压反馈：所有按钮按下轻微收缩（~200ms 内完成），松手回弹 */
.btn:active { transform: scale(0.97); }

.btn--sm { padding: 0.5rem 1rem; font-size: var(--text-xs); }
.btn--lg { padding: 1rem 1.75rem; font-size: var(--text-base); }

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

/* ---------------- 卡片 ---------------- */
.card {
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition-ui);
}
.card--hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; }

.card--raised {
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

/* ---------------- 标签 Tag 与徽章 Badge ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--surface-sunken);
  color: var(--text-3);
  transition: var(--transition-ui);
}
a.tag:hover { background: var(--action-soft); color: var(--text-brand); text-decoration: none; }
.tag--brand { background: var(--action-soft); color: var(--action-soft-text); }
.tag--sage  { background: var(--sage-100); color: var(--sage-700); }
.tag--sun   { background: var(--sun-100); color: var(--sun-700); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.5;
  white-space: nowrap;
}
.badge--brand   { background: var(--action-soft);   color: var(--action-soft-text); }
.badge--success { background: var(--success-soft);  color: var(--success-text); }
.badge--warning { background: var(--warning-soft);  color: var(--warning-text); }
.badge--error   { background: var(--error-soft);    color: var(--error-text); }
.badge--info    { background: var(--info-soft);     color: var(--info-text); }

/* ---------------- 表单 ---------------- */
.field { display: grid; gap: var(--space-2xs); }
.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-1);
  transition: color var(--duration-fast) var(--ease-out);
}
.field__label--required::after { content: " *"; color: var(--error); }
.field__hint  { font-size: var(--text-xs); color: var(--text-3); transition: color var(--duration-fast) var(--ease-out); }
.field__error {
  font-size: var(--text-xs);
  color: var(--error-text);
  /* 错误提示出现时自动播放小幅下沉入场（配合 hidden 属性切换） */
  animation: ws-drop-in var(--duration-fast) var(--ease-out);
}

/* 聚焦联动：输入区聚焦时标签点亮为品牌色 */
.field:focus-within .field__label { color: var(--text-brand); }

/* 字段组：复选/单选组请用 fieldset.fieldset + legend.legend 包裹（语义正确） */
.fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
  display: grid;
  gap: var(--space-2xs);
}
.legend {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-1);
}

/* 文本输入家族（输入框 / 多行文本 / 下拉框共享底样式） */
.input,
.textarea,
.select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text-1);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: var(--transition-ui);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-3); opacity: 0.75; }
.input:hover,
.textarea:hover,
.select:hover { border-color: var(--stone-400); }
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: none;
  border-color: var(--clay-500);
  box-shadow: 0 0 0 3px var(--clay-200);
}
.input--error, .select--error, .textarea--error,
.input--error:hover, .select--error:hover, .textarea--error:hover,
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--error);
}
.textarea { min-height: 7rem; resize: vertical; }

/* 下拉框：自绘箭头（原生外观移除后保持跨端一致） */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2368625C' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 0.875rem;
}

/* 下拉框动画增强：包一层 .select-wrap，箭头在展开（聚焦）时旋转 180°
   注：原生 select 的弹层由操作系统渲染，无法用 CSS 过渡；
   需要完全可控的展开/收起动画时，请使用下方 .collapse 或 .disclosure */
.select-wrap { position: relative; display: grid; }
.select-wrap > .select { background-image: none; }  /* 箭头改由图标绘制 */
.select-wrap__icon {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  translate: 0 -50%;
  width: 1rem;
  height: 1rem;
  pointer-events: none;
  color: var(--stone-600);
  transition: transform var(--duration-fast) var(--ease-out);
}
.select-wrap:hover .select-wrap__icon { color: var(--text-2); }
.select-wrap:focus-within .select-wrap__icon { transform: rotate(180deg); }

/* 日期 / 时间：让原生日历弹层跟随浅色主题 */
.input[type="date"],
.input[type="time"],
.input[type="datetime-local"] { color-scheme: light; }
.input[type="date"]::-webkit-calendar-picker-indicator,
.input[type="time"]::-webkit-calendar-picker-indicator,
.input[type="datetime-local"]::-webkit-calendar-picker-indicator { cursor: pointer; }

/* 文件上传：把原生按钮换成次级按钮样式 */
.input[type="file"] { padding: 0.3125rem; cursor: pointer; }
.input[type="file"]::file-selector-button {
  margin-right: var(--space-xs);
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-1);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: var(--transition-ui);
}
.input[type="file"]::file-selector-button:hover {
  border-color: var(--clay-400);
  background: var(--surface-hover);
  color: var(--text-brand);
}

/* 复选 / 单选 / 开关：统一用 .choice 行容器组装 */
.choice {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition-ui);
}
.choice:hover { color: var(--text-1); }
.choice-group { display: grid; gap: var(--space-2xs); }
.choice-group--row { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); }

/* 复选框（支持 checked / indeterminate / disabled）
   对勾与半选横杠用伪元素绘制：勾选时对勾以 ease-out-back 缩放“画出”，
   整框同时播放一次轻微收缩回弹，替代背景图的瞬时切换 */
.checkbox {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  cursor: pointer;
  transition: var(--transition-ui);
}
.checkbox:hover { border-color: var(--stone-400); }
.checkbox:checked,
.checkbox:indeterminate {
  border-color: var(--action);
  background-color: var(--action);
}
/* 对勾：scale 0 → 1，带回弹 */
.checkbox::after {
  content: "";
  width: 0.625rem;
  height: 0.375rem;
  border-left: 2px solid var(--action-text);
  border-bottom: 2px solid var(--action-text);
  transform: translate(0, -1px) rotate(-45deg) scale(0);
  transition: transform var(--duration-fast) var(--ease-out-back);
}
.checkbox:checked::after {
  transform: translate(0, -1px) rotate(-45deg) scale(1);
}
/* 半选横杠：scaleX 0 → 1 */
.checkbox::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.625rem;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--action-text);
  transform: scaleX(0);
  transition: transform var(--duration-fast) var(--ease-out);
}
.checkbox:indeterminate::before { transform: scaleX(1); }
/* 勾选瞬间：整框轻微收缩再弹出（“确认”手感） */
.checkbox:checked { animation: ws-check-pop var(--duration-fast) var(--ease-out-back); }

/* 单选框 */
.radio {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  cursor: pointer;
  transition: var(--transition-ui);
}
.radio::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--action);
  transform: scale(0);
  /* ease-out-back：圆点弹出时带轻微回弹 */
  transition: transform var(--duration-fast) var(--ease-out-back);
}
.radio:hover { border-color: var(--stone-400); }
.radio:checked { border-color: var(--action); }
.radio:checked::after { transform: scale(1); }

/* 开关（建议在 input 上加 role="switch"） */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  position: relative;
  --switch-x: 0;   /* 拇指位移距离，选中态改写为 1.125rem */
  width: 2.5rem;
  height: 1.375rem;
  margin: 0;
  border: none;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-base) var(--ease-out);
}
.switch:hover { background: var(--stone-400); }
.switch:checked { --switch-x: 1.125rem; background: var(--action); }
.switch:checked::after { transform: translateX(var(--switch-x)); }
/* 按住时拇指轻微缩小，松手回弹 */
.switch:active::after { transform: translateX(var(--switch-x)) scale(0.88); }

/* 滑块：原生控件 + 品牌色 accent */
.range {
  width: 100%;
  margin: 0;
  accent-color: var(--clay-600);
  cursor: pointer;
}

/* 控件统一禁用态 */
.input:disabled,
.textarea:disabled,
.select:disabled,
.checkbox:disabled,
.radio:disabled,
.switch:disabled,
.range:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.choice:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* 表单操作区：提交用 .btn--primary，重置用 .btn--secondary */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: flex-end;
  margin-top: var(--space-md);
}
.form-actions--start { justify-content: flex-start; }

/* ---------------- 提示条 Alert ---------------- */
.alert {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.alert--success { background: var(--success-soft); color: var(--success-text); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); }
.alert--error   { background: var(--error-soft);   color: var(--error-text); }
.alert--info    { background: var(--info-soft);    color: var(--info-text); }

/* ---------------- 头像 Avatar ---------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--action-soft);
  color: var(--action-soft-text);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  user-select: none;
}
.avatar--sm { width: 2rem; height: 2rem; font-size: var(--text-xs); }
.avatar--lg { width: 3.5rem; height: 3.5rem; font-size: var(--text-lg); }
.avatar--sage  { background: var(--sage-100);  color: var(--sage-700); }
.avatar--sun   { background: var(--sun-100);   color: var(--sun-700); }
.avatar--sky   { background: var(--sky-100);   color: var(--sky-700); }
.avatar--berry { background: var(--berry-100); color: var(--berry-700); }

/* ---------------- 博客文章卡 Article Card ---------------- */
.article-card { display: grid; gap: var(--space-xs); }
.article-card__tags { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.article-card h3 { font-size: var(--text-lg); transition: var(--transition-ui); }
a.article-card:hover h3 { color: var(--text-brand); }
.article-card__excerpt {
  font-size: var(--text-sm);
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--text-3);
}

/* ---------------- 论坛帖子行 Post Item ---------------- */
.post-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
}
.post-item + .post-item { border-top: 1px solid var(--border); }
.post-item__body { flex: 1; min-width: 0; }
.post-item__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-heading);
}
.post-item__title a { color: inherit; }
.post-item__title a:hover { color: var(--text-brand); text-decoration: none; }
.post-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
  margin-top: var(--space-3xs);
  font-size: var(--text-xs);
  color: var(--text-3);
}
.post-item__stats {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ---------------- 分页 Pagination ---------------- */
.pagination { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding-inline: var(--space-2xs);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-2);
  transition: var(--transition-ui);
}
.pagination a:hover { background: var(--action-soft); color: var(--text-brand); text-decoration: none; }
.pagination [aria-current="page"] {
  background: var(--action);
  color: var(--action-text);
  font-weight: var(--weight-semibold);
}

/* ---------------- 文章正文 Prose（博客详情页） ---------------- */
.prose { max-width: var(--measure); font-size: var(--text-base); }
.prose > * + * { margin-top: var(--space-sm); }
.prose h2 { font-size: var(--text-xl); margin-top: var(--space-lg); }
.prose h3 { font-size: var(--text-lg); margin-top: var(--space-md); }
.prose a { text-decoration: underline; text-underline-offset: 0.2em; }
.prose img { margin-block: var(--space-md); border-radius: var(--radius-lg); }
.prose blockquote {
  padding: var(--space-sm) var(--space-md);
  border-left: 3px solid var(--clay-400);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--surface);
  color: var(--text-3);
}
.prose code {
  padding: 0.125em 0.375em;
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.prose pre {
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
  background: var(--stone-900);
  color: var(--stone-100);
  border-radius: var(--radius-md);
  line-height: var(--leading-loose);
}
.prose pre code { padding: 0; background: none; color: inherit; font-size: var(--text-sm); }
.prose ul, .prose ol { padding-left: 1.5em; }

/* ---------------- 杂项 ---------------- */
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--space-md) 0; }

.kbd {
  padding: 0.125rem 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   动效层 MOTION UTILITIES
   时长阶梯 120 / 200 / 300 / 500ms，缓动见 tokens.css；
   只动 transform 与 opacity，保证合成器渲染不卡顿。
   入场动画统一用 keyframes + both：元素从 display:none 变为可见时
   会自动重放，因此「显示 / 隐藏」只需切换 hidden 属性即可获得动画。
   ============================================================ */

@keyframes ws-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ws-slide-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ws-slide-in-left {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ws-slide-in-right {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ws-scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes ws-drop-in {
  /* 小幅下沉入场：错误提示、提示条、折叠面板内容 */
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ws-check-pop {
  /* 勾选确认：轻收再弹出 */
  0%   { transform: scale(0.84); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes ws-shake {
  /* 校验失败：小幅度水平摇头 */
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* 入场工具类：挂上即播；hidden 切换（重新显示）时自动重放 */
.anim-fade-in        { animation: ws-fade-in         var(--duration-base) var(--ease-out)      both; }
.anim-slide-up       { animation: ws-slide-up        var(--duration-slow) var(--ease-out)      both; }
.anim-slide-in-left  { animation: ws-slide-in-left   var(--duration-slow) var(--ease-out)      both; }
.anim-slide-in-right { animation: ws-slide-in-right  var(--duration-slow) var(--ease-out)      both; }
.anim-scale-in       { animation: ws-scale-in        var(--duration-base) var(--ease-out-back) both; }
.anim-drop-in        { animation: ws-drop-in         var(--duration-fast) var(--ease-out)      both; }
/* 校验失败摇头：JS 加上后需在 animationend 移除，便于重复触发 */
.anim-shake          { animation: ws-shake 0.4s var(--ease-inout); }

/* 交错入场：容器加 .stagger，子元素按序延迟（步长可用 --stagger 调整，默认 60ms） */
.stagger > * { animation: ws-slide-up var(--duration-slow) var(--ease-out) both; }
.stagger > :nth-child(1) { animation-delay: calc(var(--stagger, 60ms) * 1); }
.stagger > :nth-child(2) { animation-delay: calc(var(--stagger, 60ms) * 2); }
.stagger > :nth-child(3) { animation-delay: calc(var(--stagger, 60ms) * 3); }
.stagger > :nth-child(4) { animation-delay: calc(var(--stagger, 60ms) * 4); }
.stagger > :nth-child(5) { animation-delay: calc(var(--stagger, 60ms) * 5); }
.stagger > :nth-child(6) { animation-delay: calc(var(--stagger, 60ms) * 6); }
.stagger > :nth-child(7) { animation-delay: calc(var(--stagger, 60ms) * 7); }
.stagger > :nth-child(8) { animation-delay: calc(var(--stagger, 60ms) * 8); }
/* 第 9 个起统一封顶，避免长列表末尾等待过久 */
.stagger > :nth-child(n + 9) { animation-delay: calc(var(--stagger, 60ms) * 8); }

/* 滚动入场：进入视口时由 JS 加 .is-revealed（约 2 行脚本，见风格指南）
   仅在 <html> 带 .js-reveal（JS 可用）时才隐藏内容——脚本失效时页面照常可读 */
.js-reveal [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
  transition-delay: calc(var(--reveal-step, 0) * 60ms);
}
.js-reveal [data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* 展开 / 收起：grid-template-rows 0fr ↔ 1fr，高度自适应且只触发合成 */
.collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-base) var(--ease-out);
}
.collapse > * {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.collapse.is-open { grid-template-rows: 1fr; }
.collapse.is-open > * { opacity: 1; }

/* 折叠面板（原生 details / summary）：箭头旋转 + 内容下沉入场 */
.disclosure {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-1);
  transition: var(--transition-ui);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { color: var(--text-brand); }
.disclosure__icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--stone-600);
  transition: transform var(--duration-fast) var(--ease-out);
}
.disclosure[open] > summary .disclosure__icon { transform: rotate(180deg); }
.disclosure__body {
  padding: 0 var(--space-sm) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-2);
  animation: ws-drop-in var(--duration-base) var(--ease-out);
}

/* 校验状态（配合表单 JS 切换） */
.field--shake .input,
.field--shake .select,
.field--shake .textarea {
  animation: ws-shake 0.4s var(--ease-inout);
  border-color: var(--error);
}
.field--valid .input,
.field--valid .select,
.field--valid .textarea { border-color: var(--success); }
.field--valid .field__hint { color: var(--success-text); }

/* ============================================================
   夜间模式（暮砂 Dusk Sand）
   语义层换肤见 tokens.css 的 :root[data-theme="dark"]；
   此处只放组件层面的夜间适配与主题切换控件。
   ============================================================ */

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* 日期 / 时间弹层跟随夜间主题（覆盖浅色默认） */
:root[data-theme="dark"] .input[type="date"],
:root[data-theme="dark"] .input[type="time"],
:root[data-theme="dark"] .input[type="datetime-local"] { color-scheme: dark; }

/* 烬火余温：主按钮悬停带一圈微光 */
:root[data-theme="dark"] .btn--primary:hover {
  box-shadow: var(--shadow-sm), var(--glow-ember);
}

/* 卡片悬浮：暗色下阴影之外再染一线极光 */
:root[data-theme="dark"] .card--hover:hover {
  border-color: var(--border-brand);
  box-shadow: var(--shadow-md), var(--glow-aurora);
}

/* 勾选 / 点选确认：控件点亮时带星尘微光 */
:root[data-theme="dark"] .checkbox:checked,
:root[data-theme="dark"] .radio:checked,
:root[data-theme="dark"] .switch:checked {
  box-shadow: var(--glow-ember-sm);
}

/* 主题切换按钮：日间显示月（点去夜间），夜间显示日 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition-ui);
}
.theme-toggle:hover {
  color: var(--text-brand);
  border-color: var(--clay-400);
  transform: rotate(15deg);
}
:root[data-theme="dark"] .theme-toggle:hover { box-shadow: var(--glow-ember); }
.theme-toggle svg { width: 1.125rem; height: 1.125rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 主题切换过渡兜底：不支持 View Transitions 的浏览器，
   JS 在切换前后挂/摘 .theme-switching，让颜色整体柔切 450ms */
.theme-switching,
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: background-color 0.45s var(--ease-inout),
              color 0.45s var(--ease-inout),
              border-color 0.45s var(--ease-inout),
              box-shadow 0.45s var(--ease-inout),
              fill 0.45s var(--ease-inout),
              stroke 0.45s var(--ease-inout) !important;
}

/* ---------------- 减少动效偏好 ---------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* 滚动入场直接呈现最终状态，不依赖 JS 触发 */
  .js-reveal [data-reveal] { opacity: 1; transform: none; transition: none; }
}
