/* Wiki Insights — peach Q&A video navigator */

:root {
  --bg: var(--dx-bg);
  --bg-soft: var(--dx-card-solid);
  --bg-raised: var(--dx-card);
  --border: var(--dx-border);
  --text: var(--dx-text);
  --text-dim: var(--dx-muted);
  --text-mute: var(--dx-muted);
  --peach: var(--dx-accent);
  --peach-soft: var(--dx-card);
  --peach-q: var(--dx-card);
  --accent: var(--dx-accent);
  --accent-soft: var(--dx-accent-soft);
  --success: #1d7d51;
  --success-soft: #e6f6ed;
  --watching: #b94d36;
  --watching-soft: #fff0ed;
  --shadow: var(--dx-shadow);
  --radius: var(--dx-radius);
  --font: var(--dx-font);
  --max: 960px;
}

html.dark {
  --bg: var(--dx-bg);
  --bg-soft: var(--dx-card-solid);
  --bg-raised: var(--dx-card);
  --border: var(--dx-border);
  --text: var(--dx-text);
  --text-dim: var(--dx-muted);
  --text-mute: var(--dx-muted);
  --peach: var(--dx-accent);
  --peach-soft: var(--dx-card);
  --peach-q: var(--dx-card);
  --accent: var(--dx-accent);
  --accent-soft: var(--dx-accent-soft);
  --success: #65d19a;
  --success-soft: rgba(62, 174, 113, 0.16);
  --watching: #ff9987;
  --watching-soft: rgba(255, 112, 87, 0.14);
  --shadow: var(--dx-shadow);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  background-image: none;
  color: var(--dx-text);
  font-family: var(--dx-font);
  -webkit-font-smoothing: antialiased;
}
html { background-color: var(--dx-bg); }
body.dx { overflow-x: clip; padding-bottom: env(safe-area-inset-bottom); }

#app {
  max-width: min(var(--max), 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--dx-text);
  color: var(--dx-bg);
  padding: 0.65rem 0.85rem;
  min-height: 44px;
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }

#topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  min-width: 0;
  padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--dx-header);
  backdrop-filter: blur(var(--dx-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--dx-blur)) saturate(1.4);
  border-bottom: 1px solid var(--dx-border);
  color: var(--dx-text);
}
#topbar-title {
  flex: 1;
  margin: 0;
  min-width: 0;
  font-family: var(--dx-font);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--dx-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#topbar-title.hidden { display: none; }

#topbar .dong-theme-toggle {
  position: static;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
#topbar .dong-theme-toggle__track {
  width: 44px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-raised) 88%, transparent);
  box-shadow: 0 1px 8px rgba(20, 18, 12, 0.08);
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); }
.hidden { display: none !important; }

#tab-toggle {
  display: flex;
  flex: 1;
  min-width: 0;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
#tab-toggle .seg {
  border: none;
  background: transparent;
  color: var(--text-mute);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  flex: 1;
  min-height: 44px;
  min-width: 0;
  white-space: nowrap;
}
#tab-toggle .seg.active {
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
/* Three segments plus back and theme buttons get tight on small phones. */
@media (max-width: 400px) {
  #tab-toggle .seg { font-size: 0.74rem; padding: 0.4rem 0.2rem; }
}

#view-root {
  flex: 1;
  width: 100%;
  padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom));
}
#view-root.is-detail {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 5.5rem;
}
#loading, .empty {
  padding: 2rem 0.5rem;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  text-align: center;
}

.sr-only {
  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;
}

