
/* ─── CABINET COLLAPSIBLE BLOCKS ─────────────────────────── */
.cabinet-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 15px;
}

.cab-block {
  background: var(--surface1);
  border: 1px solid var(--border2);
  border-radius: 18px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cab-block.expanded {
  border-color: var(--blue-alpha);
  box-shadow: 0 8px 24px var(--blue-alpha);
}

.cab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.cab-header:hover {
  background: var(--surface2);
}

.cab-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink1);
}

.cab-icon {
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--surface2);
  border-radius: 8px;
}

.cab-chevron {
  font-size: 10px;
  color: var(--ink3);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cab-block.expanded .cab-chevron {
  transform: rotate(180deg);
}

.cab-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--surface1);
}

.cab-block.expanded .cab-content {
  max-height: 1000px;
}

.cab-inner {
  padding: 18px;
  border-top: 1px solid var(--border2);
}

/* Segmented Control for theme */
.cab-segmented-control {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.cab-seg-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cab-seg-btn:hover {
  background: var(--surface3);
  color: var(--ink1);
}

.cab-seg-btn.active {
  background: var(--surface1);
  color: var(--blue);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Language selector grid */
.cab-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.cab-lang-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink2);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.cab-lang-btn:hover {
  border-color: var(--blue-alpha);
  background: var(--surface3);
}

.cab-lang-btn.active {
  border-color: var(--blue);
  background: var(--blue-alpha);
  color: var(--blue);
}

/* ─── MOBILE MORE MENU BOTTOM SHEET ──────────────────────── */
.mobile-more-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.mobile-more-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-more-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
  z-index: 2600;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

.mobile-more-sheet.active {
  transform: translateY(0);
}

.mobile-more-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.mobile-more-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.mobile-more-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink2);
}

.mobile-more-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-more-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface2);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.mobile-more-item:hover, .mobile-more-item:active {
  background: var(--surface3);
  border-color: var(--border2);
  transform: scale(0.98);
}

.mitem-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

/* Custom background for item icons to look premium */
.mitem-map .mitem-icon {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.mitem-lists .mitem-icon {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.mitem-test .mitem-icon {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.mitem-texts .mitem-icon {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.mitem-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.mitem-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.mitem-desc {
  font-size: 12px;
  color: var(--ink3);
  margin-top: 2px;
}

/* ── MAP SEARCH CONTAINER & FLOATING POPUP ── */
.map-search-container {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

.map-search-wrap {
  position: relative;
  width: 100%;
  height: 52px;
}

.map-search-wrap input {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  border: 1.5px solid var(--border2);
  background: var(--surface2);
  color: var(--ink);
  padding: 0 44px 0 52px;
  font-size: 16px;
  font-weight: 700;
  box-sizing: border-box;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.01), 0 2px 8px rgba(0,0,0,0.02);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-search-wrap input:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--blue-alpha), 0 4px 12px rgba(30, 80, 255, 0.05);
}

.map-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%) scale(1.15);
  pointer-events: none;
  opacity: 0.6;
  font-size: 18px;
}

#map-search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface3);
  border: none;
  color: var(--ink2);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#map-search-clear:hover {
  background: var(--border);
  color: var(--ink);
}

.map-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  box-sizing: border-box;
}

.map-search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--ink3);
  font-size: 14px;
  font-weight: 600;
}

.map-search-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  gap: 12px;
}

.map-search-item:hover, .map-search-item:active {
  background: var(--surface2);
}

.map-search-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-search-dot.status-none {
  background: var(--border2);
}
.map-search-dot.status-confident {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-alpha);
}
.map-search-dot.status-green {
  background: var(--green);
}
.map-search-dot.status-amber {
  background: var(--amber);
}
.map-search-dot.status-red {
  background: var(--red);
}

.map-search-word-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
}

