/* Warm orange theme for CCPhistroy.jianhenghu.com only. */
:root {
  --bg: #fff8ef;
  --surface: #fffefa;
  --surface-soft: #fff1dc;
  --text: #3d2b1d;
  --muted: #806b57;
  --line: #efdcc4;
  --accent: #e59a43;
  --accent-strong: #a85d17;
  --green: #3a9b68;
  --green-soft: #eaf7ef;
  --red: #c94354;
  --red-soft: #fdebed;
  --shadow: 0 6px 20px rgba(133, 82, 28, 0.08);
  --radius-card: 14px;
  --radius-pill: 999px;
  --radius-md: 9px;
  --radius-lg: 12px;
}

body {
  background: linear-gradient(180deg, #fffdf8 0%, #fff8ef 56%, #fff3e2 100%);
}

.timeline-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--surface-soft);
  border: 1px solid var(--accent);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.timeline-entry:hover {
  background: var(--accent);
  color: #fff8ef;
}

/* 「继续上次」是 button 元素，补一点重置让外观与链接入口一致。 */
button.timeline-entry {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
}
button.timeline-entry:active {
  transform: translateY(1px);
}

.question-panel,
.review-item,
.empty-state,
.stats div,
.toolbar,
.plain-button,
select,
.fill-input,
.option-button {
  border-color: var(--line);
  background: var(--surface);
}

.question-panel,
.review-item,
.empty-state {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.workspace:not(.is-hidden),
.question-panel,
.review-item,
.empty-state {
  min-height: 100svh;
}

.segmented {
  border-radius: var(--radius-lg);
}

.segmented button {
  border-radius: var(--radius-md);
  font-weight: 700;
  white-space: nowrap;
}

.segmented button.is-active,
.primary-button,
.toggle-button[aria-pressed="true"] {
  background: linear-gradient(180deg, #eda954 0%, #dc8832 100%);
  box-shadow: 0 10px 22px rgba(199, 119, 35, 0.2);
}

.chapter-filter-control {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.filter-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.chapter-picker {
  position: relative;
}

.chapter-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 150px;
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.chapter-picker > summary::after {
  content: "▾";
  position: absolute;
  right: 12px;
  color: var(--muted);
}

.chapter-picker[open] > summary::after {
  content: "▴";
}

.chapter-picker.is-empty > summary {
  color: var(--red);
}

.chapter-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 80;
  width: 260px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(105, 66, 24, 0.16);
}

.chapter-picker-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.chapter-picker-actions button {
  flex: 1;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.chapter-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.chapter-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--text);
  background: #fff9ee;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.chapter-checks input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.stats span,
.explanation summary,
.auto-clear {
  color: var(--accent-strong);
}

.pill,
.feedback,
.explanation:not([open]),
.explanation-options div {
  background: var(--surface-soft);
}

/* 复习版：未被选中的（非正确答案）选项默认白底，仅用细边框分隔，避免整片暖色显得杂乱。 */
.review-option {
  border: 1px solid var(--line);
  background: var(--surface);
}

/* 正确答案保持绿色高亮（覆盖白底）。 */
.review-option.is-answer {
  border-color: rgba(32, 164, 100, 0.4);
  background: var(--green-soft);
}

/* 仅在有真实指针（鼠标）的设备上应用 hover 高亮。
   触屏点击后 :hover 会"粘住"，会在取消选择后残留一抹淡色、与选中态难以区分，故用 hover 媒体查询排除触屏。 */
@media (hover: hover) {
  .option-button:hover {
    border-color: rgba(229, 154, 67, 0.52);
    background: #fff8ec;
    transform: none;
  }
}

.option-button.is-selected:not(.is-correct):not(.is-wrong) {
  color: #99500e;
  border-color: rgba(229, 154, 67, 0.62);
  background: #ffedcf;
}

.option-button.is-correct,
.option-button.is-correct:hover,
.option-button.is-selected.is-correct,
.option-button.is-selected.is-correct:hover {
  color: #0c6337;
  border-color: rgba(32, 164, 100, 0.48);
  background: var(--green-soft);
}

.option-button.is-wrong,
.option-button.is-wrong:hover,
.option-button.is-selected.is-wrong,
.option-button.is-selected.is-wrong:hover {
  color: #8d2222;
  border-color: rgba(211, 76, 76, 0.45);
  background: var(--red-soft);
}

select:focus,
.fill-input:focus,
.option-button:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(229, 154, 67, 0.24);
  outline-offset: 2px;
}

.explanation-highlight.tone-1 {
  color: #91500f;
  border-left-color: #e59a43;
  background: #fff3df;
}

.explanation-highlight.tone-2 {
  color: #7c5a24;
  border-left-color: #d9aa55;
  background: #fff7e8;
}

.explanation-highlight.tone-3 {
  color: #79532a;
  border-left-color: #d3a65a;
  background: #fff9ed;
}

.explanation-highlight.tone-4 {
  color: #705d4c;
  border-left-color: #c9a47c;
  background: #fffaf3;
}

.explanation-option-details > summary,
.explanation-tags span {
  color: #765e43;
  background: #f9ecd9;
}

.question-head {
  padding: 16px 22px;
  background: transparent;
}

.question-body {
  padding: 26px 28px 24px;
}

.stem {
  margin-bottom: 24px;
}

.options,
.stats {
  gap: 10px;
}

.option-button {
  padding: 16px 18px;
}

.feedback {
  margin-top: 20px;
}

@media (max-width: 760px) {
  :root {
    --mobile-focus-height: calc(100svh + 320px);
  }

  .app-shell {
    gap: 12px;
    padding: 0 10px 168px;
  }

  .study-main,
  .workspace:not(.is-hidden),
  .question-panel,
  .review-item,
  .empty-state {
    min-height: var(--mobile-focus-height);
  }

  .question-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .question-body {
    flex: 1;
    padding: 18px 14px 16px;
  }

  .pill-type,
  .pill-range {
    display: none;
  }

  .question-head {
    gap: 6px;
    padding: 8px 14px;
  }

  .meta-row:empty {
    display: none;
  }

  .toolbar {
    gap: 10px;
    margin-top: 28px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
  }

  .filters {
    gap: 10px;
  }

  .chapter-filter-control {
    min-width: 0;
  }

  .chapter-picker > summary {
    width: 100%;
    min-width: 0;
  }

  .chapter-picker-panel {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 128px;
    left: 12px;
    width: auto;
    max-height: calc(100svh - 180px);
    overflow: auto;
  }

  #randomToggle,
  .auto-clear {
    grid-column: 1 / -1;
    width: 100%;
  }

  .auto-clear select {
    width: 100%;
  }

  .sync-control {
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }

  .nav-action-row {
    right: 0;
    bottom: 0;
    left: 0;
    padding: 10px;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 254, 250, 0.97);
    box-shadow: 0 -8px 28px rgba(133, 82, 28, 0.13);
  }

  .nav-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
      "prev prev next next"
      "answer star master undo";
    gap: 8px;
    width: 100%;
  }

  .nav-actions [data-action="prev"] { grid-area: prev; }
  .nav-actions [data-action="next"] { grid-area: next; }
  .nav-actions [data-action="showAnswer"] { grid-area: answer; }
  .nav-actions [data-action="toggleStar"] { grid-area: star; }
  .nav-actions [data-action="markMastered"] { grid-area: master; }
  .nav-actions [data-action="undo"] { grid-area: undo; }

  .nav-actions.is-answer-hidden {
    grid-template-columns: repeat(6, 1fr);
    grid-template-areas:
      "prev prev prev next next next"
      "star star master master undo undo";
  }

  .nav-actions .nav-button,
  .nav-actions .side-button {
    width: 100%;
    min-width: 0;
  }

  .nav-actions .nav-button {
    min-height: 48px;
    font-weight: 700;
  }

  .nav-actions .side-button {
    min-height: 42px;
    padding: 0 6px;
    font-size: 0.82rem;
  }
}

