* {
  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-delete-bg: rgba(255,255,255,.92);
  --tp-delete-fg: rgba(17,24,39,.75);
  --tp-delete-border: rgba(0,0,0,.12);
  --tp-delete-hover-bg: #fff;
  --tp-delete-hover-fg: #111827;
  --tp-delete-hover-border: var(--tp-delete-border);
  --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.is-missing-cover,
.hero-thumb.is-missing-cover {
  background:
    linear-gradient(135deg, rgba(17,24,39,.08), rgba(17,24,39,.02)),
    repeating-linear-gradient(135deg, rgba(17,24,39,.08) 0 1px, transparent 1px 14px);
}

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

.course-thumb img[hidden],
.hero-thumb img[hidden] {
  display: none;
}

.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-access-label {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 24px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.82);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: normal;
}

.course-access-label.is-free {
  color: #047857;
  border-color: rgba(5,150,105,.25);
  background: rgba(236,253,245,.92);
}

.course-access-label.is-preview {
  color: #92400e;
  border-color: rgba(217,119,6,.28);
  background: rgba(255,251,235,.96);
}

.course-access-label.is-pro {
  color: #4338ca;
  border-color: rgba(79,70,229,.26);
  background: rgba(238,242,255,.96);
}

.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: var(--tp-on-accent);
  border-color: var(--accent);
  transform: translateY(-0.5px);
  box-shadow: 0 8px 22px var(--accent-shadow);
}
.lesson-pill:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.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: always reserve the gutter so text/highlight never shifts */
  @supports (scrollbar-gutter: stable){
    #sidebarMount .side-scroll{
      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 */
  #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: 10030; /* above the check-in calendar modal-overlay (9999) so hovers aren't clipped */
  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: var(--tp-on-accent);
  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);
}

body[data-active="dashboard"] .mini-pack[role="link"] {
  cursor: pointer;
}

.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: var(--tp-on-accent);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.btn:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.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: var(--tp-on-accent);
}
.auth-btn.primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}

/*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);
  text-decoration: none;
  color: inherit;
}

#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: 2px;
  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: 2px;
  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,
#settings-overlay .tp-settings-back {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
}

.back-icon:hover,
#settings-overlay .tp-settings-back: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-access {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.course-access-summary-text {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

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

.hero-upgrade {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.hero-upgrade[hidden] {
  display: none;
}

.hero-upgrade a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.hero-upgrade a:hover {
  text-decoration: underline;
}

.practice-access-denied {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 32px 16px;
}

.practice-access-denied-card {
  width: min(520px, 100%);
  border: 1px solid var(--tp-border-subtle);
  border-radius: 8px;
  background: var(--tp-bg-surface);
  box-shadow: 0 18px 48px rgba(15,23,42,.10);
  padding: 24px;
}

.practice-access-denied-eyebrow {
  color: #4338ca;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}

.practice-access-denied-card h1 {
  color: var(--tp-text-main);
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 10px;
}

.practice-access-denied-card p {
  color: var(--tp-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.practice-access-denied-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.practice-access-denied-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--tp-text-main);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  background: var(--tp-bg-surface-alt);
}

.practice-access-denied-actions a:first-child {
  border-color: rgba(34,197,94,.38);
  color: #047857;
  background: rgba(236,253,245,.95);
}

body[data-practice-access-denied="1"] .progress-bar-wrapper,
body[data-practice-access-denied="1"] .timer-row,
body[data-practice-access-denied="1"] .practice-meta-row,
body[data-practice-access-denied="1"] .main,
body[data-practice-access-denied="1"] .bottombar {
  display: none !important;
}

.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: var(--tp-on-accent);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.hero-start:not(:disabled):not(.is-added) {
  color: var(--tp-control-on-accent);
}

.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"] .progress-overview-note {
  margin-top: 10px;
}

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: var(--tp-on-accent);
}

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));
  }
}

body[data-active="progress"] #view-progress .progress-heatmap-card {
  overflow: hidden;
}

body[data-active="progress"] #view-progress .progress-heatmap-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

body[data-active="progress"] #view-progress .progress-heatmap-title {
  min-width: min(260px, 100%);
}

/* Shared tabs and date ranges use the Study heatmap visual standard. */
.tp-segmented {
  --tp-segmented-bg: #f8fafc;
  --tp-segmented-border: rgba(15,23,42,.08);
  --tp-segmented-highlight: rgba(255,255,255,.78);
  --tp-segmented-text: #111827;
  --tp-segmented-hover: rgba(15,23,42,.04);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  background: var(--tp-segmented-bg);
  border: 1px solid var(--tp-segmented-border);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 var(--tp-segmented-highlight);
  padding: 4px;
}

/* Direct children keep the nested Custom date picker outside these rules. */
.tp-segmented > button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tp-segmented-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  min-height: 32px;
  min-width: 0;
  max-width: 100%;
  padding: 0 14px;
  white-space: normal;
  box-shadow: none;
  transform: none;
  transition: background .16s ease, box-shadow .16s ease, color .16s ease;
}

/* Reset legacy lesson-pill hover effects, including sticky touch hover. */
.tp-segmented > button:not(.is-active):hover {
  background: transparent;
  color: var(--tp-segmented-text);
  box-shadow: none;
  transform: none;
}

@media (hover: hover) {
  .tp-segmented > button:not(.is-active):not(:disabled):hover {
    background: var(--tp-segmented-hover);
  }
}

.tp-segmented > button.is-active,
.tp-segmented > button.is-active:hover {
  background: #22c55e;
  box-shadow: 0 8px 18px rgba(34,197,94,.22);
  color: var(--tp-control-on-accent);
  transform: none;
}

.tp-segmented > button:focus-visible {
  outline: 3px solid rgba(34,197,94,.28);
  outline-offset: 2px;
}

html[data-theme="dark"] .tp-segmented {
  --tp-segmented-bg: rgba(255,255,255,.06);
  --tp-segmented-border: rgba(255,255,255,.14);
  --tp-segmented-highlight: rgba(255,255,255,.04);
  --tp-segmented-text: rgba(255,255,255,.90);
  --tp-segmented-hover: rgba(255,255,255,.08);
}

@media (max-width: 640px) {
  .tp-segmented {
    justify-content: flex-start;
    width: 100%;
  }
}

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

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

body[data-active="progress"] #view-progress .progress-heatmap-stat-value {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
  margin-top: 8px;
}

body[data-active="progress"] #view-progress .progress-heatmap-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 230px);
  gap: 18px;
  align-items: start;
  margin-top: 34px;
}

body[data-active="progress"] #view-progress .progress-heatmap-main {
  min-width: 0;
}

body[data-active="progress"] #view-progress .progress-heatmap-intensity {
  min-width: 0;
  border-left: 1px solid rgba(2,6,23,.10);
  padding-left: 16px;
}

body[data-active="progress"] #view-progress .progress-heatmap-layout {
  --progress-heatmap-cell-size: 16px;
  --progress-heatmap-cell-gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

body[data-active="progress"] #view-progress .progress-heatmap-shell {
  min-width: max-content;
}

body[data-active="progress"] #view-progress .progress-heatmap-month-row,
body[data-active="progress"] #view-progress .progress-heatmap-body {
  display: flex;
  gap: 8px;
}

body[data-active="progress"] #view-progress .progress-heatmap-month-spacer,
body[data-active="progress"] #view-progress .progress-heatmap-weekdays {
  flex: 0 0 36px;
  width: 36px;
}

body[data-active="progress"] #view-progress .progress-heatmap-months {
  display: grid;
  grid-template-columns: repeat(var(--progress-heatmap-weeks, 53), var(--progress-heatmap-cell-size));
  column-gap: var(--progress-heatmap-cell-gap);
  min-height: 20px;
  min-width: 0;
}

body[data-active="progress"] #view-progress .progress-heatmap-month {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
}

body[data-active="progress"] #view-progress .progress-heatmap-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--progress-heatmap-cell-size));
  row-gap: var(--progress-heatmap-cell-gap);
}

body[data-active="progress"] #view-progress .progress-heatmap-weekdays span {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  line-height: var(--progress-heatmap-cell-size);
  text-align: right;
}

body[data-active="progress"] #view-progress .progress-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(var(--progress-heatmap-weeks, 53), var(--progress-heatmap-cell-size));
  grid-template-rows: repeat(7, var(--progress-heatmap-cell-size));
  grid-auto-flow: column;
  gap: var(--progress-heatmap-cell-gap);
}

body[data-active="progress"] #view-progress .progress-heatmap-cell {
  display: block;
  width: var(--progress-heatmap-cell-size);
  height: var(--progress-heatmap-cell-size);
  border: 1px solid rgba(2,6,23,.06);
  border-radius: 4px;
  background: #eef2f7;
  flex: 0 0 auto;
}

body[data-active="progress"] #view-progress .progress-heatmap-cell[data-tip] {
  cursor: default;
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.is-empty {
  background: transparent;
  border-color: transparent;
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.level-1 {
  background: #bbf7d0;
  border-color: rgba(34,197,94,.18);
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.level-2 {
  background: #86efac;
  border-color: rgba(34,197,94,.24);
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.level-3 {
  background: #22c55e;
  border-color: rgba(21,128,61,.38);
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.level-4 {
  background: #15803d;
  border-color: rgba(20,83,45,.55);
}

body[data-active="progress"] #view-progress .progress-heatmap-cell.tp-hover-hi {
  border-radius: 4px;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend {
  margin-top: 0;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend-title {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend-items {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 9px;
  margin-top: 10px;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend-item .progress-heatmap-cell {
  --progress-heatmap-cell-size: 12px;
}

@media (max-width: 760px) {
  body[data-active="progress"] #view-progress .progress-heatmap-content {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  body[data-active="progress"] #view-progress .progress-heatmap-intensity {
    border-left: 0;
    border-top: 1px solid rgba(2,6,23,.10);
    padding-left: 0;
    padding-top: 12px;
  }

  body[data-active="progress"] #view-progress .progress-heatmap-layout {
    --progress-heatmap-cell-size: 15px;
    --progress-heatmap-cell-gap: 3px;
  }

  body[data-active="progress"] #view-progress .progress-heatmap-month-spacer,
  body[data-active="progress"] #view-progress .progress-heatmap-weekdays {
    flex-basis: 34px;
    width: 34px;
  }
}

@media (max-width: 640px) {
  body[data-active="progress"] #view-progress .progress-heatmap-head {
    align-items: stretch;
  }

  body[data-active="progress"] #view-progress .progress-heatmap-stats {
    grid-template-columns: 1fr;
  }

  body[data-active="progress"] #view-progress .progress-heatmap-layout {
    --progress-heatmap-cell-size: 15px;
  }
}

/*===== Progress overview refresh =====*/

body[data-active="progress"] #view-progress {
  --progress-card-bg: #ffffff;
  --progress-card-border: rgba(15,23,42,.10);
  --progress-card-shadow: 0 18px 48px rgba(15,23,42,.07);
  --progress-soft-bg: #f8fafc;
  --progress-soft-border: rgba(15,23,42,.08);
}

body[data-active="progress"] #view-progress > .card {
  background: var(--progress-card-bg);
  border-color: var(--progress-card-border);
  border-radius: 16px;
  box-shadow: var(--progress-card-shadow);
  padding: 18px;
}

body[data-active="progress"] #view-progress .card-title {
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

body[data-active="progress"] #view-progress .progress-overview-head {
  margin-bottom: 16px;
}

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

body[data-active="progress"] #view-progress .kpi {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(15,23,42,.09);
  border-radius: 14px;
  box-shadow: 0 14px 28px rgba(15,23,42,.055);
  display: grid;
  gap: 14px;
  grid-template-columns: 37px minmax(0, 1fr);
  min-height: 102px;
  overflow: hidden;
  padding: 16px;
  position: relative;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

body[data-active="progress"] #view-progress .kpi-icon,
body[data-active="progress"] #view-progress .progress-heatmap-stat-icon {
  align-items: center;
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.20);
  border-radius: 999px;
  color: #16a34a;
  display: inline-flex;
  flex: 0 0 auto;
  height: 37px;
  justify-content: center;
  width: 37px;
}

body[data-active="progress"] #view-progress .kpi-icon svg,
body[data-active="progress"] #view-progress .progress-heatmap-stat-icon svg {
  display: block;
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 19px;
}

body[data-active="progress"] #view-progress .kpi-copy,
body[data-active="progress"] #view-progress .progress-heatmap-stat-copy {
  min-width: 0;
}

body[data-active="progress"] #view-progress .kpi-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

body[data-active="progress"] #view-progress .kpi-value {
  color: #0f172a;
  font-size: 27px;
  letter-spacing: 0;
  line-height: 1.05;
  margin-top: 10px;
}

body[data-active="progress"] #view-progress .kpi-sub {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 650;
  margin-top: 7px;
}

body[data-active="progress"] #view-progress .kpi-sub:empty {
  display: none;
}

body[data-active="progress"] #view-progress .kpi-detail-indicator {
  background: rgba(34,197,94,.10);
  border-color: rgba(34,197,94,.26);
  color: #16a34a;
  right: 14px;
  top: 14px;
}

body[data-active="progress"] #view-progress .hp-kpi-link:hover,
body[data-active="progress"] #view-progress .hp-kpi-link:focus-visible {
  background: #ffffff;
  border-color: rgba(34,197,94,.38);
  box-shadow: 0 18px 34px rgba(15,23,42,.08);
}

body[data-active="progress"] #view-progress .progress-overview-note {
  align-items: center;
  background: var(--progress-soft-bg);
  border: 1px solid var(--progress-soft-border);
  border-radius: 999px;
  color: #64748b;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  margin-top: 14px;
  padding: 6px 10px;
}

body[data-active="progress"] #view-progress .progress-other-time {
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0 0;
}

body[data-active="progress"] #view-progress .overview-chart-block {
  border-top-color: rgba(15,23,42,.08);
  margin-top: 18px;
  padding-top: 18px;
}

body[data-active="progress"] #view-progress .overview-chart-head {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 14px;
}

body[data-active="progress"] #view-progress .overview-chart-title {
  margin: 0;
}

body[data-active="progress"] #view-progress .chart-controls {
  justify-content: flex-end;
  margin: 0;
}

body[data-active="progress"] #view-progress .chart-chips {
  background: var(--progress-soft-bg);
  border: 1px solid var(--progress-soft-border);
  border-radius: 999px;
  gap: 4px;
  padding: 4px;
}

body[data-active="progress"] #view-progress .chart-metric-btn {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: #334155;
  min-height: 34px;
  padding: 0 12px;
}

body[data-active="progress"] #view-progress .chart-metric-btn.is-active,
body[data-active="progress"] #view-progress .chart-metric-btn[aria-checked="true"] {
  background: #ecfdf5;
  box-shadow: 0 8px 18px rgba(34,197,94,.16);
  color: #065f46;
}

body[data-active="progress"] #view-progress .chart-metric-btn[data-metric="time"].is-active,
body[data-active="progress"] #view-progress .chart-metric-btn[data-metric="time"][aria-checked="true"] {
  background: #eff6ff;
  box-shadow: 0 8px 18px rgba(59,130,246,.14);
  color: #1d4ed8;
}

body[data-active="progress"] #view-progress .chart-wrap {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82);
  height: 340px;
  padding: 12px 12px 8px;
}

body[data-active="progress"] #view-progress #progressLineNote {
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
  margin-top: 10px;
}

body[data-active="progress"] #view-progress .progress-heatmap-card {
  padding: 18px;
  margin-top: 20px;
}

body[data-active="progress"] #view-progress .progress-heatmap-stats {
  gap: 12px;
}

body[data-active="progress"] #view-progress .progress-heatmap-stat {
  align-items: center;
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(15,23,42,.05);
  display: flex;
  gap: 13px;
  padding: 14px;
}

body[data-active="progress"] #view-progress .progress-heatmap-stat-value {
  font-size: 23px;
  letter-spacing: 0;
}

body[data-active="progress"] #view-progress .progress-heatmap-content {
  margin-top: 28px;
}

body[data-active="progress"] #view-progress .progress-heatmap-intensity {
  background: #f8fafc;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  padding: 14px;
}

body[data-active="progress"] #view-progress .progress-heatmap-legend-title,
body[data-active="progress"] #view-progress .progress-heatmap-legend-item {
  color: #64748b;
}

@media (max-width: 1100px) {
  body[data-active="progress"] #view-progress .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body[data-active="progress"] #view-progress > .card {
    padding: 14px;
  }

  body[data-active="progress"] #view-progress .overview-chart-head {
    align-items: stretch;
    flex-direction: column;
  }

  body[data-active="progress"] #view-progress .chart-controls,
  body[data-active="progress"] #view-progress .chart-chips {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 520px) {
  body[data-active="progress"] #view-progress .kpi-grid {
    grid-template-columns: 1fr;
  }

  body[data-active="progress"] #view-progress .chart-metric-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  body[data-active="progress"] #view-progress .kpi {
    grid-template-columns: 35px minmax(0, 1fr);
  }

  body[data-active="progress"] #view-progress .kpi-icon,
  body[data-active="progress"] #view-progress .progress-heatmap-stat-icon {
    height: 35px;
    width: 35px;
  }
}

/*===== 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;
}

/*===== Hanzi practiced =====*/

.hp-link {
  color: inherit;
  text-decoration: none;
}

.hp-link:hover,
.hp-link:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.hp-kpi-link {
  display: block;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

body[data-active="progress"] .hp-kpi-link:hover,
body[data-active="progress"] .hp-kpi-link:focus-visible {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .35);
  box-shadow: 0 12px 24px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
  outline: none;
  text-decoration: none;
}

body[data-active="progress"] .hp-kpi-link:focus-visible {
  box-shadow:
    0 12px 24px rgba(15, 23, 42, .08),
    0 0 0 3px rgba(34, 197, 94, .22);
}

#view-hanzi-practiced {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#view-progress[hidden],
#view-hanzi-practiced[hidden] {
  display: none !important;
}

#view-hanzi-practiced .hp-table-wrap[hidden],
#view-hanzi-practiced .hp-card-list[hidden],
#view-hanzi-practiced .hp-study-card-grid[hidden],
#view-hanzi-practiced .hp-empty[hidden] {
  display: none !important;
}

.progress-detail-head {
  background: #fff;
  padding: 0 14px;
  box-sizing: border-box;
}

.progress-detail-head .detail-title {
  margin: 0;
  line-height: 1.25;
}

#view-hanzi-practiced .hp-toolbar {
  display: grid;
  grid-template-columns: auto minmax(92px, auto) minmax(220px, 1fr) minmax(170px, auto);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

#view-hanzi-practiced .hp-search-summary {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

#view-hanzi-practiced .hp-toolbar input,
#view-hanzi-practiced .hp-toolbar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

#view-hanzi-practiced .hp-view-toggle {
  min-height: 40px;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  justify-self: start;
  white-space: nowrap;
}

#view-hanzi-practiced .hp-view-toggle-btn {
  appearance: none;
  width: 36px;
  min-height: 32px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: 9px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: .72;
}

#view-hanzi-practiced .hp-view-toggle-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"] {
  background: rgba(34, 197, 94, .12);
  border-color: var(--accent, #22c55e);
  color: var(--accent, #16a34a);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
  opacity: 1;
}

#view-hanzi-practiced .hp-view-toggle-btn:hover,
#view-hanzi-practiced .hp-view-toggle-btn:focus-visible {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .34);
  color: var(--text-primary);
  opacity: 1;
  outline: none;
}

#view-hanzi-practiced .hp-view-toggle-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16);
  outline: none;
}

#view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"]:hover,
#view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"]:focus-visible {
  background: rgba(34, 197, 94, .14);
  border-color: var(--accent, #22c55e);
  color: var(--accent, #16a34a);
}

.hp-table-wrap {
  max-height: min(68vh, 720px);
}

.hp-table {
  min-width: 980px;
}

#view-hanzi-practiced .hp-table th,
#view-hanzi-practiced .hp-table td {
  text-align: left;
}

#view-hanzi-practiced .hp-table .hp-meaning-head,
#view-hanzi-practiced .hp-table .hp-meaning-cell {
  width: 24%;
  min-width: 190px;
  text-align: left;
  white-space: normal;
}

#view-hanzi-practiced .hp-source-head,
#view-hanzi-practiced .hp-source-cell {
  width: 25%;
  min-width: 220px;
  text-align: left;
  white-space: normal;
}

#view-hanzi-practiced .hp-date-head,
#view-hanzi-practiced .hp-date-cell {
  width: 140px;
  min-width: 140px;
  text-align: left;
  white-space: nowrap;
}

#view-hanzi-practiced .hp-action-head,
#view-hanzi-practiced .hp-action-cell {
  width: 88px;
  text-align: right;
  white-space: nowrap;
}

#view-hanzi-practiced .hp-source-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 100%;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

#view-hanzi-practiced .hp-source-line {
  display: block;
  overflow-wrap: anywhere;
}

#view-hanzi-practiced .hp-source-more,
#view-hanzi-practiced .hp-source-empty {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  opacity: .78;
}

.hp-word-cell {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 3px 5px;
  margin: -3px -5px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  max-width: 100%;
}

.hp-word-cell:hover,
.hp-word-cell:focus-visible {
  background: rgba(34, 197, 94, .10);
  outline: none;
}

.hp-word-hanzi {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.hp-word-pinyin {
  color: var(--text-muted);
  font-weight: 650;
}

#view-hanzi-practiced .hp-meaning-text {
  display: block;
  color: var(--text-muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#view-hanzi-practiced .hp-meaning-empty {
  opacity: .72;
}

#view-hanzi-practiced .hp-word-remove-btn {
  appearance: none;
  border: 0;
  background: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  border-color: var(--tp-delete-border);
}

#view-hanzi-practiced .hp-word-remove-btn:hover,
#view-hanzi-practiced .hp-word-remove-btn:focus-visible {
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  outline: none;
  border-color: var(--tp-delete-hover-border);
}

.hp-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hp-word-card {
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.hp-word-card-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hp-word-card-main .hp-word-pinyin {
  text-align: right;
}

#view-hanzi-practiced .hp-card-meaning {
  margin-top: 8px;
  font-size: 13px;
}

.hp-word-card-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#view-hanzi-practiced .hp-study-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 14px;
}

#view-hanzi-practiced .hp-study-card {
  position: relative;
  aspect-ratio: 2 / 1;
  min-height: 0;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 28px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

#view-hanzi-practiced .hp-study-card:hover {
  transform: none;
  background: #f2fbf5;
  border-color: var(--accent, #22c55e);
  box-shadow: 0 14px 30px rgba(15, 23, 42, .12);
}

#view-hanzi-practiced .hp-study-card.is-popover-open {
  transform: none;
  background: #f2fbf5;
  border-color: var(--accent, #22c55e);
  box-shadow: 0 14px 30px rgba(15, 23, 42, .12);
}

#view-hanzi-practiced .hp-study-card.is-popover-open.is-popover-bottom {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  border-bottom-color: transparent;
}

#view-hanzi-practiced .hp-study-card.is-popover-open.is-popover-top {
  border-top-right-radius: 0;
  border-top-left-radius: 0;
  border-top-color: transparent;
}

#view-hanzi-practiced .hp-study-card:active {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, .10);
}

#view-hanzi-practiced .hp-study-card-audio-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  opacity: 0;
  transform: scale(.94);
  transform-origin: center;
  pointer-events: none;
  transition:
    opacity .16s ease,
    transform .16s ease,
    color .16s ease;
}

#view-hanzi-practiced .hp-study-card-audio-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#view-hanzi-practiced .hp-study-card-audio-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  opacity: 0;
  transform: scale(.72);
  pointer-events: none;
}

#view-hanzi-practiced .hp-study-card:hover .hp-study-card-audio-icon {
  opacity: .65;
  transform: scale(1);
}

#view-hanzi-practiced .hp-study-card.is-playing .hp-study-card-audio-icon {
  color: var(--accent, #22c55e);
  opacity: 1;
  transform: scale(1);
  animation: hpAudioIconPulse 760ms ease-out;
}

#view-hanzi-practiced .hp-study-card.is-playing .hp-study-card-audio-icon::after {
  animation: hpAudioRipple 760ms ease-out;
}

#view-hanzi-practiced .hp-study-card-center {
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 6px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

#view-hanzi-practiced .hp-study-card .hp-word-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0;
  padding: 4px 8px;
  transform: scale(1);
  transform-origin: center;
  transition: transform 180ms ease;
  will-change: transform;
}

#view-hanzi-practiced .hp-study-card .hp-word-cell:hover,
#view-hanzi-practiced .hp-study-card .hp-word-cell:focus-visible {
  background: transparent;
  box-shadow: none;
}

#view-hanzi-practiced .hp-study-card .hp-word-cell:hover {
  outline: none;
}

#view-hanzi-practiced .hp-study-card .hp-word-cell:focus-visible {
  outline: 2px solid rgba(34, 197, 94, .28);
  outline-offset: 2px;
}

#view-hanzi-practiced .hp-study-card-pinyin {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 750;
}

#view-hanzi-practiced .hp-study-card-hanzi {
  color: var(--text-primary);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

#view-hanzi-practiced .hp-study-card:hover .hp-study-card-pinyin,
#view-hanzi-practiced .hp-study-card.is-popover-open .hp-study-card-pinyin {
  transform: scale(1.2);
}

#view-hanzi-practiced .hp-study-card:hover .hp-study-card-hanzi,
#view-hanzi-practiced .hp-study-card.is-popover-open .hp-study-card-hanzi {
  transform: scale(1.2);
}

#view-hanzi-practiced .hp-study-card-date {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}

@keyframes hpAudioIconPulse {
  0% {
    transform: scale(.96);
  }

  35% {
    transform: scale(1.12);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes hpAudioRipple {
  0% {
    opacity: .35;
    transform: scale(.72);
  }

  100% {
    opacity: 0;
    transform: scale(1.65);
  }
}

.hp-empty {
  border: 1px dashed var(--border-subtle);
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.hp-empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

#progressDataState .btn {
  width: auto;
  min-width: 112px;
  min-height: 44px;
  margin-top: 0;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--tp-border-subtle, var(--border-subtle));
  /* Override the generic Progress button colors in both themes. */
  background: var(--tp-bg-surface, var(--surface)) !important;
  color: var(--tp-text-main, var(--text-primary)) !important;
}

#progressDataState #progressRetryBtn {
  background: #15803d !important;
  border-color: #15803d !important;
  color: #fff !important;
}
#progressDataState #progressRetryBtn:not(:disabled) {
  color: var(--tp-control-on-accent) !important;
}

#progressDataState .btn[hidden] { display: none !important; }
#progressDataState .btn:not(:disabled):hover { opacity: 1; }
#progressDataState .btn:focus-visible {
  outline: 2px solid var(--tp-text-main, var(--text-primary));
  outline-offset: 3px;
}

#view-hanzi-practiced .hp-empty-actions .btn {
  width: auto;
  min-width: 140px;
  margin-top: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#view-hanzi-practiced .hp-empty-actions .hp-empty-cta {
  min-width: 190px;
  border: none;
  background: var(--accent);
  color: var(--tp-on-accent);
  padding: 10px 12px;
  border-radius: 12px;
}
#view-hanzi-practiced .hp-empty-actions .hp-empty-cta:not(:disabled) {
  color: var(--tp-control-on-accent);
}

#view-hanzi-practiced .hp-empty-actions .hp-empty-cta:hover {
  opacity: 0.92;
  transform: none;
  box-shadow: none;
  text-decoration: none;
}

#view-hanzi-practiced .hp-secondary-btn {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

@media (max-width: 860px) {
  #view-hanzi-practiced .hp-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .hp-table-wrap {
    display: none;
  }

  .hp-word-card-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .hp-word-card-main .hp-word-pinyin {
    text-align: left;
  }

  .hp-word-card-meta {
    flex-direction: column;
    gap: 4px;
  }
}

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

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

.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;
}

#view-progress .chart-metric-btn {
  appearance: none;
  color: inherit;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

#view-progress .chart-metric-btn.is-active,
#view-progress .chart-metric-btn[aria-checked="true"] {
  background: var(--accent-soft, rgba(34,197,94,.12));
  border-color: var(--accent-border, rgba(34,197,94,.35));
  box-shadow: 0 0 0 2px rgba(34,197,94,.08);
}

#view-progress .chart-metric-btn:focus-visible,
#view-progress [data-tp="progress-chart-controls"] .seg:focus-visible {
  outline: 3px solid rgba(34,197,94,.28);
  outline-offset: 2px;
}

.chip input {
  margin: 0;
}

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

.chart-ranges:not(.tp-segmented) {
  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;
}