.map-search-hz {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.map-search-py {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
}

.map-search-translation-col {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-search-hsk-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
}

.badge-l1 { background: rgba(37, 99, 235, 0.1); color: rgb(37, 99, 235); }
.badge-l2 { background: rgba(8, 145, 178, 0.1); color: rgb(8, 145, 178); }
.badge-l3 { background: rgba(124, 58, 237, 0.1); color: rgb(124, 58, 237); }
.badge-l4 { background: rgba(217, 119, 6, 0.1); color: rgb(217, 119, 6); }
.badge-l5 { background: rgba(220, 38, 38, 0.1); color: rgb(220, 38, 38); }
.badge-l6 { background: rgba(107, 114, 128, 0.1); color: rgb(107, 114, 128); }
.badge-l7 { background: rgba(28, 25, 23, 0.1); color: rgb(28, 25, 23); }

/* ── MOBILE OVERRIDES FOR MAP & TILES ── */
@media(max-width:700px) {
  /* Make HSK Level Headers massive and super easy to tap */
  .msec-head {
    padding: 18px 20px !important;
    gap: 12px !important;
  }

  .msec-title {
    font-size: 16px !important;
    font-weight: 800 !important;
  }

  .msec-chevron {
    font-size: 16px !important;
  }

  .msec-right {
    font-size: 13px !important;
    font-weight: 600 !important;
  }

  /* Wrap the color index legend inside a clean widget / small bar for readability */
  .map-legend {
    background: var(--surface2) !important;
    border: 1px solid var(--border2) !important;
    border-radius: 12px !important;
    padding: 10px 14px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.01), 0 1px 3px rgba(0,0,0,0.02) !important;
  }

  .map-leg {
    font-size: 11.5px !important;
    font-weight: 700 !important;
    color: var(--ink2) !important;
  }

  /* Make map tiles a perfect balanced CSS Grid with no hanging words */
  .mgrid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)) !important;
    gap: 6px !important;
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    padding: 0 16px !important;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, padding 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .msec-open .mgrid {
    max-height: 60vh !important;
    opacity: 1 !important;
    overflow-y: auto !important;
    padding: 14px 16px !important;
  }

  /* Position map search inside header-top Row 2 on mobile map screen */
  .header-top .map-search-container {
    grid-column: 1 / span 4 !important;
    grid-row: 2 !important;
    width: 100% !important;
    height: 48px !important;
    margin-bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    padding: 0 4px !important;
    margin-top: -2px !important;
    position: relative !important;
  }

  .header-top .map-search-wrap {
    width: 100% !important;
    height: 38px !important;
  }

  .header-top .map-search-wrap input {
    height: 100% !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    padding: 0 36px 0 42px !important;
  }

  .header-top .map-search-icon {
    left: 14px !important;
    font-size: 14px !important;
  }

  .header-top #map-search-clear {
    right: 10px !important;
    width: 22px !important;
    height: 22px !important;
    font-size: 14px !important;
  }

  .header-top .map-search-results {
    top: calc(100% + 4px) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
    border-radius: 14px !important;
  }

  .mtile {
    font-size: 15px !important;
    padding: 8px 10px !important;
    border-radius: 8px !important;
    min-width: 0 !important;
    min-height: 38px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03) !important;
  }

  .mtile:active {
  transform: scale(0.95) !important;
  }

  /* Brandbook styles for HSK Random Cards */
  .u-btn-brand-gray {
    background: #F4F6FA !important;
    color: #1C1917 !important;
    transition: all 0.2s !important;
  }
  :root:not([data-theme="light"]) .u-btn-brand-gray {
    background: var(--surface3) !important;
    color: var(--ink) !important;
  }
  .u-btn-brand-blue {
    background: #1E50FF !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 14px rgba(30, 80, 255, 0.25) !important;
    transition: all 0.2s !important;
  }
  .u-btn-brand-blue:active {
    background: #1644D9 !important;
  }
  .u-btn:active {
    transform: scale(0.96) !important;
  }

  /* Show global search card only on mobile */
  .global-search-card {
    display: block !important;
  }

  .mobile-progress-widget {
    display: flex !important;
  }

  .desktop-progress-widget {
    display: none !important;
  }

  /* ─── COHESIVE MOBILE BOUNDS & UNIFIED BACKGROUNDS ─── */
  /* Enforce a single unified background color across the entire app workspace on mobile (excluding map) */
  body:not(.mode-map),
  body:not(.mode-map) .layout,
  body:not(.mode-map) .panel,
  body:not(.mode-map) .sidebar,
  body:not(.mode-map) .practice-layout,
  body:not(.mode-map) .practice-left,
  body:not(.mode-map) .practice-right,
  body:not(.mode-map) .dt-main-layout,
  body:not(.mode-map) .dt-wrap,
  body:not(.mode-map) .settings-container,
  body:not(.mode-map) .profile-container {
    background: var(--bg) !important;
  }

  /* Reduce margins, prevent clipping, and fit everything inside the viewport */
  .dcard,
  .u-premium-card,
  .test-main-card,
  .test-container,
  .test-menu-grid,
  .test-menu-card,
  .dt-reader-card,
  .dt-info-panel,
  .dt-hsk-list-pct,
  .settings-card,
  .cabinet-card,
  .cab-block,
  .cabinet-accordion,
  .panel > div,
  .panel > section,
  .panel > form {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Make grid elements stack vertically on mobile to prevent squishing and horizontal scrolling */
  .test-menu-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Reduce extreme padding of desktop cards so they fit and display nicely on mobile viewports */
  .dcard {
    padding: 16px 12px !important;
    border-radius: 20px !important;
  }

  .u-premium-card,
  .test-main-card {
    padding: 24px 16px !important;
    border-radius: 24px !important;
  }

  /* Align Text Analysis blocks (dailytexts) beautifully on mobile */
  .dt-main-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .dt-left-content,
  .dt-right-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .dt-reader-card,
  .dt-info-panel,
  .dt-hsk-list-pct {
    border-radius: 16px !important;
    padding: 14px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02) !important;
  }

  .dt-textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    resize: none !important;
  }

  .dt-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .dt-src {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px !important;
    border-radius: 12px !important;
  }
}

