/* 组件层：按钮、卡片三级、采集印、表单、反馈 */
@layer components {

  /* ══ 按钮：四种语气，一种尺寸纪律 ═══════════════════════ */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 44px;
    padding: var(--s3) var(--s5);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--smoke);
    color: var(--ink);
    font-size: var(--t-body);
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    transition: background-color .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .12s var(--ease);
  }

  .btn svg { flex-shrink: 0; }

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

  .btn.primary {
    background: var(--leaf);
    color: var(--white);
    font-weight: 600;
  }

  .btn.primary:hover { background: var(--leaf-deep); }

  .btn.secondary {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
  }

  .btn.secondary:hover {
    border-color: var(--leaf);
    color: var(--leaf);
    background: var(--white);
  }

  .btn.ghost {
    background: transparent;
    color: var(--muted);
    padding-inline: var(--s3);
  }

  .btn.ghost:hover { background: var(--smoke); color: var(--ink); }

  /* danger 只用于「删除」类动作，不再用于「这一个词我还没记住」 */
  .btn.danger {
    background: var(--rust-wash);
    color: var(--rust);
  }

  .btn.danger:hover { background: var(--rust); color: var(--white); }

  .btn.full { width: 100%; }

  .btn.icon {
    width: 44px;
    padding: 0;
    flex-shrink: 0;
  }

  /* 文字动作：不再是「按钮尾巴挂箭头」的默认样式 */
  .text-action {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    min-height: 44px;
    color: var(--leaf);
    font-size: var(--t-meta);
    font-weight: 600;
  }

  .text-action svg { transition: transform .16s var(--ease); }

  .text-action:hover svg { transform: translateX(2px); }

  /* ══ 表面三级 ═══════════════════════════════════════════
     plate = 图版（无面、发丝线）  card = 可交互块（白面 + 浅影）
     sheet = 浮在画面上的答题层                                          */

  .card,
  .hub-panel,
  .review-card,
  .saved-word-card,
  .prize-card,
  .order-card,
  .flashcard,
  .card-empty,
  .hub-completion,
  .unit-next,
  .scene-card,
  .memory-card,
  .textbook-word-card,
  .word-recall-card,
  .phrase-question-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: none;
  }

  .plate,
  .ready-unit,
  .textbook-scene-card,
  .unit-method,
  .home-library-list,
  .home-library-row,
  .journey-continue,
  .picture-entry,
  .due-review-banner,
  .curriculum-selector {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sheet,
  .object-popover {
    background: var(--white);
    border: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -14px 40px rgb(22 36 28 / .12);
  }

  /* 所有卡片的 hover 只提升边框，不做整块浮起 */
  .textbook-scene-card:hover,
  .unit-method:hover,
  .ready-unit:hover,
  .home-library-row:hover { border-color: var(--leaf); }

  /* ══ 药丸 / 筛选 ════════════════════════════════════════ */
  .pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s1);
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-hair);
    background: transparent;
    color: var(--muted);
    font-size: var(--t-micro);
    font-weight: 600;
    line-height: 1.7;
    letter-spacing: .02em;
  }

  .pill.is-leaf { background: var(--leaf-wash); color: var(--leaf); }
  .pill.is-rust { background: var(--rust-wash); color: var(--rust); }

  /* 筛选与标签：方角细框，跟着印刷语言走，不做胶囊 */
  .filter-chip,
  .scene-filters button,
  .picture-example-tabs .btn {
    min-height: 38px;
    padding: 0 var(--s3);
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--muted);
    font-size: var(--t-meta);
    font-weight: 600;
    transition: background-color .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
  }

  .filter-chip:hover,
  .scene-filters button:hover,
  .hub-tabs button:hover { border-color: var(--leaf); color: var(--leaf); }

  .filter-chip[aria-pressed="true"],
  .scene-filters button[aria-pressed="true"],
  .picture-example-tabs .btn[aria-pressed="true"] {
    background: var(--paper-2);
    border-color: var(--ink);
    color: var(--ink);
    font-weight: 700;
  }

  /* 页面级分页签：底边细线 + 当前项压一条墨线，像书里的页签 */
  .hub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s4);
    padding: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .hub-tabs button {
    min-height: 42px;
    padding: 0 0 6px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-size: var(--t-meta);
    font-weight: 600;
  }

  .hub-tabs button:hover { color: var(--ink); }

  .hub-tabs button[aria-pressed="true"] {
    border-bottom-color: var(--ink);
    color: var(--ink);
    font-weight: 700;
  }

  .hub-tabs,
  .mode-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--s2);
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }

  /* ══ 进度：细线 + 采集数，不再是粗绿条 ═════════════════ */
  .progress-line {
    position: relative;
    height: 2px;
    border-radius: var(--r-pill);
    background: var(--line);
    overflow: hidden;
  }

  .progress-line > span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--leaf);
    /* 进度写进 --p（0–100），动画 scaleX —— 只走合成层，不再触发布局 */
    transform: scaleX(calc(var(--p, 0) / 100));
    transform-origin: left center;
    transition: transform .32s var(--ease);
  }

  /* ══ 采集印：全站唯一的记忆点 ══════════════════════════
     none = 还空着  learned = 已收进册  retry = 收过又掉了      */
  .stamp {
    --stamp-size: 20px;
    display: inline-grid;
    place-items: center;
    width: var(--stamp-size);
    height: var(--stamp-size);
    border-radius: 50%;
    flex-shrink: 0;
    font-size: calc(var(--stamp-size) * .58);
    font-weight: 700;
    line-height: 1;
    border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
    color: transparent;
    background: transparent;
    transition: background-color .18s var(--ease), border-color .18s var(--ease), transform .2s var(--ease);
  }

  .stamp[data-state="learned"] {
    border: 1px solid var(--leaf);
    background: var(--leaf);
    color: var(--white);
  }

  .stamp[data-state="retry"] {
    border: 1px solid var(--rust);
    background: conic-gradient(var(--rust) 0 50%, transparent 50% 100%);
    color: var(--rust);
  }

  .stamp-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }

  .stamp-row > b {
    margin-left: var(--s1);
    font-size: var(--t-cap);
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

  /* ══ 表单 ══════════════════════════════════════════════ */
  .hub-input,
  .input,
  .answer-input,
  .popover-input,
  .cards-filter,
  .flow-scene-picker {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: var(--s3) var(--s4);
    background-color: var(--white);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: var(--t-body);
    line-height: 1.5;
  }

  .hub-input::placeholder,
  .answer-input::placeholder,
  .popover-input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }

  .hub-input:focus-visible,
  .input:focus-visible,
  .answer-input:focus-visible,
  .popover-input:focus-visible,
  .cards-filter:focus-visible,
  .flow-scene-picker:focus-visible {
    outline: 2px solid var(--leaf);
    outline-offset: 1px;
    border-color: var(--leaf);
  }

  .field {
    display: block;
    margin-bottom: var(--s4);
  }

  .field > span {
    display: block;
    margin-bottom: var(--s2);
    font-size: var(--t-meta);
    font-weight: 600;
    color: var(--muted);
  }

  .field-error,
  .form-error {
    min-height: 1.4em;
    margin: var(--s2) 0 0;
    color: var(--rust);
    font-size: var(--t-meta);
    line-height: 1.6;
  }

  /* ══ 浮层 ══════════════════════════════════════════════ */
  .toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--s6) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: var(--z-toast);
    max-width: min(520px, calc(100% - 32px));
    padding: var(--s3) var(--s5);
    border-radius: var(--r-pill);
    background: var(--ink);
    color: var(--paper);
    font-size: var(--t-meta);
    line-height: 1.6;
    box-shadow: var(--shadow-lift);
  }

  .academy-dialog {
    width: min(520px, calc(100% - 24px));
    max-height: 88dvh;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--white);
    color: var(--ink);
    box-shadow: 0 24px 80px rgb(16 35 28 / .20);
    overflow: auto;
  }

  .academy-dialog::backdrop {
    background: color-mix(in srgb, var(--ink) 36%, transparent);
    backdrop-filter: blur(3px);
  }

  .dialog-inner { padding: var(--s5); }

  .dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    margin-bottom: var(--s4);
  }

  .dialog-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-pill);
    background: var(--smoke);
    color: var(--muted);
    font-size: var(--t-h2);
    line-height: 1;
  }

  .dialog-close:hover { background: var(--line); color: var(--ink); }

  .dialog-actions {
    display: flex;
    gap: var(--s3);
    justify-content: flex-end;
    margin-top: var(--s5);
  }

  /* ══ 空态 ══════════════════════════════════════════════ */
  .hub-empty,
  .curriculum-empty,
  .card-empty {
    padding: var(--s7) var(--s5);
    border: 1px dashed var(--line);
    border-radius: var(--r-sm);
    text-align: center;
    background: transparent;
  }

  .hub-empty h2,
  .curriculum-empty h3 { margin-bottom: var(--s2); }

  /* 宽屏空态：图标在左、文案与动作在右，避免一整块 330px 高的空白 */
  @media (min-width: 721px) {
    .hub-empty {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      grid-template-areas:
        "icon title"
        "icon text"
        "icon action";
      align-items: center;
      column-gap: var(--s5);
      row-gap: var(--s1);
      padding: var(--s5) var(--s6);
      text-align: left;
    }

    .hub-empty .empty-sprout { grid-area: icon; margin: 0; align-self: start; }
    .hub-empty .empty-sprout svg { width: 30px; height: 30px; }
    .hub-empty h2 { grid-area: title; margin: 0; }
    .hub-empty p { grid-area: text; margin: 0; max-width: 52ch; }
    .hub-empty > .btn { grid-area: action; justify-self: start; margin-top: var(--s2); }
  }

  .hub-empty p,
  .curriculum-empty p,
  .card-empty p {
    max-width: 46ch;
    margin-inline: auto;
    color: var(--muted);
    font-size: var(--t-body);
  }

  /* 空态里的按钮跟随全站按钮形状，不再单独长成胶囊 */
  .hub-empty .btn,
  .curriculum-empty .btn,
  .card-empty .btn,
  .hub-actions .btn { border-radius: var(--r-sm); }

  .empty-sprout,
  .empty-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto var(--s4);
    border-radius: var(--r-md);
    background: var(--smoke);
    color: var(--leaf);
    font-size: var(--t-h3);
  }

  /* ══ 场景内答题卡（移动端 sheet / 桌面停靠栏）══════════ */
  .object-popover {
    color: var(--ink);
    padding: var(--s4);
  }

  .object-popover h2,
  .object-popover .popover-head h2 {
    font-size: var(--t-lead);
    font-weight: 700;
    line-height: 1.5;
  }

  .popover-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-pill);
    background: var(--smoke);
    color: var(--muted);
  }

  .phrase-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    min-height: 48px;
    padding: var(--s3) var(--s2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--white);
    color: var(--ink);
    font-size: var(--t-meta);
    transition: border-color .14s var(--ease), background-color .14s var(--ease);
  }

  .phrase-option:hover { border-color: var(--leaf); }

  .phrase-option.correct {
    border-color: var(--leaf);
    background: var(--leaf-wash);
    color: var(--leaf);
  }

  .phrase-option.incorrect {
    border-color: var(--rust);
    background: var(--rust-wash);
    color: var(--rust);
  }

  .phrase-option > strong { font-size: var(--t-body); font-weight: 600; }

  .picture-choice-explanation,
  .popover-definition,
  .phrase-translation { color: var(--muted); font-size: var(--t-meta); line-height: 1.7; }

  /* 横向空态里段落要贴左，必须排在通用 .hub-empty p 之后才能赢 */
  @media (min-width: 721px) {
    .hub-empty p { margin-inline: 0; }
  }
}