#view-progress .progress-date-picker {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(640px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(2,6,23,.12);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15,23,42,.18);
}

#view-progress .progress-date-picker[hidden] {
  display: none !important;
}

#view-progress .progress-date-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

#view-progress .progress-date-nav {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(2,6,23,.12);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#view-progress .progress-date-title {
  font-weight: 800;
  font-size: 13px;
  color: var(--text-primary);
}

#view-progress .progress-date-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#view-progress .progress-date-month-title {
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}

#view-progress .progress-date-weekdays,
#view-progress .progress-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

#view-progress .progress-date-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

#view-progress .progress-date-day {
  appearance: none;
  border: 0;
  background: transparent;
  min-width: 0;
  height: 32px;
  border-radius: 999px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
}

#view-progress .progress-date-day:hover,
#view-progress .progress-date-day:focus-visible {
  background: rgba(34,197,94,.10);
  outline: none;
}

#view-progress .progress-date-day.is-in-range {
  background: rgba(34,197,94,.12);
  border-radius: 8px;
}

#view-progress .progress-date-day.is-start,
#view-progress .progress-date-day.is-end {
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
  border-radius: 999px;
  font-weight: 800;
}

#view-progress .progress-date-empty {
  height: 32px;
}

@media (max-width: 640px) {
  #view-progress .progress-date-picker {
    left: 0;
    right: auto;
    width: min(100%, calc(100vw - 32px));
  }

  #view-progress .progress-date-months {
    grid-template-columns: 1fr;
  }
}

/*=========================
   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;
}

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"] .settings-subtitles-size.disabled,
.settings-overlay .settings-subtitles-size.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: 200px;
  min-width: 200px;
  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: var(--tp-on-accent);
  font-weight: 650;
}
body[data-active="settings"] .settings-section-btn.active:not(:disabled) {
  color: var(--tp-control-on-accent);
}

/* ===== 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-toggle-label,
.settings-overlay .settings-toggle-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

body[data-active="settings"] .settings-toggle-title,
.settings-overlay .settings-toggle-title {
  font-size: 13px;
  color: var(--tp-text-main);
  line-height: 1.2;
}

body[data-active="settings"] .settings-toggle-desc,
.settings-overlay .settings-toggle-desc {
  font-size: 12px;
  color: var(--tp-text-muted);
  line-height: 1.25;
}

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;
}

:is(body[data-active="settings"], body[data-active="practice"]) .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);
}

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

body[data-active="practice"],
body[data-active="settings"],
.settings-overlay {
  --practice-english-size-small: 36px;
  --practice-english-size-medium: 42px;
  --practice-english-size-large: 48px;
  --practice-pinyin-size-small: 42px;
  --practice-pinyin-size-medium: 50px;
  --practice-pinyin-size-large: 58px;
  --practice-word-meaning-size-small: 24px;
  --practice-word-meaning-size-medium: 28px;
  --practice-word-meaning-size-large: 32px;
  --practice-hanzi-size-small: 42px;
  --practice-hanzi-size-medium: 50px;
  --practice-hanzi-size-large: 58px;
  --practice-hanzi-line-small: 48px;
  --practice-hanzi-line-medium: 56px;
  --practice-hanzi-line-large: 64px;
  --practice-hanzi-height-small: 48px;
  --practice-hanzi-height-medium: 56px;
  --practice-hanzi-height-large: 64px;
  --practice-english-font-size: var(--practice-english-size-medium);
  --practice-pinyin-font-size: var(--practice-pinyin-size-medium);
  --practice-hanzi-font-size: var(--practice-hanzi-size-medium);
  --practice-hanzi-line-height: var(--practice-hanzi-line-medium);
  --practice-hanzi-height: var(--practice-hanzi-height-medium);
}

body[data-active="settings"] .settings-section-content[data-section="appearance"] .settings-slider-row.settings-choice-row,
body[data-active="settings"] .settings-section-content[data-section="appearance"] .settings-slider-row.settings-text-size-block,
.settings-overlay .settings-section-content[data-section="appearance"] .settings-slider-row.settings-choice-row,
.settings-overlay .settings-section-content[data-section="appearance"] .settings-slider-row.settings-text-size-block {
  gap: 10px;
}

body[data-active="settings"] .settings-choice-control,
.settings-overlay .settings-choice-control {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

body[data-active="settings"] .settings-choice-row .settings-choice-control,
.settings-overlay .settings-choice-row .settings-choice-control {
  align-items: center;
  flex-direction: row;
}

body[data-active="settings"] .settings-choice-btn,
.settings-overlay .settings-choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 999px;
  background: var(--tp-bg-surface-alt);
  color: var(--tp-text-main);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

body[data-active="settings"] .settings-choice-btn:hover,
.settings-overlay .settings-choice-btn:hover {
  background: var(--tp-bg-surface);
  box-shadow: 0 4px 10px rgba(15,23,42,.10);
}

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

body[data-active="settings"] .settings-choice-control.watch-caption-size-control,
.settings-overlay .settings-choice-control.watch-caption-size-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  width: 264px;
  max-width: 100%;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 10px;
  background: var(--tp-bg-surface-alt);
}

body[data-active="settings"] .watch-caption-size-control .settings-choice-btn,
.settings-overlay .watch-caption-size-control .settings-choice-btn {
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
}

body[data-active="settings"] .watch-caption-size-control .settings-choice-btn.active,
.settings-overlay .watch-caption-size-control .settings-choice-btn.active {
  background: var(--tp-bg-surface);
  color: var(--tp-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

body[data-active="settings"] .watch-caption-size-control .settings-choice-btn:disabled,
.settings-overlay .watch-caption-size-control .settings-choice-btn:disabled {
  cursor: not-allowed;
}

body[data-active="settings"] .practice-background-btn:disabled,
body[data-active="settings"] .practice-background-btn.is-disabled,
.settings-overlay .practice-background-btn:disabled,
.settings-overlay .practice-background-btn.is-disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

body[data-active="settings"] .practice-background-btn:disabled:hover,
body[data-active="settings"] .practice-background-btn.is-disabled:hover,
.settings-overlay .practice-background-btn:disabled:hover,
.settings-overlay .practice-background-btn.is-disabled:hover {
  background: var(--tp-bg-surface-alt);
  box-shadow: none;
}

body[data-active="settings"] .practice-background-dark-note,
.settings-overlay .practice-background-dark-note {
  display: none;
  margin: 0;
  color: var(--tp-text-muted);
  font-size: 12px;
  line-height: 1.35;
}

body[data-active="settings"] .practice-background-locked .practice-background-dark-note,
.settings-overlay .practice-background-locked .practice-background-dark-note {
  display: block;
}

body[data-active="settings"] .practice-background-swatch,
.settings-overlay .practice-background-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.16);
}

body[data-active="settings"] .practice-background-swatch-default,
.settings-overlay .practice-background-swatch-default {
  background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
}

body[data-active="settings"] .practice-background-swatch-warm,
.settings-overlay .practice-background-swatch-warm {
  background: #fff4d6;
}

body[data-active="settings"] .practice-background-swatch-green,
.settings-overlay .practice-background-swatch-green {
  background: #e7f8ef;
}

body[data-active="settings"] .practice-text-size-list,
.settings-overlay .practice-text-size-list {
  gap: 16px;
  min-width: 0;
  width: 100%;
}

body[data-active="settings"] .practice-text-size-row,
.settings-overlay .practice-text-size-row {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 9px;
}

body[data-active="settings"] .practice-text-size-row + .practice-text-size-row,
.settings-overlay .practice-text-size-row + .practice-text-size-row {
  border-top: 1px solid var(--tp-border-subtle);
  padding-top: 16px;
}

body[data-active="settings"] .practice-text-size-label,
.settings-overlay .practice-text-size-label {
  color: var(--tp-text-main);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}

body[data-active="settings"] .settings-slider-row.settings-text-size-block,
.settings-overlay .settings-slider-row.settings-text-size-block {
  align-items: stretch;
  flex-direction: column;
}

body[data-active="settings"] .settings-slider-row.settings-choice-row,
.settings-overlay .settings-slider-row.settings-choice-row {
  align-items: stretch;
  flex-direction: column;
}

body[data-active="settings"] .settings-choice-row .settings-slider-control,
.settings-overlay .settings-choice-row .settings-slider-control {
  min-width: 0;
  width: 100%;
}

body[data-active="settings"] .settings-text-size-block .settings-slider-control,
.settings-overlay .settings-text-size-block .settings-slider-control {
  min-width: 0;
  width: 100%;
}

body[data-active="settings"] .practice-text-advanced .practice-text-size-row .settings-choice-control,
.settings-overlay .practice-text-advanced .practice-text-size-row .settings-choice-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

body[data-active="settings"] .practice-text-size-btn,
.settings-overlay .practice-text-size-btn {
  align-items: center;
  border-radius: 8px;
  flex-direction: row;
  gap: 12px;
  justify-content: flex-start;
  min-height: 46px;
  min-width: 0;
  padding: 9px 12px;
  text-align: left;
  width: 100%;
}

body[data-active="settings"] .practice-text-size-btn::before,
.settings-overlay .practice-text-size-btn::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  flex: 0 0 10px;
  opacity: .55;
}

body[data-active="settings"] .practice-text-size-btn.active::before,
.settings-overlay .practice-text-size-btn.active::before {
  background: var(--tp-accent);
  box-shadow: inset 0 0 0 2px var(--tp-bg-surface-alt);
  opacity: 1;
}

body[data-active="settings"] .practice-text-size-name,
.settings-overlay .practice-text-size-name {
  color: var(--tp-text-muted);
  flex: 0 0 58px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

body[data-active="settings"] .practice-text-size-preview,
.settings-overlay .practice-text-size-preview {
  color: var(--tp-text-main);
  flex: 1 1 auto;
  letter-spacing: 0;
  line-height: normal;
  min-width: 0;
  overflow-wrap: anywhere;
}

body[data-active="settings"] .practice-text-size-btn.active .practice-text-size-name,
body[data-active="settings"] .practice-text-size-btn.active .practice-text-size-preview,
.settings-overlay .practice-text-size-btn.active .practice-text-size-name,
.settings-overlay .practice-text-size-btn.active .practice-text-size-preview {
  color: var(--tp-accent);
}

body[data-active="settings"] .practice-text-size-btn:disabled,
.settings-overlay .practice-text-size-btn:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

body[data-active="settings"] .practice-text-size-btn:disabled:hover,
.settings-overlay .practice-text-size-btn:disabled:hover {
  background: var(--tp-bg-surface-alt);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="small"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="small"] {
  --practice-preview-font-size: var(--practice-english-size-small);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="medium"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="medium"] {
  --practice-preview-font-size: var(--practice-english-size-medium);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="large"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="english"][data-practice-text-size="large"] {
  --practice-preview-font-size: var(--practice-english-size-large);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="small"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="small"] {
  --practice-preview-font-size: var(--practice-pinyin-size-small);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="medium"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="medium"] {
  --practice-preview-font-size: var(--practice-pinyin-size-medium);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="large"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="pinyin"][data-practice-text-size="large"] {
  --practice-preview-font-size: var(--practice-pinyin-size-large);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="small"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="small"] {
  --practice-preview-font-size: var(--practice-hanzi-size-small);
  --practice-preview-line-height: var(--practice-hanzi-line-small);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="medium"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="medium"] {
  --practice-preview-font-size: var(--practice-hanzi-size-medium);
  --practice-preview-line-height: var(--practice-hanzi-line-medium);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="large"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="hanzi"][data-practice-text-size="large"] {
  --practice-preview-font-size: var(--practice-hanzi-size-large);
  --practice-preview-line-height: var(--practice-hanzi-line-large);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="small"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="small"] {
  --practice-preview-font-size: var(--practice-word-meaning-size-small);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="medium"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="medium"] {
  --practice-preview-font-size: var(--practice-word-meaning-size-medium);
}

body[data-active="settings"] .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="large"],
.settings-overlay .practice-text-size-btn[data-practice-text-target="word-meanings"][data-practice-text-size="large"] {
  --practice-preview-font-size: var(--practice-word-meaning-size-large);
}

body[data-active="settings"] .practice-text-size-preview,
.settings-overlay .practice-text-size-preview {
  font-size: var(--practice-preview-font-size);
  line-height: var(--practice-preview-line-height, normal);
}

@media (max-width: 640px) {
  body[data-active="settings"] .settings-slider-row.settings-choice-row,
  body[data-active="settings"] .settings-slider-row.settings-text-size-block,
  .settings-overlay .settings-slider-row.settings-choice-row,
  .settings-overlay .settings-slider-row.settings-text-size-block {
    align-items: stretch;
  }

  body[data-active="settings"] .practice-text-size-row,
  .settings-overlay .practice-text-size-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }
  body[data-active="settings"] .practice-text-size-list,
  .settings-overlay .practice-text-size-list,
  body[data-active="settings"] .practice-text-advanced .practice-text-size-row .settings-choice-control,
  .settings-overlay .practice-text-advanced .practice-text-size-row .settings-choice-control {
    align-items: stretch;
    width: 100%;
  }
  body[data-active="settings"] .practice-text-size-btn,
  .settings-overlay .practice-text-size-btn {
    column-gap: 12px;
    display: grid;
    grid-template-columns: 12px minmax(54px, 64px) minmax(0, 1fr);
  }
  body[data-active="settings"] .practice-text-size-name,
  .settings-overlay .practice-text-size-name {
    flex-basis: auto;
  }
  body[data-active="settings"] .practice-text-size-preview,
  .settings-overlay .practice-text-size-preview {
    justify-self: start;
  }
}

/*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-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-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: 20px 0 14px;
}

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

.pack-hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--tp-on-accent);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}
.pack-hint-btn:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.pack-hint-btn:hover {
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
  text-decoration: none;
}
.pack-hint-btn:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.pack-hint-btn:not(:disabled):active {
  background: var(--tp-accent-pressed);
  color: var(--tp-control-on-accent);
}

/*===== 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: var(--tp-delete-bg);
  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;
  color: var(--tp-delete-fg);
  border-color: var(--tp-delete-border);
}

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

.course-remove:not(:disabled):hover,
.course-remove:not(:disabled):focus-visible {
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}

/*===== 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);
}

.lesson-card.is-access-locked {
  border-color: rgba(79,70,229,.28);
  background: linear-gradient(180deg, var(--surface), rgba(238,242,255,.58));
}

.lesson-lock-note {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

/*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);
}

.lesson-badge.is-pro {
  color: #4338ca;
  border-color: rgba(79,70,229,.26);
  background: rgba(238,242,255,.96);
  font-weight: 800;
}

/*===== 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"] {
  --fs-ui-offset: 0px;
}

body[data-active="practice"] {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--practice-page-bg);
  color: var(--tp-text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  --practice-page-bg: var(--tp-bg-body);
  --practice-panel-bg: transparent;
  --practice-title-bg: var(--tp-bg-surface);
  --practice-shortcut-bg: transparent;
  --practice-shortcut-border: none;
  --practice-key-bg: var(--tp-bg-surface-alt);
  --practice-input-bg: transparent;
  --practice-hint-bg: var(--tp-bg-surface);
  --practice-border-color: var(--tp-border-subtle);
  --practice-soft-hover-bg: rgba(34,197,94,.10);
  --practice-english-font-size: var(--practice-english-size-medium);
  --practice-pinyin-font-size: var(--practice-pinyin-size-medium);
  --practice-word-meaning-font-size: var(--practice-word-meaning-size-medium);
  --practice-hanzi-font-size: var(--practice-hanzi-size-medium);
  --practice-hanzi-line-height: var(--practice-hanzi-line-medium);
  --practice-hanzi-height: var(--practice-hanzi-height-medium);
}

body[data-active="practice"][data-practice-background="warm"] {
  --practice-page-bg: #fff7ed;
  --practice-panel-bg: var(--practice-page-bg);
  --practice-title-bg: var(--practice-page-bg);
  --practice-shortcut-bg: transparent;
  --practice-shortcut-border: none;
  --practice-key-bg: #fffaf0;
  --practice-input-bg: transparent;
  --practice-hint-bg: #fffaf0;
  --practice-border-color: #f2dcc0;
  --practice-soft-hover-bg: rgba(245, 158, 11, .14);
}

body[data-active="practice"][data-practice-background="green"] {
  --practice-page-bg: #eefaf2;
  --practice-panel-bg: var(--practice-page-bg);
  --practice-title-bg: var(--practice-page-bg);
  --practice-shortcut-bg: transparent;
  --practice-shortcut-border: none;
  --practice-key-bg: #f4fff7;
  --practice-input-bg: transparent;
  --practice-hint-bg: #f4fff7;
  --practice-border-color: #c8ead6;
  --practice-soft-hover-bg: rgba(34, 197, 94, .13);
}

html[data-theme="dark"] body[data-active="practice"] {
  --practice-page-bg: var(--tp-bg-body);
  --practice-panel-bg: transparent;
  --practice-title-bg: var(--tp-bg-surface);
  --practice-shortcut-bg: transparent;
  --practice-shortcut-border: none;
  --practice-key-bg: var(--tp-bg-surface-alt);
  --practice-input-bg: transparent;
  --practice-hint-bg: var(--tp-bg-surface);
  --practice-border-color: var(--tp-border-subtle);
  --practice-soft-hover-bg: rgba(34,197,94,.10);
}

/* Keep the full practice page continuous without changing embedded demos. */
html[data-theme="dark"]:not(.tp-embedded) body[data-active="practice"] {
  --practice-title-bg: var(--practice-page-bg);
}

html[data-theme="dark"]:not(.tp-embedded) body[data-active="practice"] .tp-oskb {
  background: var(--practice-page-bg);
  box-shadow: none;
}

body[data-active="practice"][data-practice-english-text-size="small"] {
  --practice-english-font-size: var(--practice-english-size-small);
}

body[data-active="practice"][data-practice-english-text-size="large"] {
  --practice-english-font-size: var(--practice-english-size-large);
}

body[data-active="practice"][data-practice-pinyin-text-size="small"] {
  --practice-pinyin-font-size: var(--practice-pinyin-size-small);
}

body[data-active="practice"][data-practice-pinyin-text-size="large"] {
  --practice-pinyin-font-size: var(--practice-pinyin-size-large);
}

body[data-active="practice"][data-practice-hanzi-text-size="small"] {
  --practice-hanzi-font-size: var(--practice-hanzi-size-small);
  --practice-hanzi-line-height: var(--practice-hanzi-line-small);
  --practice-hanzi-height: var(--practice-hanzi-height-small);
}

body[data-active="practice"][data-practice-hanzi-text-size="large"] {
  --practice-hanzi-font-size: var(--practice-hanzi-size-large);
  --practice-hanzi-line-height: var(--practice-hanzi-line-large);
  --practice-hanzi-height: var(--practice-hanzi-height-large);
}

body[data-active="practice"][data-practice-word-meanings-text-size="small"] {
  --practice-word-meaning-font-size: var(--practice-word-meaning-size-small);
}

body[data-active="practice"][data-practice-word-meanings-text-size="large"] {
  --practice-word-meaning-font-size: var(--practice-word-meaning-size-large);
}

/*Top bar*/

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

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

.lesson-title-trigger {
  min-width: 0;
  max-width: min(52vw, 720px);
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  margin: 0;
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}

.lesson-title-trigger:hover {
  background: var(--tp-bg-surface);
  color: var(--tp-green, #16a34a);
  transform: translateY(-0.5px);
}

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

@media (max-width: 820px) {
  .lesson-title-trigger {
    max-width: calc(100vw - 132px);
  }
}
@media (820px < width <= 860px) {
  :where(html:is(.tp-embedded, .tp-landing)) .lesson-title-trigger { max-width: calc(100vw - 132px); }
}

.top-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-sub {
  color: var(--tp-text-muted);
  flex: 0 0 auto;
  white-space: nowrap;
  transition: color 0.15s;
}

.lesson-title-trigger:hover .top-sub {
  color: inherit;
}

.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: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
  cursor: pointer;
  font-size: 16px;
  color: var(--tp-text-main);
  padding: 0;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s, color 0.15s;
}

.back-btn-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.back-btn-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: scale(1.2);
  transform-origin: center;
}

.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);
}

body[data-active="practice"] .back-btn {
  background: transparent;
  border-color: transparent;
}

body[data-active="practice"] .back-btn:hover {
  background: var(--tp-bg-surface);
  border-color: transparent;
  color: var(--tp-green, #16a34a);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  transform: translateY(-0.5px);
}

/*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;
}

.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);
}

.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: var(--tp-on-accent);
}

.settings-btn.answer-active:hover {
  background: var(--tp-accent-hover);
}

.settings-btn.answer-active:not(:disabled):active {
  background: var(--tp-accent-pressed);
  color: var(--tp-on-accent);
}

/*原 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: var(--sentence-list-top, 36px);
  left: var(--sentence-list-left, 64px);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 30px rgba(15,23,42,0.12);
  padding: 10px 12px;
  box-sizing: border-box;
  width: min(420px, calc(100vw - var(--sentence-list-left, 64px) - 16px));
  min-width: min(260px, calc(100vw - var(--sentence-list-left, 64px) - 16px));
  max-width: calc(100vw - var(--sentence-list-left, 64px) - 16px);
  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;
  min-width: 0;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.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;
  background: var(--practice-panel-bg);
}

/*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 var(--practice-border-color);
  background: var(--practice-hint-bg);
  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: var(--practice-word-meaning-font-size);
  font-weight: 500;
  line-height: 1.25;
  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;
}

@media (max-width: 820px) {
  body[data-active="practice"] .word-meaning {
    padding: 4px 8px;
    line-height: 1.3;
  }
}
@media (820px < width <= 860px) {
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"] .word-meaning { padding: 4px 8px; line-height: 1.3; }
}

.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;
  position: relative;
  min-height: 28px;
}

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

.tp-word-popover-title {
  display: contents;
}

.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-fullscreen-btn {
  appearance: none;
  position: absolute;
  top: 0;
  right: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}

.tp-word-popover-fullscreen-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

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

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

.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-hanzi-practiced-card-popover {
  background: #f2fbf5;
  border-color: var(--accent, #22c55e);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, .12);
  box-sizing: border-box;
  flex-direction: column;
  padding: 12px 14px;
  transform: none;
  transition: none;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-show {
  transform: none;
  transition: none;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-bottom {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-top {
  border-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.tp-word-popover.is-hanzi-practiced-card-popover::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent, #22c55e);
  pointer-events: none;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-bottom::before {
  top: 0;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-top::before {
  bottom: 0;
}

.tp-word-popover.is-hanzi-practiced-card-popover .tp-word-popover-head,
.tp-word-popover.is-hanzi-practiced-card-popover .tp-word-popover-divider,
.tp-word-popover.is-hanzi-practiced-card-popover .tp-word-popover-play-btn,
.tp-word-popover.is-hanzi-practiced-card-popover .tp-word-popover-btn {
  display: none;
}

.tp-word-popover.is-hanzi-practiced-card-popover .tp-word-popover-meaning {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  overflow: visible;
  padding-right: 0;
}

.tp-word-popover.is-hanzi-practiced-card-popover.is-constrained .tp-word-popover-meaning {
  overflow: auto;
  padding-right: 2px;
}

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

.tp-word-popover.is-review-item-detail-popover,
.tp-word-popover.is-review-item-detail-popover .tp-word-popover-meaning {
  overscroll-behavior: contain;
}

.tp-word-popover.is-review-item-detail-popover {
  z-index: 26000;
  box-sizing: border-box;
  min-width: min(220px, calc(100vw - 16px));
  max-width: min(320px, calc(100vw - 16px));
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: start;
  flex-shrink: 0;
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-head-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: start;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  max-height: min(160px, 30vh);
  overflow: auto;
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-title > div {
  max-width: 100%;
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-play-btn {
  margin-left: 0;
}

.tp-word-popover.is-review-item-detail-popover .tp-word-popover-fullscreen-btn {
  position: static;
}

.tp-word-popover.is-review-item-detail-popover.is-detail-fullscreen {
  max-width: none;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column;
}

.tp-word-popover.is-review-item-detail-popover.is-detail-fullscreen .tp-word-popover-meaning {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.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.is-review-item-detail-popover .tp-word-popover-meaning {
  font-size: 15px;
  line-height: 1.7;
}

.tp-word-popover.is-review-item-detail-popover .tp-md {
  display: block;
  gap: normal;
}

.tp-word-popover.is-review-item-detail-popover .tp-md-h3 {
  margin: 14px 0 8px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
}

.tp-word-popover.is-review-item-detail-popover .tp-md p,
.tp-word-popover.is-review-item-detail-popover .tp-md-ul {
  margin: 0 0 10px;
}

.tp-word-popover.is-review-item-detail-popover .tp-md-kv {
  margin: 0 0 8px;
}

.tp-word-popover.is-review-item-detail-popover .tp-md-li {
  margin: 4px 0;
}

.tp-word-popover.is-review-item-detail-popover .tp-md strong,
.tp-word-popover.is-review-item-detail-popover .tp-md-label {
  font-weight: 800;
  color: var(--text-primary);
}

.tp-word-popover.is-review-item-detail-popover .tp-md code {
  font-size: 0.95em;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.06);
}

.tp-word-popover.is-review-item-detail-popover .tp-md-code {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.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;
  background: var(--practice-input-bg);
  border-radius: 18px;
}

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

.tp-watch-order-hint {
  width: min(100%, 560px);
  margin: -10px auto 18px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--border-subtle) 72%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 86%, var(--accent-soft) 14%);
  color: var(--text);
  text-align: left;
}

.tp-watch-order-hint[hidden] {
  display: none !important;
}

#phrase.tp-watch-word-blocks {
  overflow-wrap: anywhere;
}


.tp-watch-order-hint__label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tp-watch-order-hint__line {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tp-watch-order-hint__sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 34px;
}

.tp-watch-order-hint__sequence[hidden] {
  display: none !important;
}

.tp-watch-order-hint__token {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--border-subtle) 78%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.15;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.tp-watch-order-hint__token.is-active {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--border-subtle));
  background: color-mix(in srgb, var(--accent-soft) 62%, var(--surface) 38%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-soft) 50%, transparent);
  transform: translateY(-2px);
}

.tp-watch-order-hint__token.is-moving {
  border-color: color-mix(in srgb, var(--accent) 78%, var(--border-subtle));
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface) 28%);
  transform: translateY(-3px) scale(1.02);
}

.tp-watch-order-hint__line--adjusted {
  margin-top: 4px;
  font-weight: 700;
}

.tp-watch-order-hint__note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tp-watch-order-hint.is-comparison {
  width: min(100%, 820px);
  text-align: center;
}

.tp-watch-order-hint.is-comparison .tp-watch-order-hint__label {
  margin-bottom: 8px;
}

.tp-watch-order-hint__sequence.tp-watch-comparison-meanings {
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 0;
}

/* Keep punctuation advances independent of the neighbouring word during reordering. */
html.tp-watch-mode [data-tp="phrase"] {
  font-kerning: none;
}

.tp-watch-comparison-token {
  border-radius: 6px;
  transition: background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.tp-watch-comparison-token--natural {
  display: inline-block;
}

.tp-watch-comparison-token--meaning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 30px;
  padding: 4px 5px;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tp-watch-comparison-token--meaning.is-empty {
  border-color: color-mix(in srgb, var(--border-subtle) 82%, transparent);
  border-style: dashed;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
}

.tp-watch-comparison-token.is-explaining {
  background: color-mix(in srgb, #5b9dff 42%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, #5b9dff 34%, transparent);
  color: var(--text);
  font-weight: inherit;
}

.tp-watch-comparison-separator {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.tp-watch-comparison-punctuation {
  margin-left: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .tp-watch-comparison-token {
    transition: none;
  }
}

@media (max-width: 480px) {
  .tp-watch-order-hint.is-comparison {
    padding-inline: 8px;
  }

  .tp-watch-order-hint__sequence.tp-watch-comparison-meanings {
    gap: 4px;
  }

  .tp-watch-comparison-token--meaning {
    min-width: 26px;
    padding: 4px;
    font-size: 13px;
  }
}

.phrase.tp-watch-phrase-order {
  display: block;
  white-space: normal;
}

.tp-watch-order-phrase-token {
  display: inline-block;
  border-radius: 4px;
  color: inherit;
  line-height: inherit;
  white-space: normal;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.tp-watch-order-phrase-token.is-selected {
  background: color-mix(in srgb, #5b9dff 42%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, #5b9dff 24%, transparent);
}

.tp-watch-order-phrase-token.is-moving {
  background: color-mix(in srgb, #5b9dff 34%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, #5b9dff 18%, transparent);
}

.tp-watch-order-phrase-token.is-hidden-source {
  visibility: hidden;
}

.tp-watch-order-ghost {
  position: fixed;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  background: color-mix(in srgb, #5b9dff 42%, transparent);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--shadow) 26%, transparent);
  color: var(--text);
  font-size: var(--practice-english-font-size);
  font-weight: 500;
  line-height: 1.18;
  pointer-events: none;
  white-space: nowrap;
}

.tp-watch-order-ghost--words {
  display: block;
  background: transparent;
  box-shadow: none;
}

.tp-watch-order-ghost--words > span {
  position: absolute;
  border-radius: 4px;
  background: color-mix(in srgb, #5b9dff 42%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, #5b9dff 24%, transparent);
}

.tp-watch-order-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1210;
  width: 22px;
  height: 28px;
  pointer-events: none;
  transform-origin: 0 0;
}

.tp-watch-order-cursor[hidden] {
  display: none !important;
}

.tp-watch-order-cursor::before {
  content: "";
  display: block;
  width: 20px;
  height: 26px;
  background: color-mix(in srgb, var(--text) 92%, white 8%);
  clip-path: polygon(0 0, 0 82%, 30% 62%, 46% 100%, 62% 92%, 47% 56%, 82% 56%);
  filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--shadow) 35%, transparent));
}

.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: var(--practice-soft-hover-bg);
}

body[data-active="practice"] #slots .slot.review-mode > :is(input, textarea).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 :is(input, textarea).slot-input.review-mode {
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

body[data-active="practice"] #input-view .slot :is(input, textarea).slot-input.review-mode.is-hover-preview-py {
  background: var(--practice-soft-hover-bg) !important;
  background-color: var(--practice-soft-hover-bg) !important;
}

body[data-active="practice"] #input-view .slot.is-shadow-word-hover {
  cursor: pointer;
}

body[data-active="practice"] #input-view .slot.is-shadow-word-hover > :is(input, textarea).slot-input {
  background: var(--practice-soft-hover-bg) !important;
  background-color: var(--practice-soft-hover-bg) !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

body[data-active="practice"] #input-view:not(.shadow-result-mode) .slot.is-shadow-word-hover > :is(input, textarea).slot-input {
  border-bottom-color: var(--tp-slot-line-ok) !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: var(--practice-soft-hover-bg);
  pointer-events: none;
  z-index: -1;
}

body[data-active="practice"] .slot.is-hanzi-hidden > .hanzi-word {
  background: transparent !important;
}

body[data-active="practice"] .slot.is-hanzi-hidden > .hanzi-word.is-hover-preview-hz::before {
  content: none;
}

.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;
}