/* Primary navigation */
#tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, var(--max));
  transform: translateX(-50%);
  border-top: 1px solid var(--dx-border);
  background: var(--dx-header);
  box-shadow: 0 -8px 24px rgba(20, 18, 12, 0.06);
  backdrop-filter: blur(16px);
  padding: 0.25rem 0.5rem env(safe-area-inset-bottom);
}
.nav-tab {
  position: relative;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.15rem;
  border: 0;
  background: transparent;
  color: var(--text-mute);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 650;
  cursor: pointer;
}
.nav-tab::before {
  content: "";
  position: absolute;
  top: -0.25rem;
  width: 2rem;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.nav-tab.active {
  color: var(--accent);
}
.nav-tab.active::before {
  opacity: 1;
  transform: scaleX(1);
}
.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Dashboard foundations */
.eyebrow {
  display: block;
  color: var(--text-mute);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.learning-hero,
.level-card,
.progress-overview {
  border: 1px solid var(--dx-border);
  border-radius: var(--dx-radius);
  background: var(--dx-card);
  box-shadow: var(--dx-shadow);
  color: var(--dx-text);
}
.learning-hero {
  padding: 1.2rem;
  margin-bottom: 0.75rem;
}
.hero-topline,
.section-heading,
.browse-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.hero-xp {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}
.learning-hero h2,
.section-heading h2,
.milestone-card h2,
.next-badge h2,
.level-card h2 {
  margin: 0;
  color: var(--text);
  letter-spacing: -0.025em;
}
.learning-hero h2 {
  margin: 0.35rem 0 0.85rem;
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
}
.progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 75%, var(--bg-soft));
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transform-origin: left center;
  animation: progress-draw 0.45s ease-out both;
}
@keyframes progress-draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.status-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 1rem;
}
.status-stats button,
.progress-stat-grid > * {
  min-width: 0;
  min-height: 62px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-soft) 82%, transparent);
  color: var(--text);
  font: inherit;
  text-align: center;
}
.status-stats button {
  cursor: pointer;
}
.status-stats strong,
.progress-stat-grid strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.1;
}
.status-stats span,
.progress-stat-grid span {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-mute);
  font-size: 0.68rem;
  font-weight: 600;
}
.primary-action {
  display: flex;
  width: 100%;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--dx-accent);
  box-shadow: var(--dx-shadow);
  color: var(--dx-accent-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.primary-action small {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  font-weight: 650;
  opacity: 0.85;
}
.primary-action strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.primary-arrow {
  flex-shrink: 0;
  font-size: 1.4rem;
}
.home-section {
  margin: 0 0 1.6rem;
}
.section-heading {
  margin: 0 0 0.7rem;
}
.section-heading h2 {
  margin-top: 0.15rem;
  font-size: 1.08rem;
}
.text-action,
.back-link {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}
.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
}
.video-grid .video-card { margin-bottom: 0; }

/* Categories */
.category-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
}
.category-row {
  display: flex;
  width: 100%;
  min-height: 70px;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  padding: 0.75rem 0.85rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.category-row:hover {
  border-color: color-mix(in srgb, var(--peach) 65%, var(--border));
  box-shadow: var(--shadow);
}
.category-row:active { transform: scale(0.99); }
.category-row:disabled,
.category-row.is-empty {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}
.category-icon {
  width: 14px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--section-color);
}
.category-icon.all-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 800;
}
.category-row-main {
  min-width: 0;
  flex: 1;
}
.category-row-title,
.category-row-count {
  display: block;
}
.category-row-title {
  margin-bottom: 0.15rem;
  font-size: 0.9rem;
  font-weight: 700;
}
.category-row-count {
  margin-bottom: 0.4rem;
  color: var(--text-mute);
  font-size: 0.7rem;
}
.category-row .progress-track { height: 4px; }
.category-chevron {
  flex-shrink: 0;
  color: var(--text-mute);
  font-size: 1.35rem;
}
.milestone-card,
.next-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--dx-border);
  border-radius: var(--dx-radius);
  background: var(--dx-card);
  color: var(--dx-text);
  padding: 0.9rem;
}
.milestone-card > div:nth-child(2),
.next-badge > div { min-width: 0; flex: 1; }
.milestone-card h2,
.next-badge h2 { margin-top: 0.15rem; font-size: 0.95rem; }
.milestone-card p,
.next-badge p {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.76rem;
}
.milestone-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 850;
  box-shadow: 0 4px 14px rgba(20, 18, 12, 0.08);
}
.milestone-card > button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