/* Hide global search card and mobile progress card on desktop by default */
.global-search-card, .mobile-progress-widget {
  display: none !important;
}

.map-search-item:hover {
  background: var(--surface) !important;
}

.map-search-item:active {
  background: var(--border) !important;
  transform: scale(0.98) !important;
}

.qv-card {
  animation: qvFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes qvFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── MAP UNIFIED & CUSTOM LISTS WIDGET ─── */
.map-lists-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.map-custom-lists-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.02);
  margin-bottom: 30px;
  box-sizing: border-box;
}

.map-custom-lists-widget .widget-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}

.map-custom-lists-widget .widget-desc {
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 16px;
  line-height: 1.4;
}

.map-custom-lists-widget .widget-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.map-custom-lists-widget .widget-input-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}

.map-custom-lists-widget .widget-input-row input:focus {
  border-color: var(--blue);
}

.map-custom-lists-widget .widget-input-row button {
  padding: 12px 20px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  box-shadow: 0 4px 12px var(--blue-alpha);
}

.map-custom-lists-widget .widget-input-row button:active {
  opacity: 0.9;
}

.map-custom-lists-widget .widget-lists-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-custom-lists-widget .widget-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  cursor: pointer;
  transition: all 0.2s;
}

.map-custom-lists-widget .widget-list-item:hover,
.map-custom-lists-widget .widget-list-item.active {
  border-color: var(--blue);
  background: var(--surface);
}

.map-custom-lists-widget .widget-list-item.active {
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.map-custom-lists-widget .list-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-custom-lists-widget .list-item-icon {
  font-size: 18px;
}

.map-custom-lists-widget .list-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-custom-lists-widget .list-item-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.map-custom-lists-widget .widget-list-item.active .list-item-name {
  color: var(--blue);
}

.map-custom-lists-widget .list-item-count {
  font-size: 11px;
  color: var(--ink3);
}

.map-custom-lists-widget .list-item-actions {
  display: flex;
  gap: 8px;
}

.map-custom-lists-widget .action-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.map-custom-lists-widget .action-btn.delete {
  color: var(--red);
  background: var(--red-alpha);
  border-color: transparent;
}

.map-custom-lists-widget .action-btn:hover {
  transform: scale(1.05);
}

/* ─── MOBILE MEDIA QUERIES FOR MAP ─── */
.map-lists-group .msec-open {
  border-color: rgba(37, 99, 235, 0.22) !important;
  box-shadow: 0 8px 26px rgba(37, 99, 235, 0.08) !important;
}

.map-lists-group .msec-open > .msec-head {
  background: var(--surface) !important;
  border-left-width: 6px !important;
}

.map-lists-group .msec-open .mgrid {
  padding: 12px 18px 18px !important;
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
}

.map-panel.map-compact .map-custom-ui-root #custom-bulk,
.map-custom-ui-root #custom-bulk {
  min-height: 132px !important;
  background: var(--surface) !important;
  border-color: var(--border2) !important;
  color: var(--ink1) !important;
  line-height: 1.45 !important;
}