body[data-active="practice"] .phrase {
  font-size: var(--practice-english-font-size) !important;
}

body[data-active="practice"] #input-view .slot :is(input, textarea).slot-input,
body[data-active="practice"] #review-view .slot :is(input, textarea).slot-input,
body[data-active="practice"] #input-view .slot :is(input, textarea).slot-input[readonly],
body[data-active="practice"] #review-view .slot :is(input, textarea).slot-input[readonly] {
  font-size: var(--practice-pinyin-font-size) !important;
}

body[data-active="practice"] .hanzi-word {
  font-size: var(--practice-hanzi-font-size) !important;
  height: var(--practice-hanzi-height) !important;
  line-height: var(--practice-hanzi-line-height) !important;
}

@media (max-width: 860px) {
  body[data-active="settings"],
  .settings-overlay {
    --practice-english-size-small: 18px;
    --practice-english-size-medium: 20px;
    --practice-english-size-large: 22px;
    --practice-pinyin-size-small: 21px;
    --practice-pinyin-size-medium: 24px;
    --practice-pinyin-size-large: 27px;
    --practice-word-meaning-size-small: 14px;
    --practice-word-meaning-size-medium: 16px;
    --practice-word-meaning-size-large: 18px;
    --practice-hanzi-size-small: 21px;
    --practice-hanzi-size-medium: 24px;
    --practice-hanzi-size-large: 27px;
    --practice-hanzi-line-small: 24px;
    --practice-hanzi-line-medium: 28px;
    --practice-hanzi-line-large: 32px;
    --practice-hanzi-height-small: 24px;
    --practice-hanzi-height-medium: 28px;
    --practice-hanzi-height-large: 32px;
  }
}
@media (max-width: 820px) {
  body[data-active="practice"] {
    --practice-english-size-small: 18px;
    --practice-english-size-medium: 20px;
    --practice-english-size-large: 22px;
    --practice-pinyin-size-small: 21px;
    --practice-pinyin-size-medium: 24px;
    --practice-pinyin-size-large: 27px;
    --practice-word-meaning-size-small: 14px;
    --practice-word-meaning-size-medium: 16px;
    --practice-word-meaning-size-large: 18px;
    --practice-hanzi-size-small: 21px;
    --practice-hanzi-size-medium: 24px;
    --practice-hanzi-size-large: 27px;
    --practice-hanzi-line-small: 24px;
    --practice-hanzi-line-medium: 28px;
    --practice-hanzi-line-large: 32px;
    --practice-hanzi-height-small: 24px;
    --practice-hanzi-height-medium: 28px;
    --practice-hanzi-height-large: 32px;
  }

  body[data-active="practice"] {
    --practice-english-font-size: var(--practice-english-size-medium);
    --practice-pinyin-font-size: var(--practice-pinyin-size-medium);
    --practice-hanzi-font-size: var(--practice-hanzi-size-medium);
    --practice-hanzi-line-height: var(--practice-hanzi-line-medium);
    --practice-hanzi-height: var(--practice-hanzi-height-medium);
  }

  body[data-active="practice"][data-practice-english-text-size="small"] {
    --practice-english-font-size: var(--practice-english-size-small);
  }

  body[data-active="practice"][data-practice-english-text-size="large"] {
    --practice-english-font-size: var(--practice-english-size-large);
  }

  body[data-active="practice"][data-practice-pinyin-text-size="small"] {
    --practice-pinyin-font-size: var(--practice-pinyin-size-small);
  }

  body[data-active="practice"][data-practice-pinyin-text-size="large"] {
    --practice-pinyin-font-size: var(--practice-pinyin-size-large);
  }

  body[data-active="practice"][data-practice-hanzi-text-size="small"] {
    --practice-hanzi-font-size: var(--practice-hanzi-size-small);
    --practice-hanzi-line-height: var(--practice-hanzi-line-small);
    --practice-hanzi-height: var(--practice-hanzi-height-small);
  }

  body[data-active="practice"][data-practice-hanzi-text-size="large"] {
    --practice-hanzi-font-size: var(--practice-hanzi-size-large);
    --practice-hanzi-line-height: var(--practice-hanzi-line-large);
    --practice-hanzi-height: var(--practice-hanzi-height-large);
  }
}
@media (820px < width <= 860px) {
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"] { --practice-english-size-small: 18px; --practice-english-size-medium: 20px; --practice-english-size-large: 22px; --practice-pinyin-size-small: 21px; --practice-pinyin-size-medium: 24px; --practice-pinyin-size-large: 27px; --practice-word-meaning-size-small: 14px; --practice-word-meaning-size-medium: 16px; --practice-word-meaning-size-large: 18px; --practice-hanzi-size-small: 21px; --practice-hanzi-size-medium: 24px; --practice-hanzi-size-large: 27px; --practice-hanzi-line-small: 24px; --practice-hanzi-line-medium: 28px; --practice-hanzi-line-large: 32px; --practice-hanzi-height-small: 24px; --practice-hanzi-height-medium: 28px; --practice-hanzi-height-large: 32px; }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"] { --practice-english-font-size: var(--practice-english-size-medium); --practice-pinyin-font-size: var(--practice-pinyin-size-medium); --practice-hanzi-font-size: var(--practice-hanzi-size-medium); --practice-hanzi-line-height: var(--practice-hanzi-line-medium); --practice-hanzi-height: var(--practice-hanzi-height-medium); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-english-text-size="small"] { --practice-english-font-size: var(--practice-english-size-small); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-english-text-size="large"] { --practice-english-font-size: var(--practice-english-size-large); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-pinyin-text-size="small"] { --practice-pinyin-font-size: var(--practice-pinyin-size-small); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-pinyin-text-size="large"] { --practice-pinyin-font-size: var(--practice-pinyin-size-large); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-hanzi-text-size="small"] { --practice-hanzi-font-size: var(--practice-hanzi-size-small); --practice-hanzi-line-height: var(--practice-hanzi-line-small); --practice-hanzi-height: var(--practice-hanzi-height-small); }
  :where(html:is(.tp-embedded, .tp-landing)) body[data-active="practice"][data-practice-hanzi-text-size="large"] { --practice-hanzi-font-size: var(--practice-hanzi-size-large); --practice-hanzi-line-height: var(--practice-hanzi-line-large); --practice-hanzi-height: var(--practice-hanzi-height-large); }
}

/* Effective practice sizes are transient; Settings previews keep their base sizes. */
body[data-active="practice"].tp-auto-fit {
  --tp-fit-scale: 1;
  --tp-fit-english-base: 42px;
  --tp-fit-pinyin-base: 50px;
  --tp-fit-hanzi-base: 50px;
  --tp-fit-meaning-base: 28px;
  --tp-fit-hanzi-line-base: 56px;
  --practice-english-font-size: var(--tp-fit-english-size, 42px);
  --practice-pinyin-font-size: var(--tp-fit-pinyin-size, 50px);
  --practice-hanzi-font-size: var(--tp-fit-hanzi-size, 50px);
  --practice-word-meaning-font-size: var(--tp-fit-meaning-size, 28px);
  --practice-hanzi-height: var(--tp-fit-hanzi-line-size, 56px);
  --practice-hanzi-line-height: var(--practice-hanzi-height);
}

html.tp-watch-mode body[data-active="practice"].tp-auto-fit {
  --practice-pinyin-font-size: var(--tp-fit-pinyin-size, 50px);
  --practice-hanzi-font-size: var(--tp-fit-hanzi-size, 50px);
  --practice-hanzi-height: var(--tp-fit-hanzi-line-size, 56px);
}

.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);
}

body[data-active="practice"] .bottom-shortcuts {
  background: var(--practice-shortcut-bg);
  border: var(--practice-shortcut-border);
  box-shadow: none;
  overflow-y: visible;
}

body[data-active="practice"] .shortcut-group {
  overflow-y: visible;
  padding-top: 3px;
  margin-top: -3px;
}

body[data-active="practice"] .key-combo {
  border-color: var(--practice-border-color);
  background: var(--practice-key-bg);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition:
    transform .12s ease,
    box-shadow .12s ease,
    background-color .12s ease,
    border-color .12s ease;
}

body[data-active="practice"] .key-combo:hover {
  background: var(--practice-key-bg);
  border-color: var(--practice-border-color);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
}

body[data-active="practice"] .key-combo:active {
  transform: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
}

.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;
}

body[data-active="practice"] .key {
  border-color: var(--practice-border-color);
  background: var(--practice-page-bg);
}

@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: var(--tp-on-accent);
}
.nav-action-btn.primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.nav-action-btn.primary:hover {
  background: var(--tp-accent-hover);
}

.nav-action-btn.primary:not(:disabled):active {
  background: var(--tp-accent-pressed);
  color: var(--tp-control-on-accent);
}

/* 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-difficulty-card.is-unavailable {
  cursor: not-allowed;
  color: var(--tp-text-muted);
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  box-shadow: none;
  transform: none;
}

.mode-difficulty-card.is-unavailable:hover {
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  box-shadow: none;
  transform: none;
}

.mode-option.active,
.mode-difficulty-card.active {
  background: #22c55e;
  border-color: #16a34a;
  color: var(--tp-on-accent);
  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: var(--tp-on-accent);
  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-recording-waveform {
  width: 48px;
  height: 40px;
  display: none;
  grid-template-columns: repeat(7, 1fr);
  align-items: center;
  gap: 4px;
}

.shadow-recording-waveform span {
  display: block;
  width: 5px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
}

.shadow-recording-waveform span:nth-child(1) { height: 14px; opacity: 0.72; }
.shadow-recording-waveform span:nth-child(2) { height: 23px; opacity: 0.86; }
.shadow-recording-waveform span:nth-child(3) { height: 34px; }
.shadow-recording-waveform span:nth-child(4) { height: 40px; }
.shadow-recording-waveform span:nth-child(5) { height: 29px; }
.shadow-recording-waveform span:nth-child(6) { height: 21px; opacity: 0.86; }
.shadow-recording-waveform span:nth-child(7) { height: 13px; opacity: 0.72; }

.shadow-controls.recording .shadow-mic-icon {
  display: none;
}

.shadow-controls.recording .shadow-recording-waveform {
  display: grid;
}

.shadow-controls.recording .shadow-recording-waveform span {
  animation: shadow-waveform-live 720ms ease-in-out infinite;
  transform-origin: center;
}

.shadow-controls.recording .shadow-recording-waveform span:nth-child(1) { animation-delay: -480ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(2) { animation-delay: -320ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(3) { animation-delay: -180ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(4) { animation-delay: -40ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(5) { animation-delay: -260ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(6) { animation-delay: -390ms; }
.shadow-controls.recording .shadow-recording-waveform span:nth-child(7) { animation-delay: -540ms; }

@keyframes shadow-waveform-live {
  0%,
  100% {
    transform: scaleY(0.52);
    opacity: 0.68;
  }
  42% {
    transform: scaleY(1.08);
    opacity: 1;
  }
  68% {
    transform: scaleY(0.74);
    opacity: 0.86;
  }
}

.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-confirmation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 12px;
  background: var(--tp-bg-surface-alt);
  color: var(--tp-text-main);
  font-size: 13px;
}

#settings-reset-confirmation[hidden] { display: none; }
#mode-modal:focus { outline: none; }
#settings-reset-confirmation p { margin: 4px 0 0; color: var(--tp-text-muted); }
.settings-reset-actions { display: flex; gap: 8px; }

#settings-reset-confirmation [data-tp="settings-reset-confirm"] {
  background: var(--tp-accent);
  color: var(--tp-on-accent);
}
#settings-reset-confirmation [data-tp="settings-reset-confirm"]:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.settings-overlay .shortcut-conflict {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--tp-text-main);
}
.settings-overlay .shortcut-conflict:empty { display: none; }

.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: 200px;
  min-width: 200px;
  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: 10px;
}

.settings-overlay .settings-section-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  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: normal;
}

.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: var(--tp-accent);
  border-color: var(--tp-accent);
  color: var(--tp-on-accent);
  font-weight: 650;
}
.settings-overlay .settings-section-btn.active:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.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;
}

/* Shared settings typography and row rhythm. Keep practice text samples independent. */
.settings-body .settings-search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  min-width: 0;
}

.settings-body .settings-search-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 48px 8px 10px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 10px;
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  font: inherit;
  font-size: var(--settings-label-size);
}

.settings-body .settings-search-box:has(.settings-search-clear[hidden]) .settings-search-input {
  padding-right: 10px;
}

.settings-body .settings-search-clear {
  position: absolute;
  right: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--tp-accent);
  font: inherit;
  font-size: var(--settings-description-size);
  cursor: pointer;
}

.settings-body .settings-search-input::-webkit-search-cancel-button {
  display: none;
}

body[data-active="settings"] #view-settings .settings-section-list[hidden] {
  display: none !important;
}

.settings-body .settings-search-status {
  margin: 0 0 8px;
  color: var(--tp-text-muted);
  font-size: var(--settings-description-size);
  line-height: 1.45;
}

.settings-body .settings-search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.settings-body .settings-search-results button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tp-text-main);
  font: inherit;
  font-size: var(--settings-label-size);
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.settings-body .settings-search-category {
  color: var(--tp-text-muted);
  font-size: var(--settings-description-size);
}

.settings-body .settings-search-results button:hover {
  background: var(--tp-bg-surface-alt);
}

.settings-body :is(.settings-search-clear, .settings-search-results button):focus-visible {
  outline: 2px solid var(--tp-accent);
  outline-offset: 2px;
}

/* Keep search focus inside the field, including clipped modal sidebars. */
body[data-active] input:is([type="search"], [data-tp="admin-audit-action"], [data-tp="admin-audit-object"]):focus,
#view-hanzi-practiced .hp-toolbar input[type="search"]:focus {
  outline: 2px solid var(--tp-accent, var(--accent));
  outline-offset: -2px;
  border-radius: 10px;
  box-shadow: none;
}

.settings-body .settings-search-target:focus {
  position: relative;
  outline: none;
}