/* Catalog */
.search-wrap { margin-bottom: 0.55rem; }
#search, #url-input, #browse-search {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
#search:focus, #url-input:focus, #browse-search:focus { border-color: var(--peach); }
.browse-tools {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.search-field {
  position: relative;
  margin-bottom: 0.65rem;
}
.search-field > span {
  position: absolute;
  top: 50%;
  left: 0.95rem;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-size: 1.1rem;
  pointer-events: none;
}
#browse-search {
  min-height: 48px;
  padding-left: 2.5rem;
  background: var(--bg-soft);
}
.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}
.filter-chip {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
}
.filter-chip span {
  min-width: 1.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 72%, transparent);
  padding: 0.12rem 0.35rem;
  font-size: 0.65rem;
  text-align: center;
}
.filter-chip.active,
html.dark .filter-chip.active {
  border-color: var(--dx-accent);
  background: var(--dx-accent);
  color: var(--dx-accent-fg);
}
.filter-chip.active span {
  background: hsl(0 0% 0% / 0.28);
  color: var(--dx-accent-fg);
}
.add-video {
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
}
.add-video summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.add-video summary::-webkit-details-marker { display: none; }
.add-video summary::before {
  content: "+";
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.add-video[open] summary { margin-bottom: 0.45rem; }
.url-bar {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0;
}
.url-bar #url-input { flex: 1; }
.url-go {
  border: none;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 0 1rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
html.dark .url-go { background: var(--peach); color: #1a1208; }
.browse-result-head {
  min-height: 48px;
  margin-bottom: 0.65rem;
}
.result-label {
  margin: 0;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  font-size: 0.82rem;
  font-weight: 650;
}
.back-link {
  min-height: 44px;
  padding: 0;
}
.sub-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  font-size: 0.72rem;
  font-weight: 700;
}
.sort-label {
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
}
.sub-filter select,
.sort-label select {
  color: var(--dx-text);
  text-shadow: none;
  background: var(--dx-card);
}
.sub-filter select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0.35rem 1.7rem 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
}
.sort-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  font-size: 0.7rem;
  white-space: nowrap;
}
.sort-label select {
  min-height: 44px;
  max-width: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0.35rem 1.7rem 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
}
.catalog-meta {
  font-size: 0.8rem;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  margin: 0 0 0.75rem;
}
.video-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.video-card-actions .kw-row {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}
.complete-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--success) 45%, var(--border));
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.complete-btn:hover {
  border-color: var(--success);
}
.kw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.video-card-body > .kw-row {
  margin-top: 0.5rem;
}
.kw-chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  min-height: 44px;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}
.kw-chip:hover {
  background: var(--peach-soft);
  border-color: color-mix(in srgb, var(--peach) 50%, var(--border));
  color: var(--text);
}
.badge-local {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #9a5b1a;
  background: var(--peach-soft);
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  vertical-align: middle;
}
html.dark .badge-local { color: #f0c48a; }
.muted { color: var(--text-mute); font-size: 0.85rem; }
code {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg-soft);
  border-radius: 8px;
  font-size: 0.78rem;
  text-align: left;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.video-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--dx-card);
  border: 1px solid var(--dx-border);
  border-radius: var(--dx-radius);
  color: var(--dx-text);
  padding: 0.9rem 1rem;
  margin-bottom: 0.55rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.video-card:hover {
  border-color: color-mix(in srgb, var(--peach) 60%, var(--border));
  box-shadow: var(--shadow);
}
.video-card:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--peach) 80%, var(--text));
  outline-offset: 2px;
}
.video-card-top {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}
.video-card-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 128px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-soft);
}
.video-card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-card-thumb-empty {
  background: linear-gradient(135deg, var(--bg-soft), var(--border));
}
.video-card-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.45);
}
.video-card-progress span {
  display: block;
  height: 100%;
  background: #ff4d4d;
}
.video-card-progress.is-done span {
  background: #3dbe7a;
}
.video-card-status {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: rgba(20, 18, 12, 0.78);
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  line-height: 1.2;
}
.video-card-status.is-watch {
  background: rgba(20, 18, 12, 0.72);
}
.video-card-watch {
  font-weight: 650;
}
.video-card-watch.is-watch { color: #d4533c; }
.video-card-watch.is-done { color: #2f9d63; }
html.dark .video-card-watch.is-watch { color: #ff8a78; }
html.dark .video-card-watch.is-done { color: #5ed392; }
.video-card-body { min-width: 0; flex: 1; }
.video-card-title {
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.35;
  margin: 0 0 0.35rem;
}
.video-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-mute);
}
.video-card-labels {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.watch-status,
.category-pill,
.content-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  font-size: 0.65rem;
  font-weight: 750;
  line-height: 1.1;
}
.watch-status.not-started {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-mute);
}
.watch-status.in-progress {
  background: var(--watching-soft);
  color: var(--watching);
}
.watch-status.completed {
  background: var(--success-soft);
  color: var(--success);
}
.category-pill {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  font-weight: 650;
}
.category-dot {
  width: 7px;
  height: 7px;
  margin-right: 0.32rem;
  border-radius: 50%;
  background: var(--section-color);
}
.content-badge {
  background: var(--accent-soft);
  color: var(--accent);
}
.video-card.is-compact .video-card-labels {
  margin-top: 0.4rem;
}
.video-card.is-compact .category-pill,
.video-card.is-compact .content-badge {
  display: none;
}
.detail-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.55rem 0 0.75rem;
}