.map-panel.map-compact .map-custom-ui-root #custom-bulk:focus,
.map-custom-ui-root #custom-bulk:focus {
  outline: none !important;
  border-color: var(--blue) !important;
  box-shadow: inset 0 0 0 1px var(--blue-alpha), 0 0 0 3px var(--blue-alpha) !important;
}

@media screen and (max-width: 700px) {
  /* Hide click -> practice help text only on mobile as requested */
  #map-total-label {
    display: none !important;
  }

  .map-lists-group {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.02) !important;
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 20px !important;
    gap: 0 !important;
  }

  .map-lists-group .msec {
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
  }

  .map-lists-group .msec:not(:last-child) {
    border-bottom: 1px solid var(--border) !important;
  }

  .map-custom-lists-widget {
    border-radius: 16px !important;
    padding: 16px !important;
    margin-bottom: 20px !important;
  }

  /* Smooth transitions for map bento widgets */
  .map-lists-group,
  .map-custom-lists-widget,
  .map-legend,
  .map-drag-hint {
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                margin 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    max-height: 1200px !important;
    overflow: hidden !important;
  }

  .bento-search-active .map-lists-group,
  .bento-search-active .map-custom-lists-widget,
  .bento-search-active .map-legend,
  .bento-search-active .map-drag-hint {
    opacity: 0 !important;
    transform: translateY(20px) !important;
    max-height: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border: none !important;
    pointer-events: none !important;
  }

  /* Seamlessly fuse sticky search input header with the results block below with transition */
  .map-panel {
    transition: padding 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .bento-search-active.map-panel {
    padding-top: 0 !important;
    position: relative !important;
  }

  .header-top .map-search-container {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  /* Remove header bottom separator when search is active on body */
  .bento-search-active header {
    border-bottom: none !important;
  }

  .bento-search-active .header-top .map-search-container {
    background: var(--surface) !important;
    border: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 16px !important;
  }

  /* Make the search input background seamlessly merge into the white surface results */
  .bento-search-active .map-search-wrap input {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .bento-search-active .map-bento-search-results {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 56px !important; /* Touch bottom of the mobile header top bar */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: calc(100% - 56px) !important;
    background: var(--surface) !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 16px calc(16px + env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 1500 !important;
    box-sizing: border-box !important;
    animation: bentoSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both !important;
  }
}

@keyframes bentoSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── MAP BENTO SEARCH RESULTS ─── */
.map-bento-search-results {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.02);
  margin-bottom: 24px;
  box-sizing: border-box;
  animation: bentoSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.bento-tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border2);
  scrollbar-width: none;
}

.bento-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.bento-tab {
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--ink3);
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.bento-tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  box-shadow: 0 2px 8px var(--blue-alpha);
}

.bento-filters-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.bento-dropdown-wrap {
  position: relative;
  flex: 1;
}

.bento-dropdown-wrap select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  box-sizing: border-box;
}

.bento-map-jump-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-sizing: border-box;
  height: 38px;
  width: 38px;
}

.bento-map-jump-btn:active {
  transform: scale(0.95);
  background: var(--border2);
}

.bento-close-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--red-alpha);
  color: var(--red);
  border: none;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  box-sizing: border-box;
  height: 38px;
  display: flex;
  align-items: center;
}

.bento-close-btn:active {
  opacity: 0.9;
}

.bento-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.bento-list-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.bento-list-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink3);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 6px;
}

.bento-words-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Rigid 4-Column Grid system so SRS indicators are 100% perfectly aligned in columns */
.bento-word-card {
  display: grid !important;
  grid-template-columns: minmax(75px, auto) 1fr 100px 55px !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 12px 14px !important;
  border-radius: 14px !important;
  background: var(--surface2) !important;
  border: 1px solid var(--border2) !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  box-sizing: border-box !important;
}

.bento-word-card:active {
  transform: scale(0.98);
  border-color: var(--blue);
}

