* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
}

:root {
--tp-topbar-h: 0px;
  --accent: #22c55e;
  --accent-soft: rgba(34,197,94,.12);
  --accent-soft-2: rgba(34,197,94,.18);
  --accent-border: rgba(34,197,94,.35);
  --accent-shadow: rgba(34,197,94,.25);

  --bg-page: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border-strong: rgba(2,6,23,.10);
  --border-subtle: #e5e7eb;
  --text-primary: #111827;
  --text-muted: #6b7280;
  --text-tertiary: #9ca3af;

  --radius-lg: 16px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --shadow-soft: 0 8px 18px rgba(15,23,42,0.06);
  --shadow-card: 0 10px 30px rgba(15,23,42,0.12);
  --shadow-card-strong: 0 14px 35px rgba(15,23,42,0.18);

  --transition-fast: 0.18s ease;

  --sidebar-collapsed: 70px;
  --sidebar-expanded: 220px;
  --sidebar-w: var(--sidebar-collapsed);
  --sidebar-pad: 16px;
  --icon-size: 18px;
  --icon-gap: 10px;
  --menu-item-h: 44px;
  --sb-dur: 500ms;
  --sb-ease: cubic-bezier(.22,1,.36,1);
  --tp-del-slide: 520ms;
  --tp-del-collapse: 260ms;
  --tp-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --tp-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dash-panel-head-h: 44px;
  --dash-panel-gap: 14px;
  --dash-panel-item-h: 88px;
  --dash-panel-foot-h: 28px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  background: var(--bg-page);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  overflow-x: hidden;
  overflow-y: visible;
  padding-left: var(--sidebar-w);
  transition: padding-left var(--sb-dur) var(--sb-ease);
  will-change: padding-left;
}

.title-main {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.title-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.badge {
  font-size: 11px;
  color: #065f46;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 4px 10px;
}

main {
  padding-top: 4px;
}

.course-grid {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.course-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 12px 12px 12px;
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
  text-align: left;
  position: relative;
}

.course-card:hover {
  box-shadow: var(--shadow-card-strong);
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--surface);
}

.course-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.course-thumb {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(34,197,94,.22), rgba(34,197,94,.08));
  aspect-ratio: 16 / 9;
  position: relative;
}

.course-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.course-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 2px 0;
}

.course-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}

.course-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.course-cta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.lesson-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 12px;
  color: #374151;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}

.lesson-pill span {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  margin-right: 4px;
  color: var(--text-tertiary);
}

.lesson-pill:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-0.5px);
  box-shadow: 0 8px 22px var(--accent-shadow);
}

.lesson-pill:hover span {
  color: rgba(255,255,255,.85);
}

@media (max-width: 600px) {
  .page {
    margin: 0;
    padding: 0;
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }
}

/*===== App Layout (Sidebar + Content) =====*/

/*Light sidebar theme*/

.sidebar {
  width: var(--sidebar-w);
  transition: width var(--sb-dur) var(--sb-ease);
  overflow-x: hidden;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 9100;
  padding: var(--sidebar-pad);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: radial-gradient(900px circle at 12% 0%,
      rgba(0,113,227,.45) 0%,
      rgba(0,113,227,0) 55%),
    radial-gradient(900px circle at 95% 90%,
      rgba(34,197,94,.40) 0%,
      rgba(34,197,94,0) 55%),
    linear-gradient(180deg,
      #071a2f 0%,
      #052e1a 55%,
      #04130b 100%);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.14);
  --icon-center: calc(var(--sidebar-collapsed) / 2 - var(--sidebar-pad));
  --text-start: calc(var(--icon-center) + (var(--icon-size) / 2) + var(--icon-gap));
  --active-left: calc(var(--icon-center) - (var(--menu-item-h) / 2));
}

@media (min-width: 861px){
  #sidebarMount.sidebar{
    overflow-y: hidden;
    overflow-anchor: none;
  }

  #sidebarMount .side-scroll{
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin-left: calc(-1 * var(--sidebar-pad));
    margin-right: calc(-1 * var(--sidebar-pad));
    padding-left: var(--sidebar-pad);
    padding-right: var(--sidebar-pad);
    padding-top: 10px;
    padding-bottom: 46px;
    overflow-anchor: none;
  }

  /* Sidebar scrollbar (internal, no layout shift, no text clipping) */
  @supports (scrollbar-gutter: stable){
    #sidebarMount .side-scroll.is-scrollable{
      scrollbar-gutter: stable;
    }
  }

  /* Firefox */
  #sidebarMount .side-scroll{
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
  }

  /* Chromium / Safari */
  #sidebarMount .side-scroll::-webkit-scrollbar{
    width: 8px;
  }
  #sidebarMount .side-scroll::-webkit-scrollbar-track{
    background: transparent;
  }
  #sidebarMount .side-scroll::-webkit-scrollbar-thumb{
    background-color: rgba(255,255,255,.35);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
  }
  #sidebarMount .side-scroll::-webkit-scrollbar-thumb:hover{
    background-color: rgba(255,255,255,.55);
  }

  /* collapsed: hide scrollbar visuals without disabling scroll */
  @supports (scrollbar-gutter: stable){
    #sidebarMount:not(.is-pinned):not(:hover):not(.is-peek) .side-scroll{
      scrollbar-gutter: auto;
    }
  }
  #sidebarMount:not(.is-pinned):not(:hover):not(.is-peek) .side-scroll{
    scrollbar-width: none;
    scrollbar-color: transparent transparent;
  }
  #sidebarMount:not(.is-pinned):not(:hover):not(.is-peek) .side-scroll::-webkit-scrollbar{
    width: 0;
    height: 0;
  }

  /* pinned + scrollable: hide scrollbar visuals until hover (keep scroll) */
  #sidebarMount.is-pinned .side-scroll.is-scrollable{
    scrollbar-width: none;
    scrollbar-color: transparent transparent;
    -ms-overflow-style: none;
  }
  #sidebarMount.is-pinned .side-scroll.is-scrollable::-webkit-scrollbar{
    width: 0;
    height: 0;
  }
  #sidebarMount.is-pinned:hover .side-scroll.is-scrollable,
  #sidebarMount.is-pinned .side-scroll.is-scrollable:hover{
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
  }
  #sidebarMount.is-pinned:hover .side-scroll.is-scrollable::-webkit-scrollbar,
  #sidebarMount.is-pinned .side-scroll.is-scrollable:hover::-webkit-scrollbar{
    width: 8px;
    height: 8px;
  }
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 8px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.sidebar .side-divider{
  height: 0px;
  background: rgba(255,255,255,.22);
  width: calc(100% + var(--sidebar-pad) + var(--sidebar-pad));
  margin-left: calc(-1 * var(--sidebar-pad));
  margin-right: calc(-1 * var(--sidebar-pad));
}

/*让品牌区和下面菜单更远一点*/

.brand-divider {
  margin: -32px 0 16px;
}

.side-foot .side-divider{
  margin: -22px 0 1px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.side-foot {
  margin-top: auto;
  padding-top: 10px;
}

/*Right content area*/

.content {
  flex: 1;
  background: #ffffff;
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

/*Dashboard cards*/

.card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.card-full {
  grid-column: 1 / -1;
}

.muted {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}

/*Stats*/

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 10px;
}

.stat-label {
  font-size: 11px;
  color: #6b7280;
}

.stat-value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
}

/*Calendar*/

.cal-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: rgba(17,24,39,0.92);
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.2;
  box-shadow: 0 14px 35px rgba(15,23,42,0.25);
  transform: translate(-50%, -120%);
  display: none;
  white-space: nowrap;
}

.cal-tooltip.is-open {
  display: block;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-head {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  padding: 2px 0 6px;
}

.cal-day {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  background: #ffffff;
  color: #374151;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}

.cal-day.is-empty {
  border-color: transparent;
  background: transparent;
}

.cal-day.studied {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.cal-day.studied:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15,23,42,0.22);
}

/*===== Dashboard: Review tiles =====*/

.dash-review .review-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.review-tile {
  text-align: left;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease;
}

.review-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 14px 35px rgba(15,23,42,0.12);
}

.review-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rt-name {
  font-size: 13px;
  font-weight: 800;
}

.rt-badge {
  min-width: 32px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 850;
  color: #065f46;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

.rt-sub {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

/*✅ 861–979px：两列时把“容易挤”的卡片改为全宽，整体更干净*/

@media (min-width: 861px) and (max-width: 979px) {
  #view-dashboard .dash-checkin,
    #view-dashboard .dash-review,
    #view-dashboard .dash-recent {
    grid-column: 1 / -1;
  }
}

/*✅ ≥980px：三列时让 Recent 横跨右侧两列，Review 在左侧*/

@media (min-width: 980px) {
  .dash-recent {
    grid-column: 2 / -1;
  }
}

/*Mini lists (Recent Course Packs with covers)*/

.mini-pack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-pack {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: #111827;
}

.mini-pack:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15,23,42,0.10);
}

.mini-pack-thumb {
  width: 88px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(34,197,94,.22), rgba(34,197,94,.08));
  flex: 0 0 auto;
}

.mini-pack-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mini-pack-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mini-pack-title {
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-pack-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/*Tables*/

.table-wrap {
  background: var(--surface);
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 720px;
}

.table th, .table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.table th {
  position: sticky;
  top: 0;
  background: var(--surface-muted);
  z-index: 1;
}

/*Membership*/

.pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.price-name {
  font-weight: 800;
}

.price {
  font-size: 26px;
  font-weight: 900;
  margin-top: 6px;
}

.btn {
  margin-top: 10px;
  width: 100%;
  border: none;
  background: var(--accent);
  color: #f9fafb;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.btn:hover {
  opacity: 0.92;
}

@media (max-width: 860px) {
  /*✅ 手机端不需要左侧让位*/
  /*✅ 手机端不固定*/
  .page {
    padding-left: 0;
    flex-direction: column;
  }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
  .menu {
    flex-direction: row;
    overflow: auto;
  }
  .menu-item {
    white-space: nowrap;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

#view-dashboard .dash-review .review-tiles {
  grid-template-columns: 1fr;
}

/*===== Course detail (lesson list) inside Store view =====*/

#store-pack-view {
  display: block;
}

#store-lesson-view {
  display: none;
}

.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  margin-bottom: 12px;
}

.lesson-title {
  font-size: 20px;
  font-weight: 700;
}

.lesson-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.lesson-back {
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.lesson-grid {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.lesson-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-soft);
  position: relative;
  cursor: pointer;
  transition: box-shadow .18s ease, transform .12s ease, border-color .18s ease;
}

.lesson-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.lesson-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 10px;
}

.lesson-start {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ecfdf5;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
}

/*===== Lesson progress (bottom) =====*/

.lesson-progress {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lesson-progress strong {
  color: #111827;
}

/*✅ 左侧“Progress”固定不被挤没*/

.lp-left {
  flex: 0 0 auto;
  white-space: nowrap;
  color: #6b7280;
  font-size: 12px;
}

/*✅ 右侧组可以缩放/换行，窄卡片也不会挡住左侧文字*/

.lp-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/*✅ 进度条宽度自适应（看起来会和课程包一致）*/

.lp-bar {
  flex: 1 1 120px;
  min-width: 90px;
  max-width: 160px;
  height: 8px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.lp-bar i {
  display: block;
  height: 100%;
  background: var(--accent, #22c55e);
  border-radius: 999px;
}

/*===== Auth UI =====*/

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

/*button*/

.auth-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
}

.auth-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/*modal*/

.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.auth-backdrop.open {
  display: flex;
}

.auth-modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 22px 60px rgba(15,23,42,0.35);
}

.auth-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.auth-title {
  font-weight: 800;
  font-size: 16px;
}

.auth-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.auth-x {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #6b7280;
}

.auth-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.auth-row.right {
  justify-content: flex-end;
}

.auth-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

.auth-msg {
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
}

/*===== Sidebar: 蓝绿渐变 + 白色文字/图标 + 玻璃悬停/选中效果 =====*/

/*品牌文字变白*/

.brand-title {
  color: rgba(255,255,255,.95);
  font-size: 22px;
}

.brand-sub {
  color: rgba(255,255,255,.70);
  font-size: 10.5px;
  margin-top: 8px;
}

/*右下角 badge 也变成“玻璃感”*/

.side-badge {
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.16);
}

/*菜单项：默认透明、白色字*/

.menu-item {
  width: 100%;
  border-radius: 13px;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255,255,255,.92);
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

/*图标容器 + SVG 跟随文字颜色*/

.menu-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
}

.menu-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .95;
}

.menu-text {
  min-width: 0;
}

/*悬停：sidebar 内由 ::before 统一绘制高亮底板*/
.sidebar .menu-item:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/*选中：同样效果但更明显一点（就是你说的“悬停和选择后的效果”）*/

/*键盘聚焦可见*/

.menu-item:focus-visible {
  outline: 2px solid rgba(255,255,255,.70);
  outline-offset: 2px;
}

/*Sidebar 宽度：hover 展开；pin 固定展开*/
.sidebar:not(.is-pinned) { width: var(--sidebar-collapsed); }

.sidebar:not(.is-pinned):hover,
.sidebar:not(.is-pinned).is-peek{
  width: var(--sidebar-expanded);

  /* ✅ 关键：临时展开时，把 sidebar 提到顶栏之上（盖住顶栏，且顶栏不右移） */
  z-index: 20001 !important;
}


/*===== Brand：logo 永远在“折叠居中”位置，文字从右侧出现 =====*/

.sidebar .brand {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 6px 0 calc(var(--text-start) + 10px);
}

#sidebarMount.sidebar .brand{
  position: sticky;
  top: 0;
  z-index: 2;
}

#sidebarMount.sidebar .brand-divider{
  position: sticky;
  top: 66px;
  z-index: 2;
}

#sidebarMount.sidebar .side-foot{
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.sidebar .brand-logo {
  position: absolute;
  left: var(--icon-center);
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1);
}

/*brand text 动画：从右侧淡入，不会“滑到图标下面”*/

.sidebar .brand-text {
  min-width: 0;
  overflow: hidden;
  max-width: 180px;
  opacity: 1;
  transform: none;
  transition: opacity var(--sb-dur) var(--sb-ease), max-width var(--sb-dur) var(--sb-ease);
  will-change: opacity, max-width;
}

.sidebar .brand-title,
.sidebar .brand-sub {
  white-space: nowrap;
}

.sidebar:not(.is-pinned) .brand-text {
  max-width: 0;
  opacity: 0;
  transform: none;
  pointer-events: none;
}

.sidebar:not(.is-pinned):hover .brand-text,
.sidebar:not(.is-pinned).is-peek .brand-text,
.sidebar.is-pinned .brand-text {
  max-width: 180px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/*===== Menu：行高固定（Pin/Unpin 不会行距变化），图标不动，文字从右侧出现 =====*/

.sidebar .menu-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--menu-item-h);
  line-height: 1;
  padding: 0 12px 0 var(--text-start);
  gap: 10px;
}

/*图标：永远居中在折叠宽度中心（展开时也不动）*/

.sidebar .menu-icon {
  position: absolute;
  left: var(--icon-center);
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--icon-size);
  height: var(--icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/*文字：折叠隐藏；hover 或 pinned 出现（从右侧出现，不会压到图标）*/

.sidebar .menu-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 220px;
  opacity: 1;
  transform: none;
  transition: opacity var(--sb-dur) var(--sb-ease), max-width var(--sb-dur) var(--sb-ease);
  will-change: opacity, max-width;
}

.sidebar:not(.is-pinned) .menu-text {
  max-width: 0;
  opacity: 0;
  transform: none;
  pointer-events: none;
}

.sidebar:not(.is-pinned):hover .menu-text,
.sidebar:not(.is-pinned).is-peek .menu-text,
.sidebar.is-pinned .menu-text {
  max-width: 220px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.sidebar .menu-group {
  position: relative;
}

.sidebar .menu-group::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--active-left);
  right: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 14px 35px rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 0;
}

.sidebar .menu-group > * {
  position: relative;
  z-index: 1;
}

.sidebar .menu-group.is-open:hover::before {
  opacity: 1;
}

.sidebar .menu-group.is-open.has-subactive::before {
  opacity: 1;
}

.sidebar:not(.is-pinned):not(:hover):not(.is-peek) .menu-group.is-open.has-subactive::before{
  right: auto;
  bottom: auto;
  top: 0;
  width: var(--menu-item-h);
  height: var(--menu-item-h);
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 16px 40px rgba(0,0,0,.30);
  border-radius: 12px;
}

.sidebar .menu-group.is-open:hover .menu-item::before {
  opacity: 0;
}

.sidebar .menu-group.is-open.has-subactive .menu-item::before {
  opacity: 0;
}

.sidebar .menu-group.is-open .menu-parent:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sidebar .menu-group.is-open .menu-subitem:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sidebar .menu-parent {
  display: flex;
  align-items: center;
}

.sidebar .menu-parent .menu-text {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar .menu-caret {
  flex: 0 0 auto;
  margin-left: auto;
  opacity: .8;
  transition: transform .15s ease, opacity .15s ease;
}

.sidebar .menu-parent[aria-expanded="true"] .menu-caret {
  transform: rotate(180deg);
  opacity: 1;
}

.sidebar:not(.is-pinned):not(:hover):not(.is-peek) .menu-parent .menu-caret {
  opacity: 0;
  pointer-events: none;
}

.sidebar .menu-submenu {
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  transition:
    max-height var(--sb-dur) var(--sb-ease),
    opacity var(--sb-dur) var(--sb-ease),
    margin-top var(--sb-dur) var(--sb-ease);
  pointer-events: none;
}

.sidebar .menu-group.is-open .menu-submenu {
  max-height: 240px;
  opacity: 1;
  margin-top: 13px;
  margin-bottom: 0;
  pointer-events: auto;
}

.sidebar:not(.is-pinned):not(:hover):not(.is-peek) .menu-group.is-open .menu-submenu {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.sidebar .menu-subitem {
  height: var(--menu-item-h);
  font-size: inherit;
  padding-left: var(--text-start);
}

.sidebar .menu-subitem .menu-text {
  padding-left: 0;
}

/* Submenu: keep text aligned with parent text; no dot in icon slot */
.sidebar .menu-subitem .menu-icon::before {
  content: "";
  display: none;
}

.sidebar .menu-subitem.is-subactive .menu-text,
.sidebar .menu-subitem.is-active .menu-text,
.sidebar .menu-subitem:hover .menu-text {
  font-weight: 700;
}

.sidebar .menu-subitem.is-subactive .menu-text {
  color: rgba(255,255,255,.98);
}

/*===== Collapsed: active highlight square size = expanded row height =====*/

/*===== Active highlight: animate between square (collapsed) and full pill (expanded) =====*/

/*让内容永远在高亮层上面*/

.sidebar .menu-item .menu-icon {
  z-index: 1;
}

.sidebar .menu-item .menu-text {
  position: relative;
  z-index: 1;
}

/*Active 本体不直接画背景，全部交给 ::before（这样不会“跳”）*/

.sidebar .menu-item.is-active {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  font-weight: 700;
  color: rgba(255,255,255,.98);
}

/* 子菜单 active 时：父级菜单文字不加粗（仅 sidebar 作用域） */
.sidebar .menu-parent.has-active-child .menu-text {
  font-weight: 400 !important;
}

/*Active 的高亮层：默认按“展开态整条”来画*/

.sidebar .menu-item::before {
  content: "";
  position: absolute;
  top: 50%;
  left: var(--active-left);
  transform: translateY(-50%);
  width: calc(100% - var(--active-left));
  height: var(--menu-item-h);
  border-radius: 12px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 16px 40px rgba(0,0,0,.30);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 0;
  opacity: 0;
  transition: left var(--sb-dur) var(--sb-ease),
    width var(--sb-dur) var(--sb-ease),
    height var(--sb-dur) var(--sb-ease),
    box-shadow var(--sb-dur) var(--sb-ease),
    background var(--sb-dur) var(--sb-ease),
    border-color var(--sb-dur) var(--sb-ease),
    opacity var(--sb-dur) var(--sb-ease);
}

/*Hover/Active：显示同一块底板*/
.sidebar .menu-item:hover::before,
.sidebar .menu-item.is-active::before {
  opacity: 1;
}

/*折叠态：把高亮“缩成正方形”，位置在图标中心*/

.sidebar:not(.is-pinned):not(:hover):not(.is-peek) .menu-item::before {
  width: var(--menu-item-h);
  height: var(--menu-item-h);
}

/*default hidden blocks (no inline style)*/

#recent-pack-empty,
#recent-pack-all-empty,
#my-pack-empty,
#mistake-table-empty {
  display: none;
}

.mini-pack-empty {
  cursor: default;
  width: 100%;
  justify-content: center;
  text-align: center;
}
.mini-pack-empty:hover {
  border-color: #e5e7eb;
  box-shadow: none;
}
.mini-pack-empty .mini-pack-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.mini-pack-empty .recent-empty-title {
  margin-bottom: 28px;
  color: #9ca3af;
}
.mini-pack-empty .recent-empty-cta {
  text-decoration: none;
}
.mini-pack-empty .recent-empty-cta:hover {
  text-decoration: none;
}

/*===== Store header (header-left / detail header) =====*/

.header-left {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-width: 0;
}

.detail-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
}