/* Progress and achievements */
.level-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.level-orb {
  display: grid;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  place-items: center;
  border: 5px solid var(--peach);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 850;
  box-shadow: 0 5px 18px rgba(20,18,12,0.09);
}
.level-main {
  min-width: 0;
  flex: 1;
}
.level-main h2 {
  margin-top: 0.1rem;
  font-size: 1.1rem;
}
.level-main p {
  margin: 0.2rem 0 0.55rem;
  color: var(--text-mute);
  font-size: 0.7rem;
}
.level-card > strong {
  align-self: flex-start;
  color: var(--accent);
  font-size: 0.75rem;
  white-space: nowrap;
}
.progress-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}
.progress-stat-grid > * {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0.5rem;
}
.progress-stat-grid button {
  cursor: pointer;
}
.progress-overview {
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-raised);
  box-shadow: none;
}
.progress-overview .section-heading > strong {
  color: var(--accent);
  font-size: 0.85rem;
}
.progress-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.progress-metrics strong,
.progress-metrics span {
  display: block;
}
.progress-metrics strong { font-size: 1rem; }
.progress-metrics span {
  margin-top: 0.18rem;
  color: var(--text-mute);
  font-size: 0.65rem;
  line-height: 1.3;
}
.next-badge {
  margin-bottom: 1.5rem;
}
.achievement-total {
  color: var(--text-mute);
  font-size: 0.78rem;
  font-weight: 700;
}
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}
.achievement-card {
  min-height: 166px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 0.8rem;
}
.achievement-card.locked {
  opacity: 0.58;
  filter: saturate(0.5);
}
.achievement-card.unlocked {
  border-color: color-mix(in srgb, var(--peach) 75%, var(--border));
  background: linear-gradient(155deg, var(--accent-soft), var(--bg-raised) 68%);
}
.achievement-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 0.65rem;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 850;
}
.achievement-card.unlocked .achievement-icon {
  background: var(--peach);
  color: #3a210d;
}
.achievement-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
}
.achievement-card p {
  min-height: 2.4em;
  margin: 0 0 0.65rem;
  color: var(--text-mute);
  font-size: 0.68rem;
  line-height: 1.35;
}
.achievement-card > span {
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 750;
}
.local-note {
  margin: 1.25rem 0 0;
  color: var(--text-mute);
  font-size: 0.72rem;
  text-align: center;
}
.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  border: 1px dashed var(--dx-border);
  border-radius: var(--dx-radius);
  background: var(--dx-card);
  color: var(--dx-muted);
  text-align: center;
}
.empty-state > div {
  font-size: 1.6rem;
}
.empty-state h2 {
  margin: 0.6rem 0 0.25rem;
  color: var(--dx-text);
  font-size: 1rem;
}
.empty-state p {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
}
.secondary-action {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Concepts panel — links out to Wiki Flashcards */
.study-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--peach) 55%, var(--border));
  background: var(--peach-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}