.bento-card-hz {
  font-size: 20px !important;
  font-weight: bold !important;
  font-family: var(--font-zh) !important;
  color: var(--ink1) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.bento-card-details {
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  min-width: 0 !important;
  overflow: hidden !important;
}

.bento-card-py {
  font-size: 11px !important;
  color: var(--blue) !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.bento-card-tr {
  font-size: 11.5px !important;
  color: var(--ink3) !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.bento-card-srs-col {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.bento-card-srs-col .srs-bars {
  margin: 0 !important;
}

.bento-hsk-badge {
  font-size: 10px !important;
  font-weight: 800 !important;
  padding: 3px 6px !important;
  border-radius: 6px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border2) !important;
  color: var(--ink3) !important;
  text-align: center !important;
  white-space: nowrap !important;
}

.bento-empty-state {
  text-align: center;
  color: var(--ink3);
  padding: 40px 20px;
  font-size: 13px;
  font-weight: 600;
}

@media screen and (max-width: 700px) {
  /* Make the bento word list container and scrolling super smooth */
  .bento-words-scroll {
    max-height: 70vh !important;
    gap: 10px !important;
    padding-bottom: 24px !important;
  }

  /* Beautifully fluid 3-column, 2-row layout to prevent ANY overflow/breakage */
  .bento-word-card {
    grid-template-columns: minmax(65px, auto) 1fr 48px !important;
    grid-template-rows: auto auto !important;
    gap: 6px 12px !important;
    padding: 12px 14px !important;
    align-items: center !important;
  }

  .bento-card-hz {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    font-size: 19px !important;
    align-self: center !important;
    margin: 0 !important;
  }

  .bento-card-details {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    align-self: end !important;
  }

  .bento-card-srs-col {
    grid-column: 2 !important;
    grid-row: 2 !important;
    justify-content: flex-start !important;
    align-items: center !important;
    align-self: start !important;
  }

  .bento-hsk-badge {
    grid-column: 3 !important;
    grid-row: 1 / span 2 !important;
    font-size: 9.5px !important;
    padding: 3px 6px !important;
    justify-self: end !important;
    align-self: center !important;
    margin: 0 !important;
  }
}

/* ─── DAY STREAK WIDGET ─── */
.streak-card {
  margin-bottom: 12px;
  border-radius: 20px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.streak-card.streak-active {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08), rgba(239, 68, 68, 0.12));
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.streak-card.streak-at-risk {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.05), rgba(249, 115, 22, 0.08));
  border: 1px dashed rgba(234, 179, 8, 0.35);
}

.streak-card.streak-inactive {
  background: var(--surface);
  border: 1px solid var(--border);
}

.streak-flame-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 26px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.streak-active .streak-flame-container {
  background: linear-gradient(135deg, #f97316, #ef4444);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  animation: streakPulse 2s infinite ease-in-out;
}

.streak-active .streak-flame-icon {
  text-shadow: 0 2px 8px rgba(255, 255, 255, 0.3);
}

.streak-at-risk .streak-flame-container {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.4), rgba(234, 179, 8, 0.4));
  box-shadow: 0 4px 10px rgba(234, 179, 8, 0.15);
}

.streak-inactive .streak-flame-container {
  background: var(--surface2);
  border: 1px solid var(--border2);
  opacity: 0.6;
}

@keyframes streakPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45); }
  100% { transform: scale(1); }
}

.streak-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.streak-number-display {
  display: flex;
  flex-direction: column;
}

.streak-num-val {
  font-size: 28px;
  font-weight: 950;
  line-height: 1.1;
  color: var(--ink1);
}

.streak-num-lbl {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.streak-desc {
  font-size: 12px;
  color: var(--ink2);
  line-height: 1.45;
  font-weight: 600;
}

.streak-timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px dashed var(--border2);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink3);
}

.streak-active .streak-timer-row {
  border-top-color: rgba(249, 115, 22, 0.15);
}

.streak-at-risk .streak-timer-row {
  border-top-color: rgba(234, 179, 8, 0.2);
}

/* ─── RESPONSIVE SAFETY LAYER ───
   Keeps legacy fixed-width/inline layouts usable on tablets and phones. */
html,
body {
  min-width: 0;
}

*,
*::before,
*::after {
  min-width: 0;
}