.detail-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.back-icon {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
}

.back-icon:hover {
  border-color: var(--accent);
}

.detail-title {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#detailHeader{
  display: none;                  /* 默认仍然隐藏：JS 打开详情时会改成 block */
  position: sticky;
  top: 40px;
  z-index: 2;

  background: #fff;               /* ✅ 背景改成白色 */
  padding: 0 14px;        /* ✅ 让左边缩进，和下面 .card 里的内容对齐 */
  box-sizing: border-box; /* ✅ 防止加 padding 后宽度计算出问题 */
}

/* ✅ 吸顶生效时：高度变为现在的约 1.5 倍（通过上下 padding 拉高） */
#detailHeader.is-stuck .detail-topbar{
  padding: 10px 0;
}


/*===== Store course hero =====*/

.course-hero {
  display: flex;
  gap: 14px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  margin: 10px 0 12px;
}

.hero-thumb {
  width: 220px;
  max-width: 40%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(34,197,94,.22), rgba(34,197,94,.08));
  flex: 0 0 auto;
}

.hero-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hero-title {
  font-size: 18px;
  font-weight: 800;
}

.hero-desc {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.hero-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

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

.hero-start.is-added {
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  color: #6b7280;
  cursor: default;
  pointer-events: none;
  opacity: 1;
}

.hero-start {
  margin-top: 8px;
  align-self: flex-start;
  border: 1px solid #e5e7eb;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.hero-start:hover {
  opacity: .92;
}

@media (max-width: 720px) {
  .course-hero {
    flex-direction: column;
  }
  .hero-thumb {
    width: 100%;
    max-width: none;
  }
}

/*================================
   Progress page styles
   (scoped to body[data-active="progress"])
==================================*/

body[data-active="progress"] .grid {
  display: grid;
  gap: 14px;
}

body[data-active="progress"] .kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

body[data-active="progress"] .kpi {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 18px rgba(15,23,42,0.05);
}

body[data-active="progress"] .kpi-label {
  font-size: 11px;
  color: #6b7280;
}

body[data-active="progress"] .kpi-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .01em;
}

body[data-active="progress"] .kpi-sub {
  margin-top: 6px;
  font-size: 11px;
  color: #9ca3af;
}

body[data-active="progress"] .two-col {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
}

body[data-active="progress"] .mini-days {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

body[data-active="progress"] .day-dot {
  height: 26px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #6b7280;
  user-select: none;
}

body[data-active="progress"] .day-dot.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

body[data-active="progress"] .bar-wrap {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  height: 12px;
  margin-top: 8px;
}

body[data-active="progress"] .bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 10px 25px var(--accent-shadow);
  transition: width .35s ease;
}

body[data-active="progress"] .trend {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
}

body[data-active="progress"] .trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

body[data-active="progress"] .trend-bar {
  width: 100%;
  border-radius: 12px;
  background: #e5e7eb;
  height: 10px;
  transition: height .35s ease;
}

body[data-active="progress"] .trend-bar.is-on {
  background: var(--accent);
}

body[data-active="progress"] .trend-label {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/*Responsive for progress page*/

@media (max-width: 860px) {
  body[data-active="progress"] .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body[data-active="progress"] .two-col {
    grid-template-columns: 1fr;
  }
  body[data-active="progress"] .mini-days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

/*===== Progress extras =====*/

.simple-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.simple-table th,
.simple-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(2,6,23,.10);
  white-space: nowrap;
}

.simple-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  text-align: left;
  font-weight: 700;
}

.simple-table tbody tr:hover {
  background: rgba(15,23,42,.04);
}

.simple-table tbody tr:last-child td {
  border-bottom: none;
}

body[data-active="progress"] .btn {
  border: 1px solid rgba(2,6,23,.10);
  background: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

body[data-active="progress"] .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15,23,42,.08);
}

body[data-active="progress"] .btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/*===== Progress chart controls =====*/

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.chart-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.10);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.chip input {
  margin: 0;
}

.legend-box {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.chart-ranges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.seg {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.10);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}

.seg.is-active {
  background: var(--accent-soft, rgba(34,197,94,.12));
  border-color: var(--accent-border, rgba(34,197,94,.35));
}

.chart-ranges .seg.is-disabled {
  opacity: .45;
  cursor: not-allowed;
}

/*=========================
   Settings page (scoped)
   =========================*/

html[data-theme="light"] body[data-active="settings"] {
  --tp-bg-body: #f7f7f9;
  --tp-bg-surface: #ffffff;
  --tp-bg-surface-alt: #f9fafb;
  --tp-border-subtle: #e5e7eb;
  --tp-text-main: #111827;
  --tp-text-muted: #6b7280;
  --tp-accent: #22c55e;
}

html[data-theme="dark"] body[data-active="settings"] {
  --tp-bg-body: #020617;
  --tp-bg-surface: #0b1220;
  --tp-bg-surface-alt: #0f172a;
  --tp-border-subtle: #1f2937;
  --tp-text-main: #e5e7eb;
  --tp-text-muted: #9ca3af;
  --tp-accent: #22c55e;
}

body[data-active="settings"] {
  background: var(--tp-bg-body);
  color: var(--tp-text-main);
}

/*===== Shared: Disabled rows (Settings page + Practice settings overlay) =====*/

body[data-active="settings"] .settings-slider-row.disabled,
.settings-overlay .settings-slider-row.disabled,
body[data-active="settings"] .simple-toggle.disabled,
.settings-overlay .simple-toggle.disabled {
  opacity: 0.45;
}

body[data-active="settings"] .settings-slider-row.disabled input[type="range"],
.settings-overlay .settings-slider-row.disabled input[type="range"] {
  pointer-events: none;
  cursor: not-allowed;
}

/*WebKit track/thumb*/

body[data-active="settings"] .settings-slider-row.disabled input[type="range"]::-webkit-slider-runnable-track,
body[data-active="settings"] .settings-slider-row.disabled input[type="range"]:disabled::-webkit-slider-runnable-track,
.settings-overlay .settings-slider-row.disabled input[type="range"]::-webkit-slider-runnable-track,
.settings-overlay .settings-slider-row.disabled input[type="range"]:disabled::-webkit-slider-runnable-track {
  background: rgba(230,230,230) !important;
}

body[data-active="settings"] .settings-slider-row.disabled input[type="range"]::-webkit-slider-thumb,
body[data-active="settings"] .settings-slider-row.disabled input[type="range"]:disabled::-webkit-slider-thumb,
.settings-overlay .settings-slider-row.disabled input[type="range"]::-webkit-slider-thumb,
.settings-overlay .settings-slider-row.disabled input[type="range"]:disabled::-webkit-slider-thumb {
  background: #cbd5e1 !important;
}

/*Firefox*/

body[data-active="settings"] .settings-slider-row.disabled input[type="range"]::-moz-range-track,
body[data-active="settings"] .settings-slider-row.disabled input[type="range"]:disabled::-moz-range-track,
.settings-overlay .settings-slider-row.disabled input[type="range"]::-moz-range-track,
.settings-overlay .settings-slider-row.disabled input[type="range"]:disabled::-moz-range-track {
  background: rgba(230,230,230) !important;
}

body[data-active="settings"] .settings-slider-row.disabled input[type="range"]::-moz-range-thumb,
body[data-active="settings"] .settings-slider-row.disabled input[type="range"]:disabled::-moz-range-thumb,
.settings-overlay .settings-slider-row.disabled input[type="range"]::-moz-range-thumb,
.settings-overlay .settings-slider-row.disabled input[type="range"]:disabled::-moz-range-thumb {
  background: #cbd5e1 !important;
}

/*text grey*/

body[data-active="settings"] .settings-slider-row.disabled .settings-slider-label,
body[data-active="settings"] .settings-slider-row.disabled .settings-slider-label strong,
body[data-active="settings"] .settings-slider-row.disabled .settings-slider-label span,
body[data-active="settings"] .settings-slider-row.disabled .settings-slider-value,
.settings-overlay .settings-slider-row.disabled .settings-slider-label,
.settings-overlay .settings-slider-row.disabled .settings-slider-label strong,
.settings-overlay .settings-slider-row.disabled .settings-slider-label span,
.settings-overlay .settings-slider-row.disabled .settings-slider-value {
  color: var(--tp-text-muted) !important;
}

/*header actions on the right*/





/*keep same inner spacing as dashboard cards*/

body[data-active="settings"] #view-settings {
  padding: 16px 20px 26px;
}


/* Settings layout helpers (keep window scrollbar + center panel) */
body[data-active="settings"] #view-settings .wrap{
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0;
}

body[data-active="settings"] #view-settings .settings-dialog{
  width: 95%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Prevent header-actions from shifting when “Saved” appears */
body[data-active="settings"] #savedBadge.settings-saved{
  min-width: 46px;         /* 预留更紧凑 */
  height: 28px;            /* 胶囊更矮（文字不变） */
  padding: 0 8px;          /* 两侧留白更小 */
  flex-shrink: 0;          /* 不会被挤到盖住 Reset */
  max-width: none;

  opacity: 0;
  visibility: hidden;
  transform: translateY(-1px);
  pointer-events: none;
  transition: opacity .18s, transform .18s, visibility 0s linear .18s;
}


body[data-active="settings"] #savedBadge.settings-saved.show{
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity .18s, transform .18s, visibility 0s;
}

/*settings container*/

body[data-active="settings"] .settings-dialog {
  background: var(--tp-bg-surface);
  border: 1px solid var(--tp-border-subtle);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15,23,42,0.16);
  padding: 18px 18px 16px;
  min-height: min(78vh, 860px);
  display: flex;
  flex-direction: column;
}

body[data-active="settings"] .settings-body {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  flex: 1;
  min-height: 0;
}

body[data-active="settings"] .settings-sidebar {
  width: 160px;
  border-right: 1px solid var(--tp-border-subtle);
  padding-right: 10px;
  overflow: visible;
}

body[data-active="settings"] .settings-section-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body[data-active="settings"] .settings-section-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  color: var(--tp-text-muted);
  cursor: pointer;
  transition: background .15s,border-color .15s,color .15s;
}

body[data-active="settings"] .settings-section-btn:hover {
  background: rgba(34,197,94,.10);
  color: var(--tp-text-main);
}

body[data-active="settings"] .settings-section-btn.active {
  background: var(--tp-accent);
  border-color: var(--tp-accent);
  color: #fff;
  font-weight: 650;
}

/* ===== Settings section icons (shared: Settings page + Settings overlay) ===== */
body[data-active="settings"] .settings-section-btn,
.settings-overlay .settings-section-btn{
  display: flex;
  align-items: center;
  gap: 10px;
}

.tp-settings-icon{
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tp-settings-icon svg{
  width: 18px;
  height: 18px;
  display: block;
}

body[data-active="settings"] .settings-section-title,
.settings-overlay .settings-section-title{
  display: flex;
  align-items: center;
  gap: 8px;
}

body[data-active="settings"] .settings-content-area {
  flex: 1;
  min-height: 0;
  overflow: visible;
  padding: 2px 14px 2px 6px;
}

body[data-active="settings"] .settings-section-content {
  display: none;
}

body[data-active="settings"] .settings-section-content.active {
  display: block;
}

body[data-active="settings"] .settings-section-title {
  font-size: 15px;
  font-weight: 750;
  margin-bottom: 6px;
}

body[data-active="settings"] .settings-section-desc {
  font-size: 13px;
  color: var(--tp-text-muted);
  margin-bottom: 14px;
  line-height: 1.35;
  max-width: 520px;
}

body[data-active="settings"] .toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 14px;
}

body[data-active="settings"] .simple-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--tp-border-subtle);
  font-size: 13px;
  color: var(--tp-text-main);
}

body[data-active="settings"] .simple-toggle span {
  flex: 1;
  line-height: 1.2;
}

/*switch*/

body[data-active="settings"] .simple-toggle input {
  margin: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: #e5e7eb;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s ease;
}

body[data-active="settings"] .simple-toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.2);
  transition: transform .2s ease;
}

body[data-active="settings"] .simple-toggle input:checked {
  background: var(--tp-accent);
}

body[data-active="settings"] .simple-toggle input:checked::before {
  transform: translateX(18px);
}

body[data-active="settings"] .settings-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--tp-border-subtle);
}

body[data-active="settings"] .settings-slider-label {
  flex: 1;
  font-size: 13px;
  color: var(--tp-text-main);
  line-height: 1.2;
}

body[data-active="settings"] .settings-slider-label strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

body[data-active="settings"] .settings-slider-label span {
  font-size: 12px;
  color: var(--tp-text-muted);
}

body[data-active="settings"] .settings-slider-control {
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body[data-active="settings"] .settings-slider-value {
  font-size: 12px;
  color: var(--tp-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

body[data-active="settings"] .settings-select {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
}

body[data-active="settings"] .theme-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

body[data-active="settings"] .theme-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  font-size: 12px;
  cursor: pointer;
  color: var(--tp-text-main);
}

body[data-active="settings"] .theme-mode-btn.active {
  border-color: var(--tp-accent);
  background: rgba(34,197,94,.12);
  color: var(--tp-accent);
}

/*shortcuts (shared: Settings page + Settings overlay)*/

body[data-active="settings"] .settings-shortcut-list,
.settings-overlay .settings-shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

body[data-active="settings"] .settings-shortcut-group-title,
.settings-overlay .settings-shortcut-group-title {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--tp-text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

body[data-active="settings"] .settings-shortcut-item,
.settings-overlay .settings-shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--tp-border-subtle);
}

body[data-active="settings"] .shortcut-tag,
.settings-overlay .shortcut-tag {
  font-size: 12px;
  color: var(--tp-text-muted);
  flex-shrink: 0;
}

body[data-active="settings"] .note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--tp-text-muted);
  line-height: 1.45;
}

@media (max-width: 720px) {
  body[data-active="settings"] .settings-body {
    flex-direction: column;
  }
  body[data-active="settings"] .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--tp-border-subtle);
    padding-bottom: 10px;
  }
}

/*===== Prevent sidebar flash during first paint =====*/

.page:not(.sb-ready) .sidebar,
.page:not(.sb-ready) .content,
.page:not(.sb-ready) .menu-item {
  transition: none !important;
}

/*===== Dashboard: Study Summary square + tabs =====*/

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.summary-tab {
  border: 1px solid rgba(148,163,184,.35);
  background: rgba(148,163,184,.10);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.summary-tab.is-active {
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.14);
  color: #16a34a;
  font-weight: 700;
}

.summary-square {
  background: transparent;   /* 去掉背景 */
  border: none;              /* 去掉边框 */
  padding: 0;                /* 去掉内边距 */
  border-radius: 0;

  display: flex;
  gap: 20px;                 /* 两个卡片之间的距离 */
}


.summary-metric + .summary-metric {
  border-top: 1px solid rgba(148,163,184,.22);
  padding-top: 12px;
}

.summary-value {
  font-size: 36px;
  font-weight: 850;
  line-height: 1.05;
}

.summary-label {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(100,116,139,1);
}

/*===== Check-in (Last 7 Days) =====*/

.checkin {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

/*My Packs - hint above pack list*/

.pack-hint {
  margin: 0 0 12px;
  font-size: 13px;
}

.pack-hint-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-border);
}

.pack-hint-link:hover {
  text-decoration: underline;
}

/*===== Dashboard compact mode (scoped) =====*/

/*===== Study Summary compact =====*/

.card-summary {
  padding: 12px;
}

.card-summary .card-title-row {
  gap: 10px;
}

.card-summary .summary-tabs {
  gap: 6px;
}

.card-summary .summary-tab {
  padding: 5px 8px;
  font-size: 11px;
}

.card-summary .summary-square {
  width: 260px;
  padding: 12px;
  border-radius: 16px;
  gap: 10px;
}

.card-summary .summary-value {
  font-size: 28px;
}

.card-summary .summary-label {
  font-size: 11px;
}

/*===== Put Summary + Calendar + Check-in in one row (desktop) =====*/

@media (min-width: 980px) {
  /*让 Study Summary 不再占满整行（覆盖 card-full 的行为）*/
  .dash-grid .card-summary.card-full {
    grid-column: auto !important;
  }
  /*Leaderboard 仍然保持全宽*/
  .dash-grid .card.card-full:not(.card-summary) {
    grid-column: 1 / -1;
  }
}

/*===== Check-in tighter =====*/

#view-dashboard .checkin {
  gap: 8px;
}

/*卡片在网格里顶部对齐，看起来更规整*/

/*Summary 的正方形居中，避免卡片很宽但内容偏一侧显得乱*/

#view-dashboard .card-summary .summary-square {
  margin-inline: auto;
}

/*===== Recent Course Packs tighter =====*/

#view-dashboard .mini-pack {
  padding: 8px;
}

/*Progress line chart*/

.chart-wrap {
  position: relative;
  height: 320px;
}

#progressLineChart {
  width: 100%;
  height: 100%;
  display: block;
}

/*===== My Packs: prominent hint + button =====*/

.pack-hint-strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--accent-border, rgba(34,197,94,.35));
  background: var(--accent-soft, rgba(34,197,94,.12));
  margin-bottom: 14px;
}

.pack-hint-text {
  font-weight: 700;
}

.pack-hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-border, rgba(34,197,94,.35));
  background: rgba(255,255,255,.7);
  text-decoration: none;
  font-weight: 800;
}

.pack-hint-btn:hover {
  background: rgba(255,255,255,.92);
}

/*===== My Packs: course card remove button (hover to show) =====*/

.course-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.15);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(.92);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.course-card:hover .course-remove,
.course-card:focus-within .course-remove {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/*===== My Packs: progress at the bottom =====*/

.course-progress {
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
  opacity: .8;
}

/*===== Course Library categories =====*/

.cat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.cat-chip {
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.cat-chip:hover {
  transform: translateY(-1px);
}

.cat-chip.is-active {
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.12);
}

/*===== Store + My Packs: grid columns (single maintenance point) =====*/
/* 只改这里：不同屏宽下“课程包列表”和“课时列表”的列数 */
body[data-active="store"],
body[data-active="my-packs"]{
  --pack-grid-cols: 4;
  --lesson-grid-cols: 4;
}

@media (max-width: 1100px) {
  body[data-active="store"],
  body[data-active="my-packs"]{
    --pack-grid-cols: 3;
    --lesson-grid-cols: 3;
  }
}

@media (max-width: 820px) {
  body[data-active="store"],
  body[data-active="my-packs"]{
    --pack-grid-cols: 2;
    --lesson-grid-cols: 2;
  }
}

@media (max-width: 520px) {
  body[data-active="store"],
  body[data-active="my-packs"]{
    --pack-grid-cols: 1;
    --lesson-grid-cols: 1;
  }
}

body[data-active="store"] #store-pack-view .course-grid,
body[data-active="my-packs"] #store-pack-view .course-grid{
  grid-template-columns: repeat(var(--pack-grid-cols), minmax(0, 1fr));
}