.study-cta:active { opacity: 0.85; }
.concept-grid { display: flex; flex-direction: column; gap: 0.45rem; }
.concept-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  overflow: hidden;
}
.concept-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  text-decoration: none;
}
.concept-card .concept-chip {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.concept-chip:hover { border-color: color-mix(in srgb, var(--peach) 60%, var(--border)); }
.concept-chip:active { opacity: 0.85; }
.concept-emoji { font-size: 1.1rem; flex-shrink: 0; line-height: 1; }
.concept-name { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.concept-md {
  padding: 0 0.8rem 0.15rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}
.concept-md.is-clamped {
  position: relative;
  max-height: 7.6rem;
  overflow: hidden;
}
.concept-md.is-clamped::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.75rem;
  background: linear-gradient(transparent, var(--bg-raised));
  pointer-events: none;
}
.concept-md p { margin: 0 0 0.6rem; }
.concept-md ul { margin: 0.15rem 0 0.7rem; padding-left: 1.15rem; }
.concept-md li { margin: 0.22rem 0; }
.concept-md strong { color: var(--text); font-weight: 700; }
.concept-md code {
  font-size: 0.84em;
  padding: 0.05em 0.25em;
  border-radius: 4px;
  background: var(--bg-soft);
}
.md-table-wrap {
  overflow-x: auto;
  margin: 0.2rem 0 0.75rem;
  -webkit-overflow-scrolling: touch;
}
.concept-md table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.8rem;
  line-height: 1.4;
}
.concept-md th,
.concept-md td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.concept-md th {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 700;
}
.show-more {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0 0.8rem 0.2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
/* Detail */
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-bottom: 0.65rem;
}
.player-wrap iframe,
.player-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}
.resume-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: -0.2rem 0 0.75rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.resume-bar #bili-scrub {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
}
.resume-bar #restart-video {
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.resume-bar #restart-video:hover { color: var(--peach); }
.detail-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
  line-height: 1.4;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.35rem 0 0.75rem;
  letter-spacing: -0.02em;
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
}
.qa-section { margin: 0.15rem 0 0.35rem; }
.qa-section-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}
.qa-section-summary::-webkit-details-marker { display: none; }
.qa-section-summary::marker { content: ""; }
.qa-section-summary .section-title { flex: 1; margin: 0; }
.fold-chevron {
  flex-shrink: 0;
  color: var(--text-mute);
  font-weight: 700;
  line-height: 1;
}
.fold-chevron::before { content: "▸"; }
.qa-section[open] > .qa-section-summary .fold-chevron::before { content: "▾"; }
.qa-section-body { margin-top: 0.7rem; }
.qa-block { margin-bottom: 0.85rem; }
.qa-q {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  width: 100%;
  border: 0;
  background: var(--dx-card);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 0.45rem;
  color: var(--dx-text);
  text-shadow: none;
  text-align: left;
  cursor: pointer;
}
.qa-q .emoji { flex-shrink: 0; }
.qa-q-text { min-width: 0; }
.qa-tag {
  margin-right: 0.28rem;
  font-weight: 800;
  color: var(--text);
}
.qa-hint {
  display: block;
  margin-top: 0.12rem;
  color: var(--text-mute);
  font-size: 0.72rem;
  font-weight: 650;
}
.qa-q[aria-expanded="true"] .qa-hint { display: none; }
.qa-a {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-dim);
  padding: 0.15rem 0.15rem 0.35rem;
}
.qa-a .label, .qa-q .label { font-weight: 700; color: var(--text); }

mark.hl {
  background: var(--peach-soft);
  color: inherit;
  padding: 0.05em 0.15em;
  border-radius: 3px;
}

.summary-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
}
.summary-body p { margin: 0 0 0.85rem; }
.key-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.5;
}
.key-list li { margin-bottom: 0.45rem; }

.missing-insights {
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-mute);
  text-align: center;
}