/* ══ 词条列表：一行一个词（生词本 / 收藏 / 以后任何按单元分组的词表） ══
   行高 52 · 词 150/104 · 音标 96 · 释义吃掉剩余 · 右侧 28px 控件列 ── 与筛选/页头同一条左轴 */
.word-list { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--white); }
.word-list__group { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 13px var(--s4) 7px; background: var(--paper-2); border-bottom: 1px solid var(--smoke); font-size: var(--t-cap); letter-spacing: .08em; color: var(--muted); }
.word-list__group b { font-weight: 600; color: var(--gold); }
.word-row { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 0 var(--s4); min-width: 0; }
.word-row + .word-row { border-top: 1px solid var(--smoke); }
.word-row:hover { background: var(--paper-2); }
.word-row__word { width: 150px; flex-shrink: 0; margin: 0; font-family: var(--font-word); font-weight: 400; font-size: var(--t-lead); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row__ph:has(.ph-part) { width: auto; max-width: 200px; }
.word-row__ph { width: 96px; flex-shrink: 0; font-size: var(--t-cap); color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row__cn { flex: 1; min-width: 0; font-size: var(--t-body); line-height: 1.5; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-row__state { flex-shrink: 0; font-size: var(--t-cap); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.word-row__practice,
.word-row__speak { display: inline-flex; align-items: center; justify-content: center; height: 28px; min-width: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--r-pill); background: transparent; color: var(--leaf); font-size: var(--t-cap); letter-spacing: .02em; flex-shrink: 0; }
.word-row__speak { width: 28px; padding: 0; color: var(--muted); }
.word-row__practice:hover,
.word-row__speak:hover { border-color: var(--leaf); color: var(--leaf); }
/* 多词性音标：v. /rɪˈkɔːd/ · n. /ˈrekɔːd/ */
/* 发音偏好：音标与朗读共用一个开关 */
.accent-switch { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--paper-2); }
.accent-switch button { height: 26px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font-size: var(--t-cap); }
.accent-switch button[aria-pressed=true] { background: var(--leaf-wash); color: var(--leaf-deep); }
.ph-sample { font-family: var(--font-word); color: var(--ink); white-space: nowrap; }
.section-title-row .accent-switch { flex-shrink: 0; }
.ph-part { display: inline-flex; align-items: baseline; gap: 3px; }
.ph-pos { font-style: normal; font-size: var(--t-meta); color: var(--muted); }
.ph-sep { margin: 0 4px; color: var(--line); }
.atlas-word__ph:empty { display: none; }
.word-row .compact-word-actions { display: flex; gap: 2px; flex-shrink: 0; margin: 0; }
.word-row .compact-word-actions > button { width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 0; border: 1px solid transparent; border-radius: var(--r-pill); background: transparent; color: var(--muted); }
.word-row .compact-word-actions > button[aria-pressed=true] { border-color: var(--line); background: var(--leaf-wash); color: var(--leaf-deep); }

/* 手机：一行放不下词 + 练习 + 两个整理键 + 喇叭，
   改成"词/控件在上、释义独占第二行"—— 高度仍然只有一行卡的三分之一，释义不再被挤成两个字 */
@media (max-width: 720px) {
  .word-list { border-radius: var(--r-sm); }
  .word-list__group { padding: 12px 12px 6px; }
  .word-row { flex-wrap: wrap; gap: 3px 6px; padding: 9px 12px; min-height: 0; }
  .word-row__word { flex: 1 1 0; width: auto; min-width: 0; font-size: var(--t-body); line-height: 1.35; }
  .word-row__cn { order: 9; flex: 1 1 100%; font-size: var(--t-meta); line-height: 1.45; }
  .word-row__ph,
  .word-row__state { display: none; }
}