body[data-active="store"] #store-lesson-view .lesson-grid,
body[data-active="my-packs"] #store-lesson-view .lesson-grid{
  grid-template-columns: repeat(var(--lesson-grid-cols), minmax(0, 1fr));
}

/*===== Lesson cards: clickable + badges =====*/

.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(15,23,42,0.12);
  border-color: var(--accent);
}

.lesson-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lesson-card:focus {
  outline: none;
}

/*===== Course card extra lines =====*/

.course-progress strong {
  font-weight: 800;
}

.course-submeta {
  margin-top: 6px;
  font-size: 12px;
  opacity: .75;
}

/*===== Lesson cards: "Last studied" highlight =====*/

.lesson-card.is-last {
  border-color: var(--accent-border);
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  background: var(--accent-soft);
}

/*right-top order like #1*/

.lesson-ord {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  opacity: .75;
  font-weight: 800;
}

/*badges row*/

.lesson-badges {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lesson-badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.75);
}

.lesson-badge.is-last {
  border-color: var(--accent-border);
  background: var(--accent-soft-2);
}

/*===== Course card progress (same vibe as lesson progress) =====*/

.course-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-left {
  flex: 0 0 auto;
  white-space: nowrap;
}

.cp-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cp-bar {
  flex: 1 1 120px;
  min-width: 90px;
  max-width: 160px;
  height: 8px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
  border: none;
}

.cp-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent, #22c55e);
  border-radius: 999px;
}

/*=== Settings 中开关排版：文字在左，开关在右 ===*/

/*=========================
   Type-Pinyin practice (scoped)
   =========================*/

html[data-theme="light"] body[data-active="practice"] {
  --tp-bg-body: #f7f7f9;
  --tp-bg-surface: #ffffff;
  --tp-bg-surface-alt: #f9fafb;
  --tp-border-subtle: #e5e7eb;
  --tp-text-main: #111827;
  --tp-text-muted: #6b7280;
  --tp-accent: var(--accent, #22c55e);
  --fs-ui-offset: 0px;
}

html[data-theme="dark"] body[data-active="practice"] {
  --tp-bg-body: #020617;
  --tp-bg-surface: #020617;
  --tp-bg-surface-alt: #020617;
  --tp-border-subtle: #1f2937;
  --tp-text-main: #e5e7eb;
  --tp-text-muted: #9ca3af;
  --tp-accent: var(--accent, #22c55e);
  --fs-ui-offset: 0px;
}

body[data-active="practice"] {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--tp-bg-body);
  color: var(--tp-text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/*Top bar*/

body[data-active="practice"] .topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  background: var(--tp-bg-surface);
  border-bottom: 1px solid var(--tp-border-subtle);
  font-size: 14px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--tp-text-main);
}

.top-sub {
  color: var(--tp-text-muted);
  cursor: pointer;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--tp-text-muted);
  font-size: 13px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 4px;
}

.timer-icon {
  font-size: 20px;
}

#timer-text {
  display: inline-block;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 6px 22px 6px 0;
}

/*如果想跟上面进度条“贴紧一点／拉开一点”，改这里的 padding 即可*/

/*Back button*/

.back-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--tp-text-main);
  padding: 0;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.back-btn:hover {
  background: var(--tp-bg-surface);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  transform: translateY(-0.5px);
}

.back-btn:active {
  box-shadow: none;
  transform: translateY(0);
}

/*Buttons in top-right*/

.settings-wrapper {
  position: relative;
}

.settings-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--tp-text-main);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s, color 0.15s;
}

.settings-btn-icon {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

body[data-active="practice"] .theme-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

body[data-active="practice"] .theme-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  font-size: 12px;
  cursor: pointer;
  color: var(--tp-text-main);
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.theme-mode-btn .icon {
  font-size: 14px;
}

.theme-mode-btn:hover {
  background: var(--tp-bg-surface);
  box-shadow: 0 4px 10px rgba(15,23,42,0.12);
  transform: translateY(-1px);
}

body[data-active="practice"] .theme-mode-btn.active {
  border-color: #22c55e;
  background: rgba(0, 113, 227, 0.12);
  color: #22c55e;
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.25);
}

.settings-btn:hover {
  background: var(--tp-bg-surface);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  transform: translateY(-0.5px);
}

.settings-btn:active {
  box-shadow: none;
  transform: translateY(0);
}

/*“Always show answer” 按钮激活时变绿*/

.settings-btn.answer-active {
  background: #22c55e;
  border-color: #16a34a;
  color: #ffffff;
}

.settings-btn.answer-active:hover {
  background: #16a34a;
}

/*原 settings-panel (保留样式, 当前不用)*/

.settings-panel {
  position: absolute;
  top: 36px;
  right: 0;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 30px rgba(15,23,42,0.12);
  padding: 10px 12px;
  min-width: 210px;
  display: none;
  z-index: 20;
}

.settings-panel.open {
  display: block;
}

.settings-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 6px;
}

.settings-panel hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 6px 0;
}

/*Sentence list panel*/

.sentence-list-panel {
  position: absolute;
  top: 36px;
  left: 16px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 30px rgba(15,23,42,0.12);
  padding: 10px 12px;
  min-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 25;
}

.sentence-list-title {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 6px;
}

.sentence-item {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: #111827;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.sentence-item-index {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
  min-width: 22px;
  text-align: right;
}

.sentence-item-text {
  flex: 1;
}

.sentence-item:hover {
  background: #f3f4f6;
}

.sentence-item.current {
  background: #eef2ff;
  color: #4338ca;
}

/*Top progress bar*/

body[data-active="practice"] .progress-bar-wrapper {
  width: 100%;
  height: 3px;
  background: #e5e7eb;
}

body[data-active="practice"] .progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0071E3, #22c55e);
  transition: width 0.3s ease;
}

/*Main content – 改为顶部对齐，整体上移，但留出气泡空间*/

body[data-active="practice"] .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(120px + var(--fs-ui-offset)) 20px 16px;
  position: relative;
}

/*Shadow 模式：同样补偿*/

.main.shadow-mode {
  padding-top: calc(100px + var(--fs-ui-offset));
}

/*Top pinyin hint bubble*/

body[data-active="practice"] .pinyin-hint {
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 16px;
  border: 2px solid #111827;
  background: #ffffff;
  color: #111827;
  font-size: 32px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 18px rgba(15,23,42,0.18);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

body[data-active="practice"] .pinyin-hint.show{
  visibility: visible !important;
  opacity: 1 !important;
}


.pinyin-hint .pinyin {
  font-size: inherit;
  font-family: inherit;
  letter-spacing: 1px;
}

/*Word meaning bubble (review)*/

body[data-active="practice"] .word-meaning {
  position: absolute;
  left: -9999px;
  top: -9999px;
  transform: translateX(-50%);
  width: max-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-size: 24px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  z-index: 15;
}

body[data-active="practice"] .word-meaning.is-visible {
  visibility: visible;
  opacity: 1;
}

.tp-word-popover {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(6px) scale(.98);
  transition: opacity 200ms ease, transform 200ms ease;
  display: none;
}

.tp-word-popover.is-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tp-word-popover-head {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.tp-word-popover-head-center {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tp-word-popover-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  max-width: 100%;
}

.tp-word-popover-pinyin {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.32;
}

.tp-word-popover-hanzi {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.32;
  margin-bottom: 0;
}

.tp-word-popover-play-btn {
  appearance: none;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  margin-left: 2px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}

.tp-word-popover-play-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.tp-word-popover-play-btn:active {
  transform: translateY(1px);
}

.tp-word-popover-play-btn svg {
  width: 14px;
  height: 14px;
}

.tp-word-popover-play-btn:disabled {
  opacity: .5;
  cursor: default;
  background: var(--tp-bg-surface-alt, transparent);
  color: var(--text-muted);
}

.tp-word-popover-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0 0 8px;
}

.tp-word-popover-section-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.tp-word-popover-meaning {
  font-size: 15px;
  line-height: 1.68;
  color: var(--text-primary);
  margin-bottom: 14px;
  word-break: break-word;
  white-space: normal;
}

.tp-word-popover.is-detail-mode .tp-word-popover-meaning {
  max-height: min(45vh, 360px);
  overflow: auto;
  padding-right: 2px;
}

.tp-word-popover-meaning .tp-md {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tp-word-popover-meaning .tp-md p,
.tp-word-popover-meaning .tp-md-kv {
  margin: 0;
}

.tp-word-popover-meaning .tp-md-h3 {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
}

.tp-word-popover-meaning .tp-md-ul {
  margin: 0;
  padding-left: 18px;
}

.tp-word-popover-meaning .tp-md-li {
  margin: 2px 0;
}

.tp-word-popover-meaning .tp-md strong {
  font-weight: 700;
}

.tp-word-popover-meaning .tp-md code {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.08);
}

.tp-word-popover-meaning .tp-md-code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.06);
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

[data-theme="dark"] .tp-word-popover-meaning .tp-md code,
[data-theme="dark"] .tp-word-popover-meaning .tp-md-code {
  background: rgba(255, 255, 255, 0.08);
}

.tp-word-popover-meaning .tp-md-label {
  font-weight: 700;
  color: var(--text-muted);
}

.tp-word-popover-pos-group + .tp-word-popover-pos-group {
  margin-top: 10px;
}

.tp-word-popover-pos {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tp-word-popover-pos-list {
  margin: 0;
  padding-left: 18px;
}

.tp-word-popover-def {
  font-size: 14px;
  line-height: 1.65;
  margin: 3px 0;
}

.tp-word-popover-meaning-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tp-word-popover-meaning-line + .tp-word-popover-meaning-line {
  margin-top: 4px;
}

.tp-word-popover-pos-inline {
  font-weight: 600;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.tp-word-popover-defs-inline {
  line-height: 1.5;
}

.tp-word-popover-btn {
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  width: 100%;
  display: block;
  text-align: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease, box-shadow .18s ease;
}

.tp-word-popover-btn:hover {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.24);
}

.tp-word-popover-btn:active {
  transform: translateY(1px);
}

/*Side arrows – 靠底部一点，稍微小一点*/

.side-nav {
  position: absolute;
  bottom: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 72px;
  color: #909191;
  line-height: 1;
  user-select: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.side-nav-left {
  left: 18px;
}

.side-nav-right {
  right: 18px;
}

.side-nav:hover {
  transform: scale(1.03);
}

.side-nav:active {
  transform: scale(0.97);
}

#input-view {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phrase {
  font-size: 36px;
  font-weight: 500;
  margin-bottom: 24px;
  text-align: center;
}

.phrase.review-mode {
  margin-top: 40px;
  margin-bottom: 0;
}

.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 8px;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

body[data-active="practice"] #slots .slot.review-mode {
  cursor: pointer;
  padding-bottom: 4px;
  margin-bottom: -4px;
}

.slot-input {
  border: none;
  border-bottom: 2px solid #d1d5db;
  background: transparent;
  padding: 4px 2px 6px;
  font-size: 42px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  caret-color: transparent;
  color: var(--tp-text-main);
}

.slot-input:focus {
  border-color: #0071E3;
  box-shadow: 0 2px 0 0 rgba(240,105,19,0);
}

.slot-input.ok {
  border-bottom-color: #22c55e;
}

.slot-input.error {
  border-bottom-color: #FA0000;
}

.slot-input.review-mode {
  cursor: default;
  box-shadow: none;
}

.mistake-clickable,
body[data-active="practice"] .slot-input.review-mode,
body[data-active="practice"] .hanzi-word {
  border-radius: 10px;
  transition: background .15s ease;
}

.mistake-clickable:hover,
body[data-active="practice"] .hanzi-word.is-hover-preview-hz {
  background: rgba(34,197,94,.10);
}

body[data-active="practice"] #slots .slot.review-mode > input.slot-input.review-mode,
body[data-active="practice"] #slots .slot.review-mode > .hanzi-word {
  cursor: inherit !important;
  pointer-events: none;
}

body[data-active="practice"] #input-view .slot input.slot-input.review-mode {
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

body[data-active="practice"] #input-view .slot input.slot-input.review-mode.is-hover-preview-py {
  background: rgba(34,197,94,.10) !important;
  background-color: rgba(34,197,94,.10) !important;
}

body[data-active="practice"] .hanzi-word.is-hover-preview-hz {
  position: relative;
  z-index: 0;
  background: transparent;
}

body[data-active="practice"] .hanzi-word.is-hover-preview-hz::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  bottom: -4px;
  width: var(--tp-slot-hover-width, 100%);
  transform: translateX(-50%);
  border-radius: 10px;
  background: rgba(34,197,94,.10);
  pointer-events: none;
  z-index: -1;
}

.slot-input.simple-hint-all::placeholder,
    .slot-input.simple-hint-active::placeholder {
  color: #9ca3af;
  opacity: 0.85;
}

.slot-input.active-word {
  border-bottom-color: var(--tp-text-main);
  box-shadow: none;
}

.hanzi-word {
  margin-top: 8px;
  font-size: 42px;
  color: var(--tp-text-main);
  height: 48px;
  line-height: 48px;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
}

.status {
  margin-top: 18px;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  display: none;
  max-width: 420px;
  text-align: center;
}

body[data-active="practice"] .status.correct {
  background: #e8f9f0;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status.wrong {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.answer-detail {
  margin-top: 8px;
  font-size: 14px;
  color: #4b5563;
  text-align: center;
  display: none;
}

.pinyin {
  font-family: inherit;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}

.shake {
  animation: shake 0.3s ease-in-out;
}

/*Bottom shortcuts – 与箭头同一高度，居中*/


.bottombar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 12px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  width: 100%;
  pointer-events: none;
}

.bottom-shortcuts {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px 18px;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
  border: none;
  border-radius: 14px;
  box-shadow: none;
  padding: 12px 16px;
  max-width: min(1040px, calc(100% - 24px));
  width: min(1040px, calc(100% - 24px));
  pointer-events: auto;
  overflow-x: auto;
}

.shortcut-stack {
  display: flex;
  flex-direction: row;
  gap: 14px;
  min-width: 190px;
  justify-content: center;
}

.shortcut-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px 18px;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  overflow-x: auto;
}

.key-combo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4b5563;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.key {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  font-size: 12px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (max-width: 640px) {
  .bottom-shortcuts {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .shortcut-stack {
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 12px;
  }

  .shortcut-group {
    width: auto;
  }
}

/*Mode overlay：略微加深背景，让弹窗更突出*/

.mode-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/*===== Back / Navigation Overlay =====*/

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

.nav-dialog {
  position: relative;
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  border-radius: 20px;
  width: min(520px, 92vw);
  padding: 22px 22px 18px;
  border: 1px solid var(--tp-border-subtle);
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.nav-title {
  font-size: 18px;
  font-weight: 700;
}

.nav-subtitle {
  font-size: 13px;
  color: var(--tp-text-muted);
  margin-bottom: 14px;
  line-height: 1.35;
}

.nav-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
  padding: 0;
}

.nav-close-btn:hover {
  color: #4b5563;
}

.nav-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.nav-action-btn {
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  cursor: pointer;
  font-size: 14px;
  color: var(--tp-text-main);
}

.nav-action-btn:hover {
  background: var(--tp-bg-surface);
}

.nav-action-btn.primary {
  background: #22c55e;
  border-color: #16a34a;
  color: #ffffff;
}

.nav-action-btn.primary:hover {
  background: #16a34a;
}

/* Mode dialog */
.mode-dialog {
  position: relative;
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  border-radius: 20px;
  padding: 22px 24px 20px;
  width: min(980px, calc(100vw - 48px));
  height: min(640px, calc(100vh - 48px));
  box-sizing: border-box;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  border: 1px solid var(--tp-border-subtle);
  overflow: hidden;
}

.mode-dialog::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.16),
    rgba(56, 189, 248, 0.10),
    rgba(37, 99, 235, 0.10)
  );
  opacity: 0.95;
  z-index: -1;
}

.mode-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.mode-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
  margin-top: 10px;
}

.mode-left {
  display: flex;
  min-width: 0;
}

.mode-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.mode-options {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
  margin-top: 0;
}

.mode-close-btn {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
  padding: 0;
}

.mode-close-btn:hover {
  color: #4b5563;
}

.mode-option {
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: rgba(255, 255, 255, 0.9);
  padding: 16px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.2s ease, transform 0.1s ease;
  font-size: 16px;
  font-weight: 750;
  color: var(--tp-text-main);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

[data-theme="dark"] .mode-option {
  background: rgba(15, 23, 42, 0.96);
}

.mode-option:hover,
.mode-difficulty-card:hover {
  background: var(--tp-bg-surface-alt);
  border-color: #22c55e;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  transform: translateY(-1px);
}

.mode-option.active,
.mode-difficulty-card.active {
  background: #22c55e;
  border-color: #16a34a;
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.45);
  transform: none;
}

.mode-detail-title {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
}

.mode-detail-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tp-text-muted);
}

.mode-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tp-text-muted);
  margin-bottom: 8px;
}

.mode-difficulty-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-difficulty-card {
  border-radius: 12px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  padding: 10px 8px;
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.mode-difficulty-explain {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
}

.mode-difficulty-desc {
  min-height: 48px;
  line-height: 1.35;
  font-size: 13px;
  color: var(--tp-text-muted);
}

.mode-hint {
  min-height: 18px;
  font-size: 13px;
  color: #ef4444;
}

.mode-actions {
  margin-top: auto;
}

.mode-continue-btn {
  width: 100%;
}

.mode-overlay.initial-hover .mode-option:hover {
  background: #22c55e;
  border-color: #16a34a;
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.45);
  transform: none;
}

@media (max-width: 520px) {
  html .mode-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html .mode-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding:
      calc(12px + env(safe-area-inset-top))
      12px
      calc(12px + env(safe-area-inset-bottom))
      12px;
  }

  html .mode-dialog-header {
    margin-bottom: 8px;
  }

  html .mode-heading {
    font-size: 16px;
  }

  html .mode-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
  }

  html .mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 0;
  }

  html .mode-option {
    min-height: 72px;
    padding: 12px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 750;
    white-space: normal;
  }

  html .mode-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
  }

  html .mode-detail-title {
    font-size: 15px;
  }

  html .mode-detail-desc {
    font-size: 13px;
    line-height: 1.45;
  }

  html .mode-difficulty-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  html .mode-difficulty-card {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 12px;
  }

  html .mode-difficulty-explain {
    font-size: 12px;
    line-height: 1.35;
    padding: 10px;
  }

  html .mode-difficulty-desc {
    min-height: 44px;
  }

  html .mode-hint {
    font-size: 12px;
    min-height: 0;
  }

  html .mode-actions {
    margin-top: 10px;
  }

  html .mode-continue-btn {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border-radius: 14px;
  }
}

@media (max-width: 900px) and (max-height: 520px) {
  html .mode-overlay {
    padding: 0;
    overflow: hidden;
    align-items: stretch;
    justify-content: stretch;
    overscroll-behavior: none;
  }

  html .mode-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding:
      calc(10px + env(safe-area-inset-top))
      10px
      calc(10px + env(safe-area-inset-bottom))
      10px;
  }

  html .mode-dialog-header {
    margin-bottom: 6px;
  }

  html .mode-heading {
    font-size: 15px;
  }

  html .mode-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
  }

  html .mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 8px;
    margin-top: 0;
  }

  html .mode-option {
    min-height: 64px;
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 740;
    white-space: normal;
  }

  html .mode-right {
    gap: 8px;
    min-height: 0;
  }

  html .mode-detail-title {
    font-size: 14px;
  }

  html .mode-detail-desc {
    font-size: 12px;
    line-height: 1.3;
  }

  html .mode-difficulty-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  html .mode-difficulty-card {
    min-height: 44px;
    padding: 8px 6px;
    font-size: 12px;
  }

  html .mode-difficulty-explain {
    font-size: 12px;
    line-height: 1.3;
    padding: 10px;
  }

  html .mode-difficulty-desc {
    min-height: 44px;
  }

  html .mode-hint {
    font-size: 12px;
    min-height: 0;
  }

  html .mode-actions {
    margin-top: 8px;
  }

  html .mode-continue-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
  }
}