.settings-body .settings-search-target:focus::after {
  content: "";
  position: absolute;
  inset: 5px -4px;
  border: 2px solid var(--tp-accent);
  border-radius: 18px;
  pointer-events: none;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body {
  --settings-label-size: 14px;
  --settings-description-size: 13px;
  --settings-control-height: 40px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-dialog.tp-narrow .settings-body {
  --settings-label-size: 15px;
  --settings-description-size: 14px;
  --settings-control-height: 44px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.settings-section-btn, .settings-select, .theme-mode-btn, .shortcut-edit-btn) {
  font-family: inherit;
  line-height: 1.45;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.simple-toggle, .settings-slider-label, .settings-slider-label strong, .settings-toggle-title, .practice-text-size-label, .settings-shortcut-item) {
  font-size: var(--settings-label-size);
  line-height: 1.45;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.settings-slider-label strong, .settings-toggle-title, .simple-toggle > span, .practice-text-size-label) {
  font-weight: 600;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.settings-slider-label span, .settings-toggle-desc, .settings-section-desc, .settings-slider-value, .note, .practice-background-dark-note) {
  font-size: var(--settings-description-size);
  font-weight: 400;
  line-height: 1.45;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .simple-toggle span {
  line-height: 1.45;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .note {
  color: var(--tp-text-muted);
  margin-top: 10px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-slider-label strong {
  margin-bottom: 3px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.settings-slider-row, .simple-toggle, .settings-shortcut-item) {
  border-top: 0;
  border-bottom: 1px solid var(--tp-border-subtle);
  margin: 0;
  padding: 16px 0;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .toggle-group {
  margin-bottom: 0;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-slider-control {
  min-width: 230px;
  gap: 6px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.settings-choice-control, .practice-text-size-list) {
  min-width: 0;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-text-size-list {
  align-items: stretch;
  gap: 16px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-select {
  box-sizing: border-box;
  min-height: var(--settings-control-height);
  padding: 8px 10px;
  font-size: var(--settings-label-size);
}

:is(body[data-active="settings"], .settings-overlay) .settings-dialog.tp-narrow .settings-slider-control {
  min-width: 0;
}

/* Compact choices share one presentation; theme and size previews keep their own styles. */
:is(body[data-active="settings"], .settings-overlay) .settings-body [hidden] {
  display: none !important;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control {
  display: grid;
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 3px;
  width: 100%;
  max-width: 360px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 10px;
  background: var(--tp-bg-surface-alt);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: var(--settings-control-height);
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--tp-text-main);
  box-shadow: none;
  transform: none;
  font-family: inherit;
  font-size: var(--settings-label-size);
  font-weight: 400;
  line-height: 1.45;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn:hover:not(:disabled) {
  background: var(--tp-bg-surface-alt);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .12);
  transform: translateY(-1px);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn.active {
  background: var(--tp-bg-surface);
  color: var(--tp-accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn.active:hover:not(:disabled) {
  background: var(--tp-bg-surface);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .12);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn:focus-visible,
:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-text-advanced > summary:focus-visible {
  outline: 2px solid var(--tp-accent);
  outline-offset: 2px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-segmented-control .settings-choice-btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  box-shadow: none;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .theme-mode-row {
  margin-bottom: 0;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-subtitles-block {
  flex-wrap: wrap;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-subtitles-size {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: 12px;
  min-width: 0;
  box-sizing: border-box;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-subtitles-size .settings-choice-control {
  flex: 1 1 210px;
}

/* Match Theme buttons, including the height of their 14px icon line. */
:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-background-btn {
  display: flex;
  min-height: calc(14px * 1.45 + 16px);
  padding: 7px 10px;
  font-family: inherit;
  line-height: 1.45;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-background-btn:where(:not(:disabled)):hover {
  background: var(--tp-bg-surface-alt);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .12);
  transform: translateY(-1px);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-background-btn.active {
  background: rgba(34, 197, 94, .12);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.theme-mode-row, .practice-background-control) {
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
  max-width: 360px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.theme-mode-btn, .practice-background-btn) {
  flex: 1 1 0;
  justify-content: center;
  min-width: 0;
  padding-inline: 4px;
  gap: 4px;
  white-space: nowrap;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-text-fixed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-text-advanced > summary {
  padding: 8px 0;
  color: var(--tp-text-main);
  font-size: var(--settings-label-size);
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .practice-text-advanced[open] > summary {
  margin-bottom: 8px;
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-shortcut-group-title {
  font-size: var(--settings-label-size);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  color: var(--tp-text-main);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body :is(.shortcut-edit-btn, .shortcut-tag) {
  font-size: var(--settings-description-size);
}

:is(body[data-active="settings"], .settings-overlay) .settings-body .settings-shortcut-item .key {
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
}

/*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;
  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;
  padding: 24px;
  overflow-y: auto;
  z-index: 9999;
}

.summary-dialog {
  background: var(--tp-bg-surface);
  border: 1px solid var(--tp-border-subtle);
  border-radius: 28px;
  padding: 24px 30px 0;
  width: min(840px, calc(100vw - 48px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.summary-course-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--tp-text-muted);
  font-size: 13px;
  font-weight: 760;
}

.summary-course-line span {
  min-width: 0;
}

.summary-course-line span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-course-line span:last-child {
  color: #16a34a;
  white-space: nowrap;
}

.summary-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--tp-border-subtle);
}

.summary-stars {
  color: var(--tp-text-main);
  font-size: 22px;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.summary-score {
  color: var(--tp-text-main);
  font-size: 46px;
  font-weight: 820;
  line-height: 1;
  margin-bottom: 0;
}

.summary-score-label {
  max-width: 520px;
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--tp-text-muted);
  font-weight: 680;
}

.summary-score-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.summary-score-ring {
  width: 116px;
  height: 116px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--tp-bg-surface) 0 54%, transparent 55%),
    conic-gradient(#22c55e 0 0%, #dbe7de 0% 100%);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.15);
}

.summary-score-ring strong {
  display: block;
  color: var(--tp-text-main);
  font-size: 30px;
  line-height: 1;
  font-weight: 820;
  text-align: center;
}

.summary-score-ring span {
  display: block;
  margin-top: 6px;
  color: var(--tp-text-muted);
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.summary-words {
  color: var(--tp-text-muted);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--tp-border-subtle);
}

.summary-cell {
  min-height: 82px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 16px;
  padding: 13px 14px;
  background: var(--tp-bg-surface);
}

.summary-cell:nth-child(1) {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.32);
}

.summary-cell:nth-child(2) {
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.30);
}

.summary-cell:nth-child(3) {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.24);
}

.summary-cell:nth-child(4) {
  background: rgba(168, 85, 247, 0.08);
  border-color: rgba(168, 85, 247, 0.24);
}

.summary-stat-label {
  color: var(--tp-text-muted);
  font-size: 12px;
  font-weight: 760;
  margin-bottom: 8px;
}

.summary-cell strong {
  display: block;
  color: var(--tp-text-main);
  font-size: 27px;
  line-height: 1.05;
  font-weight: 820;
  letter-spacing: 0;
}

.summary-sub {
  margin-top: 5px;
  color: var(--tp-text-muted);
  font-size: 12px;
  font-weight: 660;
}

.summary-spotlight {
  margin: 14px 0 0;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 18px;
  background: var(--tp-bg-surface-alt);
  padding: 16px 18px;
}

.summary-spotlight[hidden] {
  display: none !important;
}

.summary-spotlight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.summary-spotlight-title {
  color: #f97316;
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.summary-spotlight-audio {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  color: var(--tp-text-muted);
  cursor: pointer;
}

.summary-spotlight-audio:hover {
  background: var(--tp-bg-surface-alt);
}

.summary-spotlight-audio svg {
  width: 18px;
  height: 18px;
}

.summary-spotlight-hanzi {
  margin: 0 0 8px;
  color: var(--tp-text-main);
  font-size: 27px;
  line-height: 1.28;
  font-weight: 840;
}

.summary-spotlight-pinyin {
  margin: 0 0 8px;
  color: #4b5563;
  font-size: 16px;
  line-height: 1.36;
  font-weight: 760;
}

.summary-spotlight-english {
  margin: 0;
  color: var(--tp-text-muted);
  font-size: 13px;
  line-height: 1.42;
  font-weight: 680;
}

.summary-note {
  display: none;
  margin: 0 0 14px;
  color: var(--tp-text-muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 0.9fr 1.18fr 0.9fr 1.36fr;
  gap: 10px;
  margin: 14px -30px 0;
  padding: 12px 30px 20px;
  border-top: 1px solid var(--tp-border-subtle);
  background: linear-gradient(180deg, rgba(255,255,255,0.78), var(--tp-bg-surface) 38%);
  z-index: 2;
}

.summary-actions button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  cursor: pointer;
  font-size: 16px;
  font-weight: 780;
}

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

.summary-actions #summary-next-btn {
  border-color: #22c55e;
  background: #22c55e;
  color: var(--tp-on-accent);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.28);
}
.summary-actions #summary-next-btn:not(:disabled) {
  color: var(--tp-control-on-accent);
}

.summary-actions #summary-next-btn:hover {
  background: var(--tp-accent-hover);
}

.summary-actions #summary-next-btn:not(:disabled):active {
  background: var(--tp-accent-pressed);
  color: var(--tp-control-on-accent);
}

@media (max-width: 720px) {
  .summary-overlay {
    padding: 16px;
    align-items: flex-start;
  }

  .summary-dialog {
    width: 100%;
    max-height: calc(100vh - 32px);
    padding: 20px 18px 0;
  }

  .summary-course-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-hero {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .summary-score {
    font-size: 38px;
  }

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

  .summary-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 14px -18px 0;
    padding: 12px 18px 18px;
  }
}

/*===== 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 poster + side panel) =====*/

@media (max-width: 860px) {
  body[data-active="dashboard"]:has(#checkinCalendarModal[aria-hidden="false"]) .content-header.tp-mobile-unified,
  body[data-active="dashboard"]:has(#recentModal[aria-hidden="false"]) .content-header.tp-mobile-unified,
  body[data-active="dashboard"]:has(#share-overlay[aria-hidden="false"]) .content-header.tp-mobile-unified,
  body[data-active="mistakes"].modal-open .content-header.tp-mobile-unified,
  body:has(#accountModalBackdrop.open) .content-header.tp-mobile-unified {
    z-index: 9000;
  }
}

.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20050;
  padding: 24px;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}

.share-shell {
  position: relative;
  width: min(840px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  background: var(--tp-bg-surface);
  border: 1px solid var(--tp-border-subtle);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  overflow: hidden;
}

.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--tp-border-subtle);
  flex: 0 0 auto;
}

.share-head-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--tp-text-main);
}

.share-body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(260px, 1fr);
  align-items: start;
  gap: 24px;
  padding: 22px;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.share-card-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

.share-card-preview {
  --share-preview-scale: 1;
  flex: 0 0 auto;
  width: calc(360px * var(--share-preview-scale));
  height: calc(600px * var(--share-preview-scale));
  overflow: hidden;
  border-radius: calc(20px * var(--share-preview-scale));
  box-shadow: 0 16px 44px rgba(0,0,0,0.30);
}

#share-card {
  width: 360px;
  height: 600px;
  max-width: none;
  transform: scale(var(--share-preview-scale, 1));
  transform-origin: top left;
  box-sizing: border-box;
  border: 0;
  border-radius: 20px;
  padding: 30px 14px 34px;
  color: #fff;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(44px, 0.62fr) auto minmax(44px, 0.62fr) auto minmax(58px, 0.82fr) auto;
  background: linear-gradient(160deg, #124e66 0%, #2f6f73 54%, #8bc6a8 100%);
}

#share-card[data-bg="0"] { background: linear-gradient(160deg, #124e66 0%, #2f6f73 54%, #8bc6a8 100%); }
#share-card[data-bg="1"] { background: linear-gradient(160deg, #34215f 0%, #70549a 54%, #d27b8d 100%); }
#share-card[data-bg="2"] { background: linear-gradient(160deg, #0f4c5c 0%, #168aad 52%, #76e4f7 100%); }
#share-card[data-bg="3"] { background: linear-gradient(160deg, #151923 0%, #3b4659 54%, #7b8798 100%); }
#share-card[data-bg="4"] { background: linear-gradient(160deg, #1d3b7a 0%, #4f46a8 54%, #b26fd7 100%); }
#share-card[data-bg="5"] { background: linear-gradient(160deg, #355c7d 0%, #6c5b7b 55%, #c06c84 100%); }

.share-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  flex: 1 1 auto;
  max-width: calc(100% - 84px);
}

.share-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  user-select: none;
  cursor: default;
  flex: 0 0 auto;
  overflow: hidden;
}

.share-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
  display: block;
}

.share-user {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  flex: 1 1 auto;
}

.share-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: default;
  user-select: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-brandtag {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.72);
  letter-spacing: 0;
}

.share-card-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
  flex: 0 0 auto;
  grid-row: 1;
  min-width: 0;
}

.share-card-brand {
  display: grid;
  justify-items: stretch;
  gap: 5px;
  width: 74px;
  color: rgba(255,255,255,0.78);
  line-height: 1;
  text-align: center;
  letter-spacing: 0.03em;
  flex: 0 0 auto;
}

.share-card-brand div {
  white-space: nowrap;
}

.share-card-brand div:first-child {
  font-size: 10.5px;
  font-weight: 850;
}

.share-card-brand div:last-child {
  font-size: 8.7px;
  font-weight: 760;
}

.share-card-brand span {
  width: 100%;
  height: 1px;
  background: rgba(255,255,255,0.48);
}

.share-date {
  font-size: 10px;
  color: rgba(255,255,255,0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 0;
  flex: 0 0 auto;
  grid-row: 3;
  min-width: 0;
  max-width: 100%;
}

.share-stat {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 6px 5px;
  text-align: center;
  min-width: 0;
}

.share-stat-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.86);
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-stat-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-stat-icon.is-streak {
  color: #fbbf24;
}

.share-stat-icon.is-streak svg {
  fill: currentColor;
  stroke: none;
}

.share-stat-icon.is-time {
  color: #7dd3fc;
}

.share-stat-icon.is-today {
  color: #86efac;
}

.share-stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.share-stat-label {
  font-size: 12px;
  color: rgba(255,255,255,0.70);
  margin-top: 4px;
}

.share-quote {
  display: none;
}

.share-sentence {
  border-radius: 16px;
  padding: 16px 14px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 0;
  min-height: 0;
  flex: 0 0 auto;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  grid-row: 5;
  min-width: 0;
}

.share-sentence-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  color: rgba(255,255,255,0.62);
  margin-bottom: 10px;
}

.share-hanzi {
  font-size: 29px;
  font-weight: 800;
  line-height: 1.45;
  color: #fff;
  word-break: break-word;
  overflow: visible;
  display: block;
}

.share-hanzi ruby {
  ruby-align: center;
  ruby-position: over;
  display: inline-grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-items: end;
  min-width: 1em;
  margin: 0 0.03em;
  text-align: center;
  vertical-align: baseline;
  line-height: 1;
}

.share-hanzi rb {
  grid-row: 2;
  display: block;
  min-width: 1em;
  line-height: 1.12;
}

.share-hanzi ruby.share-hanzi-punctuation {
  min-width: 0.42em;
  margin: 0 -0.04em 0 -0.02em;
}

.share-hanzi ruby.share-hanzi-punctuation rb {
  min-width: 0.42em;
}

.share-hanzi ruby.share-hanzi-punctuation rt {
  visibility: hidden;
}

.share-hanzi rt {
  grid-row: 1;
  display: block;
  min-width: 100%;
  text-align: center;
  color: rgba(255,255,255,0.66);
  font-size: 9px;
  font-weight: 680;
  line-height: 1;
}

.share-pinyin {
  font-size: 16px;
  color: rgba(255,255,255,0.78);
  margin-top: 8px;
  line-height: 1.32;
  overflow: visible;
  display: block;
}

.share-english {
  font-size: 14px;
  font-style: italic;
  color: rgba(255,255,255,0.82);
  margin-top: 16px;
  line-height: 1.34;
  overflow: visible;
  display: block;
}

#share-card.is-long .share-hanzi {
  font-size: 25px;
  line-height: 1.42;
}

#share-card.is-long .share-pinyin {
  font-size: 14px;
  line-height: 1.25;
}

#share-card.is-long .share-english {
  font-size: 13px;
  line-height: 1.25;
  margin-top: 14px;
}

#share-card.is-compact .share-hanzi {
  font-size: 21px;
  line-height: 1.34;
}

#share-card.is-compact .share-pinyin {
  font-size: 13px;
  line-height: 1.18;
  margin-top: 6px;
}

#share-card.is-compact .share-english {
  font-size: 12px;
  line-height: 1.2;
  margin-top: 12px;
}

.share-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
  flex: 0 0 auto;
  grid-row: 7;
  min-width: 0;
}

.share-site-lockup {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.share-site-logo {
  width: 27px;
  height: 27px;
  border-radius: 4px;
  background: rgba(255,255,255,0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.share-site-logo img {
  width: 20px;
  height: 20px;
  display: block;
}

.share-site-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.share-site-url {
  font-size: 16px;
  line-height: 1.1;
  color: rgba(255,255,255,0.95);
  font-weight: 820;
  word-break: break-all;
}

.share-site-tagline {
  margin-top: 2px;
  max-width: none;
  white-space: nowrap;
  font-size: 10.5px;
  line-height: 1.12;
  color: rgba(255,255,255,0.86);
  font-weight: 740;
}

#share-card.is-exporting {
  border-radius: 0;
}

.share-qr {
  width: 41px;
  height: 41px;
  padding: 5px;
  border-radius: 6px;
  border: 0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.share-qr canvas,
.share-qr img {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.share-side {
  min-width: 230px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-side-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--tp-text-main);
}

.share-side-copy {
  font-size: 13px;
  line-height: 1.6;
  color: var(--tp-text-muted);
  margin: 0 0 4px;
}

.share-side-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-top: 6px;
}

.share-tool-btn {
  width: 100%;
  padding: 11px 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);
  text-align: left;
}

.share-tool-btn:hover {
  border-color: rgba(34,197,94,0.5);
}

.share-bg-control {
  position: relative;
}

.share-bg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
}

.share-bg-row .share-side-label {
  margin: 0;
}

.share-bg-trigger {
  width: 82px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 7px;
  cursor: pointer;
}

.share-bg-trigger:hover {
  border-color: rgba(34,197,94,0.5);
}

.share-bg-current {
  display: block;
  width: 46px;
  height: 24px;
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

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

.share-bg-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  padding: 10px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 14px;
  background: var(--tp-bg-surface);
  box-shadow: 0 18px 36px rgba(15,23,42,0.18);
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.share-bg-popover[hidden] {
  display: none !important;
}

.share-bg-choice {
  height: 40px;
  border: 1px solid var(--tp-border-subtle);
  border-radius: 12px;
  background: var(--tp-bg-surface-alt);
  padding: 3px;
  cursor: pointer;
}

.share-bg-choice span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9px;
}

.share-bg-choice span[data-bg="0"] { background: linear-gradient(160deg, #124e66 0%, #2f6f73 54%, #8bc6a8 100%); }
.share-bg-choice span[data-bg="1"] { background: linear-gradient(160deg, #34215f 0%, #70549a 54%, #d27b8d 100%); }
.share-bg-choice span[data-bg="2"] { background: linear-gradient(160deg, #0f4c5c 0%, #168aad 52%, #76e4f7 100%); }
.share-bg-choice span[data-bg="3"] { background: linear-gradient(160deg, #151923 0%, #3b4659 54%, #7b8798 100%); }
.share-bg-choice span[data-bg="4"] { background: linear-gradient(160deg, #1d3b7a 0%, #4f46a8 54%, #b26fd7 100%); }
.share-bg-choice span[data-bg="5"] { background: linear-gradient(160deg, #355c7d 0%, #6c5b7b 55%, #c06c84 100%); }
.share-bg-current[data-bg="0"] { background: linear-gradient(160deg, #124e66 0%, #2f6f73 54%, #8bc6a8 100%); }
.share-bg-current[data-bg="1"] { background: linear-gradient(160deg, #34215f 0%, #70549a 54%, #d27b8d 100%); }
.share-bg-current[data-bg="2"] { background: linear-gradient(160deg, #0f4c5c 0%, #168aad 52%, #76e4f7 100%); }
.share-bg-current[data-bg="3"] { background: linear-gradient(160deg, #151923 0%, #3b4659 54%, #7b8798 100%); }
.share-bg-current[data-bg="4"] { background: linear-gradient(160deg, #1d3b7a 0%, #4f46a8 54%, #b26fd7 100%); }
.share-bg-current[data-bg="5"] { background: linear-gradient(160deg, #355c7d 0%, #6c5b7b 55%, #c06c84 100%); }

.share-bg-choice.is-active {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.18);
}

.share-actions {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 10px;
}

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

.share-actions .share-action-btn {
  flex: 1;
}

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

.share-action-btn.is-primary {
  border: 0;
  color: #fff;
  background: #f97316;
}

.share-action-btn.is-primary:hover {
  background: #ea580c;
}

.share-socials {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.share-social-btn {
  min-width: 0;
  width: 42px;
  height: 58px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  color: var(--tp-text-main);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  justify-self: stretch;
  width: 100%;
}

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

.share-social-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
  flex: 0 0 auto;
}

.share-social-btn span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1;
}

.share-x {
  position: static;
  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);
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .share-overlay {
    padding: 16px;
    align-items: flex-start;
  }

  .share-shell {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
  }

  .share-body {
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
  }

  .share-side {
    width: 100%;
    min-width: 0;
  }

  .share-socials {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/*===== 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: var(--accent);
  border-color: var(--accent);
}

/*✅ 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 {
  --review-list-sticky-offset: 0px;
  display: flex;
  flex-direction: column;
  gap: 0px;
  padding-top: var(--review-list-sticky-offset);
}

.mistake-loading {
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  border-radius: 16px;
  padding: 18px 20px;
  color: var(--tp-text-muted);
  font-size: 14px;
  font-weight: 650;
  box-shadow: 0 10px 26px rgba(15,23,42,.06);
}

.review-loading-more {
  margin-top: 12px;
}

.review-item-unavailable {
  box-sizing: border-box;
  min-height: 104px;
  display: flex;
  align-items: center;
  border: 1px solid var(--tp-border-subtle);
  background: var(--tp-bg-surface);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  color: var(--tp-text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.review-item-unavailable:last-child {
  margin-bottom: 0;
}

.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 {
  position: relative;
  display: inline-block;
  font-size: 26px;
  color: rgba(15,23,42,.85);
}

.mistake-hanzi-word {
  display: inline-block;
}

.mistake-hanzi-punctuation {
  position: absolute;
  top: 0;
  line-height: inherit;
  pointer-events: none;
  user-select: none;
}

.mistake-hanzi-punctuation.is-prefix {
  right: calc(100% - 5px);
}

.mistake-hanzi-punctuation.is-suffix {
  left: calc(100% - 5px);
}

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

.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,
.mistake-item-details-btn {
  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-item-details-btn {
  color: rgba(15,23,42,.72);
}

.mistake-play svg,
.mistake-item-details-btn svg {
  width: 18px;
  height: 18px;
}

.mistake-play:hover,
.mistake-item-details-btn: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 #practiceBtn:not(:disabled) {
  color: var(--text-primary);
}

#view-mistakes [data-tp="clear-all"],
#view-mistakes [data-tp="delete-selected"] {
  border-color: var(--tp-delete-border);
  background: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
}

#view-mistakes [data-tp="clear-all"]:hover,
#view-mistakes [data-tp="delete-selected"]:hover {
  filter: none;
}

#view-mistakes [data-tp="clear-all"]:not(:disabled):hover,
#view-mistakes [data-tp="clear-all"]:not(:disabled):focus-visible,
#view-mistakes [data-tp="delete-selected"]:not(:disabled):hover,
#view-mistakes [data-tp="delete-selected"]:not(:disabled):focus-visible {
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}

#view-mistakes .review-more { position: relative; }
#view-mistakes .review-more summary { list-style: none; }
#view-mistakes .review-more summary::-webkit-details-marker { display: none; }
#view-mistakes .review-more > button {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}

/*Green primary button (for Practice)*/
#view-mistakes .mistake-btn.mistake-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--tp-on-accent);
}
#view-mistakes .mistake-btn.mistake-btn-primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}
#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;
  flex-wrap: wrap;
  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;
  flex-wrap: wrap;
  gap: 8px;
}

#view-mistakes .mistake-bulkbar.is-review-bulk-sticky {
  position: sticky;
  top: calc(var(--tp-topbar-h, 0px) + var(--review-controls-height, 0px));
  z-index: 9000;
}

/*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;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body[data-active="leaderboard"] .view[data-view="leaderboard"] .table-wrap {
  flex: 1;
  width: 100%;
  margin-top: 12px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

body[data-active="leaderboard"] .leaderboard-mobile-list {
  display: none;
}

/*（可选）表头固定，看起来更像“占满”*/

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-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.mistake-attempt-mode,
.mistake-attempt-score {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34,197,94,.22);
  background: rgba(34,197,94,.10);
  color: #166534;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.mistake-attempt-score {
  border-color: rgba(100,116,139,.18);
  background: rgba(100,116,139,.08);
  color: #475569;
}

.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: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s ease;
  border-color: var(--tp-delete-border);
}

.mistake-delete-btn:not(:disabled):hover,
.mistake-delete-btn:not(:disabled):focus-visible {
  background: var(--tp-delete-hover-bg);
  border-color: var(--tp-delete-hover-border);
  color: var(--tp-delete-hover-fg);
}

.mistake-delete-btn:active {
  transform: translateY(1px);
}

.mistake-delete-btn:focus {
  outline: none;
}

.mistake-delete-btn:focus-visible {
  outline: 2px solid var(--tp-delete-fg);
  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: 10060;

  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;
}

/* The root locks Review scrolling without creating a new sticky scroll container. */
html.modal-open body[data-active="mistakes"].modal-open {
  overflow: visible;
}

/*===== 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-word-tokenline,
.mistake-speak-tokenline {
  gap: 8px;
}

.mistake-word-token {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 4px 9px;
  font-family: inherit;
  gap: 1px;
}

.mistake-word-token-pinyin {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.25;
}

.mistake-word-token-hanzi {
  font-size: 16px;
  line-height: 1.25;
  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: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
  border-color: var(--tp-delete-border);
}

.mistake-item:hover .mistake-del {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.mistake-del:not(:disabled):hover,
.mistake-del:not(:disabled):focus-visible {
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}

/*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-word-pairs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 14px 20px;
  padding: 4px 0 2px;
}

body[data-active="mistakes"] .mistake-modal-word-token {
  min-width: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #111827;
}

body[data-active="mistakes"] .mistake-modal-word-token .mistake-word-token-pinyin {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 750;
}

body[data-active="mistakes"] .mistake-modal-word-token .mistake-word-token-hanzi {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.08;
  font-weight: 750;
  letter-spacing: 0.04em;
}

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;
}

.review-quota-note {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  --review-quota-ratio: 0;
  --review-quota-gradient: linear-gradient(90deg, #0071E3, #22c55e);
}

.review-quota-note[hidden] {
  display: none !important;
}

.review-quota-note.is-pro {
  flex: 0 0 auto;
}

.review-quota-note.is-free {
  font-variant-numeric: tabular-nums;
}

.review-quota-meter {
  display: inline-flex;
  align-items: center;
  width: 64px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 23, 42, .10);
}

.review-quota-meter[hidden] {
  display: none !important;
}

.review-quota-meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--review-quota-gradient, linear-gradient(90deg, #0071E3, #22c55e));
  transform: scaleX(var(--review-quota-ratio));
  transform-origin: left center;
  transition: transform .2s ease;
}

.review-quota-upgrade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--review-quota-gradient, linear-gradient(90deg, #0071E3, #22c55e));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 7px 14px var(--accent-shadow, rgba(34, 197, 94, .22));
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}

.review-quota-upgrade svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.review-quota-upgrade[hidden] {
  display: none !important;
}

.review-quota-upgrade:hover {
  transform: translateY(-1px);
  filter: saturate(1.08) brightness(1.02);
  box-shadow: 0 8px 16px var(--accent-shadow, rgba(34, 197, 94, .26));
}

.review-quota-upgrade[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: min(260px, 70vw);
  padding: 7px 10px;
  border-radius: 10px;
  background: #0b1220;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .20);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 20;
}

.review-quota-upgrade[data-tip]:hover::after,
.review-quota-upgrade[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.review-quota-upgrade:focus-visible {
  outline: 2px solid #047857;
  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: 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;
}

body[data-active="mistakes"] #view-mistakes,
body[data-active="mistakes"] #mistake-list,
body[data-active="mistakes"] .mistake-item {
  overflow-anchor: none;
}

body[data-active="mistakes"] #view-mistakes > .card {
  --review-card-head-gap: 12px;
  --review-card-head-gap-visible: var(--review-card-head-gap);
  --review-card-pad-y: 14px;
  --review-card-pad-x: 16px;
  --review-card-radius: 16px;
  --review-card-mb: 12px;
  --review-toolbar-mt: 0px;
  --review-toolbar-gap: 12px;
  --review-toolbar-inner-gap: 10px;
  --review-btn-pad-y: 7px;
  --review-btn-pad-x: 10px;
  --review-search-pad-y: 9px;
  --review-select-pad-y: 8px;
  position: sticky;
  top: var(--tp-topbar-h, 0px);
  /* Keep the outer shadow above the fixed title bar (9000), below dialogs (9999). */
  z-index: 9001;
  padding: var(--review-card-pad-y) var(--review-card-pad-x);
  margin-bottom: var(--review-card-mb);
  border-radius: var(--review-card-radius);
  background: rgba(249,250,251,.97);
  border-color: rgba(226,232,240,.95);
  box-shadow: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-anchor: none;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

body[data-active="mistakes"] #view-mistakes > .card::before {
  content: "";
  position: absolute;
  inset: -1px;
  bottom: calc(-1px - var(--review-bulk-shadow-height, 0px));
  border-radius: var(--review-card-radius);
  box-shadow: 0 10px 28px rgba(15,23,42,.08);
  pointer-events: none;
  z-index: -1;
}

body[data-active="mistakes"] .tp-topbar:has(.auth-menu.open) {
  z-index: 9002 !important;
}

body[data-active="mistakes"] #view-mistakes > .card.is-review-controls-stuck {
  background: rgba(255,255,255,.96);
  border-color: rgba(148,163,184,.32);
}

/* Match the controls without changing their surface when bulk actions open. */
body[data-active="mistakes"] #view-mistakes.is-bulk > .mistake-bulkbar {
  background: rgba(249,250,251,.97);
  border-color: rgba(226,232,240,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 160ms ease, border-color 160ms ease;
}

body[data-active="mistakes"] #view-mistakes.is-bulk > .card.is-review-controls-stuck + .mistake-bulkbar {
  background: rgba(255,255,255,.96);
  border-color: rgba(148,163,184,.32);
}

body[data-active="mistakes"] #view-mistakes.is-bulk > .card {
  margin-bottom: 0;
  border-bottom-width: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: none;
}

body[data-active="mistakes"] #view-mistakes.is-bulk > .mistake-bulkbar {
  border-radius: 0 0 14px 14px;
  box-shadow: none;
}

body[data-active="mistakes"] #view-mistakes > .card .card-head {
  margin-bottom: var(--review-card-head-gap-visible, var(--review-card-head-gap, 12px));
  overflow: visible;
}

body[data-active="mistakes"] #view-mistakes > .card.is-review-controls-stuck .card-head {
  visibility: visible;
  pointer-events: auto;
}

body[data-active="mistakes"] #view-mistakes > .card .mistake-toolbar {
  margin-top: var(--review-toolbar-mt);
  gap: var(--review-toolbar-gap);
}

body[data-active="mistakes"] #view-mistakes > .card .mistake-toolbar-left,
body[data-active="mistakes"] #view-mistakes > .card .mistake-toolbar-right {
  gap: var(--review-toolbar-inner-gap);
}

body[data-active="mistakes"] #view-mistakes > .card .mistake-btn {
  padding: var(--review-btn-pad-y) var(--review-btn-pad-x);
}

body[data-active="mistakes"] #view-mistakes > .card .mistake-search input {
  padding-top: var(--review-search-pad-y);
  padding-bottom: var(--review-search-pad-y);
}

body[data-active="mistakes"] #view-mistakes > .card .mistake-field select {
  padding-top: var(--review-select-pad-y);
  padding-bottom: var(--review-select-pad-y);
}

html.review-title-sticky-suppressed body[data-active="mistakes"] .tp-topbar {
  display: none !important;
}

html.review-title-sticky-suppressed body[data-active="mistakes"] .content-header {
  position: sticky;
  top: var(--review-suppressed-header-top, 18px);
  z-index: 90;
  background: #fff;
}

html.review-title-sticky-suppressed body[data-active="mistakes"] #view-mistakes > .card {
  top: var(--review-suppressed-controls-top, 92px);
}

html.review-title-sticky-suppressed body[data-active="mistakes"] .mistake-bulkbar.is-review-bulk-sticky {
  top: calc(var(--review-suppressed-controls-top, 92px) + var(--review-controls-height, 0px));
}

@media (prefers-reduced-motion: reduce) {
  body[data-active="mistakes"] #view-mistakes > .card {
    transition: none !important;
  }
}

/*===============================
   Mistakes – Scheme 1 toolbar
================================*/

body[data-active="mistakes"] .mistake-headbar {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

body[data-active="mistakes"] .mistake-tabs.tp-segmented {
  justify-content: flex-start;
}

body[data-active="mistakes"] .review-quota-note {
  position: relative;
  min-width: 0;
  max-width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
}

body[data-active="mistakes"] .review-quota-note.is-free {
  flex: 1 1 auto;
}

body[data-active="mistakes"] [data-tp="review-quota-text"],
body[data-active="mistakes"] .review-quota-upgrade {
  flex: 0 0 auto;
  white-space: nowrap;
}

body[data-active="mistakes"] .review-quota-meter {
  flex: 0 1 64px;
  min-width: 42px;
  max-width: 64px;
}

/* Anchor the hint to the available quota row, including Upgrade-only loading. */
body[data-active="mistakes"] .review-quota-upgrade {
  position: static;
}

body[data-active="mistakes"] .review-quota-upgrade:hover {
  transform: none;
  filter: none;
}

body[data-active="mistakes"] .review-quota-upgrade[data-tip]::after {
  box-sizing: border-box;
  left: 0;
  max-width: min(260px, 100%);
  transform: translateY(4px);
}

body[data-active="mistakes"] .review-quota-upgrade[data-tip]:hover::after,
body[data-active="mistakes"] .review-quota-upgrade[data-tip]:focus-visible::after {
  transform: translateY(0);
}

@media (max-width: 640px) {
  body[data-active="mistakes"] .mistake-headbar {
    align-items: flex-start;
  }

  body[data-active="mistakes"] .review-quota-note.is-free {
    width: 100%;
    white-space: normal;
  }

  body[data-active="mistakes"] .review-quota-meter {
    flex: 1 1 42px;
    max-width: 128px;
  }
}

@media (max-width: 860px) {
  html.tp-mobile-unified-bar body[data-active="mistakes"] #view-mistakes > .card {
    position: relative;
    top: auto;
    z-index: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

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-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;
}

/*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-square {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-top: 12px;
}

body[data-active="dashboard"] #view-dashboard .summary-metric {
  display: block;
  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-word-list-link {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow .16s ease, transform .16s ease;
}

body[data-active="dashboard"] #view-dashboard .summary-word-list-link:hover,
body[data-active="dashboard"] #view-dashboard .summary-word-list-link:focus-visible {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .35);
  box-shadow: 0 12px 24px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
  outline: none;
  text-decoration: none;
}

body[data-active="dashboard"] #view-dashboard .summary-word-list-link:focus-visible {
  box-shadow:
    0 12px 24px rgba(15, 23, 42, .08),
    0 0 0 3px rgba(34, 197, 94, .22);
}

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;
  background: #e5e7eb;
  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);
}

/*===== Dashboard first-paint skeleton =====*/

body[data-active="dashboard"] #view-dashboard {
  --dash-skeleton-base: rgba(226, 232, 240, .88);
  --dash-skeleton-glow: rgba(248, 250, 252, .96);
  --dash-skeleton-card: rgba(248, 250, 252, .58);
  --dash-skeleton-border: rgba(148, 163, 184, .18);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard {
  --dash-skeleton-base: rgba(51, 65, 85, .82);
  --dash-skeleton-glow: rgba(100, 116, 139, .72);
  --dash-skeleton-card: rgba(15, 23, 42, .44);
  --dash-skeleton-border: rgba(148, 163, 184, .18);
}

#view-dashboard .dashboard-skeleton {
  display: none;
}

#view-dashboard.is-dashboard-loading .card:not([data-load-state]),
#view-dashboard .card.is-dashboard-card-loading {
  position: relative;
  overflow: hidden;
}

#view-dashboard.is-dashboard-loading .card:not([data-load-state]) > :not(.dashboard-skeleton),
#view-dashboard .card.is-dashboard-card-loading > :not(.dashboard-skeleton) {
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

#view-dashboard.is-dashboard-loading .card:not([data-load-state]) > .dashboard-skeleton,
#view-dashboard .card.is-dashboard-card-loading > .dashboard-skeleton {
  position: absolute;
  inset: 16px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}

#view-dashboard .dashboard-skeleton-head {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#view-dashboard .dashboard-skel-shape {
  display: block;
  flex: 0 0 auto;
  border-radius: 999px;
  background:
    linear-gradient(
      100deg,
      var(--dash-skeleton-base) 0%,
      var(--dash-skeleton-glow) 44%,
      var(--dash-skeleton-base) 88%
    );
  background-size: 240% 100%;
  animation:
    dashboardSkeletonBreath 1.9s ease-in-out infinite,
    dashboardSkeletonSweep 2.6s ease-in-out infinite;
}

#view-dashboard .dashboard-skel-title {
  width: min(150px, 42%);
  height: 14px;
}

#view-dashboard .dashboard-skel-tabs,
#view-dashboard .dashboard-skel-stack,
#view-dashboard .dashboard-skel-list,
#view-dashboard .dashboard-skel-goals,
#view-dashboard .dashboard-skel-insights {
  display: flex;
}

#view-dashboard .dashboard-skel-tabs {
  gap: 7px;
  justify-content: flex-end;
}

#view-dashboard .dashboard-skel-pill {
  width: 46px;
  height: 24px;
}

#view-dashboard .dashboard-skel-stack,
#view-dashboard .dashboard-skel-list,
#view-dashboard .dashboard-skel-goals {
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
}

#view-dashboard .dashboard-skel-line {
  width: 100%;
  height: 11px;
}

#view-dashboard .dashboard-skel-line.is-strong {
  width: 64%;
  height: 20px;
}

#view-dashboard .dashboard-skel-line.is-short {
  width: 44%;
}

#view-dashboard .dashboard-skel-line.is-mid {
  width: 68%;
}

#view-dashboard .dashboard-skel-line.is-long {
  width: 88%;
}

#view-dashboard .dashboard-skel-icon,
#view-dashboard .dashboard-skel-small-circle {
  width: 40px;
  height: 40px;
  border-radius: 14px;
}

#view-dashboard .dashboard-skel-small-circle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
}

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

#view-dashboard .dashboard-skel-metric,
#view-dashboard .dashboard-skel-stat,
#view-dashboard .dashboard-skel-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--dash-skeleton-border);
  border-radius: 16px;
  background: var(--dash-skeleton-card);
}

#view-dashboard .dashboard-skel-metric {
  min-height: 82px;
  padding: 14px;
}

#view-dashboard .dashboard-skel-stat {
  min-height: 62px;
  padding: 10px 12px;
}

#view-dashboard .dashboard-skel-bar {
  width: 100%;
  height: 9px;
}

#view-dashboard .dashboard-skel-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 9px;
  margin-top: auto;
}

#view-dashboard .dashboard-skel-dot {
  width: 26px;
  height: 26px;
  justify-self: center;
}

#view-dashboard .dashboard-skel-month {
  width: 106px;
  height: 28px;
}

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

#view-dashboard .dashboard-skel-cal-head {
  height: 12px;
  opacity: .72;
}

#view-dashboard .dashboard-skel-cal-day {
  height: 24px;
  border-radius: 9px;
}

#view-dashboard .dashboard-skel-insights {
  gap: 12px;
  margin-top: auto;
}

#view-dashboard .dashboard-skel-insights .dashboard-skel-line {
  height: 28px;
}

#view-dashboard .dashboard-skel-list-row {
  min-height: 68px;
  padding: 10px 12px;
}

#view-dashboard .dashboard-skel-badge {
  width: 38px;
  height: 28px;
  margin-left: auto;
}