@media (min-width: 761px) {
  .toolbar,
  .filters {
    align-items: flex-end;
  }

  .filters .compact-button,
  .filters #randomToggle,
  .sync-control {
    min-height: 42px;
  }

  .nav-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .nav-actions .nav-button,
  .nav-actions .side-button {
    min-height: 42px;
  }

  .study-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }
}

/* =========================================================================
   视觉精修（2026-06）：标题栏、工具栏层级、统计区、题目卡片质感提升。
   仅作用于橙色主题覆盖层，不污染根 styles.css 共享基线。
   ========================================================================= */

/* ---------- 顶部标题栏 ---------- */
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.app-header-text {
  min-width: 0;
}
.app-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent-strong);
  line-height: 1.2;
}
.app-subtitle {
  margin: 6px 0 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}
/* 「继续上次」作为标题栏主操作按钮（不再是工具栏里的胶囊入口）。 */
#resumeButton.resume-entry {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff8ef;
  background: linear-gradient(180deg, #eda954 0%, #dc8832 100%);
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 18px rgba(199, 119, 35, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease;
  white-space: nowrap;
}
#resumeButton.resume-entry:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(199, 119, 35, 0.3);
}
#resumeButton.resume-entry:active {
  transform: translateY(0);
}

/* ---------- 工具栏层级重排 ---------- */
.toolbar {
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
/* 把模式分段与入口按钮各自分组，避免挤成一团。 */
.toolbar-entries {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar .filters {
  flex: 1 1 100%;
  justify-content: flex-start;
  gap: 12px 14px;
}

/* ---------- 统计区：主指标 + 次要卡片分层 ---------- */
.stats-rail {
  top: 16px;
}
.stats {
  gap: 10px;
}
.stats div {
  min-height: 0;
  padding: 14px 14px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(133, 82, 28, 0.04);
  transition: transform 160ms ease;
}
.stats div:hover {
  transform: translateY(-1px);
}
.stats span {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.05;
}
.stats small {
  margin-top: 6px;
  font-size: 0.76rem;
  font-weight: 600;
}
/* 全部题：主指标卡，橙色强调。 */
.stats div:first-child {
  background: linear-gradient(160deg, #fff3df 0%, #ffe9c6 100%);
  border-color: rgba(229, 154, 67, 0.45);
}
.stats div:first-child span {
  font-size: 1.7rem;
  color: var(--accent-strong);
}
.stats div:first-child small {
  color: var(--accent-strong);
}

/* ---------- 题目卡片：头部 / pill 排版 ---------- */
.question-head {
  gap: 10px 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffaf0 0%, #fffdf8 100%);
}
.meta-row {
  gap: 7px;
}
.pill {
  min-height: 26px;
  padding: 0 11px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
}
.pill pill-type,
.pill-type {
  color: #fff8ef;
  background: linear-gradient(180deg, #eda954 0%, #dc8832 100%);
}
.pill-index {
  color: var(--accent-strong);
  background: #fff3df;
}
.pill-range {
  color: var(--muted);
  background: #fff7ea;
}

/* ---------- 题干 / 选项：更宽松透气 ---------- */
.question-body {
  padding: 28px 30px 26px;
}
.stem {
  margin-bottom: 22px;
  font-size: clamp(1.1rem, 1.8vw, 1.32rem);
  line-height: 1.8;
}
.options {
  gap: 12px;
}
.option-button {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  line-height: 1.6;
}
/* 字母 key 做成带背景的小圆角 chip。 */
.option-button > strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9em;
  height: 1.9em;
  margin-right: 12px;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 0.92em;
}
.option-button.is-selected > strong,
.option-button.is-picked > strong {
  background: #ffedcf;
  color: #99500e;
}
.option-button.is-correct > strong {
  background: #d6efe1;
  color: #0c6337;
}
.option-button.is-wrong > strong {
  background: #f7d9db;
  color: #8d2222;
}

/* ---------- 反馈 / 解析：间距统一 ---------- */
.feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.95rem;
}
.feedback.is-correct {
  border-color: rgba(32, 164, 100, 0.28);
}
.feedback.is-wrong {
  border-color: rgba(211, 76, 76, 0.28);
}
.explanation {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
}
.explanation summary {
  font-size: 0.98rem;
}

/* ---------- 操作按钮质感统一 ---------- */
.nav-actions .nav-button {
  font-weight: 700;
}

/* ---------- 「移出后暂留」提示条 ---------- */
.pinned-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 6px;
  background: linear-gradient(180deg, #fff3df 0%, #ffe9c6 100%);
  border: 1px solid rgba(229, 154, 67, 0.45);
  border-radius: var(--radius-md);
}
.pinned-banner-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-strong);
}
.pinned-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pinned-undo {
  color: var(--accent-strong);
  border-color: rgba(229, 154, 67, 0.5);
}
.pinned-undo:hover { background: #ffedcf; }
.pinned-question .question-head {
  border-radius: var(--radius-md);
}
/* 「移出错题本」放在主操作行：尺寸与其它操作按钮一致，但保留红色危险色提示。 */
.remove-wrong-button {
  color: var(--red);
  border-color: rgba(211, 76, 76, 0.4);
}
.remove-wrong-button:hover {
  background: var(--red-soft);
  border-color: var(--red);
}
.toggle-button[aria-pressed="true"] {
  border-color: transparent;
}

/* 按钮里的按键提示 chip（如「熟练掌握 e」里的 e）。 */
.key-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  height: 1.4em;
  margin-left: 2px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-family: var(--mono-font, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.78em;
  font-weight: 600;
  line-height: 1;
  color: inherit;
  opacity: 0.75;
}
.remove-wrong-button .key-chip {
  background: rgba(211, 76, 76, 0.08);
  border-color: rgba(211, 76, 76, 0.3);
  color: var(--red);
}

/* ---------- 移动端适配：标题栏与统计区 ---------- */
@media (max-width: 760px) {
  .app-header {
    align-items: center;
    padding: 4px 2px 10px;
    margin-bottom: 0;
  }
  .app-title {
    font-size: 1.28rem;
  }
  .app-subtitle {
    margin-top: 3px;
    font-size: 0.78rem;
  }
  #resumeButton.resume-entry {
    min-height: 40px;
    padding: 0 14px;
    font-size: 0.84rem;
  }
  .stats {
    gap: 6px;
  }
  .stats div:first-child {
    background: linear-gradient(160deg, #fff3df 0%, #ffe9c6 100%);
  }
}