/*Shadow mode controls*/

.shadow-controls {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.shadow-text-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  height: 140px;
  text-align: center;
}

.shadow-pinyin {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 4px;
}

.shadow-hanzi {
  font-size: 40px;
  margin-bottom: 2px;
}

.shadow-english {
  font-size: 36px;
  font-weight: 500;
  color: var(--tp-text-main);
}

.shadow-mic-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: default;
}

.shadow-mic-circle {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #bbf7d0, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

.shadow-mic-circle svg {
  width: 40px;
  height: 40px;
  stroke: #ffffff;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shadow-instruction {
  font-size: 13px;
  color: #4b5563;
  text-align: center;
}

.shadow-status {
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

.shadow-status.ok {
  color: #15803d;
}

.shadow-status.error {
  color: #b91c1c;
}

.shadow-controls.recording .shadow-mic-circle {
  animation: shadow-pulse 0.9s ease-in-out infinite;
}

@keyframes shadow-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 14px rgba(34,197,94,0.2);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34,197,94,0);
  }
}

.shadow-controls.error-shake .shadow-mic-circle {
  animation: shake 0.3s ease-in-out;
}

/*Settings overlay (new)*/

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 110;
}

.settings-overlay .settings-dialog {
  background: var(--tp-bg-surface);
  border-radius: 16px;
  padding: 24px 26px 20px;
  max-width: 900px;
  width: 95%;
  max-height: 80vh;
  height: 70vh;
  box-shadow: 0 20px 40px rgba(15,23,42,0.25);
  display: flex;
  flex-direction: column;
}

.settings-overlay .settings-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
}

.settings-subtitle {
  font-size: 13px;
  color: #6b7280;
}

.settings-close-btn {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
  padding: 0;
}

.settings-close-btn:hover {
  color: #4b5563;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/*Saved badge (hidden by default, shows briefly after auto-save)*/

.settings-saved {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  color: #16a34a;
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.35);
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  padding: 0;
  white-space: nowrap;
  transition: max-width .22s ease, opacity .18s ease, padding .22s ease;
}

.settings-saved.show {
  max-width: 80px;
  opacity: 1;
  padding: 0 10px;
}

.settings-reset-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--tp-text-main);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
}

.settings-reset-btn:hover {
  background: var(--tp-bg-surface);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  transform: translateY(-0.5px);
}

.settings-reset-btn:active {
  box-shadow: none;
  transform: translateY(0);
}

.settings-reset-btn.voice-preview-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-reset-btn.voice-preview-btn svg {
  width: 18px;
  height: 18px;
}

.tp-voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tp-voice-row select {
  flex: 1;
  min-width: 0;
}

/* Force Voice select + preview button to stay in one row */
body[data-active="settings"] .settings-slider-control.tp-voice-row,
.settings-overlay .settings-slider-control.tp-voice-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Ensure the select can shrink so the button stays on the right */
body[data-active="settings"] .settings-slider-control.tp-voice-row select,
.settings-overlay .settings-slider-control.tp-voice-row select {
  flex: 1 1 auto;
  min-width: 0;
}

/* Keep preview button fixed-size on the right */
body[data-active="settings"] .settings-slider-control.tp-voice-row .voice-preview-btn,
.settings-overlay .settings-slider-control.tp-voice-row .voice-preview-btn {
  flex: 0 0 auto;
}

.settings-reset-btn.voice-preview-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.settings-overlay .settings-body {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  flex: 1;
  min-height: 0;
}

.settings-overlay .settings-sidebar {
  width: 170px;
  min-width: 170px;
  border-right: 1px solid var(--tp-border-subtle);
  padding-right: 10px;
  overflow-y: auto;
}

.settings-overlay .settings-section-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-overlay .settings-section-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 16px;
  color: var(--tp-text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.settings-overlay .settings-section-btn .tp-settings-label{
  white-space: nowrap;
}

.settings-overlay .settings-section-btn:hover {
  background: rgba(34, 197, 94, 0.1);
  color: var(--tp-text-main);
}

.settings-overlay .settings-section-btn.active {
  background: rgba(34, 197, 94, 1);
  border-color: #22c55e;
  color: #FFFFFF;
  font-weight: 500;
}

.settings-overlay .settings-content-area {
  flex: 1;
  min-height: 0;
  padding-left: 6px;
  padding-right: 20px;
  overflow-y: auto;
}

.settings-overlay .settings-section-content {
  display: none;
}

.settings-section-content.active {
  display: block;
}

.settings-overlay .settings-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.settings-overlay .settings-section-desc {
  font-size: 13px;
  color: var(--tp-text-muted);
  margin-bottom: 16px;
  max-width: 420px;
}

.settings-section-desc,
.settings-slider-label,
.settings-slider-label span,
.simple-toggle span {
  line-height: 1.2;
}

/*右侧每一行加浅色分隔线*/

.settings-section-content .settings-slider-row,
.settings-section-content .simple-toggle,
.settings-section-content .settings-shortcut-item {
  border-bottom: 1px solid var(--tp-border-subtle);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.settings-overlay .settings-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.settings-overlay .settings-slider-label {
  flex: 1;
  font-size: 13px;
  color: var(--tp-text-main);
}

.settings-overlay .settings-slider-label strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.settings-overlay .settings-slider-label span {
  font-size: 12px;
  color: var(--tp-text-muted);
}

.settings-overlay .settings-slider-control {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/*Playback / 其它设置里的滑块：只作用于 Settings 页面 + Settings overlay*/

body[data-active="settings"] .settings-slider-control input[type="range"],
.settings-overlay .settings-slider-control input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  --range-progress: 50%;
}

/*WebKit track*/

body[data-active="settings"] .settings-slider-control input[type="range"]::-webkit-slider-runnable-track,
.settings-overlay .settings-slider-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--tp-accent) 0%,
    var(--tp-accent) var(--range-progress),
    rgba(230, 230, 230) var(--range-progress),
    rgba(230, 230, 230) 100%
  );
}

/*WebKit thumb*/

body[data-active="settings"] .settings-slider-control input[type="range"]::-webkit-slider-thumb,
.settings-overlay .settings-slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--tp-accent);
  border: 2px solid #ffffff;
  margin-top: -6px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

/*Firefox track*/

body[data-active="settings"] .settings-slider-control input[type="range"]::-moz-range-track,
.settings-overlay .settings-slider-control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--tp-accent) 0%,
    var(--tp-accent) var(--range-progress),
    rgba(230, 230, 230) var(--range-progress),
    rgba(230, 230, 230) 100%
  );
}

/*Firefox thumb*/

body[data-active="settings"] .settings-slider-control input[type="range"]::-moz-range-thumb,
.settings-overlay .settings-slider-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--tp-accent);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

/*old Edge/IE*/

body[data-active="settings"] .settings-slider-control input[type="range"]::-ms-fill-lower,
.settings-overlay .settings-slider-control input[type="range"]::-ms-fill-lower {
  border-radius: 999px;
  background: var(--tp-accent);
}

body[data-active="settings"] .settings-slider-control input[type="range"]::-ms-fill-upper,
.settings-overlay .settings-slider-control input[type="range"]::-ms-fill-upper {
  border-radius: 999px;
  background: rgba(230, 230, 230);
}

.settings-overlay .settings-slider-value {
  font-size: 12px;
  color: var(--tp-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settings-placeholder {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 6px;
}

/*Shortcuts: only the bits not covered above*/

body[data-active="settings"] .settings-shortcut-item-main,
.settings-overlay .settings-shortcut-item-main {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

body[data-active="settings"] .shortcut-edit-btn,
.settings-overlay .shortcut-edit-btn {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  cursor: pointer;
  flex-shrink: 0;
  color: var(--tp-text-main);
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}

body[data-active="settings"] .shortcut-edit-btn.recording,
.settings-overlay .shortcut-edit-btn.recording {
  border-color: #f97316;
  background: rgba(249,115,22,.08);
  box-shadow: 0 4px 10px rgba(249,115,22,.25);
  transform: none;
}

body[data-active="settings"] .shortcut-edit-btn:hover,
.settings-overlay .shortcut-edit-btn:hover {
  background: var(--tp-bg-surface);
  border-color: var(--tp-accent);
  box-shadow: 0 4px 10px rgba(15,23,42,.12);
  transform: translateY(-1px);
}

.settings-shortcut-note {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}

@media (max-width: 640px) {
  .settings-overlay .settings-dialog {
    padding: 16px 14px;
  }
  .settings-overlay .settings-body {
    flex-direction: column;
  }
  .settings-overlay .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--tp-border-subtle);
    padding-bottom: 8px;
    margin-bottom: 8px;
    padding-right: 0;
  }
}

/*Answering 中的 toggle 纵向排列，每一项单独一行*/

.settings-overlay .toggle-group {
  display: flex;
  flex-direction: column;
  gap: 0px;
  margin-bottom: 20px;
}

.settings-overlay .simple-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--tp-text-main);
}

.settings-overlay .simple-toggle span {
  flex: 1;
}

/*把 checkbox 画成开关*/

.settings-overlay .simple-toggle input {
  margin: 0;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: #e5e7eb;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: background 0.2s ease;
}

.settings-overlay .simple-toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15,23,42,0.2);
  transition: transform 0.2s ease;
}

.settings-overlay .simple-toggle input:checked {
  background: #22c55e;
}

.settings-overlay .simple-toggle input:checked::before {
  transform: translateX(18px);
}

.settings-radio-group {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.settings-radio-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.settings-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.settings-radio input {
  margin: 0;
}

/*Tooltip*/

.tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: rgba(17,24,39,0.95);
  color: #f9fafb;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.05s ease;
}

.tooltip.show {
  opacity: 1;
}

/*=== FULLSCREEN: Top / Center / Bottom Dock Layout (override at end) ===*/

body[data-active="practice"] #viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/*top and bottom always stick to screen edges*/

body[data-active="practice"] #topDock {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 30;
}

body[data-active="practice"] #bottomDock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 30;
}

/*center stays at the same screen position (fullscreen/non-fullscreen一致)*/

body[data-active="practice"] #centerDock {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(860px, calc(100% - 40px));
  z-index: 20;
}

body[data-active="practice"] .centerPack {
  pointer-events: auto;
}

/*===== Lesson Summary Modal =====*/

.summary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.summary-dialog {
  background: var(--tp-bg-surface);
  border-radius: 22px;
  padding: 36px 32px 28px;
  width: 420px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.summary-stars {
  font-size: 22px;
  margin-bottom: 12px;
}

.summary-score {
  font-size: 44px;
  font-weight: 750;
  line-height: 1.15;
  margin-bottom: 10px;
}

.summary-score-label {
  font-size: 14px;
  color: var(--tp-text-muted);
  margin-bottom: 22px;
}

.summary-box {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #ecfdf5;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.summary-cell {
  flex: 1;
  text-align: center;
}

.summary-note {
  font-size: 12px;
  color: var(--tp-text-muted);
  margin-bottom: 18px;
}

.summary-box strong {
  font-size: 20px;
}

.summary-sub {
  font-size: 12px;
  color: #6b7280;
}

.summary-actions {
  display: flex;
  gap: 12px;
}

.summary-actions button {
  flex: 1;
  padding: 10px 0;
  border-radius: 12px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  cursor: pointer;
  font-size: 14px;
}

.summary-actions button:hover {
  background: var(--tp-bg-surface);
}

/*===== Achievement Confetti =====*/

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10001;
  display: none;
}

.confetti {
  position: absolute;
  top: -16px;
  opacity: 0.95;
  transform: rotate(0deg);
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0,0,0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--dx, 0px), calc(100vh + 60px), 0) rotate(var(--rot, 720deg));
  }
}

/*===== Share Overlay (exportable card) =====*/

.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10010;
}

.share-shell {
  position: relative;
  width: min(980px, 94vw);
  max-height: 88vh;
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.share-card-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

#share-card {
  width: min(680px, 100%);
  background: var(--tp-bg-surface);
  border: 1px solid var(--tp-border-subtle);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  padding: 22px;
  overflow: hidden;
}

.share-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.share-avatar {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: var(--tp-bg-surface-alt);
  border: 1px solid var(--tp-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  user-select: none;
  cursor: pointer;
}

.share-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.share-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--tp-text-main);
  cursor: pointer;
  user-select: none;
}

.share-date {
  font-size: 13px;
  color: var(--tp-text-muted);
}

.share-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.share-stat {
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  border-radius: 16px;
  padding: 12px 12px;
}

.share-stat-label {
  font-size: 12px;
  color: var(--tp-text-muted);
  margin-bottom: 6px;
}

.share-stat-value {
  font-size: 18px;
  font-weight: 750;
  color: var(--tp-text-main);
}

.share-quote {
  border-radius: 16px;
  padding: 14px 14px;
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--tp-text-main);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.share-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.share-site-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--tp-text-main);
  margin-bottom: 4px;
}

.share-site-url {
  font-size: 12px;
  color: var(--tp-text-muted);
  word-break: break-all;
}

.share-qr {
  width: 118px;
  height: 118px;
  padding: 6px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--tp-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-actions {
  width: 170px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.share-action-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  cursor: pointer;
  font-size: 14px;
  color: var(--tp-text-main);
}

.share-action-btn:hover {
  background: var(--tp-bg-surface-alt);
}

.share-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--tp-text-main);
}

@media (max-width: 720px) {
  .share-shell {
    flex-direction: column;
  }
  .share-actions {
    width: 100%;
    flex-direction: row;
  }
  .share-action-btn {
    flex: 1;
  }
}

/*===== End copy =====*/

/*=========================
   Scroll + layout defaults for sidebar pages
   (exclude fullscreen practice page)
=========================*/

body[data-active]:not([data-active="practice"]) {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden; /* ✅ 把横向裁切移到 body，避免破坏 sticky */
}

body[data-active]:not([data-active="practice"]) .page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: visible;  /* ✅ 关键：让 sticky 能参照页面滚动生效 */
  overflow-y: visible;
}


/*=========================
   Dashboard compact + tweaks (override)
   paste at END of app.css
=========================*/

/*更紧凑一点（只影响 dashboard）*/

#view-dashboard .dash-grid {
  align-items: stretch;
  gap: 14px;
}

#view-dashboard .card {
  padding: 16px;
}

#view-dashboard .card-title {
  font-size: 14px;
}

#view-dashboard .muted {
  margin-top: 8px;
  font-size: 12px;
}

/*Dashboard-only calendar sizing + studied gradient*/

#view-dashboard .calendar {
  gap: 5px;
}

#view-dashboard .cal-day {
  aspect-ratio: 1/1;
  border-radius: 10px;
}

#view-dashboard .cal-head {
  font-size: 11px;
}

#view-dashboard .cal-day.studied {
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(34,197,94,.25));
  border-color: rgba(34,197,94,.45);
}

/*✅ Study time / Sentences 并排*/

#view-dashboard .summary-square {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#view-dashboard .summary-metric {
  padding: 10px 12px;
  border: 1px solid rgba(2,6,23,.10);
  border-radius: 14px;
  background: rgba(255,255,255,.7);
}

#view-dashboard .summary-value {
  line-height: 1.05;
}

/*Calendar 更小一点*/

#view-dashboard .calendar.calendar-sm {
  gap: 6px;
}

#view-dashboard .calendar.calendar-sm .cal-head {
  font-size: 11px;
  height: 22px;
}

#view-dashboard .calendar.calendar-sm .cal-day {
  height: 26px;
}

/*标题行 + 月份左右箭头*/

#view-dashboard .card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#view-dashboard .cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

#view-dashboard .cal-month {
  font-size: 12px;
  color: var(--muted, #64748b);
  white-space: nowrap;
cursor: pointer;
user-select: none;

}

#view-dashboard .icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(255,255,255,.8);
  cursor: pointer;
}

/*Recent “More” 文字按钮*/

#view-dashboard .mini-link {
  border: 0;
  background: transparent;
  color: var(--accent, #22c55e);
  cursor: pointer;
  padding: 6px 2px;
  font-weight: 700;
  text-align: left;
}

/*Recent modal*/

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal {
  width: min(720px, 96vw);
  max-height: 80vh;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(2,6,23,.12);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(2,6,23,.08);
}

.modal-title {
  font-weight: 800;
}

.modal-body {
  padding: 12px 16px 16px;
  overflow: auto;
  max-height: calc(80vh - 56px);
}

/*===== Mistakes (review) card list =====*/

.mistake-list {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.mistake-item {
  border: 1px solid rgba(2,6,23,.10);
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 26px rgba(15,23,42,.06);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform, height;
  transition: transform var(--tp-del-slide) var(--tp-spring),
    opacity   var(--tp-del-slide) var(--tp-ease-out),
    height    var(--tp-del-collapse) var(--tp-ease-out),
    margin-bottom var(--tp-del-collapse) var(--tp-ease-out),
    padding-top    var(--tp-del-collapse) var(--tp-ease-out),
    padding-bottom var(--tp-del-collapse) var(--tp-ease-out);
  margin-bottom: 12px;
}

.mistake-wrong {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: .2px;
}

.mistake-hanzi {
  margin-top: 6px;
  font-size: 14px;
  color: rgba(15,23,42,.65);
  white-space: pre-wrap;
}

.mistake-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(15,23,42,.55);
  justify-content: flex-start;
  gap: 8px;
}

.mistake-meta-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  text-decoration: none;
}

.mistake-badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 800;
  color: #b91c1c;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.22);
  white-space: nowrap;
  margin-left: 10px;
}

/*拼音-汉字按列对齐（两行同列宽）*/

.mistake-cell-py {
  font-size: 20px;
  font-weight: 750;
}

.mistake-cell-hz {
  font-size: 26px;
  color: rgba(15,23,42,.85);
}

/*顶部：对齐块 + 喇叭 —— 让喇叭紧贴“拼音结束”*/

.mistake-toprow {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}

.mistake-align-main {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
}

/*喇叭按钮：不要被推到最右边*/

/*喇叭按钮*/

.mistake-play {
  margin-left: 0 !important;
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 2px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(2,6,23,.12);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mistake-play svg {
  width: 18px;
  height: 18px;
}

.mistake-play:hover {
  transform: translateY(-1px);
}

/*链接样式*/

.mistake-link {
  text-decoration: none;
  font-weight: 650;
  color: var(--accent, #22c55e);
}

.mistake-link:hover {
  text-decoration: underline;
}

.mistake-sep {
  opacity: .6;
}

.mistake-date {
  opacity: .75;
}

.mistake-clickable {
  cursor: pointer;
  border-radius: 10px;
  padding: 2px 6px;
}

.mistake-clickable:hover {
  background: rgba(34,197,94,.10);
}

/*Mistakes: badge + details button (tight spacing)*/


/*Make the mistake badge clickable (opens details modal)*/

#view-mistakes .mistake-badge-click {
  cursor: pointer;
  user-select: none;
}

#view-mistakes .mistake-badge-click:hover {
  filter: brightness(0.98);
}

#view-mistakes .mistake-details-btn:hover {
  background: rgba(15,23,42,.08);
}

/*Modal*/

.mistake-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,.35);
  z-index: 9999;
}

.mistake-modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  overflow: hidden;
}

.mistake-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.mistake-modal-title {
  font-weight: 800;
}

.mistake-modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

/*===== Mistake modal: align label/value columns =====*/

.mistake-modal-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  column-gap: 14px;
  align-items: baseline;
}

.mistake-modal-row .k {
  text-align: left;
  white-space: nowrap;
  font-weight: 500;
}

.mistake-modal-row .v {
  min-width: 0;
}

.mistake-modal-list {
  margin: 6px 0 0 18px;
}