img,
svg,
canvas,
video,
iframe {
  max-width: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

.panel,
.layout,
.sidebar,
.modal-card,
.cw-wrap,
.dt-wrap,
.tch-body {
  min-width: 0;
}

@media (max-width: 1100px) {
  .cw-layout {
    grid-template-columns: 1fr !important;
  }

  .cw-side {
    max-height: none !important;
  }

  .match-board,
  .match-grid,
  .profile-stats,
  .tch-progress-grid,
  .tch-detail-stats,
  .tch-add-block-grid {
    grid-template-columns: 1fr !important;
  }

  .panel [style*="grid-template-columns:1fr 1fr"],
  .panel [style*="grid-template-columns: 1fr 1fr"],
  .panel [style*="grid-template-columns:2fr 1fr"],
  .panel [style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 700px) {
  body {
    height: 100dvh;
  }

  .layout {
    width: 100% !important;
    max-width: 100% !important;
  }

  .panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  .panel > *,
  .modal-card,
  .auth-form,
  .cab-content,
  .profile-add-word,
  .cw-wrap,
  .cw-board-card,
  .cw-side,
  .map-panel,
  .sp-wrap,
  .rand-wrap,
  .test-wrap,
  .stats-wrap,
  .notes-wrap,
  .gram-wrap,
  .compbox {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .btn,
  .lbtn,
  .tnav,
  .fbtn,
  .dropdown-trigger,
  .cw-btn,
  .tch-btn {
    min-height: 44px;
  }

  .header-top {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto auto !important;
    align-items: center !important;
  }

  .lsw-wrap,
  .lsw {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .lsw,
  .top-nav,
  .filter-row,
  .bento-tabs-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .lsw::-webkit-scrollbar,
  .top-nav::-webkit-scrollbar,
  .filter-row::-webkit-scrollbar,
  .bento-tabs-scroll::-webkit-scrollbar {
    display: none;
  }

  .search-wrap {
    height: 48px !important;
  }

  .search-wrap input {
    height: 48px !important;
    border-radius: 16px !important;
  }

  .filter-controls {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .dropdown-menu {
    left: 0 !important;
    right: auto !important;
    width: min(100%, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(360px, 62vh) !important;
    overflow: auto !important;
  }

  #dropdown-topic .dropdown-menu,
  #dropdown-status .dropdown-menu {
    left: 0 !important;
    right: auto !important;
  }

  .wi {
    grid-template-columns: 4px minmax(54px, auto) minmax(0, 1fr) auto !important;
    gap: 8px !important;
  }

  .wi-b,
  .wi-p,
  .wi-r,
  .bento-card-hz,
  .bento-card-py,
  .bento-card-tr {
    overflow-wrap: anywhere !important;
  }

  .cw-wrap {
    padding: 12px 10px calc(92px + env(safe-area-inset-bottom)) !important;
  }

  .cw-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .cw-head-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .cw-board-card {
    padding: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .cw-grid {
    grid-template-columns: repeat(var(--cw-cols), 28px) !important;
    grid-auto-rows: 28px !important;
    width: max-content !important;
    min-width: max-content !important;
    padding: 12px !important;
  }

  .cw-cell {
    width: 28px !important;
    height: 28px !important;
    font-size: 13px !important;
  }

  .cw-active-answer,
  .cw-answer-row,
  .cw-clue {
    grid-template-columns: 1fr !important;
  }

  .cw-clues {
    max-height: none !important;
    overflow: visible !important;
  }

  .cw-side {
    padding: 14px !important;
  }

  .panel [style*="display:grid"],
  .panel [style*="display: grid"] {
    max-width: 100% !important;
  }

  .panel [style*="grid-template-columns"] {
    gap: 12px !important;
  }

  .panel [style*="max-width:600px"],
  .panel [style*="max-width: 600px"],
  .panel [style*="max-width:700px"],
  .panel [style*="max-width: 700px"],
  .panel [style*="max-width:900px"],
  .panel [style*="max-width: 900px"],
  .panel [style*="max-width:1100px"],
  .panel [style*="max-width: 1100px"] {
    max-width: 100% !important;
  }

  .panel [style*="width:600px"],
  .panel [style*="width: 600px"],
  .panel [style*="width:700px"],
  .panel [style*="width: 700px"],
  .panel [style*="width:900px"],
  .panel [style*="width: 900px"],
  .panel [style*="width:1100px"],
  .panel [style*="width: 1100px"] {
    width: 100% !important;
  }

  .panel table,
  .modal-card table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .panel {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .cw-grid {
    grid-template-columns: repeat(var(--cw-cols), 24px) !important;
    grid-auto-rows: 24px !important;
  }

  .cw-cell {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
  }

  .cw-num {
    font-size: 7px !important;
    left: 2px !important;
    top: 1px !important;
  }

  .cw-head-actions,
  .topts,
  .scards,
  .bento-filters-row,
  .map-custom-lists-widget .widget-input-row {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .bento-word-card {
    grid-template-columns: minmax(46px, auto) minmax(0, 1fr) auto !important;
    padding: 10px 12px !important;
  }
}

/* ---- QUICK PRACTICE BUTTON ---- */
.quick-practice-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--amber, #f59e0b) !important;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  outline: none;
  pointer-events: auto !important;
  position: relative;
  z-index: 110 !important;
}
.quick-practice-btn:hover {
  background: var(--border2);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  color: #fbbf24 !important;
}
.quick-practice-btn:active {
  transform: scale(0.95);
}
.quick-practice-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
  fill: currentColor !important;
}

/* ---- QUICK PRACTICE MODAL (⚡) ---- */
.qp-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-alpha, rgba(255, 255, 255, 0.75));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: qp-fade-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
:root:not([data-theme="light"]) .qp-overlay {
  background: rgba(11, 16, 32, 0.8) !important;
}

@keyframes qp-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qp-container {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 28px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.08);
  padding: 24px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: qp-scale-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes qp-scale-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.qp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 14px;
}

.qp-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.qp-header-title svg {
  color: var(--amber, #f59e0b);
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
  fill: currentColor !important;
}

.qp-close-btn {
  background: var(--surface2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink2);
  transition: all 0.15s;
}
.qp-close-btn:hover {
  background: var(--border2);
  transform: scale(1.05);
}
.qp-close-btn svg {
  width: 14px;
  height: 14px;
}

/* Flashcard Styles */
.qp-card {
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: 20px;
  padding: 30px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  position: relative;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.005);
}

.qp-hz {
  font-size: 64px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.qp-audio-btn {
  background: var(--surface);
  border: 1px solid var(--border2);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--blue);
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all 0.15s;
}
.qp-audio-btn:hover {
  transform: scale(1.08);
  background: var(--surface2);
}
.qp-audio-btn svg {
  width: 16px;
  height: 16px;
}

.qp-show-ans-btn {
  background: var(--blue);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 800;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--blue-alpha);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  margin-top: 16px;
}
.qp-show-ans-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 18px var(--blue-alpha);
}
.qp-show-ans-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Back Answer Card styles */
.qp-ans-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: qp-fade-in 0.25s ease both;
}

.qp-py {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 6px;
}

.qp-tr {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 20px;
}

/* Examples container inside Quick Practice */
.qp-examples {
  width: 100%;
  text-align: left;
  border-top: 1px dashed var(--border2);
  padding-top: 16px;
  box-sizing: border-box;
}

.qp-examples-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink3);
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.qp-example-item {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13.5px;
  line-height: 1.4;
  box-sizing: border-box;
}