#view-dashboard .dashboard-skel-thumb {
  width: 76px;
  height: 50px;
  border-radius: 12px;
}

#view-dashboard .dashboard-skeleton-checkin .dashboard-skel-goals,
#view-dashboard .dashboard-skeleton-checkin .dashboard-skel-week {
  flex: 0 0 auto;
  padding: 14px;
  border: 1px solid var(--dash-skeleton-border);
  border-radius: 16px;
  background: var(--dash-skeleton-card);
}

#view-dashboard .dashboard-skeleton-checkin .dashboard-skel-week {
  margin-top: 0;
}

#view-dashboard .dashboard-skeleton-checkin .dashboard-skel-dot {
  width: 44px;
  height: 56px;
  border-radius: 18px;
}

#view-dashboard .dashboard-skel-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

#view-dashboard .dashboard-skel-action {
  width: 100%;
  height: 54px;
  border-radius: 18px;
}

#view-dashboard .dashboard-skel-action.is-primary {
  opacity: .9;
}

@keyframes dashboardSkeletonBreath {
  0%, 100% { opacity: .64; }
  50% { opacity: .98; }
}

@keyframes dashboardSkeletonSweep {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
  #view-dashboard .dashboard-skel-shape {
    animation: none;
  }
}

@media (max-width: 640px) {
  #view-dashboard .dashboard-skeleton-checkin .dashboard-skel-stat-grid {
    grid-template-columns: 1fr;
  }
}

/*===== 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-goal {
    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";
  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;
}

/*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";
  }
}

/*1-column mobile*/

@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "checkin"
        "summary"
        "calendar"
        "review"
        "recent";
  }
}

/*=========================
   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 – Goals
   (append to end of app.css)
   ========================= */

body[data-active="dashboard"] #view-dashboard .dash-goal{
  grid-column: span 4;
  overflow: visible;
  position: relative;
}

/* 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;
}
/* Goal met: full bar in success green + a "✓ +N" bonus badge for extra effort. */
body[data-active="dashboard"] #view-dashboard .goal-bar-fill.is-met{
  background: var(--success, #16a34a);
}
body[data-active="dashboard"] #view-dashboard .goal-badge{
  margin-left: 6px;
  font-weight: 600;
  color: var(--success, #16a34a);
  font-variant-numeric: tabular-nums;
}
body[data-active="dashboard"] #view-dashboard .goal-presets{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
body[data-active="dashboard"] #view-dashboard .goal-preset{
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid rgba(2,6,23,.12);
  border-radius: 999px;
  background: rgba(2,6,23,.02);
  color: var(--muted, #64748b);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
body[data-active="dashboard"] #view-dashboard .goal-preset:hover,
body[data-active="dashboard"] #view-dashboard .goal-preset:focus-visible{
  background: rgba(34,197,94,.10);
  border-color: rgba(34,197,94,.35);
  color: #047857;
  outline: none;
}
body[data-active="dashboard"] #view-dashboard .goal-preset.is-active{
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.45);
  color: #047857;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-trigger.is-active{
  background: rgba(34,197,94,.14);
  border-color: rgba(34,197,94,.45);
  color: #047857;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-popover{
  position: absolute;
  right: 16px;
  top: 48px;
  z-index: 30;
  width: min(280px, calc(100% - 32px));
  padding: 12px;
  border: 1px solid rgba(2,6,23,.10);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(15,23,42,.14);
}
body[data-active="dashboard"] #view-dashboard .goal-custom-popover[hidden]{
  display: none !important;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-field{
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-label{
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 750;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-control{
  align-items: center;
  display: flex;
  gap: 8px;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-input{
  width: 100%;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(34,197,94,.45);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  outline: none;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-input:focus{
  border-color: rgba(34,197,94,.72);
  box-shadow: 0 0 0 3px rgba(34,197,94,.14);
}
body[data-active="dashboard"] #view-dashboard .goal-custom-input[hidden]{
  display: none !important;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-unit{
  color: var(--muted, #64748b);
  font-size: 12px;
  white-space: nowrap;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-action{
  min-height: 30px;
  padding: 6px 11px;
  border: 1px solid rgba(2,6,23,.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #0f172a);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-action:hover,
body[data-active="dashboard"] #view-dashboard .goal-custom-action:focus-visible{
  border-color: rgba(34,197,94,.35);
  color: #047857;
  outline: none;
}
body[data-active="dashboard"] #view-dashboard .goal-custom-action.is-primary{
  background: var(--accent, #22c55e);
  border-color: transparent;
  color: var(--tp-on-accent);
}

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);
}

@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-goal {
    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));
  }
}

@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 .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-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; }

/* 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-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: minmax(0, 1fr);
  gap: 14px;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric{
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  width: 100%;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric + .summary-metric{
  border-top: 1px solid var(--border, rgba(2,6,23,.10));
  padding-top: 14px;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(34,197,94,.20);
  border-radius: 14px;
  background: rgba(34,197,94,.10);
  color: #16a34a;
  overflow: hidden;
  box-shadow: none;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric-icon.is-hanzi{
  color: #16a34a;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric-icon svg{
  display: block;
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-hanzi-frame{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-hanzi-glyph{
  display: block;
  transform: translateY(-1px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric-copy{
  display: block;
  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{
  display: block;
  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{
  appearance: none;
  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;
  cursor: default;
}
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);
}

/* Two-tier Study calendar dots: .studied = full green (checked in), .partial =
   half empty / half green (studied but short of the check-in goal). No study = base empty dot. */
body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day.partial{
  position: relative;
  overflow: hidden;
  background: rgba(2,6,23,.04);
  border-color: rgba(34,197,94,.36);
}

body[data-active="dashboard"] #view-dashboard .calendar.calendar-sm .cal-day.partial::before{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 42%, rgba(34,197,94,.5) 56%, rgba(34,197,94,0) 72%, rgba(34,197,94,0) 100%);
  border-radius: inherit;
}

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  recent";
  }
}

/* ===== 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:
      "goal"
      "summary"
      "checkin"
      "review"
      "calendar"
      "recent";
  }
}


/* 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;
  }
}

/* ===== Dashboard: action-first polish ===== */
body[data-active="dashboard"] #view-dashboard{
  --dash-card-border: rgba(15,23,42,.10);
  --dash-card-bg: #f9fafb;
  --dash-inner-bg: #ffffff;
  --dash-soft-bg: #f8fafc;
  --dash-row-border: rgba(15,23,42,.08);
  --dash-row-hover: rgba(34,197,94,.07);
  --dash-warning-bg: #fff7ed;
  --dash-warning-border: rgba(245,158,11,.34);
  --dash-warning-text: #9a3412;
  --dash-info-bg: #eff6ff;
  --dash-info-border: rgba(59,130,246,.30);
  --dash-info-text: #1d4ed8;
}

body[data-active="dashboard"] #view-dashboard .dash-grid{
  grid-template-columns: minmax(0, 2.8fr) minmax(0, 3.45fr) minmax(var(--dash-right-w), 2fr);
  gap: 18px;
}

body[data-active="dashboard"] #view-dashboard .card{
  background: var(--dash-card-bg);
  border-color: var(--dash-card-border);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(15,23,42,.06);
}

body[data-active="dashboard"] #view-dashboard .dash-goal{
  padding: 20px;
  border-color: var(--dash-card-border);
  background: var(--dash-card-bg);
  box-shadow: 0 16px 40px rgba(15,23,42,.06);
}

body[data-active="dashboard"] #view-dashboard .goal-heading{
  min-width: 0;
}

body[data-active="dashboard"] #view-dashboard .goal-heading-sub{
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .goal-status-row{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

body[data-active="dashboard"] #view-dashboard .goal-status{
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--dash-card-border);
  border-radius: 16px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .goal-status-value{
  color: #14532d;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-active="dashboard"] #view-dashboard .goal-status-label{
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 11px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .goal-block{
  margin-top: 14px;
  padding-top: 14px;
}

body[data-active="dashboard"] #view-dashboard .goal-label{
  color: #0f172a;
  font-size: 13px;
}

body[data-active="dashboard"] #view-dashboard .goal-value{
  color: #14532d;
  font-size: 16px;
  font-weight: 850;
}

body[data-active="dashboard"] #view-dashboard .goal-bar{
  height: 12px;
  background: rgba(21,128,61,.12);
}

body[data-active="dashboard"] #view-dashboard .goal-presets{
  opacity: .82;
}

body[data-active="dashboard"] #view-dashboard .goal-actions{
  margin-top: 16px;
}

body[data-active="dashboard"] #view-dashboard .goal-continue{
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 14px 28px rgba(34,197,94,.22);
}

body[data-active="dashboard"] #view-dashboard .goal-continue:hover,
body[data-active="dashboard"] #view-dashboard .goal-continue:focus-visible{
  background: var(--tp-accent-hover);
  outline: none;
  box-shadow: 0 16px 32px rgba(22,163,74,.24), 0 0 0 3px rgba(34,197,94,.20);
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-value{
  font-size: 28px;
  letter-spacing: 0;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric{
  min-height: 88px;
  padding: 14px 16px;
}

body[data-active="dashboard"] #view-dashboard .dash-summary .summary-label{
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

body[data-active="dashboard"] #view-dashboard .summary-trend{
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(15,23,42,.07);
}

body[data-active="dashboard"] #view-dashboard .summary-trend-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 800;
}

body[data-active="dashboard"] #view-dashboard .summary-trend-head strong{
  color: #14532d;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

body[data-active="dashboard"] #view-dashboard .summary-trend-bars{
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

body[data-active="dashboard"] #view-dashboard .summary-trend-bar{
  min-width: 0;
  height: 72px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  align-items: end;
}

body[data-active="dashboard"] #view-dashboard .summary-trend-fill{
  display: block;
  width: 100%;
  height: var(--bar-h, 6%);
  min-height: 6px;
  border-radius: 999px 999px 6px 6px;
  background: rgba(148,163,184,.22);
  transition: height .18s ease, background .18s ease;
}

body[data-active="dashboard"] #view-dashboard .summary-trend-bar.is-active .summary-trend-fill{
  background: var(--accent, #22c55e);
}

body[data-active="dashboard"] #view-dashboard .summary-trend-day{
  color: var(--muted, #64748b);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

body[data-active="dashboard"] #view-dashboard .summary-empty{
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--dash-card-border);
  border-radius: 16px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .summary-empty[hidden]{
  display: none;
}

body[data-active="dashboard"] #view-dashboard .summary-empty-title{
  color: #0f172a;
  font-size: 14px;
  font-weight: 850;
}

body[data-active="dashboard"] #view-dashboard .summary-empty-body{
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .summary-empty-cta{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}
body[data-active="dashboard"] #view-dashboard .summary-empty-cta:not(:disabled) {
  color: var(--tp-control-on-accent);
}