.mistake-modal-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/*=========================
   Mistakes: toolbar layout (override)
=========================*/


/*✅ 左侧：强制一行；太挤就横向滚动*/


/*sort*/


/*右侧按钮*/


/*✅ 如果你暂时没加 .mistake-tools-left，也能不换行*/


#view-mistakes .mistake-btn {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

#view-mistakes .mistake-btn:hover {
  filter: brightness(.98);
}

#view-mistakes .mistake-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

#view-mistakes .mistake-btn.danger {
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
  color: #b91c1c;
}

/*Green primary button (for Practice)*/
#view-mistakes .mistake-btn.mistake-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#view-mistakes .mistake-btn.mistake-btn-primary:hover {
  filter: brightness(0.95);
}
#view-mistakes .mistake-btn.mistake-btn-primary:active {
  transform: translateY(1px);
}

/*Bulk action bar*/

#view-mistakes .mistake-bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
}

#view-mistakes .mistake-bulkbar-right {
  display: flex;
  gap: 8px;
}

/*Checkbox*/

#view-mistakes .mistake-checkwrap {
  display: flex;
  align-items: flex-start;
  min-width: 26px;
  margin-right: 8px;
  padding-top: 4px;
}

#view-mistakes .mistake-check {
  width: 18px;
  height: 18px;
}

#view-mistakes .mistake-item.is-selected {
  outline: 2px solid rgba(34,197,94,.35);
  background: rgba(34,197,94,.04);
}

/*===== Fill page height (Leaderboard) =====*/

body[data-active="leaderboard"] .page {
  min-height: 100vh;
  min-height: 100dvh;
}

body[data-active="leaderboard"] .content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body[data-active="leaderboard"] .view[data-view="leaderboard"] {
  flex: 1;
  min-height: 0;
  display: flex;
}

body[data-active="leaderboard"] .view[data-view="leaderboard"] > .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body[data-active="leaderboard"] .view[data-view="leaderboard"] .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/*（可选）表头固定，看起来更像“占满”*/

body[data-active="leaderboard"] .view[data-view="leaderboard"] .table thead th {
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}

/*===== Mistake modal: sticky header + scroll attempts =====*/

.mistake-modal-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 520px);
}

/*顶部固定区域*/

.mistake-modal-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  padding-bottom: 8px;
}

/*Pinyin/Hanzi box（保留你已有的外观）*/

.mistake-modal-wordbox {
  border: 1px solid rgba(2,6,23,.12);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

/*只让 attempts 区滚动*/

.mistake-attempts-scroll {
  overflow: auto;
  padding-right: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

/*attempts 列表块*/

.mistake-attempts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0 2px;
}

.mistake-attempt {
  border: 1px solid rgba(2,6,23,.12);
  border-radius: 14px;
  padding: 10px 12px;
}

.mistake-attempt-typed code {
  white-space: pre-wrap;
  word-break: break-word;
}

.mistake-attempt-time {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}

/*底部按钮区域固定在底部（因为 body 是 column）*/

.mistake-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(2,6,23,.08);
  margin-top: 10px;
}

/*Delete all records: make it a normal button (not red)*/

.mistake-delete-btn {
  appearance: none;
  border: 1px solid rgba(2,6,23,.12);
  background: rgba(2,6,23,.04);
  color: #0f172a;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.mistake-delete-btn:hover {
  background: rgba(2,6,23,.07);
  border-color: rgba(2,6,23,.18);
}

.mistake-delete-btn:active {
  transform: translateY(1px);
}

.mistake-delete-btn:focus {
  outline: none;
}

.mistake-delete-btn:focus-visible {
  outline: 2px solid rgba(2,6,23,.25);
  outline-offset: 2px;
}

/*===== Mistakes: hide "Add to ..." chips until hover (keep layout) =====*/

body[data-active="mistakes"] .mistake-item .mistake-chip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
}

/*hover 或键盘 focus 时显示*/

body[data-active="mistakes"] .mistake-item:hover .mistake-chip,
body[data-active="mistakes"] .mistake-item:focus-within .mistake-chip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity .15s ease, transform .15s ease, visibility 0s;
}

/*Bulk 模式下隐藏，避免误点（可选但强烈建议）*/

#view-mistakes.is-bulk .mistake-chip {
  display: none !important;
}

/*===== Tiny toast feedback =====*/

.tp-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(15,23,42,.92);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.tp-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Practice action toast (independent from .tp-toast variants) */
.tp-action-toast {
  position: fixed;
  left: 50%;
  top: 82px;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  z-index: 9800;

  max-width: min(88vw, 520px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.14);

  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  transition: opacity .3s ease, transform .3s ease;
}

.tp-action-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

html[data-theme="dark"] .tp-action-toast {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.94);
  color: #e5e7eb;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.42);
}

/*✅ When modal open: prevent background scrolling*/

html.modal-open, body.modal-open {
  overflow: hidden;
}

/*===== Mistake modal: highlight wrong token =====*/

.mistake-tokenline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  line-height: 1.5;
}

.mistake-token {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.6;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(2,6,23,.03);
  border: 1px solid rgba(2,6,23,.10);
  font-size: 13px;
}

.mistake-token.is-wrong {
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.10);
  color: #b91c1c;
  font-weight: 750;
}

.mistake-missing {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #475569;
}

.mistake-missing-label {
  margin-right: 2px;
  opacity: .85;
}

.mistake-token.is-missing {
  background: rgba(245,158,11,.16);
  border-color: rgba(245,158,11,.32);
  color: #7c2d12;
  font-weight: 700;
}

/*Bulk 模式：整张卡片像可点的*/

#view-mistakes.is-bulk .mistake-item {
  cursor: pointer;
}

/*Bulk 模式：避免点选时选中一堆文字*/

#view-mistakes.is-bulk .mistake-item * {
  user-select: none;
}

/*=========================
   Mistakes modal spacing tweaks
   =========================*/

/*✅ Pronunciation / Characters 两行之间更松一点*/

body[data-active="mistakes"] .mistake-modal-wordbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0 2px;
}

/*✅ “Each attempt” 这一行更贴近下面列表*/

body[data-active="mistakes"] .mistake-modal-sticky > .mistake-modal-row {
  margin-top: 8px;
  margin-bottom: 2px;
}

/*✅ attempt 列表顶部不要留太多空*/

body[data-active="mistakes"] .mistake-attempts-scroll {
  margin-top: 0;
  padding-top: 0;
}

/*===== Force Practice button to green =====*/


/*=========================
   Mistakes: per-item delete button + remove animation
=========================*/

/*右侧“删除(✕)”按钮：默认隐藏，hover 出现*/

.mistake-del {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%) scale(.96);
  width: 32px;
  height: 32px;
  border-radius: 12px;
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(2,6,23,.06);
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease, background .15s ease, color .15s ease;
}

.mistake-item:hover .mistake-del {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.mistake-del:hover {
  background: rgba(2,6,23,.10);
  color: #0f172a;
}

/*tooltip：hover 显示英文提示*/

.mistake-del::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  white-space: nowrap;
  background: #0b1220;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.mistake-del:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/*bulk 模式下隐藏单条删除按钮，避免和批量选择冲突*/

#view-mistakes.is-bulk .mistake-del {
  display: none;
}

.mistake-item.is-removing {
  transform: translateX(-120%);
  opacity: 0;
}

/*✅ 折叠：只改属性，不要改 transition*/

.mistake-item.is-collapsing {
  height: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-top-width: 0 !important;
  border-bottom-width: 0 !important;
  pointer-events: none;
}

.mistake-item:last-child {
  margin-bottom: 0;
}

/*=========================
   Mistakes (review) - English line + meaning tip + modal typography
   =========================*/

/*列表里：汉字下的英文释义（整句）*/

body[data-active="mistakes"] .mistake-enline {
  margin-top: 6px;
  font-size: 22px;
  color: #6b7280;
  text-align: left;
  line-height: 1.35;
  padding: 0 6px;
}

/*发音时显示的英文释义小气泡*/

.mistake-meaning-tip {
  position: fixed;
  z-index: 9999;
  background: rgba(17,24,39,0.92);
  color: #ffffff;
  font-size: 20px;
  line-height: 1.25;
  box-shadow: 0 14px 35px rgba(15,23,42,0.25);
  transform: translate(-50%, -100%);
  max-width: min(520px, 92vw);
  white-space: normal;
  left: 0;
  top: 0;
  opacity: 0;
  padding: 8px 12px;
  border-radius: 12px;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}

.mistake-meaning-tip.is-open {
  display: block;
  opacity: 1;
  transform: translate(-50%, -140%);
}

/*弹窗顶部：拼音/汉字/英文（去掉 Pronunciation/Characters 后的新排版）*/

body[data-active="mistakes"] .mistake-modal-py {
  font-size: 20px;
  font-weight: 650;
  text-align: center;
  color: #111827;
}

body[data-active="mistakes"] .mistake-modal-hz {
  font-size: 24px;
  font-weight: 850;
  text-align: center;
  line-height: 1.18;
  color: #111827;
  letter-spacing: 0.08em;
}

body[data-active="mistakes"] .mistake-modal-en {
  font-size: 22px;
  color: #6b7280;
  text-align: center;
  line-height: 1.4;
  padding: 0 6px;
}

/*===== Mistakes modal: make it wider =====*/

body[data-active="mistakes"] .mistake-modal-card {
  width: min(920px, 94vw) !important;
  max-width: 920px !important;
}

/*（可选）弹窗顶部英文样式*/

.mistake-modal-en {
  margin-top: 6px;
  font-size: 20px;
  color: #6b7280;
  line-height: 1.35;
}

/*===== Mistakes: toggle looks like button; checked = green =====*/


/*hide native checkbox*/


/*default = like Clear all button*/


/*checked = green primary*/


/*===== Mistakes tabs =====*/

@media (max-width: 720px) {
  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/*small action chips (optional)*/

.mistake-chip {
  border: 1px solid rgba(2,6,23,.12);
  background: #fff;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mistake-chip:hover {
  background: rgba(2,6,23,.04);
}

/*===== Mistakes Tabs (more visible) =====*/

.card-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

/*隐藏标题但保留 DOM（给 JS 用）*/

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

.mistake-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: rgba(2,6,23,.04);
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}

.mistake-tab {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  color: #334155;
  transition: transform .12s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}

.mistake-tab:hover {
  background: rgba(2,6,23,.06);
  transform: translateY(-1px);
}

.mistake-tab.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px var(--accent-shadow);
}

.mistake-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/*✅ Mistakes tabs 下方留更大的空隙*/

#view-mistakes .card-head {
  margin-bottom: 30px;
}

/*=========================
   Mistakes: Tabs + Tools
   =========================*/

body[data-active="mistakes"] .mistake-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

body[data-active="mistakes"] .mistake-tools-left,
body[data-active="mistakes"] .mistake-tools-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/*✅ Sort by：和左边 toggle 拉开距离 + 分隔线*/

body[data-active="mistakes"] .mistake-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 50px;
  padding-left: 10px;
  border-left: 0px solid rgba(2,6,23,.10);
}

body[data-active="mistakes"] .mistake-sort select {
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(2,6,23,.12);
  background: #fff;
  font-size: 13px;
}

/*===== Mistakes: Tabs =====*/

body[data-active="mistakes"] .mistake-tab {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  padding: 10px 14px;
}

body[data-active="mistakes"] .mistake-tab.is-active {
  font-weight: 800;
}

/*=========================
   Mistakes: aligned block
   - Pinyin/Hanzi: centered, width independent from English
   - English: full width, left aligned
=========================*/

.mistake-align {
  grid-template-columns: repeat(var(--cols), max-content);
  column-gap: 0px;
  row-gap: 2px;
  justify-content: start;
  margin-bottom: 8px;
  width: fit-content;
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/*上面两行：用 inline-grid 让宽度只由拼音/汉字决定（不受英文影响）*/

.mistake-align-grid {
  /* B 方案：超长时自动折行成多行（保持“每个词：上拼音下汉字”的对齐） */
  display: flex;
  flex-wrap: wrap;
  flex: 0 1 auto;
  justify-content: flex-start;
  align-items: flex-start;
  align-content: flex-start;
  max-width: 100%;
  min-width: 0;
  /* flex 支持 row/column gap */
  column-gap: 0px;
  row-gap: 8px;
  overflow: visible;
}

/* 每个“词块”：上拼音下汉字（两行同宽、居中） */
.mistake-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  flex: 0 0 auto;
}

/*每个拼音/汉字单元：居中*/

.mistake-cell {
  text-align: center;
  white-space: nowrap;
}

/*英文：单独一行，铺满容器并靠左；它再长也不会影响上面 grid 的宽度*/

.mistake-enline {
  align-self: stretch;
  width: 100%;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/*✅ Mistakes：让“拼音+汉字”整块靠最左边（但每个词内部仍可居中）
  + B：窄屏折行更稳定（避免 inline-flex 的 shrink-to-fit 兼容差异） */

body[data-active="mistakes"] .mistake-toprow {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  justify-content: flex-start;
}

body[data-active="mistakes"] .mistake-align {
  flex: 0 1 auto;
  width: fit-content;
  justify-content: flex-start;
}

/*===============================
   Mistakes – Scheme 1 toolbar
================================*/

body[data-active="mistakes"] .mistake-headbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body[data-active="mistakes"] .mistake-search {
  position: relative;

  display: flex;
  align-items: center;
  justify-content: flex-end;
}

body[data-active="mistakes"] .mistake-search input {
  width: min(280px, 60vw);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

body[data-active="mistakes"] .mistake-search input:focus {
  border-color: rgba(34,197,94,.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

body[data-active="mistakes"] .mistake-toolbar {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body[data-active="mistakes"] .mistake-toolbar-left,
body[data-active="mistakes"] .mistake-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

body[data-active="mistakes"] .mistake-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

body[data-active="mistakes"] .mistake-field-label {
  font-size: 12px;
  color: #6b7280;
}

body[data-active="mistakes"] .mistake-field select {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
}

/*Display dropdown*/

body[data-active="mistakes"] .tp-dd {
  position: relative;
}

body[data-active="mistakes"] .tp-dd-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 18px 55px rgba(15,23,42,0.18);
  display: none;
  z-index: 80;
}

body[data-active="mistakes"] .tp-dd.is-open .tp-dd-menu {
  display: block;
}

body[data-active="mistakes"] .tp-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

body[data-active="mistakes"] .tp-dd-item:hover {
  background: rgba(34,197,94,.10);
}

body[data-active="mistakes"] .tp-dd-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

body[data-active="mistakes"] .tp-dd-check {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #16a34a;
  font-weight: 900;
  font-size: 12px;
}

body[data-active="mistakes"] .tp-dd-item input:checked + .tp-dd-check {
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.12);
}

body[data-active="mistakes"] .tp-dd-item input:checked + .tp-dd-check::before {
  content: "✓";
}

/*Bulk button active feel*/

body[data-active="mistakes"] #bulkToggleBtn.is-on {
  border-color: rgba(34,197,94,.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

/*=========================
   Dashboard – Compact & Clean
   (paste at end of app.css)
=========================*/

body[data-active="dashboard"] #view-dashboard .dash-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  width: 100%;
}

body[data-active="dashboard"] #view-dashboard .dash-grid > * {
  min-width: 0;
}

/*2-row layout:
   Row 1: Summary(4) + Calendar(5) + Checkin(3) = 12
   Row 2: Recent(4) + Leaderboard(8) = 12*/

body[data-active="dashboard"] #view-dashboard .dash-cal {
  grid-column: span 3;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin {
  grid-column: span 5;
}

/*✅ Row 2: Review(4) + Recent(8)*/

body[data-active="dashboard"] #view-dashboard .dash-review {
  grid-column: span 6;
}

body[data-active="dashboard"] #view-dashboard .dash-recent {
  grid-column: span 6;
}

/*✅ Leaderboard 放到下一行全宽（如果你有 leaderboard 卡片）*/

body[data-active="dashboard"] #view-dashboard .dash-leaderboard {
  grid-column: 1 / -1;
}

/*Make cards tighter (only on dashboard)*/

body[data-active="dashboard"] #view-dashboard .card {
  padding: 16px;
  border-radius: 18px;
}

body[data-active="dashboard"] #view-dashboard .card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

body[data-active="dashboard"] #view-dashboard .card-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--text, #0b1220);
}

body[data-active="dashboard"] #view-dashboard .muted {
  font-size: 12px;
  color: var(--muted, #64748b);
  margin-top: 10px;
}

/*===== Study Summary (tabs + metrics) =====*/

body[data-active="dashboard"] #view-dashboard .summary-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(2,6,23,.04);
  border: 1px solid rgba(2,6,23,.06);
}

body[data-active="dashboard"] #view-dashboard .summary-tab {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
}

body[data-active="dashboard"] #view-dashboard .summary-tab.is-active {
  background: var(--accent-soft, rgba(34,197,94,.12));
  border-color: var(--accent-border, rgba(34,197,94,.35));
  color: #166534;
}

body[data-active="dashboard"] #view-dashboard .summary-square {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-top: 12px;
}

body[data-active="dashboard"] #view-dashboard .summary-metric {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(2,6,23,.10));
  background: var(--surface, #fff);
}

body[data-active="dashboard"] #view-dashboard .summary-value {
  font-size: 32px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text, #0b1220);
}

body[data-active="dashboard"] #view-dashboard .summary-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted, #64748b);
}

/*✅ 防止 Summary 卡片出现“巨大空白”*/

body[data-active="dashboard"] #view-dashboard .dash-summary {
  grid-column: span 4;
  min-height: unset;
}


/*===== Check-in: tighter pills =====*/

body[data-active="dashboard"] #view-dashboard .checkin {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(2,6,23,.03);
  border: 1px solid rgba(2,6,23,.06);
}

body[data-active="dashboard"] #view-dashboard .checkin-day {
  border-radius: 14px;
  padding: 10px 6px;
  border: 1px solid var(--border, rgba(2,6,23,.10));
  background: var(--surface, #fff);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

body[data-active="dashboard"] #view-dashboard .checkin-wd {
  font-size: 12px;
  color: var(--muted, #64748b);
}

body[data-active="dashboard"] #view-dashboard .checkin-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(2,6,23,.25);
}

body[data-active="dashboard"] #view-dashboard .checkin-day.is-on {
  background: var(--accent-soft, rgba(34,197,94,.12));
  border-color: var(--accent-border, rgba(34,197,94,.35));
}

body[data-active="dashboard"] #view-dashboard .checkin-day.is-on .checkin-dot {
  background: var(--accent, #22c55e);
}

/*===== Recent packs: smaller rows =====*/

body[data-active="dashboard"] #view-dashboard .mini-pack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

body[data-active="dashboard"] #view-dashboard .mini-pack {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(2,6,23,.10));
  background: var(--surface, #fff);
  text-decoration: none;
  color: inherit;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-thumb {
  width: 70px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  flex: 0 0 auto;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-title {
  font-size: 14px;
  font-weight: 750;
  margin-bottom: 2px;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-meta {
  font-size: 12px;
  color: var(--muted, #64748b);
}

/*===== Leaderboard: keep it compact with scroll =====*/

body[data-active="dashboard"] #view-dashboard .dash-leaderboard .table-wrap {
  max-height: 320px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border, rgba(2,6,23,.10));
}

body[data-active="dashboard"] #view-dashboard .dash-leaderboard .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface, #fff);
}

body[data-active="dashboard"] #view-dashboard .dash-leaderboard .table th,
body[data-active="dashboard"] #view-dashboard .dash-leaderboard .table td {
  padding: 10px 12px;
  font-size: 13px;
}

@media (max-width: 640px) {
  body[data-active="dashboard"] #view-dashboard .dash-leaderboard .table {
    min-width: 0;
    width: 100%;
  }
}

/*===== Responsive: stack on smaller screens =====*/