.qp-example-zh {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}

.qp-example-py {
  font-size: 11.5px;
  color: var(--blue);
  margin-bottom: 2px;
}

.qp-example-tr {
  font-size: 11.5px;
  color: var(--ink2);
}

/* Actions Footer */
.qp-actions-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.qp-footer-btn {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 800;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-sizing: border-box;
}

.qp-footer-btn svg {
  width: 16px;
  height: 16px;
}

.qp-next-btn {
  background: var(--surface2);
  color: var(--ink);
  border: 1.5px solid var(--border2);
}
.qp-next-btn:hover {
  background: var(--border2);
  transform: translateY(-2px);
}

.qp-practice-btn {
  background: var(--blue);
  color: white;
  box-shadow: 0 4px 12px var(--blue-alpha);
}
.qp-practice-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--blue-alpha);
}

/* ---- MOBILE MEDIA OVERRIDES (max-width: 700px) ---- */
@media (max-width: 700px) {
  .header-top {
    grid-template-columns: auto 1fr auto auto auto !important;
  }
  .quick-practice-btn {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    margin-left: 8px !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: var(--surface2) !important;
    border: 1px solid var(--border2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all .2s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    color: var(--amber, #f59e0b) !important;
    padding: 0 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
    z-index: 110 !important;
    pointer-events: auto !important;
  }
  .quick-practice-btn svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
  }
  #langSelector {
    grid-column: 4 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    margin-left: 8px !important;
  }
  .theme-btn {
    grid-column: 5 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    margin-left: 8px !important;
  }
}