.agent-marker {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 750;
  line-height: 1.2;
  vertical-align: middle;
  white-space: nowrap;
}
.video-card-labels .agent-marker {
  margin-left: 0;
  min-height: 24px;
  padding: 0.16rem 0.48rem;
}
.agent-block { margin-top: 0.35rem; }
.agent-entry {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.agent-entry p { margin: 0.25rem 0; }
.agent-title { font-weight: 700; color: var(--text); }
.agent-meta {
  margin-top: 0;
  color: var(--text-mute);
  font-size: 0.72rem;
}
.agent-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-top: 0.45rem;
}
.agent-links a {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
}
.agent-fold-summary,
.agent-note > summary {
  cursor: pointer;
  list-style: none;
}
.agent-fold-summary::-webkit-details-marker,
.agent-note > summary::-webkit-details-marker { display: none; }
.agent-fold-summary::marker,
.agent-note > summary::marker { content: ""; }
.agent-fold-summary {
  display: block;
  min-height: 44px;
  padding: 0.2rem 0;
}
.agent-fold-summary h2 {
  margin: 0.15rem 0 0;
  color: var(--text);
  font-size: 1.08rem;
  letter-spacing: -0.025em;
}
.agent-chevron {
  display: inline-block;
  color: var(--text-mute);
  font-weight: 700;
}
.agent-chevron::before { content: "▸"; }
.agent-fold[open] > .agent-fold-summary .agent-chevron::before,
.agent-note[open] > summary .agent-chevron::before { content: "▾"; }
.agent-fold-body { margin-top: 0.7rem; }
.agent-note > summary {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-height: 44px;
}
.agent-note-label {
  flex: 1;
  min-width: 0;
}
.agent-note > summary .agent-chevron {
  flex-shrink: 0;
  line-height: 1.35;
}
.agent-note-body { margin-top: 0.2rem; }

/* FAB */
.fab {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 0.35rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  z-index: 30;
}
.fab-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.fab-btn:hover { background: var(--bg-soft); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(4.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

button:focus-visible,
summary:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--peach) 80%, var(--text));
  outline-offset: 2px;
}

@media (min-width: 720px) {
  #view-root {
    padding: 1.25rem 1.5rem calc(6.25rem + env(safe-area-inset-bottom));
  }
  .video-grid,
  .category-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .achievement-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .learning-hero,
  .level-card,
  .progress-overview {
    padding: 1.25rem;
  }
}

@media (max-width: 520px) {
  #view-root {
    padding-inline: 0.75rem;
  }
  .video-card {
    padding: 0.75rem;
  }
  .video-card-top {
    gap: 0.6rem;
  }
  .video-card-thumb-wrap {
    width: 112px;
    height: 63px;
  }
  .video-card-title {
    font-size: 0.86rem;
  }
  .video-card-meta {
    gap: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }
  .video-card-labels {
    margin-left: calc(-112px - 0.6rem);
    padding-top: 0.5rem;
  }
  .video-card.is-compact .video-card-labels {
    margin-left: 0;
    padding-top: 0;
  }
  .browse-result-head {
    align-items: flex-end;
  }
  .sort-label {
    align-items: flex-end;
    flex-direction: column;
  }
  .sort-label select {
    max-width: 136px;
  }
  .level-card {
    align-items: flex-start;
  }
  .level-orb {
    width: 50px;
    height: 50px;
  }
  .level-card > strong {
    display: none;
  }
}

@media (max-width: 360px) {
  .status-stats {
    gap: 0.3rem;
  }
  .status-stats button {
    padding-inline: 0.2rem;
  }
  .status-stats span {
    font-size: 0.61rem;
  }
  .progress-stat-grid {
    gap: 0.35rem;
  }
  .progress-stat-grid span {
    font-size: 0.6rem;
  }
  .achievement-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.home-section > .section-heading,
.home-section > .section-heading h2,
.home-section > .section-heading .eyebrow,
.home-section > .section-heading .text-action,
.home-section > .section-heading .achievement-total,
.local-note {
  color: var(--dx-on-bg);
  text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85), 0 0 12px hsl(0 0% 0% / 0.6);
}
.dx-actions { min-width: 0; }
#tab-toggle { min-width: 0; }

.badge-new { background: #e8f5e9; color: #1b5e20; }
html.dark .badge-new { background: #1f3a24; color: #9be3a5; }