@media (max-width: 1100px) {
  body[data-active="dashboard"] #view-dashboard .dash-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  body[data-active="dashboard"] #view-dashboard .dash-summary,
    body[data-active="dashboard"] #view-dashboard .dash-cal,
    body[data-active="dashboard"] #view-dashboard .dash-checkin,
    body[data-active="dashboard"] #view-dashboard .dash-review,
    body[data-active="dashboard"] #view-dashboard .dash-recent,
    body[data-active="dashboard"] #view-dashboard .dash-leaderboard,
    body[data-active="dashboard"] #view-dashboard .dash-queue,
    body[data-active="dashboard"] #view-dashboard .dash-weak,
    body[data-active="dashboard"] #view-dashboard .dash-goal,
    body[data-active="dashboard"] #view-dashboard .dash-pb,
    body[data-active="dashboard"] #view-dashboard .dash-tip {
    grid-column: span 6;
  }
}

/*=== Search paused hint (review page) ===*/

body[data-active="mistakes"] .search-paused-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #64748b;
  background: rgba(255,255,255,.85);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(2,6,23,.10);
  pointer-events: none;
  white-space: nowrap;
}

/*==============================
   Dashboard: Review vs Recent aligned
   ==============================*/

/*只处理这两张卡：让内部结构可控，footer 能贴底*/

.dash-review,
.dash-recent {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/*标题区：两边同高 + 同样的下间距*/

.dash-review .card-title-row,
.dash-recent .card-title-row {
  min-height: var(--dash-panel-head-h);
  display: flex;
  align-items: center;
  margin-bottom: var(--dash-panel-gap);
}

/*中间内容区：两边用同样的排布和间距，并把 footer 顶到最底*/

.dash-review .review-tiles,
.dash-recent .mini-pack-list {
  display: flex;
  flex-direction: column;
  gap: var(--dash-panel-gap);
  flex: 1;
  min-height: 0;
}

/*三张可点击卡：两边同高度*/

.dash-review .review-tile,
.dash-recent .mini-pack {
  min-height: var(--dash-panel-item-h);
}

/*footer：两边同高度、贴底对齐*/

.dash-foot {
  margin-top: auto;
  min-height: var(--dash-panel-foot-h);
  display: flex;
  align-items: center;
}

/*“More” 作为按钮也要像一行 footer 一样高*/

.dash-foot .mini-link {
  min-height: var(--dash-panel-foot-h);
  display: inline-flex;
  align-items: center;
}

/*=========================
   Dashboard layout (3 cols)
   =========================*/

.dash-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.05fr 1.25fr 0.9fr;
  grid-template-areas: "checkin summary calendar"
    "review  review  recent"
    "leaderboard leaderboard leaderboard";
  align-items: stretch;
}

/*assign cards to grid areas*/

.dash-summary {
  grid-area: summary;
}

.dash-cal {
  grid-area: calendar;
}

.dash-review {
  grid-area: review;
}

.dash-recent {
  grid-area: recent;
}

.dash-leaderboard {
  grid-area: leaderboard;
}

/*top row height feels balanced*/

.dash-checkin, .dash-summary, .dash-cal {
  min-height: 220px;
}

/*2-column responsive*/

@media (max-width: 1100px) {
  .dash-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "checkin summary"
        "calendar recent"
        "review review"
        "leaderboard leaderboard";
  }
}

/*1-column mobile*/

@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "checkin"
        "summary"
        "calendar"
        "review"
        "recent"
        "leaderboard";
  }
}

/*=========================
   Check-in card UI
   =========================*/

.dash-checkin .card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.checkin-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  background: rgba(0,0,0,.02);
}

.checkin-stat-label {
  font-size: 12px;
  opacity: .7;
  margin-bottom: 6px;
}

.checkin-stat-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.checkin-stat-unit {
  font-size: 12px;
  opacity: .7;
  font-weight: 600;
}

.checkin-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.checkin-day {
  aspect-ratio: 1 / 1;
  background: rgba(148,163,184,.10);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed rgba(0,0,0,.18);
  border-radius: 14px;
  padding: 10px 0;
  text-align: center;
  user-select: none;
}

.checkin-wd {
  color: rgba(100,116,139,1);
  font-weight: 700;
  font-size: 12px;
  opacity: .7;
}

.checkin-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin: 8px auto 0;
  background: rgba(0,0,0,.12);
}

.checkin-day.is-on {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.checkin-day.is-on .checkin-dot {
  background: var(--accent);
}

/*check-in button*/

/*check-in progress button*/
.checkin-btn{
  position: relative;
  overflow: hidden;

  /* ✅ 只改颜色与效果，不设置 width/height/padding/radius */
  background: #e5e7eb;      /* 灰色底 */
  color: #111827;           /* 黑字 */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); /* 用内阴影当边框，不改变尺寸 */
  font-weight: 600;
}

/* 绿色进度覆盖（从左往右），宽度由 --p 控制 */
.checkin-btn::before{
  content:"";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--p, 0%);
  background: var(--accent);
  pointer-events: none;
  transition: width .25s ease;
}

/* 文字在最上层 */
.checkin-btn .checkin-btn-label{
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  text-align: center;
}

/* 可选：达到 5 分钟后（可打卡）稍微强调一下 */
.checkin-btn.is-ready{
  border-color: var(--accent-border);
}

/* 可选：已打卡 */
.checkin-btn.is-checked{
  border-color: var(--accent-border);
  background: var(--accent-soft);
}


/*=== Daily Check-in: 7 天完整显示 ===*/

.dash-checkin .checkin-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.dash-checkin .checkin-day {
  min-width: 0;
  padding: 8px 0;
  text-align: center;
}

.dash-checkin .checkin-wd {
  font-size: 12px;
  line-height: 1;
  margin-bottom: 6px;
}

/*如果你遇到卡片底部被裁切（看不到圆点/文字），加这个兜底*/

.dash-checkin {
  grid-area: checkin;
  overflow: visible;
  min-height: 220px;
}

/*✅ Dashboard 顶部三张：强制跟网格同高*/

body[data-active="dashboard"] #view-dashboard .dash-summary,
body[data-active="dashboard"] #view-dashboard .dash-cal,
body[data-active="dashboard"] #view-dashboard .dash-checkin {
  height: 100%;
  display: flex;
  flex-direction: column;
}
/* =========================
   Dashboard – Extra Widgets
   (append to end of app.css)
   ========================= */

/* Make the new widgets fit the 12-col dashboard grid:
   Row 3: Queue(4) + Weak(8) = 12 */
body[data-active="dashboard"] #view-dashboard .dash-queue{
  grid-column: span 4;
}
body[data-active="dashboard"] #view-dashboard .dash-weak{
  grid-column: span 8;
}

/* Small link/button in card header */
body[data-active="dashboard"] #view-dashboard .dash-link{
  border: 1px solid rgba(2,6,23,.12);
  background: rgba(2,6,23,.02);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted, #64748b);
  cursor: pointer;
  text-decoration: none;
}
body[data-active="dashboard"] #view-dashboard .dash-link:hover{
  background: rgba(2,6,23,.05);
}

/* Review Queue layout */
body[data-active="dashboard"] #view-dashboard .dq-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

body[data-active="dashboard"] #view-dashboard .dq-item{
  border: 1px solid rgba(2,6,23,.08);
  background: rgba(2,6,23,.02);
  border-radius: 14px;
  padding: 12px;
}

body[data-active="dashboard"] #view-dashboard .dq-num{
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -0.01em;
  color: var(--text, #0b1220);
}

body[data-active="dashboard"] #view-dashboard .dq-label{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #64748b);
}

body[data-active="dashboard"] #view-dashboard .dq-actions{
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Dashboard-only buttons (don’t touch your global .btn) */
body[data-active="dashboard"] #view-dashboard .dash-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

body[data-active="dashboard"] #view-dashboard .dash-btn.is-primary{
  background: var(--accent);
  color: #fff;
}

body[data-active="dashboard"] #view-dashboard .dash-btn.is-ghost{
  background: rgba(2,6,23,.03);
  border-color: rgba(2,6,23,.10);
  color: var(--text, #0b1220);
}

body[data-active="dashboard"] #view-dashboard .dash-btn:hover{
  opacity: .92;
}

/* Weak Spots list */
body[data-active="dashboard"] #view-dashboard .weak-sub{
  margin-top: 8px;
}

body[data-active="dashboard"] #view-dashboard .weak-list{
  margin-top: 12px;
  padding-left: 18px;
}

body[data-active="dashboard"] #view-dashboard .weak-list li{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(2,6,23,.08);
  background: rgba(2,6,23,.02);
  margin-bottom: 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

body[data-active="dashboard"] #view-dashboard .weak-key{
  font-weight: 750;
  color: var(--text, #0b1220);
}

body[data-active="dashboard"] #view-dashboard .weak-count{
  font-variant-numeric: tabular-nums;
  color: var(--muted, #64748b);
}

body[data-active="dashboard"] #view-dashboard .weak-empty{
  list-style: none;
  padding-left: 0;
  border: 1px dashed rgba(2,6,23,.18);
  background: transparent;
  color: var(--muted, #64748b);
}

/* Responsive: follow your existing rule (<=1100px -> 6 columns) */
@media (max-width: 1100px){
  body[data-active="dashboard"] #view-dashboard .dash-queue,
  body[data-active="dashboard"] #view-dashboard .dash-weak{
    grid-column: span 6;
  }
}



/* =========================
   Dashboard – Goals / PB / Tips
   (append to end of app.css)
   ========================= */

body[data-active="dashboard"] #view-dashboard .dash-goal{ grid-column: span 4; }
body[data-active="dashboard"] #view-dashboard .dash-pb{   grid-column: span 4; }
body[data-active="dashboard"] #view-dashboard .dash-tip{  grid-column: span 4; }

/* Goals */
body[data-active="dashboard"] #view-dashboard .goal-block{
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(2,6,23,.06);
}
body[data-active="dashboard"] #view-dashboard .goal-block:first-of-type{
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
body[data-active="dashboard"] #view-dashboard .goal-row{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
body[data-active="dashboard"] #view-dashboard .goal-label{
  font-weight: 750;
}
body[data-active="dashboard"] #view-dashboard .goal-value{
  color: var(--muted, #64748b);
  font-variant-numeric: tabular-nums;
}
body[data-active="dashboard"] #view-dashboard .goal-bar{
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: rgba(2,6,23,.06);
  overflow: hidden;
}
body[data-active="dashboard"] #view-dashboard .goal-bar-fill{
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 200ms ease;
}
body[data-active="dashboard"] #view-dashboard .goal-quick{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
body[data-active="dashboard"] #view-dashboard .goal-chip{
  border: 1px solid rgba(2,6,23,.10);
  background: rgba(2,6,23,.02);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
body[data-active="dashboard"] #view-dashboard .goal-chip:hover{
  background: rgba(2,6,23,.05);
}

/* PB */
body[data-active="dashboard"] #view-dashboard .pb-grid{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
body[data-active="dashboard"] #view-dashboard .pb-item{
  border: 1px solid rgba(2,6,23,.08);
  background: rgba(2,6,23,.02);
  border-radius: 14px;
  padding: 12px;
}
body[data-active="dashboard"] #view-dashboard .pb-value{
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
body[data-active="dashboard"] #view-dashboard .pb-label{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #64748b);
}
body[data-active="dashboard"] #view-dashboard .pb-sub{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #64748b);
}

/* Tips */
body[data-active="dashboard"] #view-dashboard .tip-body{
  margin-top: 12px;
  border: 1px solid rgba(2,6,23,.08);
  background: rgba(2,6,23,.02);
  border-radius: 14px;
  padding: 12px;
}
body[data-active="dashboard"] #view-dashboard .tip-title{
  font-weight: 850;
  margin-bottom: 8px;
}
body[data-active="dashboard"] #view-dashboard .tip-text{
  color: var(--muted, #64748b);
  line-height: 1.55;
}

@media (max-width: 720px) {
  body[data-active="dashboard"] #view-dashboard .dash-grid {
    grid-template-columns: 1fr;
  }
  body[data-active="dashboard"] #view-dashboard .dash-summary,
    body[data-active="dashboard"] #view-dashboard .dash-cal,
    body[data-active="dashboard"] #view-dashboard .dash-checkin,
    body[data-active="dashboard"] #view-dashboard .dash-review,
    body[data-active="dashboard"] #view-dashboard .dash-recent,
    body[data-active="dashboard"] #view-dashboard .dash-leaderboard,
    body[data-active="dashboard"] #view-dashboard .dash-queue,
    body[data-active="dashboard"] #view-dashboard .dash-weak,
    body[data-active="dashboard"] #view-dashboard .dash-goal,
    body[data-active="dashboard"] #view-dashboard .dash-pb,
    body[data-active="dashboard"] #view-dashboard .dash-tip {
    grid-column: 1 / -1;
  }
  body[data-active="dashboard"] #view-dashboard .summary-square {
    grid-template-columns: 1fr;
  }
  body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(36px, 1fr);
  }
  body[data-active="dashboard"] #view-dashboard .checkin {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  body[data-active="dashboard"] #view-dashboard .dq-grid,
    body[data-active="dashboard"] #view-dashboard .pb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm {
    grid-auto-rows: minmax(32px, 1fr);
    gap: 6px;
  }
  body[data-active="dashboard"] #view-dashboard .dq-grid,
    body[data-active="dashboard"] #view-dashboard .pb-grid {
    grid-template-columns: 1fr;
  }
  body[data-active="dashboard"] #view-dashboard .checkin {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

/* =========================================================
   Dashboard layout spec (3 columns -> 2 columns -> 1 column)
   (This block is scoped to body[data-active="dashboard"])
   ========================================================= */
body[data-active="dashboard"] #view-dashboard .dash-grid{
  display: grid;
  gap: 16px;
  width: 100%;
  align-items: stretch;

  /* Right column should stay stable as the window shrinks */
  --dash-right-w: 340px;

  /* 3/8, 3/8, 1/4 */
  grid-template-columns: minmax(0, 3fr) minmax(0, 3fr) minmax(var(--dash-right-w), 2fr);
  grid-template-areas:
  "summary goal    calendar"
  "checkin review  recent";
}

body[data-active="dashboard"] #view-dashboard .dash-summary{ grid-area: summary; }
body[data-active="dashboard"] #view-dashboard .dash-goal{ grid-area: goal; }
body[data-active="dashboard"] #view-dashboard .dash-tip{ grid-area: tip; }
body[data-active="dashboard"] #view-dashboard .dash-checkin{ grid-area: checkin; }
body[data-active="dashboard"] #view-dashboard .dash-review{ grid-area: review; }
body[data-active="dashboard"] #view-dashboard .dash-cal{ grid-area: calendar; }
body[data-active="dashboard"] #view-dashboard .dash-recent{ grid-area: recent; }

/* Hide extra widgets (not part of the 7-card layout) */
body[data-active="dashboard"] #view-dashboard .dash-queue,
body[data-active="dashboard"] #view-dashboard .dash-weak,
body[data-active="dashboard"] #view-dashboard .dash-pb,
body[data-active="dashboard"] #view-dashboard .dash-leaderboard{
  display: none !important;
}

/* Prevent overflow in grid columns */
body[data-active="dashboard"] #view-dashboard .dash-summary,
body[data-active="dashboard"] #view-dashboard .dash-goal,
body[data-active="dashboard"] #view-dashboard .dash-tip,
body[data-active="dashboard"] #view-dashboard .dash-checkin,
body[data-active="dashboard"] #view-dashboard .dash-review,
body[data-active="dashboard"] #view-dashboard .dash-cal,
body[data-active="dashboard"] #view-dashboard .dash-recent{
  min-width: 0;
}

/* ===== Study Summary: metrics must fill width and never grow taller due to wrapping ===== */
body[data-active="dashboard"] #view-dashboard .dash-summary .summary-square{
  width: 100% !important;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric{
  min-width: 0;
}

/* No wrapping -> no unexpected height growth */
body[data-active="dashboard"] #view-dashboard .dash-summary .summary-value,
body[data-active="dashboard"] #view-dashboard .dash-summary .summary-label{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Tooltips: fixed spot (no mouse tracking), wrap safely, never clipped ===== */
/* ===== Tooltips: fixed spot (no mouse tracking), single-line, never clipped ===== */
body[data-active="dashboard"] .cal-tooltip{
  transform: translate(-50%, 0);
  white-space: nowrap;   /* ✅ 不换行 */
  max-width: none;       /* ✅ 不用 max-width 逼它换行 */
}


/* ===== Study Calendar (sm): smaller dots + fixed 6-row height ===== */
body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm{
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 22px;           /* 1 header row + 6 week rows => stable height */
  gap: 8px;
  justify-items: center;
  align-items: center;
  align-content: start;
  margin-top: 8px;
}

body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-head{
  width: 100%;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day{
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.14);
  background: rgba(2,6,23,.04);

  /* ✅ 小圆点视觉 2 倍，但不改变格子尺寸 => 模块高度仍稳定 */
  transform: scale(1.5);
  transform-origin: center;

  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}
body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day:hover{
  transform: scale(1.8);
}


body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day.studied{
  background: var(--accent);
  border-color: var(--accent);
}

body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day.is-empty{
  visibility: hidden;            /* keep space (height stable) but hide non-month days */
  border-color: transparent;
  background: transparent;
}

/* ===== Review / Recent: keep footer pinned to bottom when stretched ===== */
body[data-active="dashboard"] #view-dashboard .dash-review,
body[data-active="dashboard"] #view-dashboard .dash-recent{
  display: flex;
  flex-direction: column;
}

body[data-active="dashboard"] #view-dashboard .dash-review .dash-foot,
body[data-active="dashboard"] #view-dashboard .dash-recent .dash-foot{
  margin-top: auto;
}

/* ===== Bottom nav (only visible in 1-column mode) ===== */
body[data-active]:not([data-active="practice"]) .bottom-nav{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 250;

  display: none;
  align-items: center;
  justify-content: space-around;

  height: 74px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.92);
  border-top: 1px solid rgba(2,6,23,.10);
  backdrop-filter: blur(10px);
}

body[data-active]:not([data-active="practice"]) .bottom-nav .bn-btn{
  appearance: none;
  border: 0;
  background: transparent;
  color: #6b7280;
  border-radius: 14px;
  padding: 8px 10px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  font-size: 11px;
  line-height: 1.1;
  cursor: pointer;
  min-width: 56px;
}

body[data-active]:not([data-active="practice"]) .bottom-nav .bn-ico{
  font-size: 18px;
  line-height: 1;
}

body[data-active]:not([data-active="practice"]) .bottom-nav .bn-btn:active{
  background: rgba(2,6,23,.06);
}

body[data-active]:not([data-active="practice"]) .bottom-nav .bn-btn.is-active{
  color: #111827;
}

/* ===== Responsive: 2 columns (keep right stable; Micro Tip moves under Recent) ===== */
@media (max-width: 1100px){
  body[data-active="dashboard"] #view-dashboard .dash-grid{
    grid-template-columns: minmax(0, 1fr) var(--dash-right-w);
    grid-template-areas:
      "summary calendar"
      "goal    recent"
      "checkin recent"
      "review  tip";
  }
}

/* ===== Responsive: hide sidebar earlier (when it would become top menu) + show bottom nav ===== */
@media (max-width: 860px){
  body[data-active]:not([data-active="practice"]) .sidebar{
    display: none !important;
  }
  body[data-active]:not([data-active="practice"]) .page{
    padding-left: 0 !important;
  }
  body[data-active]:not([data-active="practice"]) .content{
    padding-bottom: 90px; /* avoid bottom nav overlap */
  }
  body[data-active]:not([data-active="practice"]) .bottom-nav{
    display: flex;
  }
}

/* ===== Responsive: dashboard becomes 1 column only on smaller phones ===== */
@media (max-width: 720px){
  body[data-active="dashboard"] #view-dashboard .dash-grid{
    grid-template-columns: 1fr;
    grid-template-areas:
      "summary"
      "goal"
      "checkin"
      "review"
      "calendar"
      "recent"
      "tip";
  }
}