body[data-active="dashboard"] #view-dashboard .checkin-top{
  margin-top: 8px;
  padding: 10px 12px;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-unit{
  white-space: nowrap;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin{
  min-height: 0;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .card-title-row{
  margin-bottom: 8px;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-stat-value{
  font-size: 24px;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-week{
  gap: 6px;
  margin-top: 8px;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day{
  padding: 7px 0;
  border-radius: 12px;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .muted{
  margin-top: 8px;
}

body[data-active="dashboard"] #view-dashboard .checkin-btn{
  min-height: 34px;
  border-radius: 999px;
  padding: 8px 12px;
}

body[data-active="dashboard"] #view-dashboard .checkin-btn.is-checked{
  background: #ecfdf5;
  color: #166534;
  box-shadow: inset 0 0 0 1px rgba(34,197,94,.28);
}

body[data-active="dashboard"] #view-dashboard .checkin-btn.is-checked::before{
  width: 0;
  opacity: 0;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tiles{
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 2px;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile{
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 0 14px;
  align-items: center;
  min-height: 68px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--dash-row-border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:last-child{
  border-bottom: 0;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile::before{
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border-radius: 12px;
  pointer-events: none;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:hover,
body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:focus-visible{
  transform: none;
  background: transparent;
  border-color: var(--dash-row-border);
  box-shadow: none;
  outline: none;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:hover::before,
body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:focus-visible::before{
  background: var(--accent-soft);
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile:focus-visible::before{
  box-shadow: inset 0 0 0 2px var(--accent);
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-top{
  display: contents;
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-copy{
  grid-column: 2;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-name{
  color: #0f172a;
  font-size: 14px;
  line-height: 18px;
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-sub{
  margin-top: 0;
  line-height: 18px;
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-icon{
  grid-column: 1;
  width: 40px;
  height: 40px;
  border: 1px solid currentColor;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-icon svg{
  width: 21px;
  height: 21px;
  display: block;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-mistakes .rt-icon{
  color: var(--dash-warning-text);
  background: var(--dash-warning-bg);
  border-color: var(--dash-warning-border);
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-new .rt-icon{
  color: var(--dash-info-text);
  background: var(--dash-info-bg);
  border-color: var(--dash-info-border);
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-notes .rt-icon{
  color: #6d28d9;
  background: rgba(124,58,237,.10);
  border-color: rgba(124,58,237,.24);
}

body[data-active="dashboard"] #view-dashboard .dash-review .rt-badge{
  grid-column: 3;
  align-self: center;
  justify-self: end;
  min-width: 36px;
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-mistakes .rt-badge{
  color: var(--dash-warning-text);
  background: var(--dash-warning-bg);
  border-color: var(--dash-warning-border);
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-new .rt-badge{
  color: var(--dash-info-text);
  background: var(--dash-info-bg);
  border-color: var(--dash-info-border);
}

body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-notes .rt-badge{
  color: #6d28d9;
  background: rgba(124,58,237,.10);
  border-color: rgba(124,58,237,.24);
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-list{
  gap: 8px;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack{
  position: relative;
  min-height: 66px;
  padding: 9px 52px 9px 10px;
  border-radius: 16px;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-thumb{
  width: 76px;
  height: 50px;
  border-radius: 12px;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-title{
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.25;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty{
  min-height: 116px;
  padding: 18px;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty .recent-empty-title{
  margin-bottom: 4px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 850;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty .recent-empty-body{
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty .recent-empty-cta{
  margin-top: 14px;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-action{
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  margin-left: auto;
  padding: 0;
  color: #15803d;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

body[data-active="dashboard"] #view-dashboard .mini-pack-action:hover,
body[data-active="dashboard"] #view-dashboard .mini-pack-action:focus-visible{
  color: #047857;
  outline: none;
  text-decoration: underline;
}

body[data-active="dashboard"] #view-dashboard .cal-insights{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

body[data-active="dashboard"] #view-dashboard .cal-insight{
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .cal-insight strong{
  display: block;
  color: #14532d;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-active="dashboard"] #view-dashboard .cal-insight span{
  display: block;
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

body[data-active="dashboard"] #view-dashboard .cal-detail{
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .cal-detail-kicker{
  color: var(--muted, #64748b);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

body[data-active="dashboard"] #view-dashboard .cal-detail-title{
  margin-top: 4px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 850;
}

body[data-active="dashboard"] #view-dashboard .cal-detail-meta,
body[data-active="dashboard"] #view-dashboard .cal-detail-course{
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

@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  recent";
  }
}

@media (max-width: 720px){
  body[data-active="dashboard"] #view-dashboard .dash-grid{
    grid-template-columns: 1fr;
    grid-template-areas:
      "goal"
      "summary"
      "checkin"
      "review"
      "calendar"
      "recent";
  }
}

@media (max-width: 540px){
  body[data-active="dashboard"] #view-dashboard .goal-status-row{
    grid-template-columns: 1fr;
  }

  body[data-active="dashboard"] #view-dashboard .cal-insights{
    grid-template-columns: 1fr;
  }

  body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack{
    padding-right: 44px;
  }

  body[data-active="dashboard"] #view-dashboard .mini-pack-action{
    display: none;
  }
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard{
  --dash-card-border: var(--tp-border-subtle);
  --dash-card-bg: var(--tp-bg-surface);
  --dash-inner-bg: var(--tp-bg-surface-alt);
  --dash-soft-bg: var(--tp-bg-surface-alt);
  --dash-row-border: var(--tp-border-subtle);
  --dash-row-hover: var(--tp-bg-hover);
  --dash-warning-bg: var(--tp-warning-bg);
  --dash-warning-border: var(--tp-warning);
  --dash-warning-text: var(--tp-warning);
  --dash-info-bg: var(--tp-info-bg);
  --dash-info-border: var(--tp-info);
  --dash-info-text: var(--tp-info);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-goal{
  background: var(--dash-card-bg);
  border-color: var(--dash-card-border);
  box-shadow: 0 20px 46px rgba(0,0,0,.24);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-heading-sub,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-status-label{
  color: var(--dash-muted) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-status{
  background: rgba(255,255,255,.06);
  border-color: rgba(74,222,128,.18);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-status-value,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-trend-head strong,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-insight strong,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-empty-title,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-detail-title,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty .recent-empty-title,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-value,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-review .rt-name{
  color: var(--dash-text) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-trend{
  border-top-color: rgba(255,255,255,.10);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-trend-head,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-trend-day,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-insight span,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-empty-body,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-detail-kicker,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-detail-meta,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-detail-course,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-recent .mini-pack-empty .recent-empty-body{
  color: var(--dash-muted) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-trend-fill{
  background: rgba(255,255,255,.12);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-insight{
  background: var(--dash-inner-bg);
  border-color: rgba(255,255,255,.10);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-empty,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .cal-detail{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.10);
}

body[data-active="dashboard"] #view-dashboard .summary-empty.is-background-refresh,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-empty.is-background-refresh {
  margin-top: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-continue{
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-btn.is-checked{
  background: rgba(34,197,94,.16) !important;
  border-color: rgba(74,222,128,.38) !important;
  color: #bbf7d0 !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-btn.is-checked::before{
  width: 0;
  opacity: 0;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-review .review-tile{
  border-color: var(--dash-row-border);
  color: var(--dash-text);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-notes .rt-icon,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-review .review-tile.is-notes .rt-badge{
  color: #c4b5fd;
  background: rgba(124,58,237,.18);
  border-color: rgba(167,139,250,.34);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .mini-pack-action{
  color: #86efac;
}

/* ===== Store search ===== */
.store-search{
  display:flex;
  gap:10px;
  align-items:center;
  margin:12px 0 6px;
}
.store-course-count{
  flex:0 0 auto;
  min-width:128px;
  color:#374151;
  font-size:13px;
  font-weight:700;
  line-height:1.25;
  white-space:nowrap;
}
.store-search input{
  flex:1;
  width:100%;
  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; }
body[data-active="store"] .store-search{
  gap:12px;
  margin-bottom:10px;
}
body[data-active="store"] .store-create-course-button{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  height:42px;
  padding:0 16px;
  border:1px solid transparent;
  border-radius:12px;
  background:var(--accent);
  color: var(--tp-on-accent);
  font-size:14px;
  font-weight:800;
  line-height:1;
  text-decoration:none;
  white-space:nowrap;
  box-shadow:0 8px 18px rgba(34,197,94,.18);
}
body[data-active="store"] .store-create-course-button:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="store"] .store-create-course-button:hover{
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
  text-decoration:none;
}
body[data-active="store"] .store-create-course-button:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="store"] .store-create-course-button:focus-visible,
body[data-active="store"] .store-sort-button:focus-visible{
  outline:2px solid rgba(34,197,94,.35);
  outline-offset:2px;
}
body[data-active="store"] .store-create-course-button svg,
body[data-active="store"] .store-sort-button svg{
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
body[data-active="store"] .store-sort{
  position:relative;
  flex:0 0 auto;
}
body[data-active="store"] .store-search .store-sort-button{
  width:auto;
  min-width:108px;
  height:42px;
  padding:0 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  border-radius:12px;
  font-size:14px;
  font-weight:700;
  color:#15803d;
  background:#fff;
  opacity:1;
}
body[data-active="store"] .store-search .store-sort-button:hover,
body[data-active="store"] .store-search .store-sort-button.is-open,
body[data-active="store"] .store-search .store-sort-button.is-active{
  border-color:var(--accent);
  background:var(--accent-soft);
}
body[data-active="store"] .store-sort-chevron{
  width:18px;
  height:18px;
}
body[data-active="store"] .store-sort-panel{
  position:absolute;
  top:calc(100% + 10px);
  right:0;
  z-index:60;
  width:min(212px, calc(100vw - 40px));
  padding:10px 16px;
  border:1px solid var(--border-subtle);
  border-radius:14px;
  background:#fff;
  box-shadow:0 18px 48px rgba(15,23,42,.16);
  color:#111827;
}
body[data-active="store"] .store-sort-panel[hidden]{
  display:none;
}
body[data-active="store"] .store-sort-option{
  display:grid;
  grid-template-columns:18px 1fr;
  align-items:center;
  gap:10px;
  min-height:36px;
  margin:0;
  font-size:15px;
  font-weight:400;
  line-height:1.2;
  cursor:pointer;
}
body[data-active="store"] .store-sort-option input{
  appearance:none;
  -webkit-appearance:none;
  display:grid;
  place-content:center;
  width:18px;
  height:18px;
  margin:0;
  padding:0;
  border:2px solid var(--accent);
  border-radius:999px;
  background:#fff;
  box-sizing:border-box;
  box-shadow:none;
  cursor:pointer;
}
body[data-active="store"] .store-sort-option input::before{
  content:"";
  width:8px;
  height:8px;
  border-radius:999px;
  background:var(--accent);
  transform:scale(0);
  transition:transform .12s ease;
}
body[data-active="store"] .store-sort-option input:checked::before{
  transform:scale(1);
}
body[data-active="store"] .store-sort-option input:focus-visible{
  outline:2px solid rgba(34,197,94,.35);
  outline-offset:2px;
}
.store-grid-state{
  grid-column:1 / -1;
  display:flex;
  min-height:180px;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:28px 18px;
  border:1px dashed var(--border-subtle);
  border-radius:14px;
  background:var(--surface-muted);
  color:#374151;
  text-align:center;
}
.store-grid-state-title{
  color:#111827;
  font-size:18px;
  font-weight:800;
  line-height:1.25;
}
.store-grid-state-body{
  margin-top:8px;
  color:var(--text-muted);
  font-size:14px;
  line-height:1.45;
}
.course-state-actions{
  display:flex;
  justify-content:center;
  margin-top:16px;
}
.course-state-retry.btn{
  width:auto;
  min-width:112px;
  min-height:44px;
  margin-top:0;
  padding:10px 18px;
  font-size:14px;
  font-weight:800;
}
.course-state-retry:focus-visible{
  outline:2px solid rgba(34,197,94,.4);
  outline-offset:3px;
}
.course-state-retry:disabled{
  cursor:wait;
  opacity:.7;
}
body[data-active="store"] .store-grid-state-search{
  min-height:420px;
  padding:48px 18px 56px;
  border:0;
  background:transparent;
}
body[data-active="store"] .store-empty-title{
  max-width:min(720px, 100%);
  font-size:30px;
  line-height:1.2;
  overflow-wrap:anywhere;
}
body[data-active="store"] .store-empty-body{
  margin-top:14px;
  color:#6b7280;
  font-size:18px;
  line-height:1.45;
}
body[data-active="store"] .store-empty-actions{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:18px;
  margin-top:32px;
}
body[data-active="store"] .store-empty-create-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-width:206px;
  height:54px;
  padding:0 24px;
  border:1px solid transparent;
  border-radius:14px;
  background:var(--accent);
  color: var(--tp-on-accent);
  font-size:17px;
  font-weight:800;
  line-height:1;
  text-decoration:none;
  box-shadow:0 14px 28px rgba(34,197,94,.22);
}
body[data-active="store"] .store-empty-create-button:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="store"] .store-empty-create-button:hover{
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
  text-decoration:none;
}
body[data-active="store"] .store-empty-create-button:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="store"] .store-empty-create-button:focus-visible{
  outline:2px solid rgba(34,197,94,.35);
  outline-offset:2px;
}
body[data-active="store"] .store-empty-create-button svg{
  width:22px;
  height:22px;
  fill:none;
  stroke:currentColor;
  stroke-width:2.2;
  stroke-linecap:round;
  stroke-linejoin:round;
}

body[data-active="my-packs"] .store-search{
  flex-wrap:wrap;
}
body[data-active="my-packs"] .my-courses-count{
  flex:0 0 auto;
  min-width:88px;
  color:#374151;
  font-size:13px;
  font-weight:700;
  line-height:1.25;
  white-space:nowrap;
}
body[data-active="my-packs"] #my-pack-empty.my-courses-empty{
  max-width:420px;
  margin:18px auto 0;
  padding:18px;
  border:0;
  border-radius:0;
  background:transparent;
  color:#374151;
  text-align:center;
}
body[data-active="my-packs"] .my-courses-empty-title{
  color:#111827;
  font-size:24px;
  font-weight:800;
  line-height:1.25;
}
body[data-active="my-packs"] .my-courses-empty-body{
  margin-top:12px;
  color:#4b5563;
  font-size:20px;
  line-height:1.5;
}
body[data-active="my-packs"] .my-courses-empty-actions{
  display:flex;
  justify-content:center;
  margin-top:14px;
}
body[data-active="my-packs"] .my-courses-empty-cta{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:auto;
  min-width:154px;
  margin-top:0;
  padding:12px 18px;
  border-radius:12px;
  color:#fff;
  font-size:14px;
  font-weight:800;
  text-decoration:none;
}
body[data-active="my-packs"] .my-courses-empty-cta:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="my-packs"] .my-courses-empty-cta:hover{
  color:#fff;
  text-decoration:none;
}
body[data-active="my-packs"] .my-courses-empty-cta:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}
body[data-active="my-packs"] .my-courses-filter{
  position:relative;
  flex:0 0 auto;
}
body[data-active="my-packs"] .store-search .my-courses-filter-button{
  width:auto;
  min-width:108px;
  height:42px;
  padding:0 16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  border-radius:12px;
  font-size:14px;
  font-weight:700;
  color:#15803d;
  background:#fff;
  opacity:1;
}
body[data-active="my-packs"] .my-courses-filter-button svg,
body[data-active="my-packs"] .my-courses-filter-title svg{
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}
body[data-active="my-packs"] .store-search .my-courses-filter-button:hover,
body[data-active="my-packs"] .store-search .my-courses-filter-button.is-active{
  border-color:var(--accent);
  background:var(--accent-soft);
}
body[data-active="my-packs"] .my-courses-filter-panel{
  position:absolute;
  top:calc(100% + 10px);
  right:0;
  z-index:60;
  width:min(212px, calc(100vw - 40px));
  padding:10px 0 0;
  border:1px solid var(--border-subtle);
  border-radius:14px;
  background:#fff;
  box-shadow:0 18px 48px rgba(15,23,42,.16);
  color:#111827;
}
body[data-active="my-packs"] .my-courses-filter-panel[hidden]{
  display:none;
}
body[data-active="my-packs"] .my-courses-filter-title{
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 16px 10px;
  color:#111827;
  font-weight:800;
  font-size:16px;
  border-bottom:1px solid var(--border-subtle);
}
body[data-active="my-packs"] .my-courses-filter-title svg{
  color:#16a34a;
}
body[data-active="my-packs"] .my-courses-filter-group{
  margin:0;
  min-width:0;
  padding:0 16px;
  border:0;
  border-bottom:1px solid var(--border-subtle);
}
body[data-active="my-packs"] .my-courses-filter-group:last-child{
  border-bottom:0;
}
body[data-active="my-packs"] .my-courses-filter-group legend{
  display:flex;
  float:left;
  align-items:center;
  width:100%;
  min-height:31px;
  padding:0;
  margin:0;
  color:#6b7280;
  font-size:13px;
  font-weight:400;
  line-height:1.2;
}
body[data-active="my-packs"] .my-courses-filter-group legend + .my-courses-filter-option{
  clear:both;
}
body[data-active="my-packs"] .my-courses-filter-option{
  display:grid;
  grid-template-columns:18px 1fr;
  align-items:center;
  gap:10px;
  min-height:31px;
  margin:0;
  font-size:15px;
  font-weight:400;
  line-height:1.2;
  cursor:pointer;
}
body[data-active="my-packs"] .my-courses-filter-option input{
  appearance:none;
  -webkit-appearance:none;
  display:grid;
  place-content:center;
  width:18px;
  height:18px;
  margin:0;
  padding:0;
  border:2px solid var(--accent);
  border-radius:999px;
  background:#fff;
  box-sizing:border-box;
  box-shadow:none;
  cursor:pointer;
}
body[data-active="my-packs"] .my-courses-filter-option input::before{
  content:"";
  width:8px;
  height:8px;
  border-radius:999px;
  background:var(--accent);
  transform:scale(0);
  transition:transform .12s ease;
}
body[data-active="my-packs"] .my-courses-filter-option input:checked::before{
  transform:scale(1);
}
body[data-active="my-packs"] .my-courses-filter-option input:focus-visible{
  outline:2px solid rgba(34,197,94,.35);
  outline-offset:2px;
}
body[data-active="my-packs"] .my-courses-filter-option span{
  display:block;
}

@media (max-width: 767px){
  body[data-active="store"] .store-search{
    flex-wrap:wrap;
  }
  body[data-active="store"] .store-course-count{
    flex:0 0 auto;
  }
  body[data-active="store"] .store-search > input{
    flex:1 1 0;
    width:0;
    min-width:180px;
  }
  body[data-active="store"] .store-create-course-button{
    flex:1 1 auto;
  }
  body[data-active="store"] .store-sort{
    flex:0 0 auto;
    margin-left:auto;
  }
}

@media (max-width: 520px){
  body[data-active="store"] .store-grid-state-search{
    min-height:360px;
    padding:36px 12px 44px;
  }
  body[data-active="store"] .store-empty-title{
    font-size:24px;
  }
  body[data-active="store"] .store-empty-body{
    font-size:16px;
  }
  body[data-active="my-packs"] .my-courses-count{
    flex-basis:100%;
  }
  body[data-active="my-packs"] .store-search .my-courses-filter-button{
    min-width:42px;
    width:42px;
    padding:0;
  }
  body[data-active="my-packs"] .my-courses-filter-button-text{
    display:none;
  }
}

/* ✅ 保证导航栏永远在顶栏上面（包括临时展开→缩回的过渡动画中） */
.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; /* 改这里：正数=更远，负数=更近 */
}
/* =========================
   Legacy dark aliases resolve to the shared semantic palette.
   ========================= */
html[data-theme="dark"]{
  --tp-delete-bg: rgba(15,23,42,.72);
  --tp-delete-fg: rgba(255,255,255,.92);
  --tp-delete-border: rgba(255,255,255,.18);
  --tp-delete-hover-bg: rgba(15,23,42,.88);
  --tp-delete-hover-fg: #fff;
  --tp-delete-hover-border: rgba(34,197,94,.55);
  color-scheme: dark;
  --mi-bg: var(--tp-bg-body);
  --mi-border: var(--tp-border-subtle);
  --mi-text: var(--tp-text-main);
  --mi-muted: var(--tp-text-muted);
  --mi-field: var(--tp-bg-surface-alt);
}

/* 页面整体背景（解决“框外还是亮色”） */
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(--tp-bg-body) !important;
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom: 1px solid var(--tp-border-subtle) !important;
}

html[data-theme="dark"] .title-main{ color: var(--mi-text) !important; }
html[data-theme="dark"] .title-sub{ color: var(--mi-muted) !important; }

/* Card surfaces stay distinct from the page. */
html[data-theme="dark"] .card{
  background: var(--tp-bg-surface) !important;
  border-color: var(--mi-border) !important;
}

/* These wrappers overlap the title divider, so let the page show through. */
html[data-theme="dark"] body[data-active="store"] .content > .card,
html[data-theme="dark"] body[data-active="my-packs"] .content > .card{
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none;
}

/* Structural wrappers share the page canvas; their content cards keep surfaces. */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes > .card,
html[data-theme="dark"] #view-hanzi-practiced > #wordListDataContent,
html[data-theme="dark"] body[data-active="leaderboard"] #view-leaderboard > .card,
html[data-theme="dark"] body[data-active="membership"] #view-membership > .card{
  background: var(--tp-bg-body) !important;
  border-color: transparent !important;
  box-shadow: none;
}

html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes > .card{
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes > .card::before{
  box-shadow: none;
}

/* 表单控件：避免下拉框/输入框还发白 */
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(--tp-border-control) !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-text-subtle:#64748b;
  --tp-bg-floating:#ffffff;
  --tp-bg-hover:#eef2f7;
  --tp-border-control:#64748b;
  --tp-accent:#22c55e;
  --tp-accent-hover:#4ade80;
  --tp-accent-pressed:#1db954;
  --tp-on-accent:#052e16;
  --tp-control-on-accent:#ffffff;
  --tp-success:#166534;
  --tp-success-bg:#ecfdf5;
  --tp-danger:#b91c1c;
  --tp-danger-bg:#fef2f2;
  --tp-warning:#854d0e;
  --tp-warning-bg:#fffbeb;
  --tp-info:#1d4ed8;
  --tp-info-bg:#eff6ff;
}

/* One dark palette for pages, controls and body-level dialogs. */
html[data-theme="dark"]{
  --tp-control-on-accent:#000000;
  --tp-bg-body:#0b1321;
  --tp-bg-surface:#111c2e;
  --tp-bg-surface-alt:#18253a;
  --tp-bg-floating:#18253a;
  --tp-bg-hover:#223149;
  --tp-border-subtle:#334155;
  --tp-border-control:#8191a9;
  --tp-text-main:#e5e7eb;
  --tp-text-muted:#a8b3c5;
  --tp-text-subtle:#8d9bb1;
  --tp-success:#86efac;
  --tp-success-bg:#123022;
  --tp-danger:#fca5a5;
  --tp-danger-bg:#351f2b;
  --tp-warning:#fcd34d;
  --tp-warning-bg:#322918;
  --tp-info:#93c5fd;
  --tp-info-bg:#172b43;
}

/* page background */
html[data-theme="dark"],
html[data-theme="dark"] body{
  background: var(--tp-bg-body);
  color: var(--tp-text-main);
}

/* Keep title bars on the same canvas as the page. */
html[data-theme="dark"] .content-header{
  background: var(--tp-bg-body);
  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-main);
}


/* 表格（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"] .course-meta,
html[data-theme="dark"] .mini-pack-meta,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-month,
html[data-theme="dark"] .lb-toggle,
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;
}

html[data-theme="dark"] body[data-active="leaderboard"] .lb-card,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-toggle{
  background: var(--tp-bg-surface, #101827);
  border-color: var(--tp-border-subtle, rgba(255,255,255,.10));
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-rank,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-name,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-side-value{
  color: var(--tp-text-main, #e5e7eb);
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-meta,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-side-label{
  color: var(--tp-text-muted, #94a3b8);
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card.is-top .lb-card-rank,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-avatar{
  color: #86efac;
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-avatar{
  background: rgba(34,197,94,.14);
  border-color: rgba(74,222,128,.22);
}
/* ==============================
   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,
#settings-overlay .simple-toggle input:checked{
  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"] .btn{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: rgba(255,255,255,.92) !important;
}

html[data-theme="dark"] body[data-active="progress"] .chart-metric-btn.is-active,
html[data-theme="dark"] body[data-active="progress"] .chart-metric-btn[aria-checked="true"]{
  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"] .progress-date-picker{
  background: var(--tp-bg-surface, #0a1220) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
  box-shadow: 0 24px 60px rgba(0,0,0,.48) !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-nav,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day{
  background: transparent;
  color: var(--tp-text-main, #e5e7eb);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-nav{
  border-color: rgba(255,255,255,.12);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-title,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-month-title{
  color: var(--tp-text-main, #e5e7eb);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-weekdays span{
  color: var(--tp-text-muted);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day:not(:disabled):not(.is-disabled):not(.is-start):not(.is-end):hover,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day:not(:disabled):not(.is-disabled):not(.is-start):not(.is-end):focus-visible,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day.is-in-range{
  background: rgba(34,197,94,.18);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day.is-start,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day.is-end{
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day:disabled,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-date-day.is-disabled{
  background: transparent;
  color: var(--tp-text-muted);
}

/* 文字（灰字在暗色里稍微提亮） */
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;
}

html[data-theme="dark"] body[data-active="progress"] .hp-kpi-link:hover,
html[data-theme="dark"] body[data-active="progress"] .hp-kpi-link:focus-visible{
  background: rgba(34,197,94,.18) !important;
  border-color: rgba(74,222,128,.55) !important;
  box-shadow: 0 12px 24px rgba(0,0,0,.22), 0 0 0 3px rgba(34,197,94,.18) !important;
  color: rgba(255,255,255,.94) !important;
  text-decoration: none !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;
}

html[data-theme="dark"] #progressDataState,
html[data-theme="dark"] #view-hanzi-practiced .hp-toolbar input,
html[data-theme="dark"] #view-hanzi-practiced .hp-toolbar select,
html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle,
html[data-theme="dark"] #view-hanzi-practiced .hp-word-card,
html[data-theme="dark"] #view-hanzi-practiced .hp-study-card,
html[data-theme="dark"] #view-hanzi-practiced .hp-empty,
html[data-theme="dark"] #view-hanzi-practiced .hp-secondary-btn{
  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;
}

html[data-theme="dark"] #view-hanzi-practiced .progress-detail-head {
  background: var(--tp-bg-body);
}

html[data-theme="dark"] #progressDataState,
html[data-theme="dark"] #view-hanzi-practiced .hp-word-pinyin,
html[data-theme="dark"] #view-hanzi-practiced .hp-meaning-text,
html[data-theme="dark"] #view-hanzi-practiced .hp-study-card-pinyin,
html[data-theme="dark"] #view-hanzi-practiced .hp-study-card-date,
html[data-theme="dark"] #view-hanzi-practiced .hp-study-card-audio-icon,
html[data-theme="dark"] #view-hanzi-practiced .hp-word-card-meta,
html[data-theme="dark"] #view-hanzi-practiced .hp-empty{
  color: var(--tp-text-muted, rgba(229,231,235,.65)) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-empty-actions .hp-empty-cta{
  background: var(--accent) !important;
  border-color: transparent !important;
  color: var(--tp-on-accent) !important;
}
html[data-theme="dark"] #view-hanzi-practiced .hp-empty-actions .hp-empty-cta:not(:disabled) {
  color: var(--tp-control-on-accent) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card-hanzi{
  color: var(--tp-text-main, #e5e7eb) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn{
  color: var(--tp-text-muted, rgba(229,231,235,.65)) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"]{
  background: rgba(34,197,94,.18) !important;
  border-color: rgba(74,222,128,.58) !important;
  color: #86efac !important;
  box-shadow: 0 1px 8px rgba(0,0,0,.26) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn:hover,
html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn:focus-visible{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.16) !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"]:hover,
html[data-theme="dark"] #view-hanzi-practiced .hp-view-toggle-btn[aria-pressed="true"]:focus-visible{
  background: rgba(34,197,94,.20) !important;
  border-color: rgba(74,222,128,.64) !important;
  color: #86efac !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card:hover{
  box-shadow: 0 16px 34px rgba(0,0,0,.35) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card:hover,
html[data-theme="dark"] #view-hanzi-practiced .hp-study-card.is-popover-open{
  background: #10231b !important;
  border-color: rgba(74,222,128,.72) !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card.is-popover-open.is-popover-bottom{
  border-bottom-color: transparent !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card.is-popover-open.is-popover-top{
  border-top-color: transparent !important;
}

html[data-theme="dark"] #view-hanzi-practiced .hp-study-card.is-playing .hp-study-card-audio-icon{
  color: #86efac !important;
}

html[data-theme="dark"] .tp-word-popover.is-hanzi-practiced-card-popover{
  --text-primary: var(--tp-text-main, #e5e7eb);
  --text-muted: var(--tp-text-muted, rgba(229,231,235,.65));
  background: #10231b !important;
  border-color: rgba(74,222,128,.72) !important;
}

html[data-theme="dark"] .tp-word-popover.is-hanzi-practiced-card-popover a{
  color: #86efac;
}

html[data-theme="dark"] .tp-word-popover.is-hanzi-practiced-card-popover::before{
  background: rgba(74,222,128,.72) !important;
}
/* ===============================
   Dark mode fixes: Mistakes page
   (override hard-coded light styles)
   =============================== */

html[data-theme="dark"] body[data-active="mistakes"] .review-quota-note{
  color: var(--tp-text-muted);
}

html[data-theme="dark"] body[data-active="mistakes"] .review-quota-meter{
  background: rgba(148, 163, 184, .24);
}

html[data-theme="dark"] body[data-active="mistakes"] .review-quota-upgrade{
  background: var(--review-quota-gradient, linear-gradient(90deg, #0071E3, #22c55e));
  color: #fff;
}

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,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-item-details-btn{
  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;
}

/* Shared word and Detail popovers keep theme colors through reuse and dismissal. */
html[data-theme="dark"] .tp-word-popover{
  --surface: var(--tp-bg-floating);
  --text-primary: var(--tp-text-main);
  --text-muted: var(--tp-text-muted);
  --border-subtle: var(--tp-border-subtle);
}
html[data-theme="dark"] body[data-active="mistakes"] .tp-word-popover.is-detail-mode .tp-md code,
html[data-theme="dark"] body[data-active="mistakes"] .tp-word-popover.is-detail-mode .tp-md-code{
  background: var(--tp-bg-body);
}
html[data-theme="dark"] .tp-word-popover .tp-word-popover-play-btn:not(:disabled):hover{
  color: var(--tp-control-on-accent);
}

/* =========================
   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"] .review-note-item .review-note-entry-text,
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,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-item-details-btn{
  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,
html[data-theme="dark"] body[data-active="mistakes"] .mistake-item-details-btn 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;
}
/* Keep delete controls separate from other toolbar actions. */
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="clear-all"],
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="delete-selected"],
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="clear-all"]:disabled:hover,
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="delete-selected"]:disabled:hover{
  background: var(--tp-delete-bg) !important;
  border-color: var(--tp-delete-border) !important;
  color: var(--tp-delete-fg) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="clear-all"]:not(:disabled):hover,
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="clear-all"]:not(:disabled):focus-visible,
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="delete-selected"]:not(:disabled):hover,
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn[data-tp="delete-selected"]:not(:disabled):focus-visible{
  background: var(--tp-delete-hover-bg) !important;
  color: var(--tp-delete-hover-fg) !important;
  border-color: var(--tp-delete-hover-border) !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: var(--tp-on-accent) !important;
}
html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes .mistake-btn.mistake-btn-primary:not(:disabled) {
  color: var(--tp-control-on-accent) !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;
}

html[data-theme="dark"] body[data-active="mistakes"] #view-mistakes.is-bulk > .mistake-bulkbar{
  background: var(--tp-bg-body) !important;
  border-color: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* 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;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-attempt-mode{
  background: rgba(34,197,94,.16) !important;
  border-color: rgba(34,197,94,.32) !important;
  color: #86efac !important;
}
html[data-theme="dark"] body[data-active="mistakes"] .mistake-attempt-score{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
  color: var(--tp-text-muted, rgba(229,231,235,.72)) !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;
}

html[data-theme="dark"] body[data-active="mistakes"] .mistake-token.is-wrong{
  background: var(--tp-danger-bg) !important;
  border-color: var(--tp-danger) !important;
  color: var(--tp-danger) !important;
}

html[data-theme="dark"] body[data-active="mistakes"] .mistake-token.is-missing{
  background: var(--tp-warning-bg) !important;
  border-color: var(--tp-warning) !important;
  color: var(--tp-warning) !important;
}

html[data-theme="dark"] body[data-active="mistakes"] .mistake-modal-word-token{
  background: transparent !important;
  border-color: transparent !important;
  color: var(--tp-text-main, #e5e7eb) !important;
}

/* =========================
   Dark mode fixes: Store / My Courses (Course Library)
   （把这一段放到 app.css 最底部）
   ========================= */

/* My Courses：Go to Course Library → 保持 primary CTA 对比度 */
html[data-theme="dark"] .pack-hint-btn{
  color: var(--tp-on-accent);
  background:var(--accent);
  border-color:transparent;
}
html[data-theme="dark"] .pack-hint-btn:not(:disabled) {
  color: var(--tp-control-on-accent);
}
html[data-theme="dark"] .pack-hint-btn:hover{
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
}
html[data-theme="dark"] .pack-hint-btn:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}

html[data-theme="dark"] .pack-hint-btn:not(:disabled):active{
  background: var(--tp-accent-pressed);
  color: var(--tp-control-on-accent);
}

/* 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-body);
}
html[data-theme="dark"] .back-icon{
  background: var(--tp-bg-surface-alt);
  border-color: var(--tp-border-subtle);
  color: var(--tp-text-main);
}

html[data-theme="dark"] #settings-overlay .tp-settings-back {
  background: var(--tp-bg-surface-alt);
  border-color: var(--tp-border-subtle);
  color: rgba(255,255,255,.92);
}

/* 进入课程后：课程介绍大卡片（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"] .course-access-summary-text,
html[data-theme="dark"] .hero-upgrade,
html[data-theme="dark"] .lesson-lock-note{
  color: var(--tp-text-muted);
}
html[data-theme="dark"] .course-access-label{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
}
html[data-theme="dark"] .course-access-label.is-free{
  color: #86efac;
  border-color: rgba(134,239,172,.28);
}
html[data-theme="dark"] .course-access-label.is-preview{
  color: #fcd34d;
  border-color: rgba(252,211,77,.30);
}
html[data-theme="dark"] .course-access-label.is-pro,
html[data-theme="dark"] .lesson-badge.is-pro{
  color: #c4b5fd;
  border-color: rgba(196,181,253,.30);
  background: rgba(124,58,237,.14);
}
html[data-theme="dark"] .practice-access-denied-card{
  background: var(--tp-bg-surface);
  border-color: rgba(255,255,255,.14);
  box-shadow: 0 18px 48px rgba(0,0,0,.34);
}
html[data-theme="dark"] .practice-access-denied-eyebrow{
  color: #c4b5fd;
}
html[data-theme="dark"] .practice-access-denied-actions a{
  color: var(--tp-text-main);
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
}
html[data-theme="dark"] .practice-access-denied-actions a:first-child{
  color: #86efac;
  border-color: rgba(134,239,172,.28);
  background: rgba(22,163,74,.12);
}
html[data-theme="dark"] .lesson-card.is-access-locked{
  background: linear-gradient(180deg, var(--tp-bg-surface), rgba(124,58,237,.10));
  border-color: rgba(196,181,253,.24);
}
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);
}
html[data-theme="dark"] .store-course-count{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="store"] .store-create-course-button{
  color: var(--tp-on-accent);
  background:var(--accent);
  border-color:transparent;
  box-shadow:none;
}
html[data-theme="dark"] body[data-active="store"] .store-create-course-button:not(:disabled) {
  color: var(--tp-control-on-accent);
}
html[data-theme="dark"] body[data-active="store"] .store-create-course-button:hover{
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
}
html[data-theme="dark"] body[data-active="store"] .store-create-course-button:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}
html[data-theme="dark"] body[data-active="store"] .store-search .store-sort-button{
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  color:#86efac;
}
html[data-theme="dark"] body[data-active="store"] .store-search .store-sort-button:hover,
html[data-theme="dark"] body[data-active="store"] .store-search .store-sort-button.is-open,
html[data-theme="dark"] body[data-active="store"] .store-search .store-sort-button.is-active{
  border-color:var(--accent);
  background:rgba(34,197,94,.16);
}
html[data-theme="dark"] body[data-active="store"] .store-sort-panel{
  border-color:var(--tp-border-subtle);
  background:var(--tp-bg-surface);
  color:var(--tp-text-main);
  box-shadow:0 18px 48px rgba(0,0,0,.38);
}
html[data-theme="dark"] body[data-active="store"] .store-sort-option input{
  background:var(--tp-bg-surface);
  border-color:var(--accent);
}
html[data-theme="dark"] .store-grid-state{
  border-color:var(--tp-border-subtle);
  background:var(--tp-bg-surface-alt);
  color:var(--tp-text-main);
}
html[data-theme="dark"] .store-grid-state-title{
  color:var(--tp-text-main);
}
html[data-theme="dark"] .store-grid-state-body{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="store"] .store-grid-state-search{
  border-color:transparent;
  background:transparent;
}
html[data-theme="dark"] body[data-active="store"] .store-empty-body{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="store"] .store-empty-create-button{
  color: var(--tp-on-accent);
  background:var(--accent);
  box-shadow:none;
}
html[data-theme="dark"] body[data-active="store"] .store-empty-create-button:not(:disabled) {
  color: var(--tp-control-on-accent);
}
html[data-theme="dark"] body[data-active="store"] .store-empty-create-button:hover{
  background: var(--tp-accent-hover);
  color: var(--tp-on-accent);
}
html[data-theme="dark"] body[data-active="store"] .store-empty-create-button:hover:not(:disabled) {
  color: var(--tp-control-on-accent);
}

body[data-active="store"] .store-create-course-button:not(:disabled):active,
body[data-active="store"] .store-empty-create-button:not(:disabled):active,
html[data-theme="dark"] body[data-active="store"] .store-create-course-button:not(:disabled):active,
html[data-theme="dark"] body[data-active="store"] .store-empty-create-button:not(:disabled):active{
  background: var(--tp-accent-pressed);
  color: var(--tp-control-on-accent);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-count{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="my-packs"] #my-pack-empty.my-courses-empty{
  background:transparent;
  color:var(--tp-text-main);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-empty-title{
  color:var(--tp-text-main);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-empty-body{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="my-packs"] .store-search .my-courses-filter-button{
  border-color: var(--tp-border-subtle);
  background: var(--tp-bg-surface-alt);
  color:#86efac;
}
html[data-theme="dark"] body[data-active="my-packs"] .store-search .my-courses-filter-button:hover,
html[data-theme="dark"] body[data-active="my-packs"] .store-search .my-courses-filter-button.is-active{
  border-color:var(--accent);
  background:rgba(34,197,94,.16);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-panel{
  border-color:var(--tp-border-subtle);
  background:var(--tp-bg-surface);
  color:var(--tp-text-main);
  box-shadow:0 18px 48px rgba(0,0,0,.38);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-title{
  color:var(--tp-text-main);
  border-bottom-color:var(--tp-border-subtle);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-title svg{
  color:#86efac;
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-group{
  border-bottom-color:var(--tp-border-subtle);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-group legend{
  color:var(--tp-text-muted);
}
html[data-theme="dark"] body[data-active="my-packs"] .my-courses-filter-option input{
  background:var(--tp-bg-surface);
  border-color:var(--accent);
}
/* 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"]{
  --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-inner-bg) !important;
  border: 1px solid var(--dash-border) !important;
  color: var(--dash-text) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-word-list-link:not(.review-tile):hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-word-list-link:not(.review-tile):focus-visible{
  background: rgba(34,197,94,.18) !important;
  border-color: rgba(74,222,128,.55) !important;
  box-shadow: 0 12px 24px rgba(0,0,0,.22), 0 0 0 3px rgba(34,197,94,.18) !important;
  color: var(--dash-text) !important;
  text-decoration: none !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;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-metric-icon{
  border-color: rgba(74,222,128,.24) !important;
  background: rgba(22,101,52,.18) !important;
  color: #86efac !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .summary-metric-icon.is-hanzi{
  border-color: rgba(74,222,128,.24) !important;
  background: rgba(22,101,52,.18) !important;
  color: #86efac !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 .goal-value{
  color: var(--dash-muted) !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-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: var(--tp-on-accent) !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 .dash-recent .mini-pack{
  background: var(--dash-inner-bg) !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: var(--tp-on-accent) !important;
}

/* Two-tier dots (dark) — !important to beat the dark base dot fill */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .calendar-sm .cal-day.partial{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(74,222,128,.36) !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-preset{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.16) !important;
  color: var(--dash-muted) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-preset:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-preset:focus-visible{
  background: rgba(34,197,94,.18) !important;
  border-color: rgba(74,222,128,.55) !important;
  color: rgba(255,255,255,.94) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-preset.is-active{
  background: rgba(34,197,94,.22) !important;
  border-color: rgba(74,222,128,.62) !important;
  color: rgba(255,255,255,.96) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-trigger.is-active{
  background: rgba(34,197,94,.22) !important;
  border-color: rgba(74,222,128,.62) !important;
  color: rgba(255,255,255,.96) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-popover{
  background: rgba(15,23,42,.98) !important;
  border-color: rgba(255,255,255,.14) !important;
  box-shadow: 0 18px 38px rgba(0,0,0,.38) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-unit{
  color: var(--dash-muted) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-input{
  background: rgba(15,23,42,.92) !important;
  border-color: rgba(74,222,128,.62) !important;
  color: rgba(255,255,255,.96) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-input:focus{
  border-color: rgba(74,222,128,.82) !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,.18) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-action{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.16) !important;
  color: rgba(255,255,255,.92) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-action:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-action:focus-visible{
  border-color: rgba(74,222,128,.55) !important;
  color: rgba(255,255,255,.96) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-custom-action.is-primary{
  background: var(--accent, #22c55e) !important;
  border-color: transparent !important;
  color: var(--tp-on-accent) !important;
}

/* ===== Dashboard: merged Daily Check-in panel ===== */
body[data-active="dashboard"] #view-dashboard .dash-grid{
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr) minmax(var(--dash-right-w), .95fr);
  grid-template-areas:
    "checkin summary calendar"
    "checkin review  recent";
}

body[data-active="dashboard"] #view-dashboard .dash-checkin{
  position: relative;
  overflow: visible;
  padding: 20px;
  border-color: var(--dash-card-border);
  background: var(--dash-card-bg);
  box-shadow: 0 16px 40px rgba(15,23,42,.06);
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .card-title-row{
  align-items: flex-start;
  margin-bottom: 14px;
}

body[data-active="dashboard"] #view-dashboard .checkin-heading{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

body[data-active="dashboard"] #view-dashboard .checkin-heading .card-title{
  margin-bottom: 0;
  font-weight: 850;
}

body[data-active="dashboard"] #view-dashboard .checkin-settings-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  line-height: 1;
  transition: box-shadow 0.15s, transform 0.1s, color 0.15s;
}

body[data-active="dashboard"] #view-dashboard .checkin-settings-btn .tp-icon,
body[data-active="dashboard"] #view-dashboard .checkin-settings-btn svg{
  width: 20px;
  height: 20px;
  display: block;
}

body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:hover,
body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:focus-visible{
  color: #047857;
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  transform: translateY(-0.5px);
}

body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:focus-visible{
  outline: 2px solid rgba(22,163,74,.4);
  outline-offset: 2px;
}

body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:hover{
  outline: none;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .goal-settings-modal{
  position: fixed;
  inset: 0;
  z-index: 26000;
  display: none;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: rgba(2,6,23,.55);
  box-shadow: none;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .goal-settings-modal[hidden]{
  display: none !important;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-dialog{
  width: min(460px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 32px));
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(2,6,23,.12);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(15,23,42,.08);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-title{
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-sub{
  margin-top: 3px;
  color: var(--muted, #64748b);
  font-size: 11px;
  font-weight: 600;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-close{
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-close:hover,
body[data-active="dashboard"] #view-dashboard .goal-settings-close:focus-visible{
  background: rgba(236,253,245,.92);
  color: #047857;
  outline: none;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-body{
  padding: 0 16px;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-slider-row{
  padding: 12px 0;
  border-bottom: 1px solid rgba(15,23,42,.07);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-slider-row:last-of-type{
  border-bottom: 0;
  padding-bottom: 0;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-slider-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-label{
  color: #475569;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-value{
  color: #0f172a;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

body[data-active="dashboard"] #view-dashboard .goal-slider-control{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range{
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  --range-progress: 0%;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range::-webkit-slider-runnable-track{
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent, #22c55e) 0%,
    var(--accent, #22c55e) var(--range-progress),
    #e2e8f0 var(--range-progress),
    #e2e8f0 100%
  );
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15,23,42,.16), 0 0 0 1px rgba(148,163,184,.28);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range::-moz-range-track{
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range::-moz-range-progress{
  height: 5px;
  border-radius: 999px;
  background: var(--accent, #22c55e);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-range::-moz-range-thumb{
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15,23,42,.16), 0 0 0 1px rgba(148,163,184,.28);
}

body[data-active="dashboard"] #view-dashboard .goal-slider-minmax{
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-slider-row .goal-custom-field{
  display: flex;
  justify-content: flex-end;
  margin: 14px 0 0;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-slider-row .goal-custom-field[hidden]{
  display: none !important;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-actions{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(15,23,42,.08);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-action{
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 12px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-action:hover,
body[data-active="dashboard"] #view-dashboard .goal-settings-action:focus-visible{
  border-color: rgba(34,197,94,.38);
  color: #047857;
  outline: none;
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary{
  border-color: transparent;
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
}
body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}

body[data-active="dashboard"] #view-dashboard .checkin-top{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat{
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--dash-card-border);
  border-radius: 16px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(34,197,94,.20);
  border-radius: 14px;
  background: rgba(34,197,94,.10);
  color: #16a34a;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-icon.is-total{
  border-color: rgba(59,130,246,.20);
  background: rgba(59,130,246,.10);
  color: #2563eb;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-icon svg{
  width: 19px;
  height: 19px;
  display: block;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-copy{
  min-width: 0;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-label{
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-value{
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  color: #0f172a;
  font-size: 30px !important;
  font-weight: 850;
  line-height: 1;
}

body[data-active="dashboard"] #view-dashboard .checkin-stat-unit{
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section,
body[data-active="dashboard"] #view-dashboard .checkin-week-section{
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  background: var(--dash-inner-bg);
}

body[data-active="dashboard"] #view-dashboard .checkin-section-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body[data-active="dashboard"] #view-dashboard .checkin-section-title{
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-block{
  margin-top: 14px;
  padding-top: 0;
  border-top: 0;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-block + .goal-block{
  padding-top: 14px;
  border-top: 1px solid rgba(15,23,42,.07);
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-row{
  align-items: center;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-label{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-value{
  color: #64748b;
  font-weight: 500;
}

body[data-active="dashboard"] #view-dashboard .goal-label-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 9px;
  background: #f8fafc;
  color: #64748b;
}

body[data-active="dashboard"] #view-dashboard .goal-label-icon svg{
  display: block;
  width: 15px;
  height: 15px;
}

body[data-active="dashboard"] #view-dashboard .checkin-goal-section .goal-bar{
  height: 11px;
  background: rgba(15,23,42,.08);
}

body[data-active="dashboard"] #view-dashboard .checkin-week-section .checkin-week{
  gap: 8px;
  margin-top: 12px;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day{
  aspect-ratio: auto;
  min-height: 58px;
  min-width: 0;
  padding: 8px 4px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  background: #fff;
  position: relative;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today{
  border-color: rgba(34,197,94,.44);
  box-shadow: 0 0 0 3px rgba(34,197,94,.10);
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-on{
  border-color: rgba(34,197,94,.32);
  background: #ecfdf5;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-wd{
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today .checkin-wd{
  color: #047857;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-dot{
  width: 7px;
  height: 7px;
  margin-top: 4px;
  background: #cbd5e1;
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-on .checkin-dot{
  background: var(--accent, #22c55e);
}

/* ===== Daily Check-in: breathing "today + checked-in" cell =====
   When today already meets a goal, the cell carries BOTH .is-today and .is-on and
   breathes between its two looks: the check-in look (green fill + colored dot) and
   the today look (no fill + green border + idle dot). A non-checked today never
   matches .is-on, so it gets no animation and keeps its static look.

   The dark theme paints fill/border/dot with !important, which @keyframes cannot
   override; so the cross-fade is driven by opacity on fresh overlay pseudo-elements
   (immune to !important) instead of animating the locked color properties. The
   cell's own is-today ring stays lit throughout — only fill + dot breathe. */
@keyframes checkinTodayFade { 0%,100%{ opacity:0 } 50%{ opacity:1 } }
@keyframes checkinTodayDim  { 0%,100%{ opacity:1 } 50%{ opacity:.24 } }

/* label + dot ride above the cell overlay so they stay readable */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-wd,
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot{
  position: relative;
  z-index: 2;
}

/* cell overlay = the "today" (unfilled) look, faded over the check-in fill */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #fff;
  border: 1px solid rgba(34,197,94,.44);
  pointer-events: none;
  z-index: 1;
  animation: checkinTodayFade 3s ease-in-out infinite;
}

/* dot grey overlay = the "today" (idle) dot, faded over the green dot */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #cbd5e1;
  pointer-events: none;
  animation: checkinTodayFade 3s ease-in-out infinite;
}

/* dark: opaque card surface masks the solid-green fill; the dark dot is white-on-
   dark (not green), so it breathes by dimming its own opacity instead. */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met::after{
  background: var(--dash-card-bg);
  border-color: rgba(74,222,128,.42);
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot::after{
  display: none;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot{
  animation: checkinTodayDim 3s ease-in-out infinite;
}

/* reduced motion: no breathing — fall back to the static combined look */
@media (prefers-reduced-motion: reduce){
  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met::after,
  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot::after{
    animation: none;
    opacity: 0;
  }
  html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-dot{
    animation: none;
  }
}

/* ===== Manual check-in "claim" (tap the breathing cell to celebrate) ===== */
/* the breathing today cell invites a tap */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met:not(.is-claimed){
  cursor: pointer;
}
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met:not(.is-claimed):focus-visible{
  outline: 2px solid rgba(34,197,94,.7);
  outline-offset: 2px;
}
/* claimed -> stop breathing, settle into the static checked-in look */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met.is-claimed::after,
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met.is-claimed .checkin-dot::after{
  animation: none;
  opacity: 0;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met.is-claimed .checkin-dot{
  animation: none;
}
/* one-shot pop when claimed */
@keyframes checkinClaimPop { 0%{ transform:scale(1) } 35%{ transform:scale(1.16) } 100%{ transform:scale(1) } }
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met.is-pop{
  animation: checkinClaimPop .55s ease;
}
@media (prefers-reduced-motion: reduce){
  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met.is-pop{ animation: none; }
}
body[data-active="dashboard"] #view-dashboard .dash-checkin{ position: relative; }

/* Lift the breathing today cell (and its overflowing ripple) above the neighbouring
   cells. Without this the ripple is occluded by the NEXT day: sibling cells are
   position:relative with z-index:auto, so later DOM siblings paint on top. */
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met{
  z-index: 5;
}

/* breathing ripples around the claimable today cell (two staggered expanding rings) */
@keyframes checkinRipple {
  0%   { transform: scale(.9); opacity: .7; }
  70%  { opacity: 0; }
  100% { transform: scale(1.85); opacity: 0; }
}
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-ripple,
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-ripple::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(34,197,94,.7);
  pointer-events: none;
  z-index: 0;
  animation: checkinRipple 2.4s ease-out infinite;
}
body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-ripple::after{
  animation-delay: 1.2s;
}
@media (prefers-reduced-motion: reduce){
  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-ripple{ display: none; }
}

/* dim scrim behind the centered check-in confirmation (below confetti, above page) */
.checkin-scrim{
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.5);
  opacity: 0;
  pointer-events: none;
  z-index: 10000; /* above the check-in calendar modal (9999) so it dims too; below confetti(10001)+toast */
  transition: opacity .28s ease;
}
.checkin-scrim.is-show{ opacity: 1; }

/* celebratory toast — centered on the whole page, above the scrim and confetti */
.checkin-toast{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.92);
  background: #16a34a;
  color: #fff;
  font: 700 15px/1.25 -apple-system, system-ui, sans-serif;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 18px 48px rgba(2,6,23,.45);
  opacity: 0;
  pointer-events: none;
  z-index: 10020;
  white-space: nowrap;
  transition: opacity .25s ease, transform .25s ease;
}
.checkin-toast.is-show{
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

body[data-active="dashboard"] #view-dashboard .checkin-actions{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

body[data-active="dashboard"] #view-dashboard .checkin-action{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 12px;
  background: var(--dash-inner-bg);
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.1;
}

body[data-active="dashboard"] #view-dashboard .checkin-action-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

body[data-active="dashboard"] #view-dashboard .checkin-action-icon svg{
  display: block;
  width: 16px;
  height: 16px;
}

body[data-active="dashboard"] #view-dashboard .checkin-action:hover,
body[data-active="dashboard"] #view-dashboard .checkin-action:focus-visible{
  border-color: rgba(34,197,94,.38);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary{
  border-color: transparent;
  background: var(--accent, #22c55e);
  color: var(--tp-on-accent);
}
body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-btn{
  width: 100%;
  margin-top: 14px;
  min-height: 38px;
  background: rgba(15,23,42,.04);
  color: #334155;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.08);
}

body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-status-copy{
  margin-top: 8px;
  color: var(--muted, #64748b);
  font-size: 12px;
  font-weight: 750;
}

body[data-active="dashboard"] .checkin-calendar-dialog{
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-active="dashboard"] .checkin-calendar-dialog .modal-head{
  padding: 12px 14px;
}

body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn,
body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn{
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
}

body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn:hover,
body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn:focus-visible,
body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:hover,
body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:focus-visible{
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #0f172a;
  outline: none;
}

body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:disabled,
body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn[aria-disabled="true"]{
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #cbd5e1;
  cursor: not-allowed;
  opacity: .62;
  pointer-events: none;
}

body[data-active="dashboard"] .checkin-calendar-monthbar{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px 6px;
}

body[data-active="dashboard"] .checkin-calendar-month{
  min-width: 136px;
  color: #0f172a;
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

body[data-active="dashboard"] .checkin-calendar-stats{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px;
}

body[data-active="dashboard"] .checkin-calendar-stat{
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 32px minmax(0, 1fr);
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  background: #f8fafc;
}

body[data-active="dashboard"] .checkin-calendar-stat-icon{
  align-items: center;
  background: rgba(34,197,94,.10);
  border: 1px solid rgba(34,197,94,.20);
  border-radius: 10px;
  color: #16a34a;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

body[data-active="dashboard"] .checkin-calendar-stat-icon.is-total{
  background: rgba(59,130,246,.10);
  border-color: rgba(59,130,246,.20);
  color: #2563eb;
}

body[data-active="dashboard"] .checkin-calendar-stat-icon.is-bonus{
  background: rgba(168,85,247,.10);
  border-color: rgba(168,85,247,.22);
  color: #9333ea;
}

body[data-active="dashboard"] .checkin-calendar-stat-icon svg{
  display: block;
  height: 16px;
  width: 16px;
}

body[data-active="dashboard"] .checkin-calendar-stat-copy{
  min-width: 0;
}

body[data-active="dashboard"] .checkin-calendar-stat-value{
  display: block;
  color: #0f172a;
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
}

body[data-active="dashboard"] .checkin-calendar-stat-label{
  display: block;
  margin-top: 7px;
  color: #64748b;
  font-size: 12px;
  font-weight: 650;
}

body[data-active="dashboard"] .checkin-calendar-grid{
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 16px;
  background: #f8fafc;
}

body[data-active="dashboard"] .checkin-calendar-head{
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

body[data-active="dashboard"] .checkin-calendar-day{
  --checkin-calendar-checked-fill: var(--accent, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

body[data-active="dashboard"] .checkin-calendar-day.is-checked{
  background: var(--checkin-calendar-checked-fill);
  color: var(--tp-control-on-accent);
}

body[data-active="dashboard"] .checkin-calendar-day.is-today:not(.is-checked){
  border-color: rgba(34,197,94,.72);
  color: #0f172a;
}

body[data-active="dashboard"] .checkin-calendar-day:not(.is-checked):not(.is-future):not(:disabled):hover,
body[data-active="dashboard"] .checkin-calendar-day:not(.is-checked):not(.is-future):not(:disabled):focus-visible{
  border-color: rgba(34,197,94,.44);
  color: #0f172a;
  outline: none;
}

body[data-active="dashboard"] .checkin-calendar-day.is-future,
body[data-active="dashboard"] .checkin-calendar-day:disabled{
  background: transparent;
  border-color: transparent;
  color: #cbd5e1;
  cursor: default;
  pointer-events: none;
}

body[data-active="dashboard"] .checkin-calendar-day.is-empty{
  visibility: hidden;
  pointer-events: none;
}

/* ===== Check-in calendar: breathing + ripple + claim on TODAY (mirrors This week) ===== */
/* day number sits above the breathing fill overlay */
body[data-active="dashboard"] .checkin-calendar-day .cal-day-num{
  position: relative;
  z-index: 2;
}
/* today met & unclaimed -> breathe between the today-look (border) and the green fill;
   lift above neighbours so the ripple isn't occluded by the next day */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met{
  position: relative;
  z-index: 5;
}
/* overlay = the green "checked" fill, faded in/out over the today-look base */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--checkin-calendar-checked-fill);
  pointer-events: none;
  z-index: 1;
  animation: checkinTodayFade 3s ease-in-out infinite;
}
/* Keep a stable pair beneath the number while the surrounding fill breathes. */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .cal-day-num{
  color: var(--tp-control-on-accent);
  background: var(--checkin-calendar-checked-fill);
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--checkin-calendar-checked-fill);
}
/* claimed (transient, until the views rebuild) -> settle on the green fill */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met.is-claimed::after{
  animation: none;
  opacity: 1;
}
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met.is-claimed .cal-day-num{
  animation: none;
  color: var(--tp-control-on-accent);
}
/* one-shot pop on claim */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met.is-pop{
  animation: checkinClaimPop .55s ease;
}
/* breathing ripples around the today cell (two staggered expanding rings) */
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .checkin-ripple,
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .checkin-ripple::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(34,197,94,.7);
  pointer-events: none;
  z-index: 0;
  animation: checkinRipple 2.4s ease-out infinite;
}
body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .checkin-ripple::after{
  animation-delay: 1.2s;
}
@media (prefers-reduced-motion: reduce){
  body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met::after{ animation: none; opacity: 0; }
  body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .cal-day-num{ animation: none; }
  body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .checkin-ripple{ display: none; }
}

@media (max-width: 1100px){
  body[data-active="dashboard"] #view-dashboard .dash-grid{
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "checkin checkin"
      "summary calendar"
      "review  recent";
  }
}

@media (max-width: 720px){
  body[data-active="dashboard"] #view-dashboard .dash-grid{
    grid-template-columns: 1fr;
    grid-template-areas:
      "checkin"
      "summary"
      "review"
      "calendar"
      "recent";
  }

  body[data-active="dashboard"] #view-dashboard .dash-checkin{
    padding: 16px;
  }

  body[data-active="dashboard"] #view-dashboard .dash-checkin .goal-settings-modal{
    left: 0;
    right: 0;
    width: auto;
  }

  body[data-active="dashboard"] #view-dashboard .goal-settings-slider-head{
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  body[data-active="dashboard"] #view-dashboard .goal-settings-slider-row .goal-custom-field{
    justify-content: flex-start;
  }

  body[data-active="dashboard"] #view-dashboard .checkin-heading{
    flex-wrap: wrap;
  }
}

@media (max-width: 540px){
  body[data-active="dashboard"] #view-dashboard .checkin-top,
  body[data-active="dashboard"] #view-dashboard .checkin-actions{
    grid-template-columns: 1fr;
  }

  body[data-active="dashboard"] .checkin-calendar-monthbar{
    padding-top: 12px;
  }

  body[data-active="dashboard"] .checkin-calendar-month{
    min-width: 112px;
    font-size: 17px;
  }

  body[data-active="dashboard"] .checkin-calendar-stats{
    gap: 6px;
    padding: 10px 12px;
  }

  body[data-active="dashboard"] .checkin-calendar-stat{
    gap: 6px;
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 10px 8px;
    border-radius: 12px;
  }

  body[data-active="dashboard"] .checkin-calendar-stat-icon{
    border-radius: 8px;
    height: 24px;
    width: 24px;
  }

  body[data-active="dashboard"] .checkin-calendar-stat-icon svg{
    height: 13px;
    width: 13px;
  }

  body[data-active="dashboard"] .checkin-calendar-stat-value{
    font-size: 19px;
  }

  body[data-active="dashboard"] .checkin-calendar-stat-label{
    font-size: 10px;
    line-height: 1.15;
  }

  body[data-active="dashboard"] .checkin-calendar-grid{
    gap: 5px;
    margin: 0 12px 12px;
    padding: 10px;
    border-radius: 14px;
  }

  body[data-active="dashboard"] .checkin-calendar-day{
    border-radius: 9px;
    font-size: 12px;
  }

  body[data-active="dashboard"] #view-dashboard .checkin-stat{
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    min-height: 78px;
    padding: 12px;
  }

  body[data-active="dashboard"] #view-dashboard .checkin-stat-icon{
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  body[data-active="dashboard"] #view-dashboard .dash-summary .summary-metric-icon{
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  body[data-active="dashboard"] #view-dashboard .checkin-actions{
    gap: 10px;
  }

  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-week{
    gap: 4px;
  }

  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day{
    min-height: 54px;
    padding: 7px 2px;
    border-radius: 12px;
  }

  body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-wd{
    font-size: 11px;
  }
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin{
  background: var(--dash-card-bg);
  border-color: var(--dash-card-border);
  box-shadow: 0 18px 42px rgba(0,0,0,.24);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-icon,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-label-icon,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat-icon{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: #86efac;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-icon.is-total{
  background: rgba(59,130,246,.18);
  border-color: rgba(96,165,250,.30);
  color: #93c5fd;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat-icon.is-total{
  background: rgba(59,130,246,.18);
  border-color: rgba(96,165,250,.30);
  color: #93c5fd;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat-icon.is-bonus{
  background: rgba(168,85,247,.18);
  border-color: rgba(192,132,252,.34);
  color: #d8b4fe;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-goal-section,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-week-section{
  background: var(--dash-inner-bg) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--dash-text) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-action,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-grid{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: var(--dash-text) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-title,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-value,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-value,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-section-title,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-label,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-month,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat-value{
  color: var(--dash-text) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-sub,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-slider-minmax,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-unit,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-wd,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-status-copy,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-head,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-stat-label,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day{
  color: var(--dash-muted) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today .checkin-wd{
  color: var(--tp-success) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-label,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-stat-unit,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-wd{
  opacity: 1;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-on .checkin-wd{
  color: var(--tp-on-accent) !important;
}

/* A stable label backing avoids low contrast halfway through the fill animation. */
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today.is-on.is-goal-met .checkin-wd{
  background: var(--tp-accent);
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--tp-accent);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .checkin-day.is-today{
  border-color: rgba(74,222,128,.42) !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,.14);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-close{
  color: rgba(255,255,255,.92) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-close:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-close:focus-visible{
  background: rgba(255,255,255,.08) !important;
  color: #86efac !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:focus-visible{
  color: #86efac !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:focus-visible{
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  transform: translateY(-0.5px);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-settings-btn:focus-visible{
  outline: 2px solid rgba(134,239,172,.35);
  outline-offset: 2px;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-dialog{
  background: rgba(15,23,42,.98) !important;
  border-color: rgba(255,255,255,.14) !important;
  box-shadow: 0 24px 80px rgba(0,0,0,.48) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-actions{
  border-top-color: rgba(255,255,255,.12) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-action{
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.16) !important;
  color: rgba(255,255,255,.92) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-action:hover,
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-action:focus-visible{
  border-color: rgba(74,222,128,.55) !important;
  color: rgba(255,255,255,.96) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary{
  background: var(--accent, #22c55e) !important;
  border-color: transparent !important;
  color: var(--tp-on-accent) !important;
}
html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary:not(:disabled) {
  color: var(--tp-control-on-accent) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .dash-checkin .goal-settings-modal{
  background: rgba(2,6,23,.55) !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn:hover,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-dialog .modal-head .icon-btn:focus-visible,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:hover,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:focus-visible{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:not(:disabled):not([aria-disabled="true"]){
  color: var(--dash-muted) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:not(:disabled):not([aria-disabled="true"]):hover,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-monthbar .icon-btn:not(:disabled):not([aria-disabled="true"]):focus-visible{
  color: var(--dash-text) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-range::-webkit-slider-runnable-track{
  background: linear-gradient(
    to right,
    var(--accent, #22c55e) 0%,
    var(--accent, #22c55e) var(--range-progress),
    rgba(255,255,255,.14) var(--range-progress),
    rgba(255,255,255,.14) 100%
  );
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .goal-settings-range::-moz-range-track{
  background: rgba(255,255,255,.14);
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day.is-checked{
  background: var(--accent, #22c55e) !important;
  border-color: transparent !important;
  color: var(--tp-on-accent) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day.is-checked,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day.is-today.is-goal-met .cal-day-num{
  color: var(--tp-control-on-accent) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary:not(:disabled){
  color: var(--tp-control-on-accent) !important;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary:not(:disabled):hover,
body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary:not(:disabled):hover{
  background: var(--tp-accent-hover) !important;
  color: var(--tp-control-on-accent) !important;
}

body[data-active="dashboard"] #view-dashboard .goal-settings-action.is-primary:not(:disabled):active,
body[data-active="dashboard"] #view-dashboard .checkin-action.is-primary:not(:disabled):active{
  background: var(--tp-accent-pressed) !important;
  color: var(--tp-control-on-accent) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day.is-future,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day:disabled{
  background: transparent !important;
  border-color: transparent !important;
  color: rgba(148,163,184,.42) !important;
}

html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day:not(.is-checked):hover,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day:not(.is-checked):focus-visible,
html[data-theme="dark"] body[data-active="dashboard"] .checkin-calendar-day.is-today:not(.is-checked){
  color: var(--dash-text) !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;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-stat,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-intensity{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.level-0{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.10);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.is-empty{
  background: transparent;
  border-color: transparent;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.level-1{
  background: rgba(34,197,94,.28);
  border-color: rgba(74,222,128,.18);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.level-2{
  background: rgba(34,197,94,.48);
  border-color: rgba(74,222,128,.26);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.level-3{
  background: rgba(34,197,94,.72);
  border-color: rgba(134,239,172,.34);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-cell.level-4{
  background: #4ade80;
  border-color: rgba(187,247,208,.46);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress {
  --progress-card-bg: var(--tp-bg-surface, #0a1220);
  --progress-card-border: rgba(255,255,255,.12);
  --progress-card-shadow: 0 18px 48px rgba(0,0,0,.30);
  --progress-soft-bg: rgba(255,255,255,.06);
  --progress-soft-border: rgba(255,255,255,.12);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .card-title,
html[data-theme="dark"] body[data-active="progress"] #view-progress .kpi-value,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-stat-value{
  color: var(--tp-text-main, #e5e7eb) !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .kpi,
html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-chips,
html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-wrap,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-overview-note,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-stat,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-intensity{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.12) !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-wrap{
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04) !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-metric-btn{
  color: rgba(255,255,255,.78);
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-metric-btn[data-metric="time"].is-active,
html[data-theme="dark"] body[data-active="progress"] #view-progress .chart-metric-btn[data-metric="time"][aria-checked="true"]{
  background: rgba(59,130,246,.18) !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress .kpi-icon,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-stat-icon{
  background: rgba(34,197,94,.16) !important;
  border-color: rgba(74,222,128,.25) !important;
  color: #86efac !important;
}

html[data-theme="dark"] body[data-active="progress"] #view-progress #progressLineNote,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-overview-note,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-legend-title,
html[data-theme="dark"] body[data-active="progress"] #view-progress .progress-heatmap-legend-item{
  color: rgba(229,231,235,.68) !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(--practice-border-color);
  background: var(--practice-hint-bg);
  color: var(--tp-text-main);
}

body[data-active="practice"] .word-meaning{
  background: var(--practice-hint-bg);
  color: var(--tp-text-main);
  border: 1px solid var(--practice-border-color);
}

body[data-active="practice"] .sentence-item:hover{
  background: var(--practice-soft-hover-bg);
}


/* ===== 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-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;
  overflow:hidden;
  flex-shrink:0;
}
.lb-avatar img,
.lb-card-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
}
.lb-medal{
  display:inline-block;
  width:24.7px;
  height:24.7px;
  vertical-align:middle;
}
@media (min-width: 721px){
  body[data-active="leaderboard"] .table th:first-child,
  body[data-active="leaderboard"] .table [data-tp="leaderboard-rank"]{
    box-sizing:border-box;
    width:56px;
    text-align:center;
    vertical-align:middle;
    font-variant-numeric:tabular-nums;
  }
  body[data-active="leaderboard"] .table .lb-medal{
    display:block;
    margin-inline:auto;
  }
}
body[data-active="leaderboard"] .lb-avatar.is-default,
body[data-active="leaderboard"] .lb-card-avatar.is-default,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-avatar.is-default,
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card-avatar.is-default{
  background:var(--accent, #22c55e);
  border:0;
}
body[data-active="leaderboard"] .lb-avatar.is-default img,
body[data-active="leaderboard"] .lb-card-avatar.is-default img{
  box-sizing:border-box;
  padding:3px;
  object-fit:contain;
  filter:brightness(0) invert(1);
}
.lb-you{
  display:inline-block;
  flex-shrink:0;
  margin-left:6px;
  padding:2px 6px;
  border-radius:999px;
  background:rgba(34,197,94,.14);
  color:var(--text-primary);
  font-size:11px;
  font-weight:700;
  vertical-align:middle;
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-you{
  color:#f8fafc;
}
body[data-active="leaderboard"] .table tbody tr.is-you td,
body[data-active="leaderboard"] .lb-card.is-you{
  background:rgba(34,197,94,.10);
}
body[data-active="leaderboard"] .table tbody tr.is-you td:first-child{
  box-shadow:inset 3px 0 #22c55e;
}
body[data-active="leaderboard"] .lb-card.is-you{
  border-color:rgba(34,197,94,.55);
}
html[data-theme="dark"] body[data-active="leaderboard"] .table tbody tr.is-you td{
  background:rgba(34,197,94,.14) !important;
}
html[data-theme="dark"] body[data-active="leaderboard"] .lb-card.is-you{
  background:rgba(34,197,94,.14);
  border-color:rgba(34,197,94,.55);
}
.lb-show-more{ display:none; }
.lb-name{
  display:inline-block;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.lb-card{
  display:grid;
  grid-template-columns:auto 36px minmax(0, 1fr) auto;
  align-items:center;
  gap:10px;
  min-width:0;
  padding:12px;
  border:1px solid rgba(15,23,42,.08);
  border-radius:14px;
  background:#ffffff;
}
.lb-card-rank{
  min-width:34px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  color:#0f172a;
  font-size:14px;
  font-weight:850;
  line-height:1;
}
.lb-card.is-top .lb-card-rank{
  color:#16a34a;
}
.lb-card-avatar{
  width:36px;
  height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  border:1px solid rgba(34,197,94,.18);
  background:rgba(34,197,94,.10);
  color:#16a34a;
  font-size:14px;
  font-weight:800;
  line-height:1;
  overflow:hidden;
}
.lb-card-main{
  min-width:0;
}
.lb-card-name-line{
  display:flex;
  align-items:center;
  min-width:0;
}
.lb-card-name{
  min-width:0;
  color:#0f172a;
  font-size:14px;
  font-weight:800;
  line-height:1.2;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.lb-card-meta{
  margin-top:5px;
  color:#64748b;
  font-size:12px;
  font-weight:600;
  line-height:1.2;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:normal;
}
.lb-card-side{
  min-width:46px;
  text-align:right;
}
.lb-card-side-value{
  color:#0f172a;
  font-size:15px;
  font-weight:850;
  line-height:1;
}
.lb-card-side-label{
  margin-top:5px;
  color:#64748b;
  font-size:11px;
  font-weight:700;
  line-height:1.25;
  max-width:55px;
}

@media (max-width: 720px){
  body[data-active="leaderboard"] .content{
    min-width:0;
    overflow-x:hidden;
  }
  body[data-active="leaderboard"] .view[data-view="leaderboard"]{
    display:block;
    min-width:0;
  }
  body[data-active="leaderboard"] .view[data-view="leaderboard"] > .card{
    width:100%;
    min-width:0;
  }
  body[data-active="leaderboard"] .leaderboard-controls{
    align-items:stretch;
    margin-top:10px;
  }
  body[data-active="leaderboard"] .lb-toggle{
    width:100%;
    justify-content:space-between;
    padding:10px 12px;
    border:1px solid rgba(15,23,42,.08);
    border-radius:12px;
    background:rgba(248,250,252,.86);
  }
  body[data-active="leaderboard"] .view[data-view="leaderboard"] .table-wrap{
    display:none;
  }
  body[data-active="leaderboard"] .leaderboard-mobile-list{
    display:grid;
    gap:10px;
    margin-top:12px;
  }
  body[data-active="leaderboard"] .leaderboard-mobile-list[hidden]{
    display:none;
  }
  body[data-active="leaderboard"] .lb-show-more:not([hidden]){
    display:block;
    margin:12px auto 0;
  }
}


/* --- 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: var(--tp-on-accent);
    }
.auth-btn.primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}

    /* 头像按钮 */
    .auth-btn.is-avatar{
      width:34px;
      height:34px;
      padding:0;
      border-radius:999px;
      display:flex;
      align-items:center;
      justify-content:center;
      background: transparent;
      border: 1px solid rgba(0,0,0,.10);
      color: inherit;
      box-shadow: none;

    }
    .auth-btn.is-avatar svg{ width:18px; height:18px; display:block; }
    html[data-theme="dark"] .auth-btn.is-avatar{ border-color:var(--tp-border-control); }

    /* 下拉菜单 */
    .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; }

    .sidebar .menu-item[hidden],
    .account-plan-badge[hidden]{ display:none !important; }

    .account-plan-badge{
      margin-left:auto;
      flex:0 0 auto;
      white-space:nowrap;
      padding:2px 8px;
      border:1px solid var(--border-subtle);
      border-radius:999px;
      background:var(--surface-muted);
      color:var(--text-primary);
      font-size:11px;
      font-weight:600;
      line-height:1.5;
    }

    .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-progress-setup{
  margin:6px 0;
  padding:10px;
  max-width:280px;
  border-bottom:1px solid var(--border-subtle);
  color:var(--text-primary);
  font-size:13px;
  line-height:1.4;
}
.account-progress-setup[hidden]{ display:none; }
.account-progress-setup p{ margin:6px 0 10px; }
/* 菜单项（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;
}
.theme-preference-status{
  padding: 0 10px 8px;
  font-size: 12px;
  line-height: 1.4;
  color: inherit;
  opacity: .75;
}
.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.active svg,
#tpAvatarMenuOverlay .tp-theme-btn.active svg{ color:#fff; }
.auth-theme-btn:hover{ background:#f3f4f6; }
.auth-theme-btn.active{
  background: var(--auth-accent);
  border-color: var(--auth-accent);
  color: var(--tp-on-accent);
}

[data-theme="dark"] .auth-theme-btn:not(.active){
  color:var(--tp-text-main);
  border-color:var(--tp-border-control);
}
[data-theme="dark"] .auth-theme-btn:not(.active):hover{
  background:var(--tp-bg-hover);
}
[data-theme="dark"] .auth-theme-btn.active:hover{
  background:var(--tp-accent-hover);
}

.auth-theme-btn.active:not(:disabled):active,
[data-theme="dark"] .auth-theme-btn.active:not(:disabled):active{
  background:var(--tp-accent-pressed);
  color:var(--tp-on-accent);
}

/* 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,
.auth-avatar-default{
  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:calc(100vh - 32px);
  max-height:calc(100dvh - 32px);
  display:flex;
  flex-direction:column;
}
.acct-modal > .auth-top{ flex:0 0 auto; }

[data-theme="dark"] .acct-modal{
  background:var(--tp-bg-floating);
  color:var(--tp-text-main);
  border-color:var(--tp-border-subtle);
}

[data-theme="dark"] .acct-modal .auth-sub,
[data-theme="dark"] .acct-modal .auth-msg,
[data-theme="dark"] .auth-modal .auth-x{
  color:var(--tp-text-muted);
}

[data-theme="dark"] .acct-modal .auth-btn:not(.primary):not(.acct-delete-account-btn),
[data-theme="dark"] .delete-account-actions .auth-btn:not(.delete-account-confirm){
  background:var(--tp-bg-surface);
  color:var(--tp-text-main);
  border-color:var(--tp-border-control);
}

/* 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;
  min-height:0;
  overflow:auto;
  padding-right:2px;
}

.acct-grid{
  display:grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 12px 16px;
  margin-top: 14px;
}
.acct-grid > *{ min-width:0; }
.acct-grid .acct-input{ width:100%; max-width:100%; }
@media (max-width: 760px){
  .acct-modal{
    width:100%;
    max-width:560px;
    height:min(680px, calc(100vh - 32px));
    height:min(680px, calc(100dvh - 32px));
  }
  .acct-grid{ grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 480px){
  .acct-modal{ height:auto; overflow:auto; }
  .acct-body{ flex:0 0 auto; overflow:visible; }
}

.acct-label{
  font-size:13px;
  font-weight:600;
  color:#111827;
  padding-top:10px;
}
[data-theme="dark"] .acct-label{ color:var(--tp-text-main); }

.acct-help{
  font-size:12px;
  color:#6b7280;
  margin-top:-6px;
}
[data-theme="dark"] .acct-help{ color:var(--tp-text-muted); }

.acct-input:disabled{
  opacity:.7;
  cursor:not-allowed;
}

/* The disabled email is still information the user needs to read. */
[data-theme="dark"] .acct-input:disabled{
  opacity:1;
  -webkit-text-fill-color:var(--tp-text-main);
}

.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:var(--tp-border-control);
  background:var(--tp-bg-surface-alt);
  color:var(--tp-text-main);
}

.auth-btn.is-avatar.is-default,
.acct-avatar-preview.is-default,
[data-theme="dark"] .acct-avatar-preview.is-default{
  background:var(--accent, #22c55e);
  border:0;
}
.auth-btn.is-default img,
.acct-avatar-preview.is-default img{
  box-sizing:border-box;
  padding:12%;
  object-fit:contain;
  filter:brightness(0) invert(1);
}
.auth-btn.is-avatar.is-default > img.auth-avatar-default{
  border-radius:0;
  padding:3px;
}
.acct-avatar-preview.is-default > img.auth-avatar-default{
  border-radius:0;
}

/* 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:space-between;
  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-danger-actions{
  display:flex;
  align-items:center;
  min-width:0;
}

.acct-delete-account-btn{
  border-color: var(--tp-delete-border);
  color: var(--tp-delete-fg);
  background: var(--tp-delete-bg);
}
.acct-delete-account-btn:not(:disabled):hover,
.acct-delete-account-btn:not(:disabled):focus-visible{
  background: var(--tp-delete-hover-bg);
  border-color: var(--tp-delete-hover-border);
  color: var(--tp-delete-hover-fg);
}

.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;
}

#deleteAccountBackdrop{
  display:none;
  background: rgba(2,6,23,0.62) !important;
  backdrop-filter:none !important;
  z-index:30000;
}
#deleteAccountBackdrop.open{ display:flex; }

.delete-account-modal{
  width:min(94vw, 720px);
  max-width:720px;
  max-height:calc(100dvh - 32px);
  padding:0;
  overflow:hidden;
  border-radius:18px;
  display:flex;
  flex-direction:column;
}

.delete-account-top{
  align-items:center;
  padding:24px 30px;
  border-bottom:1px solid rgba(229,231,235,.9);
}
.delete-account-top .auth-title{
  font-size:24px;
  line-height:1.2;
}

.delete-account-body{
  padding:22px 30px 12px;
  overflow:auto;
}

.delete-account-warning{
  display:grid;
  gap:12px;
  padding:20px 22px;
  border-radius:14px;
  background:#fff1f2;
  color:#b91c1c;
}

.delete-account-warning-head{
  display:flex;
  align-items:center;
  gap:14px;
  font-size:18px;
  line-height:1.35;
}

.delete-account-warning-icon{
  width:26px;
  height:26px;
  border:2px solid #ef4444;
  color:#ef4444;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  line-height:1;
  flex:0 0 auto;
}

.delete-account-warning ul{
  margin:0 0 0 46px;
  padding:0;
  display:grid;
  gap:8px;
  font-size:16px;
  line-height:1.35;
}

.delete-account-email{
  margin:18px 0 12px;
  color:#64748b;
  font-size:14px;
  font-weight:700;
}

.delete-account-label{
  display:block;
  margin:0 0 10px;
  font-size:15px;
  font-weight:800;
  color:#374151;
}

.delete-account-link-note{
  margin:0 0 12px;
  color:#64748b;
  font-size:13px;
  font-weight:700;
  line-height:1.35;
}

.delete-account-code-row{
  display:grid;
  grid-template-columns:minmax(0, 1fr);
  gap:12px;
}

.delete-account-code{
  min-height:52px;
  font-size:18px;
}

.delete-account-send{
  min-height:52px;
  border-radius:14px;
  font-size:15px;
  font-weight:800;
  width:100%;
}

.delete-account-msg{
  min-height:20px;
  margin-top:12px;
  font-size:13px;
  font-weight:700;
  color:#166534;
}
.delete-account-msg[data-state="error"]{ color:#b91c1c; }

.delete-account-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  padding:0 30px 24px;
}

.delete-account-actions .auth-btn{
  min-height:54px;
  border-radius:14px;
  font-size:16px;
  font-weight:900;
}

.delete-account-confirm{
  background: var(--tp-delete-bg);
  border-color: var(--tp-delete-border);
  color: var(--tp-delete-fg);
}
.delete-account-confirm:not(:disabled):hover,
.delete-account-confirm:not(:disabled):focus-visible{
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}
.delete-account-confirm:disabled{
  cursor:not-allowed;
  opacity:.65;
}

[data-theme="dark"] .delete-account-modal{
  background:var(--tp-bg-floating);
  color:var(--tp-text-main);
}
[data-theme="dark"] .delete-account-top{
  border-bottom-color:#1f2937;
}
[data-theme="dark"] .delete-account-warning{
  background:var(--tp-danger-bg);
  color:var(--tp-danger);
}
[data-theme="dark"] .delete-account-warning-icon{
  border-color:var(--tp-danger);
  color:var(--tp-danger);
}
[data-theme="dark"] .delete-account-msg{
  color:var(--tp-success);
}
[data-theme="dark"] .delete-account-msg[data-state="error"]{
  color:var(--tp-danger);
}
[data-theme="dark"] .delete-account-email,
[data-theme="dark"] .delete-account-label,
[data-theme="dark"] .delete-account-link-note{
  color:var(--tp-text-muted);
}

@media (max-width: 760px){
  .acct-footer{
    flex:0 0 auto;
    flex-wrap:wrap;
    align-items:stretch;
  }
  .acct-danger-actions,
  .acct-footer .acct-actions{
    width:100%;
  }
  .acct-delete-account-btn,
  .acct-footer .acct-actions .auth-btn{
    flex:1 1 auto;
  }
  .delete-account-modal{
    width:calc(100vw - 20px);
    max-height:calc(100vh - 20px);
    border-radius:16px;
  }
  .delete-account-top{
    padding:18px 20px;
  }
  .delete-account-body{
    padding:20px 20px 12px;
  }
  .delete-account-warning{
    padding:18px;
  }
  .delete-account-warning-head{
    font-size:16px;
  }
  .delete-account-warning ul{
    margin-left:34px;
    font-size:15px;
  }
  .delete-account-code-row,
  .delete-account-actions{
    grid-template-columns:1fr;
  }
  .delete-account-actions{
    gap:10px;
    padding:0 20px 20px;
  }
}

/* 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:var(--tp-bg-floating); border-color:var(--tp-border-subtle); }
    [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:var(--tp-text-muted); }
    [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 #answer-toggle-btn[hidden],
body[data-active="practice"] #tp-more-menu-overlay #tp-more-answer-row[hidden]{
  display: none !important;
}
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);
}

/* Practice item notes */
body[data-active="practice"] .phrase.review-mode{
  position: relative;
}
body[data-active="practice"] .tp-note-trigger{
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  min-width: 36px;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  vertical-align: middle;
  cursor: pointer;
  white-space: nowrap;
  z-index: 2;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}
body[data-active="practice"] .tp-note-trigger:hover,
body[data-active="practice"] .tp-note-trigger:focus-visible{
  background: rgba(255,255,255,0.72);
  border-color: rgba(15,23,42,0.08);
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  color: var(--tp-green, #16a34a);
  transform: translateY(calc(-50% - 0.5px));
  outline: none;
}
body[data-active="practice"] .tp-note-trigger:active{
  box-shadow: none;
  transform: translateY(-50%);
}
body[data-active="practice"] .tp-note-trigger.has-notes{
  color: #6b7280;
  background: transparent;
  border-color: transparent;
}
body[data-active="practice"] .tp-note-trigger.has-notes:hover,
body[data-active="practice"] .tp-note-trigger.has-notes:focus-visible{
  background: rgba(255,255,255,0.72);
  border-color: rgba(15,23,42,0.08);
  color: var(--tp-green, #16a34a);
}
body[data-active="practice"] .tp-note-trigger-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
body[data-active="practice"] .tp-note-trigger-icon svg{
  width: 20px;
  height: 20px;
}
.tp-note-overlay{
  position: fixed;
  inset: 0;
  z-index: 10030;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px;
  background: rgba(17,24,39,0.18);
  color: #111827;
}
.tp-note-dialog{
  width: min(720px, calc(100vw - 32px));
  max-height: min(740px, calc(100vh - 48px));
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.18);
}
.tp-note-header{
  height: 64px;
  border-bottom: 1px solid rgba(17,24,39,0.12);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
}
.tp-note-header h2{
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
}
.tp-note-header h2 span{
  color: #6b7280;
  font-size: 19px;
  font-weight: 700;
}
.tp-note-close{
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4b5563;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
}
.tp-note-close:hover,
.tp-note-close:focus-visible{
  background: rgba(17,24,39,0.08);
  outline: none;
}
.tp-note-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 24px;
}
.tp-note-overlay.is-empty .tp-note-body{
  overflow: hidden;
}
.tp-note-empty{
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #111827;
}
.tp-note-empty[hidden]{
  display: none;
}
.tp-note-empty-icon{
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--accent, #22c55e);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}
.tp-note-empty-icon svg{
  width: 36px;
  height: 36px;
}
.tp-note-empty h3{
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.2;
}
.tp-note-empty p{
  margin: 0;
  color: #6b7280;
  font-size: 17px;
}
.tp-note-list{
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tp-note-card{
  border: 1px solid rgba(17,24,39,0.14);
  border-left: 5px solid var(--accent, #22c55e);
  border-radius: 8px;
  padding: 16px 18px;
  background: #fff;
}
.tp-note-card.is-editing{
  border-color: var(--accent-border, rgba(34,197,94,.35));
  background: color-mix(in srgb, var(--accent-soft, rgba(34,197,94,.12)) 36%, #fff 64%);
}
.tp-note-card-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.tp-note-card-meta{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: #6b7280;
  font-size: 15px;
  font-weight: 700;
}
.tp-note-card-time{
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
}
.tp-note-card-kind{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent, #22c55e);
}
.tp-note-card-kind svg,
.tp-note-card-action svg{
  width: 20px;
  height: 20px;
}
.tp-note-card-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.tp-note-card-action{
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tp-note-card-action:hover,
.tp-note-card-action:focus-visible{
  color: #111827;
  background: rgba(17,24,39,0.08);
  outline: none;
}
.tp-note-card-action[data-tp="note-delete"]{
  background: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
}
.tp-note-card-action[data-tp="note-delete"]:hover,
.tp-note-card-action[data-tp="note-delete"]:focus-visible{
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
}
.tp-note-card-text{
  margin: 0;
  color: #111827;
  font-size: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tp-note-card-editor{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tp-note-card-edit-input{
  width: 100%;
  min-height: 102px;
  resize: vertical;
  border: 1px solid rgba(17,24,39,0.14);
  border-radius: 8px;
  padding: 14px 16px;
  color: #111827;
  font: inherit;
  font-size: 18px;
  line-height: 1.4;
  outline: none;
  background: #fff;
}
.tp-note-card-edit-input:focus{
  border-color: var(--accent, #22c55e);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(34,197,94,.12));
}
.tp-note-card-edit-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.tp-note-card-edit-counter{
  color: #6b7280;
  font-size: 16px;
}
.tp-note-card-edit-actions{
  display: flex;
  align-items: center;
  gap: 10px;
}
.tp-note-card-edit-btn{
  border: 0;
  border-radius: 8px;
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  color: #111827;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.tp-note-card-edit-btn:hover,
.tp-note-card-edit-btn:focus-visible{
  background: rgba(17,24,39,0.08);
  outline: none;
}
.tp-note-card-edit-btn.is-primary{
  background: var(--accent, #22c55e);
  color: #fff;
  box-shadow: 0 6px 16px var(--accent-shadow, rgba(34,197,94,.25));
}
.tp-note-card-edit-btn.is-primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}
.tp-note-card-edit-btn:disabled{
  cursor: not-allowed;
  opacity: .5;
  box-shadow: none;
}
.tp-note-composer{
  flex: 0 0 auto;
  border-top: 1px solid rgba(17,24,39,0.12);
  padding: 16px 24px 16px;
  background: #fff;
}
.tp-note-composer textarea{
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid rgba(17,24,39,0.16);
  border-radius: 8px;
  padding: 14px 16px;
  color: #111827;
  font: inherit;
  font-size: 18px;
  line-height: 1.35;
  outline: none;
}
.tp-note-composer textarea:focus{
  border-color: var(--accent, #22c55e);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(34,197,94,.12));
}
.tp-note-composer-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}
.tp-note-counter{
  color: #6b7280;
  font-size: 16px;
}
.tp-note-actions{
  display: flex;
  align-items: center;
  gap: 14px;
}
.tp-note-secondary,
.tp-note-save{
  border: 0;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.tp-note-secondary{
  background: transparent;
  color: #111827;
}
.tp-note-secondary:hover,
.tp-note-secondary:focus-visible{
  background: rgba(17,24,39,0.08);
  outline: none;
}
.tp-note-save{
  background: var(--accent, #22c55e);
  color: #fff;
  box-shadow: 0 6px 16px var(--accent-shadow, rgba(34,197,94,.25));
}
.tp-note-save:not(:disabled) {
  color: var(--tp-control-on-accent);
}
.tp-note-save:disabled{
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

/* Review Notes tab */
body[data-active="mistakes"] .review-note-item{
  padding: 28px 32px;
}
body[data-active="mistakes"] .review-note-item-shell{
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
}
body[data-active="mistakes"] .review-note-item-shell .mistake-toprow{
  min-width: 0;
}
body[data-active="mistakes"] .review-note-meta{
  position: static;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  text-align: left;
  padding-right: 38px;
  margin-top: 10px;
}
body[data-active="mistakes"] .review-note-record-delete{
  top: auto;
  right: 0;
  bottom: 0;
  transform: scale(.96);
}
body[data-active="mistakes"] .review-note-item:hover .review-note-record-delete{
  opacity: 0;
  pointer-events: none;
  transform: scale(.96);
}
body[data-active="mistakes"] .review-note-item-shell:hover .review-note-record-delete,
body[data-active="mistakes"] .review-note-item .review-note-record-delete:focus-visible{
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
body[data-active="mistakes"] .review-note-entries{
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(17,24,39,0.08);
}
body[data-active="mistakes"] .review-note-entry{
  position: relative;
  border-left: 4px solid var(--accent, #22c55e);
  padding: 12px 0 22px 24px;
}
body[data-active="mistakes"] .review-note-entry + .review-note-entry{
  border-top: 1px solid rgba(17,24,39,0.08);
  padding-top: 22px;
}
body[data-active="mistakes"] .review-note-entry-meta{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-bottom: 14px;
  color: #6b7280;
  font-size: 16px;
  font-weight: 700;
}
body[data-active="mistakes"] .review-note-kind{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent, #22c55e);
}
body[data-active="mistakes"] .review-note-kind svg,
body[data-active="mistakes"] .review-note-action svg{
  width: 18px;
  height: 18px;
}
body[data-active="mistakes"] .review-note-actions{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
body[data-active="mistakes"] .review-note-entry:hover .review-note-actions,
body[data-active="mistakes"] .review-note-entry:focus-within .review-note-actions{
  opacity: 1;
  pointer-events: auto;
}
body[data-active="mistakes"] .review-note-item .review-note-action{
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid var(--tp-delete-border);
  border-radius: 12px;
  background: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
body[data-active="mistakes"] .review-note-item .review-note-action:not(:disabled):hover,
body[data-active="mistakes"] .review-note-item .review-note-action:not(:disabled):focus-visible{
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}
body[data-active="mistakes"] .review-note-action::after{
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  white-space: nowrap;
  background: #0b1220;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 3;
}
body[data-active="mistakes"] .review-note-action:hover::after,
body[data-active="mistakes"] .review-note-action:focus-visible::after{
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
body[data-active="mistakes"] .review-note-entry-text{
  color: #111827;
  font-size: 20px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
body[data-active="mistakes"] .review-note-time{
  display: inline-block;
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  white-space: nowrap;
  vertical-align: baseline;
}
body[data-active="mistakes"] .review-note-edit-input{
  width: 100%;
  min-height: 112px;
  border: 1px solid rgba(17,24,39,0.18);
  border-radius: 8px;
  padding: 12px 14px;
  font: inherit;
  font-size: 18px;
  line-height: 1.4;
  resize: vertical;
  outline: none;
}
body[data-active="mistakes"] .review-note-edit-input:focus{
  border-color: var(--accent, #22c55e);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(34,197,94,.12));
}
body[data-active="mistakes"] .review-note-edit-row{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
body[data-active="mistakes"] .review-note-edit-btn{
  border: 1px solid rgba(17,24,39,0.14);
  border-radius: 8px;
  background: #fff;
  color: #111827;
  min-height: 34px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
body[data-active="mistakes"] .review-note-edit-btn.is-primary{
  border-color: var(--accent, #22c55e);
  background: var(--accent, #22c55e);
  color: #fff;
}
body[data-active="mistakes"] .review-note-edit-btn.is-primary:not(:disabled) {
  color: var(--tp-control-on-accent);
}
@media (max-width: 720px){
  .tp-note-overlay{
    align-items: stretch;
    padding: 0;
  }
  .tp-note-dialog{
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .tp-note-header{
    height: 64px;
    padding: 0 20px;
  }
  .tp-note-header h2{
    font-size: 24px;
  }
  .tp-note-body{
    padding: 18px 16px 22px;
  }
  .tp-note-empty{
    min-height: 260px;
  }
  .tp-note-empty h3{
    font-size: 22px;
  }
  .tp-note-empty p{
    font-size: 17px;
  }
  .tp-note-composer{
    padding: 16px;
  }
  .tp-note-composer textarea{
    min-height: 92px;
    padding: 14px;
    font-size: 18px;
  }
  .tp-note-composer-row{
    align-items: flex-start;
  }
  .tp-note-actions{
    gap: 8px;
  }
  .tp-note-secondary,
  .tp-note-save{
    min-height: 40px;
    padding: 0 14px;
    font-size: 16px;
  }
  body[data-active="mistakes"] .review-note-item{
    padding: 22px 18px;
  }
  body[data-active="mistakes"] .review-note-item-shell{
    display: block;
    padding: 0;
  }
  body[data-active="mistakes"] .review-note-meta{
    position: static;
    max-width: 100%;
    justify-content: flex-start;
    text-align: left;
    margin-top: 10px;
    padding-right: 38px;
  }
  body[data-active="practice"] .tp-note-trigger{
    left: calc(100% + 4px);
  }
}

/* Shared action notifications, above practice captions and modal overlays. */
.tp-notice {
  position: fixed;
  z-index: 2147483647;
  top: max(24px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 12px;
  background: rgba(24, 32, 42, .96);
  color: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
  font: 500 14px/1.5 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
}
.tp-notice[hidden] { display: none; }
#summary-overlay .summary-dialog:focus { outline: none; }
#my-pack-list[hidden] { display: none; }

[data-tp="read-along-play"][hidden] { display: none; }

/* Read-along: stage controls and answer visibility. */
body[data-active="practice"] .practice-control-btn[hidden],
.read-along-stages[hidden], .read-along-settings-panel[hidden],
.read-along-prompt[hidden], :is(html.tp-embedded, html.tp-landing) .read-along-pause-hint[hidden], [data-tp="read-along-display-settings"][hidden] { display: none !important; }
:is(html.tp-embedded, html.tp-landing) .read-along-pause-hint {
  position: fixed;
  left: 50%;
  bottom: clamp(110px, 18vh, 180px);
  transform: translateX(-50%);
  z-index: 80;
  width: max-content;
  max-width: calc(100% - 40px);
  color: var(--accent);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.read-along-stages {
  position: relative;
  width: min(940px, calc(100% - 48px));
  margin: 12px auto 0;
  z-index: 15;
}
.read-along-stage-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.read-along-stage {
  position: relative;
  display: flex;
  border: 1px solid var(--practice-border-color);
  border-radius: 12px;
  background: var(--practice-hint-bg);
  color: var(--tp-text-main);
}
.read-along-stage.is-current { border-color: var(--accent); background: var(--accent-soft); }
.read-along-stage-main {
  display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0;
  padding: 12px 0 12px 14px; border: 0; border-radius: 12px; background: transparent;
  color: inherit; text-align: left; font: inherit; cursor: pointer;
}
.read-along-stage-name { font-size: 14px; font-weight: 600; }
.read-along-stage-summary, .read-along-stage-status { font-size: 12px; color: var(--tp-text-muted); }
.read-along-stage-status { min-height: 16px; }
.read-along-settings-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: center; width: 36px; height: 36px; margin: 4px;
  border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; font: inherit;
}
.read-along-settings-btn:hover, .read-along-stage-main:hover { background: var(--practice-soft-hover-bg); }
.read-along-settings-btn:disabled { opacity: .45; cursor: default; }
.read-along-stages button:focus-visible, .read-along-stages select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.read-along-settings-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 1; width: min(360px, 100%); box-sizing: border-box;
  padding: 14px; border: 1px solid var(--practice-border-color); border-radius: 12px;
  background: var(--practice-hint-bg); color: var(--tp-text-main); box-shadow: 0 12px 32px rgba(0,0,0,.15);
}
.read-along-settings-heading { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.read-along-settings-fields { display: flex; gap: 16px; }
.read-along-settings-fields label { display: flex; flex: 1; flex-direction: column; gap: 6px; font-size: 13px; }
.read-along-settings-fields select { padding: 8px; border: 1px solid var(--practice-border-color); border-radius: 8px; background: var(--practice-hint-bg); color: var(--tp-text-main); font: inherit; }
.read-along-settings-panel fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; padding: 12px 0 0; margin: 12px 0 0; border: 0; font-size: 13px; }
.read-along-settings-panel fieldset label { display: flex; align-items: center; gap: 6px; }
.read-along-settings-panel p { margin: 14px 0 0; font-size: 12px; color: var(--tp-text-muted); }
#input-view.tp-read-along-blind { position: relative; min-height: 180px; }
#input-view.tp-read-along-blind > :not(.read-along-prompt),
#input-view.tp-read-along-blind > :not(.read-along-prompt) * { visibility: hidden !important; pointer-events: none !important; }
.read-along-prompt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--tp-text-muted); font-size: 24px; text-align: center; white-space: nowrap; }
#input-view.tp-read-along-hide-english [data-tp="phrase"],
#input-view.tp-read-along-hide-pinyin [data-tp="slot-input"],
#input-view.tp-read-along-hide-hanzi [data-tp="hanzi-word"],
#input-view.tp-read-along-hide-hanzi [data-tp="punctuation"],
#input-view.tp-read-along-hide-meanings [data-tp="slot-word-meaning"] { visibility: hidden !important; pointer-events: none !important; }
@media (max-width: 600px) {
  .read-along-stages { width: calc(100% - 32px); }
  .read-along-stage-list { grid-template-columns: 1fr; gap: 6px; }
  .read-along-stage-main { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 9px 0 9px 12px; }
  .read-along-stage-name { font-size: 13px; }
  .read-along-stage-status { margin-left: auto; min-height: 0; }
  .read-along-prompt { font-size: 20px; }
}

@media (max-width: 820px) {
  html.tp-read-along-mode .tp-oskb,
  html.tp-read-along-mode .tp-oskb-show { display: none !important; }
  html.tp-read-along-mode.tp-oskb-on .bottombar { bottom: var(--tp-kb-bottom, 28px) !important; }
  html.tp-read-along-mode body[data-active="practice"] .main.has-inline-word-meanings { padding-bottom: calc(188px + env(safe-area-inset-bottom)) !important; }
}
@media (820px < width <= 860px) {
  html:where(:is(.tp-embedded, .tp-landing)).tp-read-along-mode .tp-oskb,
  html:where(:is(.tp-embedded, .tp-landing)).tp-read-along-mode .tp-oskb-show { display: none !important; }
  html:where(:is(.tp-embedded, .tp-landing)).tp-read-along-mode.tp-oskb-on .bottombar { bottom: var(--tp-kb-bottom, 28px) !important; }
  html:where(:is(.tp-embedded, .tp-landing)).tp-read-along-mode body[data-active="practice"] .main.has-inline-word-meanings { padding-bottom: calc(188px + env(safe-area-inset-bottom)) !important; }
}

/* Admin data cleanup shares delete colors without changing other danger UI. */
body[data-active="admin-courses"] button:is([data-tp="admin-user-data-delete-selected"], [data-tp="admin-user-data-delete-sync"], [data-tp="admin-user-data-delete-backend"]) {
  background: var(--tp-delete-bg);
  color: var(--tp-delete-fg);
  border-color: var(--tp-delete-border);
}
body[data-active="admin-courses"] button:is([data-tp="admin-user-data-delete-selected"], [data-tp="admin-user-data-delete-sync"], [data-tp="admin-user-data-delete-backend"]):hover {
  opacity: 1;
}
body[data-active="admin-courses"] button:is([data-tp="admin-user-data-delete-selected"], [data-tp="admin-user-data-delete-sync"], [data-tp="admin-user-data-delete-backend"]):not(:disabled):is(:hover, :focus-visible) {
  background: var(--tp-delete-hover-bg);
  color: var(--tp-delete-hover-fg);
  border-color: var(--tp-delete-hover-border);
}