/* Extra-small: stack summary metrics if needed */
@media (max-width: 420px){
  body[data-active="dashboard"] #view-dashboard .dash-summary .summary-square{
    grid-template-columns: 1fr;
  }
}

/* ===== Store search ===== */
.store-search{
  display:flex;
  gap:10px;
  align-items:center;
  margin:12px 0 6px;
}
.store-search input{
  flex:1;
  min-width:0;
  padding:10px 12px;
  border:1px solid rgba(0,0,0,.15);
  border-radius:12px;
  font-size:14px;
  background:transparent;
  color:inherit;
}
.store-search button{
  width:36px;
  height:36px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.15);
  background:transparent;
  cursor:pointer;
  font-size:20px;
  line-height:1;
  opacity:.75;
}
.store-search button:hover{ opacity:1; }

/* ✅ 保证导航栏永远在顶栏上面（包括临时展开→缩回的过渡动画中） */
.tp-topbar{
  z-index: 9000 !important;
}
/* === Mobile header: hide Local data + auth, show dashboard logo === */
.tp-mobile-dash-logo{
  display:none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}
.tp-mobile-dash-logo img{
  width: 24px;
  height: 24px;
  display:block;
}
/* ✅ 深色背景时 logo 反白 */
html[data-theme="dark"] .tp-mobile-dash-logo img,
body[data-theme="dark"] .tp-mobile-dash-logo img{
  filter: brightness(0) invert(1);
}
html[data-theme="light"] .tp-mobile-dash-logo img,
body[data-theme="light"] .tp-mobile-dash-logo img{
  filter: none;
}

@media (max-width: 860px){
  .tp-hide-on-mobile{ display:none !important; }
  .tp-mobile-dash-logo{ display:inline-flex; }
}

/* Store (Course Library) page: remove the big container background & border */
body[data-active="store"] .card{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important; /* 有些“描边”其实是 shadow 做的细线 */
}
body[data-active="my-packs"] .card{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
/* spacing between "Course details" bar and the big card below */
body[data-active="store"] #detailHeader + .card,
body[data-active="my-packs"] #detailHeader + .card{
  margin-top: -26px; /* 改这里：正数=更远，负数=更近 */
}
/* =========================
   Global Dark Theme (统一用 #0b1321)
   ========================= */
html[data-theme="dark"]{
  color-scheme: dark;
  --mi-bg: #0b1321;                  /* ✅ 小框同款底色 */
  --mi-border: rgba(255,255,255,.10);
  --mi-text: rgba(255,255,255,.92);
  --mi-muted: rgba(255,255,255,.62);
  --mi-field: rgba(255,255,255,.06);
}

/* 页面整体背景（解决“框外还是亮色”） */
html[data-theme="dark"] body,
html[data-theme="dark"] .page,
html[data-theme="dark"] .content,
html[data-theme="dark"] .view,
html[data-theme="dark"] .wrap{
  background: var(--mi-bg) !important;
  color: var(--mi-text) !important;
}

/* 顶部那一栏（解决“顶部暗色不统一”） */
html[data-theme="dark"] .content-header{
  background: var(--mi-bg) !important;
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom: 1px solid rgba(255,255,255,.08) !important;
}

html[data-theme="dark"] .title-main{ color: var(--mi-text) !important; }
html[data-theme="dark"] .title-sub{ color: var(--mi-muted) !important; }

/* 通用卡片/面板（如果你想“卡片也完全同色”） */
html[data-theme="dark"] .card{
  background: var(--mi-bg) !important;
  border-color: var(--mi-border) !important;
}

/* 表单控件：避免下拉框/输入框还发白 */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
  background: var(--mi-field) !important;
  border: 1px solid var(--mi-border) !important;
  color: var(--mi-text) !important;
}

html[data-theme="dark"] option{ background: var(--mi-bg); }

/* 徽章/按钮（避免右上角 badge 还是亮） */
html[data-theme="dark"] .badge,
html[data-theme="dark"] .settings-saved,
html[data-theme="dark"] .settings-reset-btn{
  background: rgba(255,255,255,.08) !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  color: rgba(255,255,255,.90) !important;
}
/* =========================
   Global theme tokens + dark overrides
   ========================= */
:root{
  --tp-bg-body:#f7f7f9;
  --tp-bg-surface:#ffffff;
  --tp-bg-surface-alt:#f3f4f6;
  --tp-border-subtle:#e5e7eb;
  --tp-text-main:#0f172a;
  --tp-text-muted:#64748b;
  --tp-accent:#22c55e;
}

/* 你截图里“小框”的深色大约是 #0a1220；页面底色更深一档 */
html[data-theme="dark"]{
  --tp-bg-body:#070c16;
  --tp-bg-surface:#0a1220;
  --tp-bg-surface-alt:#0d172a;
  --tp-border-subtle:rgba(255,255,255,.08);
  --tp-text-main:#e5e7eb;
  --tp-text-muted:rgba(229,231,235,.65);
}

/* page background */
html[data-theme="dark"],
html[data-theme="dark"] body{
  background: var(--tp-bg-body);
  color: var(--tp-text-main);
}

/* 顶部栏也用“小框”的颜色（你之前说“顶部那一栏要和下面一致”） */
html[data-theme="dark"] .content-header{
  background: var(--tp-bg-surface);
  border-bottom: 1px solid var(--tp-border-subtle);
}

/* 统一把常见“白模块”改成深色卡片 */
html[data-theme="dark"] .card,
html[data-theme="dark"] .course-card,
html[data-theme="dark"] .lesson-card,
html[data-theme="dark"] .price-card,
html[data-theme="dark"] .review-tile,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .mini-pack,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-head,
html[data-theme="dark"] .modal-body{
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  border: 1px solid var(--tp-border-subtle);
}

/* 输入框/下拉/搜索框（避免白底） */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
  background: var(--tp-bg-surface-alt);
  border: 1px solid rgba(255,255,255,.18);
  color: var(--tp-text);
}


/* 表格（Leaderboard 那种大白块通常就是 table / th / td） */
html[data-theme="dark"] table{
  background: transparent;
  color: var(--tp-text-main);
}
html[data-theme="dark"] th,
html[data-theme="dark"] td{
  border-color: var(--tp-border-subtle);
}
html[data-theme="dark"] th{
  background: var(--tp-bg-surface);
}

/* 一些“灰字” */
html[data-theme="dark"] .muted,
html[data-theme="dark"] .title-sub{
  color: var(--tp-text-muted);
}

/* 保险：暗色模式下，simple-toggle 打开时永远用绿色 */
html[data-theme="dark"] .simple-toggle input:checked{
  background: #22c55e !important;
}
html[data-theme="dark"] .simple-toggle input:checked::before{
  background: #fff !important;
}
/* ===== Leaderboard: dark theme table fix ===== */
html[data-theme="dark"] body[data-active="leaderboard"] .table-wrap{
  background: transparent !important;
}

html[data-theme="dark"] body[data-active="leaderboard"] table.table{
  background: transparent !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

html[data-theme="dark"] body[data-active="leaderboard"] table.table th,
html[data-theme="dark"] body[data-active="leaderboard"] table.table td{
  background: transparent !important;
  color: var(--tp-text-main, #e5e7eb) !important;
  border-color: var(--tp-border-subtle, rgba(255,255,255,.08)) !important;
}

/* 表头给一点深色底 + 更清晰的字 */
html[data-theme="dark"] body[data-active="leaderboard"] table.table thead th{
  background: var(--tp-bg-surface-alt, #0d172a) !important;
  color: rgba(229,231,235,.9) !important;
}

/* 可选：隔行底色 + hover，避免一片黑不好读 */
html[data-theme="dark"] body[data-active="leaderboard"] table.table tbody tr:nth-child(even) td{
  background: rgba(255,255,255,.02) !important;
}
html[data-theme="dark"] body[data-active="leaderboard"] table.table tbody tr:hover td{
  background: rgba(255,255,255,.04) !important;
}
/* ==============================
   Dark mode polish (Progress + Settings switch)
   ✅ 放到 app.css 最底部
   ============================== */

/* Settings：开关“开启”永远用绿色（不跟随其它 accent） */
body[data-active="settings"] .simple-toggle input:checked,
body[data-active="settings"] .simple-toggle input:checked + .toggle-track{
  background: #22c55e !important;
  border-color: #22c55e !important;
}

/* Progress：把残留白底模块改成暗色表面 */
html[data-theme="dark"] body[data-active="progress"] .kpi,
html[data-theme="dark"] body[data-active="progress"] .day-dot:not(.is-on),
html[data-theme="dark"] body[data-active="progress"] .bar-wrap,
html[data-theme="dark"] body[data-active="progress"] .trend,
html[data-theme="dark"] body[data-active="progress"] .table-wrap,
html[data-theme="dark"] body[data-active="progress"] .chip,
html[data-theme="dark"] body[data-active="progress"] .seg:not(.is-active),
html[data-theme="dark"] body[data-active="progress"] .btn{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: rgba(255,255,255,.92) !important;
}

/* Range 按钮激活态：保留绿色高亮 */
html[data-theme="dark"] body[data-active="progress"] .seg.is-active{
  background: rgba(34,197,94,.18) !important;
  border-color: rgba(34,197,94,.45) !important;
  color: rgba(255,255,255,.92) !important;
}

/* 文字（灰字在暗色里稍微提亮） */
html[data-theme="dark"] body[data-active="progress"] .kpi-label,
html[data-theme="dark"] body[data-active="progress"] .kpi-sub,
html[data-theme="dark"] body[data-active="progress"] .trend-label{
  color: rgba(255,255,255,.62) !important;
}

/* Practice trend：未点亮的柱子底色（原来是 #e5e7eb 太亮） */
html[data-theme="dark"] body[data-active="progress"] .trend-bar{
  background: rgba(255,255,255,.16) !important;
}

/* Recent Sessions 表格：表头/分割线/hover */
html[data-theme="dark"] body[data-active="progress"] .simple-table th,
html[data-theme="dark"] body[data-active="progress"] .simple-table td{
  border-bottom-color: rgba(255,255,255,.10) !important;
  color: rgba(255,255,255,.90) !important;
}

html[data-theme="dark"] body[data-active="progress"] .simple-table thead th{
  background: rgba(255,255,255,.08) !important;
  color: rgba(255,255,255,.92) !important;
}

html[data-theme="dark"] body[data-active="progress"] .simple-table tbody tr:hover{
  background: rgba(255,255,255,.06) !important;
}
/* ===============================
   Dark mode fixes: Mistakes page
   (override hard-coded light styles)
   =============================== */

html[data-theme="dark"] body[data-active="mistakes"] .mistake-item{
  background: var(--tp-bg-surface-alt, #0d172a) !important;
  border-color: var(--tp-border-subtle, rgba(255,255,255,.10)) !important;
  box-shadow: 0 10px 26px rgba(0,0,0,.30) !important;
}

html[data-theme="dark"] body[data-active="mistakes"] .mistake-wrong,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-cell-py,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-cell-hz{
  color: var(--tp-text-main, #e5e7eb) !important;
}

html[data-theme="dark"] body[data-active="mistakes"] .mistake-hanzi,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-meta,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-field-label,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-date,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-sep{
  color: var(--tp-text-muted, rgba(229,231,235,.65)) !important;
}

/* play button (speaker) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-play{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* toolbar controls: search + selects */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-search input,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-field select,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-sort select{
  background: var(--tp-bg-surface-alt, #0d172a) !important;
  border-color: var(--tp-border-subtle, rgba(255,255,255,.10)) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* Display dropdown menu */
html[data-theme="dark"] body[data-active="mistakes"] .tp-dd-menu{
  background: var(--tp-bg-surface, #0a1220) !important;
  border-color: var(--tp-border-subtle, rgba(255,255,255,.10)) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
  box-shadow: 0 18px 55px rgba(0,0,0,.55) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .tp-dd-check{
  border-color: rgba(255,255,255,.18) !important;
}

/* top buttons (Display / Bulk / Clear...) */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn:not(.mistake-btn-primary){
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn:not(.mistake-btn-primary):hover{
  filter: none !important;
  background: rgba(255,255,255,.08) !important;
}

/* tabs text (inactive) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-tab{
  color: var(--tp-text-muted, rgba(229,231,235,.70)) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-tab:hover{
  background: rgba(255,255,255,.06) !important;
}

/* per-item delete X */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-del{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-muted, rgba(229,231,235,.70)) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-del:hover{
  background: rgba(255,255,255,.10) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* =========================
   Mistakes: dark mode fixes (fix invalid rgba + remove remaining white)
   ========================= */

/* list cards */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-item{
  background: var(--tp-bg-surface, #0a1220) !important;
  border-color: rgba(255,255,255,.12) !important;
  box-shadow: 0 16px 40px rgba(0,0,0,.35) !important;
}

/* texts inside list */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-cell-hz{
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-meta,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-enline,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-missing,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-attempt-time{
  color: var(--tp-text-muted, rgba(229,231,235,.65)) !important;
}

/* speaker button (was white) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-play{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-play svg{
  fill: var(--tp-text-main, #e5e7eb) !important;
  stroke: var(--tp-text-main, #e5e7eb) !important;
}

/* right-side buttons (Clear / Bulk / etc) */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn:hover{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.20) !important;
}
/* danger button text needs contrast */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn.danger{
  background: rgba(239,68,68,.12) !important;
  border-color: rgba(239,68,68,.35) !important;
  color: #fca5a5 !important;
}
/* keep Practice = green */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn.mistake-btn-primary{
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

/* bulk action bar */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-bulkbar{
  background: rgba(255,255,255,.04) !important;
  border-color: rgba(255,255,255,.10) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* hover chips: “Add to mastered …” (was white) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-chip{
  border-color: rgba(255,255,255,.12) !important;
  background: rgba(255,255,255,.06) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-chip:hover{
  background: rgba(255,255,255,.10) !important;
}

/* modal card */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-card{
  background: var(--tp-bg-surface, #0a1220) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-head{
  border-bottom-color: rgba(255,255,255,.10) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-footer{
  border-top-color: rgba(255,255,255,.10) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-close{
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* 👇 the big white block in your screenshot (sticky area was background:#fff) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-sticky{
  background: var(--tp-bg-surface, #0a1220) !important;
}

/* wordbox + modal title texts (were black/gray on white) */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-wordbox{
  background: rgba(255,255,255,.04) !important;
  border-color: rgba(255,255,255,.12) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-py,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-hz{
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-en{
  color: var(--tp-text-muted, rgba(229,231,235,.65)) !important;
}

/* attempts blocks */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-attempt{
  border-color: rgba(255,255,255,.12) !important;
  background: rgba(255,255,255,.04) !important;
}

/* tokens */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-token{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
}

/* delete button in modal */
html[data-theme="dark"] body[data-active="mistakes"] .mistake-delete-btn{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-delete-btn:hover{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.20) !important;
}

/* =========================
   Dark mode fixes: Store / My Courses (Course Library)
   （把这一段放到 app.css 最底部）
   ========================= */

/* My Courses：Go to Course Library → 变成可读（解决“紫色字+灰底看不清”） */
.pack-hint-btn{
  color: var(--tp-text-main, #0f172a);
  background: var(--tp-bg-surface, rgba(255,255,255,.70));
}
.pack-hint-btn:hover{
  background: var(--tp-bg-surface-alt, rgba(255,255,255,.92));
}

/* Course Library：分类 chips（解决“白色胶囊 + 白字看不见”） */
html[data-theme="dark"] .cat-chip{
  background: var(--tp-bg-surface-alt);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-main);
}
html[data-theme="dark"] .cat-chip:hover{
  background: var(--tp-bg-surface);
}
html[data-theme="dark"] .cat-chip.is-active{
  background: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.45);
  color: var(--tp-text-main);
}

/* 进入课程后：顶部“← Course details” 那条白底（解决大白条+箭头不清楚） */
html[data-theme="dark"] #detailHeader{
  background: var(--tp-bg-surface);
  border-bottom: 1px solid var(--tp-border-subtle);
}
html[data-theme="dark"] .back-icon{
  background: var(--tp-bg-surface-alt);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-main);
}

/* 进入课程后：课程介绍大卡片（course hero）白底（解决白底+文字看不清） */
html[data-theme="dark"] .course-hero{
  background: var(--tp-bg-surface);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-main);
}
html[data-theme="dark"] .hero-desc,
html[data-theme="dark"] .hero-meta{
  color: var(--tp-text-muted);
}
html[data-theme="dark"] .hero-start.is-added{
  background: rgba(255,255,255,.06);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-muted);
}

/* 课程列表：一些灰字/分割线在暗色里更清晰 */
html[data-theme="dark"] .lesson-meta,
html[data-theme="dark"] .lesson-progress,
html[data-theme="dark"] .lp-left{
  color: var(--tp-text-muted);
}
html[data-theme="dark"] .lesson-progress{
  border-top-color: rgba(255,255,255,.10);
}
html[data-theme="dark"] .lesson-progress strong{
  color: var(--tp-text-main);
}
html[data-theme="dark"] .lp-bar{
  background: rgba(255,255,255,.12);
}

/* 搜索框右侧清除按钮：避免边框/文字发黑或看不见 */
html[data-theme="dark"] .store-search input{
  background: var(--tp-bg-surface-alt);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-main);
}
html[data-theme="dark"] .store-search button{
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  color: var(--tp-text-main);
}
/* Dark mode: lesson “Studied X times” badge 更清晰 */
html[data-theme="dark"] .lesson-badge{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.16);
  color: var(--tp-text-main);
}

/* “Last studied” 那个也确保字清晰（不改变你原来的绿色/边框逻辑） */
html[data-theme="dark"] .lesson-badge.is-last{
  color: var(--tp-text-main);
}
/* ===============================
   Dashboard: Dark mode readability fix
   =============================== */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard{
  --dash-surface: var(--tp-bg-surface, #0a1220);
  --dash-surface-alt: var(--tp-bg-surface-alt, #0d172a);
  --dash-border: var(--tp-border-subtle, rgba(255,255,255,.10));
  --dash-text: var(--tp-text-main, rgba(255,255,255,.92));
  --dash-muted: var(--tp-text-muted, rgba(229,231,235,.65));
  color: var(--dash-text);
}

/* ---- Study Summary 白色方块（summary-metric）---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-metric{
  background: var(--dash-surface) !important;
  border: 1px solid var(--dash-border) !important;
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-value{
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-label{
  color: var(--dash-muted) !important;
}

/* ---- Dashboard 模块标题/灰字 ---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .card-title{
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-link,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-wd,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .pb-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .pb-sub,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .tip-text,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-value{
  color: var(--dash-muted) !important;
}

/* ---- Summary tabs（Total/Year/Month/Week）---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-tabs{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.10) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-tab{
  color: var(--dash-muted) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-tab.is-active{
  color: rgba(255,255,255,.92) !important;
}

/* ---- Daily Check-in：按钮 & 天格子（你图里全是白的）---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .btn.checkin-btn{
  background: rgba(255,255,255,.10) !important;
  border: 1px solid rgba(255,255,255,.14) !important;
  color: rgba(255,255,255,.92) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-top{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.10) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-day{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.16) !important; /* 原来是黑色虚线，暗色下看不见 */
}

/* ✅ 已打卡：恢复绿色填充（未打卡保持现在这样） */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-day.is-on{
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-day.is-on .checkin-wd{
  color: rgba(255,255,255,.95) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-day.is-on .checkin-dot{
  background: rgba(255,255,255,.92) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-dot{
  background: rgba(255,255,255,.22) !important;
}


/* ---- Recent Courses / Practice：白色长条卡片（mini-pack）---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .mini-pack{
  background: var(--dash-surface) !important;
  border-color: var(--dash-border) !important;
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .mini-pack-title{
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .mini-pack-meta{
  color: var(--dash-muted) !important;
}

/* ---- Study Calendar：非打卡日期看不到（小圆点太暗）+ 箭头按钮太白 ---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .calendar-sm .cal-day{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.18) !important;
}

/* ✅ 已打卡：恢复绿色填充（否则会被上面的 !important 盖掉） */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .calendar-sm .cal-day.studied{
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: rgba(255,255,255,.96) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .calendar-sm .cal-head,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-month{
  color: var(--dash-muted) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .icon-btn{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.16) !important;
  color: rgba(255,255,255,.92) !important;
}

/* ---- Today’s Goal：进度条底色/快捷按钮不清晰 ---- */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-bar{
  background: rgba(255,255,255,.14) !important; /* 让底槽明显 */
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-chip{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
  color: rgba(255,255,255,.92) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-chip:hover{
  background: rgba(255,255,255,.10) !important;
}
/* ===== Progress: dark theme remaining white blocks fix ===== */
html[data-theme="dark"] body[data-active="progress"] .bar-wrap,
html[data-theme="dark"] body[data-active="progress"] .trend,
html[data-theme="dark"] body[data-active="progress"] .table-wrap{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
}

html[data-theme="dark"] body[data-active="progress"] .simple-table{
  background: transparent !important;
}
/* Practice trend：点亮的柱子必须是绿色 */
body[data-active="progress"] .trend-bar.is-on{
  background: #22c55e !important;
}
html[data-theme="dark"] body[data-active="progress"] .trend-bar:not(.is-on){
  background: rgba(255,255,255,.16) !important;
}
/* ✅ Progress > Practice trend：点亮（有学习记录）的柱子强制用绿色 */
body[data-active="progress"] #trend-7 .trend-col.is-on .trend-bar,
body[data-active="progress"] #trend-7 .trend-bar.is-on{
  background: #22c55e !important;
}

/* 暗色模式下：未点亮柱子用更柔和的灰色（可选，但推荐） */
html[data-theme="dark"] body[data-active="progress"] #trend-7 .trend-bar:not(.is-on){
  background: rgba(255,255,255,.16) !important;
}
/* --- Practice: force follow theme tokens --- */
body[data-active="practice"] .pinyin-hint{
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
}

body[data-active="practice"] .word-meaning{
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  border: 1px solid var(--tp-border-subtle);
}

body[data-active="practice"] .sentence-item:hover{
  background: var(--tp-bg-surface-alt);
}


/* ===== Prevent sidebar/page flash on navigation & first paint ===== */

/* First paint + navigation moment: disable transitions to avoid layout 'jump' */
html.sb-noanim .sidebar,
html.sb-noanim .page {
  transition: none !important;
}

/* Freeze sidebar width on navigation to prevent hover/peek collapse revealing page content */
html.sb-freeze .sidebar {
  width: var(--sidebar-freeze-w) !important;
  transition: none !important;
}

/* Before sidebar.js adds .is-pinned/.is-peek, keep first paint consistent with persisted state */
html.sb-pinned-init .sidebar {
  width: var(--sidebar-expanded) !important;
}

html.sb-peek-init .sidebar:not(.is-pinned) {
  width: var(--sidebar-expanded) !important;
  z-index: 20001 !important;
}

/* Ensure text isn't hidden during the init-expanded state (prevents 'text pop-in') */
html.sb-pinned-init .sidebar .brand-text,
html.sb-peek-init .sidebar:not(.is-pinned) .brand-text {
  max-width: 180px;
  opacity: 1;
  pointer-events: auto;
}

html.sb-pinned-init .sidebar .menu-text,
html.sb-peek-init .sidebar:not(.is-pinned) .menu-text {
  max-width: 220px;
  opacity: 1;
  pointer-events: auto;
}

/* Keep active highlight full-width during init-expanded state */
html.sb-pinned-init .sidebar .menu-item.is-active::before,
html.sb-peek-init .sidebar:not(.is-pinned) .menu-item.is-active::before {
  width: calc(100% - var(--active-left));
  height: var(--menu-item-h);
}
/* Appearance: make the "Dark" button look black */
.theme-mode-row .theme-mode-btn[data-theme="dark"]{
  background: #000;
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
}

.theme-mode-row .theme-mode-btn[data-theme="dark"]:hover{
  background: #111;
}

.theme-mode-row .theme-mode-btn[data-theme="dark"] .icon{
  filter: brightness(1.1);
}

/* iOS: short page => disable empty scroll (Settings only) */
html.tp-shortpage body[data-active="settings"],
html.tp-shortpage body[data-active="settings"] .page,
html.tp-shortpage body[data-active="settings"] .content {
  overflow-y: hidden !important;
}

/* =========================================================
   Settings page (narrow): iOS-like full width
   - remove double horizontal padding (#view-settings + .content)
   - let the panel use the full content width
   ========================================================= */
@media (max-width: 900px){
  body[data-active="settings"] #view-settings{
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  body[data-active="settings"] #view-settings .wrap{
    justify-content: stretch !important;
  }
  body[data-active="settings"] #view-settings .settings-dialog{
    width: 100% !important;
    max-width: none !important;
  }
}


/* ===== Leaderboard controls (range + hide me) ===== */
.leaderboard-controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.lb-range{ display:flex; align-items:center; gap:8px; }
.lb-range-btn{ cursor:pointer; }
.lb-range-btn.is-active{
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}
.lb-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color: var(--text-muted);
  user-select:none;
}
.lb-toggle input{
  width:16px;
  height:16px;
}
.lb-toggle[aria-disabled="true"]{
  opacity:.6;
}


/* ===== Leaderboard user cell (avatar + name) ===== */
.lb-user{
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.lb-avatar{
  width:26px;
  height:26px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  font-size:15px;
  line-height:1;
}
.lb-name{
  display:inline-block;
}


/* --- Auth UI (moved from auth.js) --- */
    :root{ --auth-accent: var(--accent, var(--tp-accent, #22c55e)); }

    .auth-wrap{ position:relative; display:inline-flex; align-items:center; }

    /* 修复：有些页面没定义 --accent 时，primary 会变成白字看不见 */
    .auth-btn.primary{
      background: var(--auth-accent);
      border-color: var(--auth-accent);
      color:#fff;
    }

    /* 头像按钮 */
    .auth-btn.is-avatar{
      width:34px;
      height:34px;
      padding:0;
      border-radius:999px;
      display:flex;
      align-items:center;
      justify-content:center;
      background: transparent;
      border-color: transparent;
      color: inherit;
      box-shadow: none;

    }
    .auth-btn.is-avatar svg{ width:18px; height:18px; display:block; }

    /* 下拉菜单 */
    .auth-menu{
      position:absolute;
      right:0;
      top:calc(100% + 8px);
      min-width:240px;
      background:#fff;
      border:1px solid #e5e7eb;
      border-radius:14px;
      box-shadow:0 18px 45px rgba(15,23,42,0.16);
      padding:6px;
      display:none;
      z-index:10000;
    }
    .auth-menu.open{ display:block; }

    .auth-menu-email{
      padding:10px 10px 8px;
      border-bottom:1px solid #e5e7eb;
      display:flex;
      flex-direction:column;
      gap:2px;
    }
    .auth-menu-name{
      font-size:13px;
      font-weight: 400;
      color:#111827;
      line-height:1.2;
    }
    .auth-menu-email-line{
      font-size:12px;
      font-weight:400;
      color:#6b7280;
      word-break:break-all;
      line-height:1.2;
    }
/* 菜单项（Account / Settings / Billing） */
.auth-menu-item{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  width:100%;
  text-align:left;
  padding:10px;
  border-radius:10px;
  cursor:pointer;
  font-size:13px;
  font-weight: 400;
  color:#111827;
  background:transparent;
  border:none;
}
.auth-menu-item:hover{ background:#f9fafb; }

.auth-menu-ico{
  width:18px;
  height:18px;
  flex:0 0 18px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:rgba(17,24,39,.75);
}
.auth-menu-ico svg{ width:18px; height:18px; display:block; }

.auth-menu-label{   font-size:13px;
  font-weight:400;
flex:1; }

/* Theme row with icon-only selector */
.auth-menu-theme{
    font-size:13px;
  font-weight:400;
display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border-radius:10px;
display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border-radius:10px;
}
.auth-theme-icons{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:6px;
}
.auth-theme-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.auth-theme-btn{
  width:28px;
  height:28px;
  border-radius:10px;
  border:1px solid rgba(229,231,235,.9);
  background:transparent;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  color:rgba(17,24,39,.75);
  padding:0;
}
.auth-theme-btn svg{ width:16px; height:16px; display:block; }
.auth-theme-btn:hover{ background:#f3f4f6; }
.auth-theme-btn.active{
  background: var(--auth-accent);
  border-color: var(--auth-accent);
  color:#fff;
}
[data-theme="dark"] .auth-theme-btn{
  border-color:#1f2937;
  color:rgba(229,231,235,.82);
}
[data-theme="dark"] .auth-theme-btn:hover{ background: rgba(255,255,255,.06); }

/* Theme tooltip bubble */
.auth-theme-tip{
  position:absolute;
  left:50%;
  top:-10px;
  transform: translate(-50%, -100%);
  background: rgba(17,24,39,.92);
  color:#fff;
  font-size:12px;
  font-weight:700;
  padding:7px 9px;
  border-radius:10px;
  box-shadow: 0 16px 38px rgba(0,0,0,.25);
  white-space:nowrap;
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease, transform .12s ease;
  z-index:2;
}
.auth-theme-tip:after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-6px;
  transform: translateX(-50%);
  border:6px solid transparent;
  border-top-color: rgba(17,24,39,.92);
}
.auth-theme-wrap:hover .auth-theme-tip{
  opacity:1;
  transform: translate(-50%, calc(-100% - 2px));
}

/* dark theme（可选）*/
[data-theme="dark"] .auth-menu-item{ color:#e5e7eb; }
[data-theme="dark"] .auth-menu-item:hover{ background:rgba(255,255,255,.06); }
[data-theme="dark"] .auth-menu-ico{ color:rgba(229,231,235,.82); }

/* 头像内容 */
.auth-avatar-initial{
  font-weight:900;
  font-size:14px;
  line-height:1;
  letter-spacing:.3px;
  text-transform:uppercase;
}
.auth-avatar-img{
  width:100%;
  height:100%;
  border-radius:999px;
  object-fit:cover;
  display:block;
}

/* Account modal */
.acct-modal{
  width:60vw;
  height:60vh;
  max-width:none;
  max-height:none;
  display:flex;
  flex-direction:column;
}

/* Account backdrop: darken background (no blur) */
#accountModalBackdrop{
  display:none;
  background: rgba(2,6,23,0.62) !important;
  backdrop-filter:none !important;
}
#accountModalBackdrop.open{ display:flex; }

html.tp-modal-lock, body.tp-modal-lock{ overflow:hidden !important; }

/* Body area scrolls; footer is reserved so modal size never changes */
.acct-body{
  flex:1 1 auto;
  overflow:auto;
  padding-right:2px;
}

.acct-grid{
  display:grid;
  grid-template-columns: 200px 1fr;
  gap: 12px 16px;
  margin-top: 14px;
}
@media (max-width: 760px){
  .acct-grid{ grid-template-columns: 1fr; }
}

.acct-label{
  font-size:13px;
  font-weight:600;
  color:#111827;
  padding-top:10px;
}
[data-theme="dark"] .acct-label{ color:#e5e7eb; }

.acct-help{
  font-size:12px;
  color:#6b7280;
  margin-top:-6px;
}
[data-theme="dark"] .acct-help{ color: rgba(229,231,235,.72); }

.acct-input:disabled{
  opacity:.7;
  cursor:not-allowed;
}

.acct-avatar-row{
  display:flex;
  align-items:flex-start;
  gap:14px;
  flex-wrap:wrap;
}

.acct-avatar-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.acct-avatar-preview{
  width:64px;
  height:64px;
  border-radius:18px;
  border:1px solid #e5e7eb;
  background:#f3f4f6;
  color:#111827;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  overflow:hidden;
  cursor:pointer;
  user-select:none;
}
.acct-avatar-preview img{ width:100%; height:100%; object-fit:cover; display:block; }
.acct-avatar-preview:active{ transform: scale(.98); }

[data-theme="dark"] .acct-avatar-preview{
  border-color:#1f2937;
  background: rgba(255,255,255,.06);
  color:#e5e7eb;
}

/* Tooltip bubble (separate bubble, not text on the image) */
.acct-avatar-file{ position:absolute; width:1px; height:1px; opacity:0; left:-9999px; }

.acct-avatar-tip{
  position:absolute;
  left:50%;
  top:-12px;
  transform: translate(-50%, -100%);
  background: rgba(17,24,39,.92);
  color:#fff;
  font-size:12px;
  font-weight:600;
  padding:8px 10px;
  border-radius:10px;
  box-shadow: 0 16px 38px rgba(0,0,0,.25);
  white-space:nowrap;
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease, transform .12s ease;
  z-index:2;
}
.acct-avatar-tip:after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-6px;
  transform: translateX(-50%);
  border:6px solid transparent;
  border-top-color: rgba(17,24,39,.92);
}
.acct-avatar-wrap:hover .acct-avatar-file{ position:absolute; width:1px; height:1px; opacity:0; left:-9999px; }

.acct-avatar-wrap:hover .acct-avatar-wrap:hover .acct-avatar-tip{
  opacity:1;
  transform: translate(-50%, calc(-100% - 2px));
}

/* Footer row reserved; buttons appear without changing modal size */
.acct-footer{
  flex:0 0 56px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(229,231,235,.9);
}
[data-theme="dark"] .acct-footer{ border-top-color: rgba(31,41,55,.9); }

.acct-footer .acct-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  opacity:0;
  pointer-events:none;
  transition: opacity .12s ease;
}

.acct-modal[data-dirty="1"] .acct-footer .acct-actions{
  opacity:1;
  pointer-events:auto;
}

/* Toast notifications */
.tp-toast-host{
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 2147483647;
  pointer-events:none;
}
.tp-toast{
  display:flex;
  align-items:center;
  gap:10px;
  background:#111827;
  color:#fff;
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  font-size: 13px;
  font-weight: 800;
  opacity:0;
  transform: translateY(-6px);
  transition: opacity .12s ease, transform .12s ease;
}
.tp-toast.show{
  opacity:1;
  transform: translateY(0);
}
.tp-toast svg{ width:18px; height:18px; display:block; }

    .auth-menu-logout{
      width:100%;
      text-align:left;
      border:none;
      background:transparent;
      padding:10px;
      border-radius:10px;
      cursor:pointer;
      font-size:13px;
      font-weight: 500;
      color:#111827;
    }
    .auth-menu-logout:hover{ background:#f9fafb; }
    .auth-menu-logout:disabled{ opacity:.6; cursor:not-allowed; }

    /* dark theme（可选）*/
    [data-theme="dark"] .auth-menu{ background:#020617; border-color:#1f2937; }
    [data-theme="dark"] .auth-menu-email{ border-color:#1f2937; }
    [data-theme="dark"] .auth-menu-name{ color:#e5e7eb; }
    [data-theme="dark"] .auth-menu-email-line{ color: rgba(229,231,235,.72); }
    [data-theme="dark"] .auth-menu-logout{ color:#e5e7eb; }
    [data-theme="dark"] .auth-menu-logout:hover{ background:rgba(255,255,255,.06); }

/* --- End Auth UI --- */

/* --- Sync Policy Advanced UI --- */
.sync-advanced{
  margin-top:12px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  padding:10px 12px;
  background: rgba(0,0,0,.02);
}
.sync-advanced summary{
  cursor:pointer;
  font-weight:600;
}
.sync-advanced-body{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.sync-keylist{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:260px;
  overflow:auto;
  padding-right:4px;
}
.sync-key-group-title{
  font-size:12px;
  opacity:.7;
  text-transform:uppercase;
  letter-spacing:.04em;
  margin:6px 0;
}
.sync-key-item{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding:8px 10px;
  border:1px solid rgba(0,0,0,.06);
  border-radius:12px;
  background:#fff;
}
.sync-key-item input{ margin-top:2px; }
.sync-key-meta{ display:flex; flex-direction:column; gap:2px; min-width:0; }
.sync-key-name{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; min-width:0; }
.sync-key-name code{ font-size:12px; }
.sync-key-badge{
  font-size:11px;
  padding:2px 6px;
  border-radius:999px;
  background:rgba(0,0,0,.06);
}
.sync-key-desc{ font-size:12px; opacity:.75; }
.sync-key-item.is-forced .sync-key-badge{ outline:1px solid rgba(34,197,94,.35); }
.sync-key-item.is-excluded{ opacity:.75; }

[data-theme="dark"] .sync-advanced{
  border-color: rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
[data-theme="dark"] .sync-key-item{
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.10);
}
[data-theme="dark"] .sync-key-badge{ background: rgba(255,255,255,.10); }
/* --- End Sync Policy Advanced UI --- */
#report-overlay .report-card{
  display: flex;
  flex-direction: column;
  gap: var(--tp-report-row-gap, 8px);         /* 三行之间的距离：改这里 */
}
/* Type-pinyin top-right icon buttons */
body[data-active="practice"] .top-right .tp-icon-btn{
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: #111;
  cursor: pointer;
}
body[data-active="practice"] .top-right .tp-icon-btn:hover{
  color: var(--tp-green, #16a34a);
}
body[data-active="practice"] .top-right #answer-toggle-btn.answer-active{
  color: var(--tp-green, #16a34a);
}
body[data-active="practice"] .top-right .tp-icon-btn:focus-visible{
  outline: 2px solid rgba(22,163,74,.4);
  outline-offset: 2px;
}
body[data-active="practice"] .top-right .tp-icon{
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body[data-active="practice"] .top-right .tp-icon svg{
  width: 18px;
  height: 18px;
  display: block;
  transform: scale(1.2);
  transform-origin: center;
}
body[data-active="practice"] .top-right .settings-btn{
  background: transparent;
  border: 0;
}
#tp-topright-tooltip{
  position: fixed;
  z-index: 99999;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  background: #f3f4f6;
  color: #111;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}
#tp-topright-tooltip.is-visible{
  opacity: 1;
}
#tp-nav-tooltip{
  position: fixed;
  z-index: 99999;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  background: #f3f4f6;
  color: #111;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}
#tp-nav-tooltip.is-visible{
  opacity: 1;
}
html[data-theme="dark"] body[data-active="practice"] .top-right .tp-icon-btn{
  color: #f3f4f6;
}
html[data-theme="dark"] #tp-topright-tooltip{
  background: rgba(17,17,17,0.92);
  color: #f3f4f6;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
}
html[data-theme="dark"] #tp-nav-tooltip{
  background: rgba(17,17,17,0.92);
  color: #f3f4f6;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
}
/* Type-pinyin small-screen "More" menu overlay */
#tp-more-menu-overlay{
  z-index: 10002;
}
#tp-more-menu-overlay .settings-dialog{
  width: min(420px, 92vw);
}
#tp-more-menu-overlay .settings-content-area{
  padding: 16px;
}
#tp-more-menu-overlay .tp-more-menu-list{
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#tp-more-menu-overlay .tp-more-menu-item{
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--tp-text-main);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}
#tp-more-menu-overlay .tp-more-menu-item:hover{
  background: var(--tp-bg-surface-alt);
}
#tp-more-menu-overlay .tp-more-menu-text{
  flex: 1;
  font-size: 18px;
  font-weight: 600;
}
#tp-more-menu-overlay .tp-more-menu-icon{
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}
#tp-more-menu-overlay .tp-more-menu-icon svg{
  width: 24px;
  height: 24px;
  display: block;
}
#tp-more-menu-overlay .tp-more-switch{
  position: relative;
  display: inline-flex;
  align-items: center;
}
#tp-more-menu-overlay .tp-more-switch input{
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
#tp-more-menu-overlay .tp-more-switch-slider{
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
  transition: background 150ms ease;
}
#tp-more-menu-overlay .tp-more-switch-slider::after{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}
#tp-more-menu-overlay .tp-more-switch input:checked + .tp-more-switch-slider{
  background: var(--tp-green, #16a34a);
}
#tp-more-menu-overlay .tp-more-switch input:checked + .tp-more-switch-slider::after{
  transform: translateX(16px);
}
