
.d-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
}

.dcard-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.dcard-t {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}

.dcard-st {
  font-size: 13px;
  color: var(--ink3);
  margin-top: 4px;
}

/* Chart */
.chart-wrap {
  height: 200px;
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.bar {
  width: 100%;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: 0.3s;
  opacity: 0.8;
}

.bar:hover {
  opacity: 1;
  transform: scaleX(1.05);
}

.bar-lbl {
  font-size: 9px;
  color: var(--ink3);
  font-weight: 600;
  margin-top: 6px;
  text-align: center;
}

/* Hard words widget */
.d-hard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.d-hard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 12px;
}

.d-hard-hz {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.d-hard-py {
  font-size: 12px;
  color: var(--blue);
  white-space: nowrap;
}

.d-risk-subtitle {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--ink3);
  font-weight: 700;
}

.d-risk-item {
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 1.2fr);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--surface2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.d-risk-item:hover {
  transform: translateY(-1px);
  background: var(--surface1);
}

.d-risk-word {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.d-risk-word .d-hard-hz,
.d-risk-word .d-hard-py {
  min-width: 0;
}

.d-risk-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 5px 7px;
  min-width: 0;
  text-align: right;
}

.d-risk-label {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.d-risk-detail,
.d-risk-memory {
  color: var(--ink3);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
}

.d-risk-memory {
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .d-risk-item {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .d-risk-meta {
    justify-content: flex-start;
    text-align: left;
  }
}

@media (max-width: 1320px) and (min-width: 701px) {
  .sidebar {
    width: clamp(260px, 27vw, 320px) !important;
    min-width: 240px !important;
    max-width: 320px !important;
  }

  .panel {
    padding: 20px 18px !important;
  }

  .dash {
    grid-template-columns: 1fr !important;
    max-width: 760px !important;
    gap: 18px !important;
  }

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

  .dcard {
    padding: 20px !important;
  }

  .d-risk-item {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
}

@media (max-width: 1120px) and (min-width: 701px) {
  .dash {
    max-width: 680px !important;
  }

  .d-risk-item {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .d-risk-meta {
    justify-content: flex-start;
    text-align: left;
  }
}

/* Premium widget */
.premium-card {
  background: linear-gradient(135deg, #3B82F6, #7C3AED);
  color: #fff;
  border: none;
}

.premium-card .dcard-t {
  color: #fff;
}

.premium-card .dcard-st {
  color: rgba(255, 255, 255, 0.7);
}

.premium-btn {
  background: #fff;
  color: var(--blue);
  border: none;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  margin-top: 15px;
  box-shadow: var(--shadow-md);
}

.rlvl {
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--ink3);
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 600;
}

.rhz {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 6px;
  font-weight: 300;
}

.rpy {
  font-size: 14px;
  color: var(--ink3);
  margin-bottom: 8px;
}

.rru {
  font-size: 17px;
  font-weight: 600;
  color: var(--blue);
}

.rru-h {
  font-size: 13px;
  color: transparent;
  background: var(--surface2);
  border-radius: var(--r);
  cursor: pointer;
  user-select: none;
  padding: 6px 14px;
  display: inline-block;
  transition: .2s;
}

.rru-h.shown {
  color: var(--blue);
  background: var(--blue-bg);
}

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

.ract .btn {
  flex: 1;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
}

/* ─── STATS ─── */
.stats-wrap {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.scard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  text-align: center;
}

.scard-v {
  font-size: 24px;
  font-weight: 700;
}

.scard-l {
  font-size: 11px;
  color: var(--ink3);
  margin-top: 2px;
  font-weight: 500;
}

.pbar-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}

.pbar-t {
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 6px;
}

.pbar-lbl {
  width: 44px;
  color: var(--ink2);
  font-weight: 500;
}

.pbar-track {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.pbar-fill {
  height: 100%;
  border-radius: 3px;
  transition: .3s;
}

.pbar-pct {
  min-width: 60px;
  text-align: right;
  color: var(--ink3);
  font-weight: 600;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hw-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}

.hw-t {
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.hw-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: .1s;
}

.hw-item:last-child {
  border: none;
}

.hw-item:hover {
  color: var(--blue);
}

.hw-hz {
  font-size: 20px;
  min-width: 44px;
  width: auto;
  white-space: nowrap;
}

.hw-info {
  flex: 1;
  color: var(--ink2);
  min-width: 0;
  overflow: hidden;
}

.hw-rate {
  color: var(--red);
  font-weight: 700;
  font-size: 11px;
}

.sreset {
  width: 100%;
  padding: 9px;
  font-size: 12px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: transparent;
  cursor: pointer;
  color: var(--ink3);
  font-family: inherit;
  font-weight: 500;
  transition: .15s;
}

.sreset:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ─── MAP ─── */
.map-panel {
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1000px; /* Ограничили ширину */
  margin: 0 auto;
}

.map-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11px;
  color: var(--ink3);
  font-weight: 500;
  padding: 0 4px;
}

.map-leg {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.msec {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r); /* Уменьшили радиус до стандартного */
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.msec-head {
  display: flex;
  align-items: center;
  padding: 8px 14px; /* Уменьшили высоту */
  margin: 0;
  gap: 8px;
}

.msec-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.msec-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink3);
  margin-left: auto;
  white-space: nowrap;
}

.msec-bar {
  display: inline-block;
  width: 60px;
  height: 5px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}

.msec-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.mgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  gap: 6px;
  align-content: flex-start;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 14px;
  border-radius: 0;
  background: var(--bg);
  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);
}

.msec-open > .mgrid,
.msec-open .mgrid {
  max-height: 60vh;
  opacity: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

.mgrid::-webkit-scrollbar {
  width: 4px;
}

.mgrid::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.mtile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  padding: 6px 8px;
  transition: transform .15s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  white-space: nowrap;
  font-weight: 600;
  box-sizing: border-box;
  width: 100%;
}

.mtile:hover {
  transform: scale(1.15);
  z-index: 3;
  box-shadow: var(--shadow-md);
}

.mt-n {
  background: #F5F3F0;
  color: #6B6560;
  border-color: #E7E5E4;
}

.mt-g {
  background: #D1FAE5;
  color: #166534;
  border-color: #86EFAC;
}

.mt-y {
  background: #FEF3C7;
  color: #92400E;
  border-color: #FCD34D;
}

.mt-r {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #FCA5A5;
}

.mt-c {
  background-color: #047857;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.12) 4px,
    rgba(255, 255, 255, 0.12) 8px
  );
  color: #FFFFFF;
  border-color: #047857;
}

.mt-l,
.mtile:not(.mt-n):not(.mt-g):not(.mt-y):not(.mt-r):not(.mt-c) {
  background: #EFF6FF;
  color: #1D4ED8;
  border-color: #BFDBFE;
}

/* Dark theme tile colors — without these, all tiles look like bright
   white/yellow chips on a dark background which hurts the eyes. */
html[data-theme="dark"] .mt-n {
  background: #33302E;
  color: #A8A29E;
  border-color: #57534E;
}

html[data-theme="dark"] .mt-g {
  background: #14532D;
  color: #86EFAC;
  border-color: #22C55E;
}

html[data-theme="dark"] .mt-y {
  background: #451A03;
  color: #FCD34D;
  border-color: #F59E0B;
}

html[data-theme="dark"] .mt-r {
  background: #450A0A;
  color: #FCA5A5;
  border-color: #F87171;
}

html[data-theme="dark"] .mt-c {
  background-color: #065F46;
  color: #FFFFFF;
  border-color: #10B981;
}

html[data-theme="dark"] .mt-l,
html[data-theme="dark"] .mtile:not(.mt-n):not(.mt-g):not(.mt-y):not(.mt-r):not(.mt-c) {
  background: #172554;
  color: #93C5FD;
  border-color: #2563EB;
}

html[data-theme="dark"] .mgrid {
  background: var(--surface2);
}

/* ─── GRAMMAR & SENTENCES ─── */
.gram-wrap {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.gram-level-sw {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.glbtn {
  padding: 5px 13px;
  border-radius: var(--r-full);
  font-size: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--ink2);
  font-family: inherit;
  transition: .12s;
  font-weight: 500;
}

.glbtn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.gram-prog {
  font-size: 12px;
  color: var(--ink3);
  text-align: center;
  font-weight: 500;
}

.gram-legend {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.gl-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--ink3);
}

.gl-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.gpat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.gpat-hsk {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}

.gpat-desc {
  font-size: 12px;
  color: var(--ink2);
  margin-bottom: 12px;
  line-height: 1.6;
}

.gram-formula {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  background: var(--bg);
  border-radius: var(--r);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.gf-part {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.gf-plus {
  color: var(--ink3);
  font-size: 14px;
}

.gram-exs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gram-ex {
  background: var(--bg);
  border-radius: var(--r);
  padding: 12px;
}

.gram-ex-zh {
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 3px;
}

.gram-ex-py {
  font-size: 10px;
  color: var(--ink3);
  margin-bottom: 2px;
}

.gram-ex-ru {
  font-size: 12px;
  color: var(--ink2);
}

.gram-nav {
  display: flex;
  gap: 8px;
}

.gnav-btn {
  flex: 1;
  padding: 9px;
  border-radius: var(--r);
  font-size: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  transition: .15s;
  font-weight: 500;
}

.gnav-btn:hover {
  background: var(--surface2);
}

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

/* Exercise slots */
.gex-sent {
  font-size: 13px;
  color: var(--ink2);
  margin-bottom: 3px;
  font-style: italic;
}

.gex-ru {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 14px;
  font-weight: 600;
}

.gex-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.gex-slot {
  min-width: 80px;
  min-height: 56px;
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  cursor: pointer;
  transition: .12s;
  text-align: center;
}

.gex-slot.filled {
  border-style: solid;
}

.gex-slot-word {
  font-size: 16px;
  font-weight: 600;
}

.gex-slot-label {
  font-size: 9px;
  margin-top: 2px;
}

.gex-words {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.gex-word {
  padding: 9px 14px;
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  font-size: 16px;
  cursor: grab;
  background: var(--surface);
  transition: .12s;
  font-family: inherit;
  font-weight: 500;
}

.gex-word:hover {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.gex-word.sel {
  border-color: var(--blue);
  background: var(--blue-bg);
  color: var(--blue);
}

.gex-word.placed {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
  font-size: 13px;
  opacity: .7;
  cursor: default;
}

.gex-fb {
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: 12px;
  margin-top: 4px;
}

.gex-ok {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 600;
}

.gex-err {
  background: var(--red-bg);
  color: var(--red);
}

/* Sentence practice */
.sp-task {
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 5px;
}

.sp-ru {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--ink);
}

.sp-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sp-slot {
  min-width: 76px;
  min-height: 56px;
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  cursor: pointer;
  transition: .15s;
  text-align: center;
}

.sp-slot:hover {
  opacity: .8;
}

.sp-slot.filled {
  border-style: solid;
}

.sp-slot-word {
  font-size: 17px;
  font-weight: 600;
}

.sp-slot-label {
  font-size: 9px;
  margin-top: 2px;
}

.sp-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.sp-word {
  padding: 10px 16px;
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  font-size: 17px;
  cursor: grab;
  background: var(--surface);
  transition: .12s;
  user-select: none;
  font-family: inherit;
  font-weight: 500;
}

.sp-word:hover {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.sp-word.sel {
  border-color: var(--blue);
  background: var(--blue-bg);
  color: var(--blue);
}

.sp-word.placed {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
  font-size: 13px;
  opacity: .6;
  cursor: default;
}

.sp-fb {
  padding: 10px 12px;
  border-radius: var(--r);
  font-size: 12px;
  margin-top: 2px;
}

.sp-ok {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 600;
}

.sp-err {
  background: var(--red-bg);
  color: var(--red);
}

/* Notes */
.notes-wrap {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.notes-score {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 12px;
  color: var(--ink3);
}

.notes-score span {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: block;
  text-align: center;
}

.notes-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.notes-label {
  font-size: 10px;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
  font-weight: 600;
}

.notes-zh {
  font-size: 28px;
  line-height: 1.5;
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: 300;
}

.notes-py {
  font-size: 13px;
  color: var(--blue);
  margin-bottom: 6px;
  min-height: 20px;
  font-weight: 500;
}

.notes-ru {
  font-size: 15px;
  color: var(--ink);
  min-height: 20px;
  font-weight: 600;
}

.notes-ru-hidden {
  background: var(--surface2);
  color: transparent;
  border-radius: var(--r);
  cursor: pointer;
  padding: 4px 14px;
  user-select: none;
  display: inline-block;
  font-size: 13px;
  transition: .2s;
}

.notes-ru-hidden.shown {
  background: var(--blue-bg);
  color: var(--blue);
}

.notes-hint {
  font-size: 10px;
  color: var(--ink3);
  margin-top: 6px;
}

.notes-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.notes-actions .btn {
  flex: 1;
  min-width: 90px;
  padding: 11px 8px;
  font-size: 13px;
  font-weight: 600;
}

.notes-idx {
  font-size: 12px;
  color: var(--ink3);
  text-align: center;
  font-weight: 500;
}

.notes-filter {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.nfbtn {
  padding: 5px 13px;
  border-radius: var(--r-full);
  font-size: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--ink2);
  font-family: inherit;
  transition: .12s;
  font-weight: 500;
}

.nfbtn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ─── LOADING ─── */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--blue);
  transition: width .3s;
  z-index: 100;
}

.w-more-btn {
  padding: 12px;
  text-align: center;
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  transition: .12s;
  display: none;
}

.w-more-btn:hover {
  background: var(--blue-bg);
}

@media(max-width:700px) {
  .w-more-btn {
    padding: 6px 12px;
    font-size: 11px;
    border-top: none;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    min-width: 100px;
  }
}

/* ─── MOBILE ─── */
@media(max-width:700px) {

  /* Header: two-row, auto height */
  header {
    padding: 0;
  }

  .header-top {
    padding: 6px 10px;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 44px;
  }

  .logo {
    font-size: 14px;
  }

  .lsw {
    max-width: calc(100vw - 120px);
  }

  .lbtn {
    padding: 3px 7px;
    font-size: 10px;
  }

  .langbtn {
    padding: 2px 6px;
    font-size: 10px;
  }

  .lang-select {
    font-size: 12px;
    padding: 4px 6px;
  }

  .theme-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  /* Nav row */
  .top-nav {
    padding: 4px 8px;
    gap: 2px;
    border-top: 1px solid var(--border);
  }

  .tnav {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
  }

  /* Hide header-search on mobile */
  .header-search {
    display: none !important;
  }

  /* Layout */
  .layout {
    flex-direction: column;
    overflow: visible;
    height: auto;
    min-height: 0;
  }

  /* Sidebar: compact horizontal word strip */
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    flex-shrink: 0;
  }

  .sbar-top {
    padding: 6px 10px;
    gap: 6px;
  }

  .filter-controls {
    gap: 6px;
  }

  .dropdown-trigger {
    padding: 8px 10px;
    font-size: 12px;
  }

  .custom-section {
    display: none;
  }

  /* hide on mobile */
  /* Word list: full-width vertical list */
  .wlist {
    display: flex !important;
    flex-direction: column !important;
    max-height: none !important;
    height: auto !important;
    overflow-y: visible !important;
    border-top: none !important;
  }

  .wi {
    display: grid !important;
    grid-template-columns: 6px 72px minmax(0, 1fr) auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px 16px !important;
    min-height: 64px !important;
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    border-right: none !important;
    transition: background 0.2s;
  }

  .wi:active {
    background: var(--surface2) !important;
  }

  .wi-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    overflow: hidden !important;
  }

  .wi-b {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
  }

  .wcount {
    display: block !important;
    padding: 12px 16px 4px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--ink3) !important;
  }

  /* Panel */
  .panel {
    flex: 1;
    min-height: 60vh;
    padding: 12px 12px calc(100px + env(safe-area-inset-bottom)) !important;
    justify-content: flex-start;
    overflow-y: auto;
  }

  /* Practice canvas */
  .cwrap {
    width: 200px !important;
    height: 200px !important;
  }

  #hz-target {
    width: 200px !important;
    height: 200px !important;
  }

  /* Cards */
  .test-wrap,
  .rand-wrap,
  .stats-wrap,
  .notes-wrap,
  .gram-wrap,
  .sp-wrap {
    max-width: 100%;
  }

  .topts {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .topt {
    padding: 12px 6px;
    font-size: 13px;
  }

  .test-hz,
  .rhz {
    font-size: 44px;
  }

  .rand-score,
  .test-score {
    gap: 12px;
  }

  .ract {
    flex-wrap: wrap;
    gap: 8px;
  }

  .ract .btn {
    min-width: 80px;
    flex: 1;
  }

  .compb {
    flex-direction: column;
    gap: 8px;
  }

  .compb .btn {
    width: 100%;
  }

  /* Stats */
  .scards {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .scard-v {
    font-size: 18px;
  }

  /* Map */
  .map-panel {
    padding: 10px 8px;
  }

  .mtile {
    font-size: 12px;
    padding: 3px 4px;
  }

  /* Grammar / Sentence */
  .gram-formula {
    gap: 3px;
    padding: 8px;
  }

  .gf-part {
    padding: 3px 7px;
    font-size: 11px;
  }

  .gram-legend {
    gap: 4px;
  }

  .gl-item {
    font-size: 9px;
  }

  .gram-nav {
    flex-wrap: wrap;
  }

  .gnav-btn {
    min-width: 80px;
  }
}

@media(max-width:390px) {
  .cwrap {
    width: 200px !important;
    height: 200px !important;
  }

  #hz-target {
    width: 200px !important;
    height: 200px !important;
  }

  .topts {
    grid-template-columns: 1fr;
  }

  .tnav {
    padding: 5px 8px;
    font-size: 11px;
  }
}

/* Language dropdown (mobile) */
.lang-select {
  display: none;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
}

@media(max-width:700px) {
  .lang-sw {
    display: none !important;
  }

  .lang-select {
    display: block;
  }

  .header-top {
    padding: 6px 10px;
    gap: 8px;
  }

  .lbtn {
    padding: 3px 8px;
    font-size: 11px;
  }
}

/* Prevent canvas jump */
.practice-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.cwrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cwrap>div {
  display: flex;
  align-items: center;
  justify-content: center;
}

#hz-target {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#hz-target svg {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Theme toggle button ── */
/* Custom word cards */
.custom-word-item {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.custom-word-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-color: var(--accent) !important;
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.05);
    opacity: 1;
  }

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

.auth-form input,
.profile-add-word input {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input:focus,
.profile-add-word input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-alpha);
  outline: none;
}

.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--ink2);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: .15s;
  line-height: 1;
  padding: 0;
}

.theme-btn:hover {
  background: var(--border2);
}

.header-search {
  flex: 1;
  max-width: 400px;
  min-width: 150px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 5px 14px 5px 34px;
  border: 1px solid var(--border2);
  border-radius: var(--r-full);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface2);
  color: var(--ink);
  outline: none;
  transition: .15s;
  box-sizing: border-box;
}

.header-search input:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.header-search::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink3);
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

/* Search Popover */
#searchPopover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  padding: 8px;
}

#searchPopover .hw-item {
  padding: 8px;
  border-radius: var(--r);
}

#searchPopover .hw-item:hover {
  background: var(--bg);
}

#searchPopover .hw-hz {
  font-size: 18px;
  min-width: 45px;
  font-weight: 700;
}

#searchPopover .hw-py {
  color: var(--blue);
  font-weight: 600;
  margin-right: 8px;
}

#searchPopover .hw-ru {
  color: var(--ink2);
  font-size: 12px;
}

/* ─── AUTH & PROFILE ─── */
.btn-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface2);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: .15s;
}

.btn-profile:hover {
  background: var(--border);
  border-color: var(--border2);
}

.btn-profile .nav-label {
  font-size: 12px;
}

@media(max-width:700px) {
  .btn-profile .nav-label {
    display: none;
  }

  .btn-profile {
    padding: 6px 8px;
    font-size: 16px;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: var(--shadow-md);
  animation: modalIn .3s ease-out;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

@keyframes modalIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--ink3);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: .15s;
}

.auth-form input:focus {
  border-color: var(--blue);
  background: var(--surface);
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--ink3);
  margin-top: 12px;
}

.auth-switch a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.profile-email {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink2);
}

.profile-stats {
  background: var(--surface2);
  border-radius: var(--r);
  padding: 12px;
  font-size: 13px;
  text-align: left;
}

.ps-row {
  display: flex;
  justify-content: space-between;
  color: var(--ink2);
}

.ps-row span:first-child {
  font-weight: 700;
  color: var(--blue);
}


/* ── Mobile search in sidebar ── */
.mobile-search-wrap {
  display: none;
  position: relative;
}

.mobile-search-wrap input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}

.mobile-search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink3);
  font-size: 15px;
  pointer-events: none;
}

/* search-wrap was old class — hide it */
.search-wrap {
  display: none;
}

@media(max-width:700px) {
  .header-search {
    display: none !important;
  }

  .mobile-search-wrap {
    display: block;
  }
}

/* ── DARK THEME ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C0A09;
    --surface: #1C1917;
    --surface2: #292524;
    --ink: #FAFAF9;
    --ink2: #D6D3D1;
    --ink3: #78716C;
    --border: #292524;
    --border2: #44403C;
    --blue: #3B82F6;
    --blue-bg: #1E3A5F;
  }
}

/* ── THEMES ────────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface2: #F1F0ED;
  --ink: #1C1917;
  --ink2: #57534E;
  --ink3: #A8A29E;
  --border: #E7E5E4;
  --border2: #D6D3D1;
  --blue: rgb(30, 80, 255);
  --blue-bg: rgba(30, 80, 255, 0.08);
}

[data-theme="dark"] {
  --bg: #0C0A09;
  --surface: #1C1917;
  --surface2: #292524;
  --ink: #FAFAF9;
  --ink2: #D6D3D1;
  --ink3: #78716C;
  --border: #292524;
  --border2: #44403C;
  --blue: #3B82F6;
  --blue-bg: #1E3A5F;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .5);
}

/* Dark mode button/input fixes */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] button {
  color-scheme: dark;
}

html[data-theme="dark"] .topt,
html[data-theme="dark"] .gex-word,
html[data-theme="dark"] .sp-word {
  color: var(--ink);
}

html[data-theme="dark"] .lbtn.active {
  background: #292524;
  color: var(--blue);
}

html[data-theme="dark"] .langbtn.active {
  background: #292524;
  color: var(--blue);
}


/* Collapsible map sections */
.msec-collapsible .msec-head {
  border-left: 3px solid var(--border2);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}

.msec-collapsible .msec-head:hover {
  background: var(--surface2);
}

.msec-locked {
  opacity: 0.7;
  filter: grayscale(0.5);
}

.msec-locked .msec-head {
  cursor: default;
}

.msec-locked .msec-title {
  color: var(--ink3);
}

.msec.over {
  border: 2px dashed var(--blue);
}

.msec-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ink3);
  transition: transform .2s;
  width: 12px;
  flex-shrink: 0;
}

.msec-open>.msec-head {
  border-bottom: 1px solid var(--border);
}

.msec-collapsible .mgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  gap: 6px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 14px;
  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);
}

.msec-open .mgrid,
.msec-collapsible.msec-open .mgrid {
  max-height: 1200px;
  opacity: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

/* ── Speak button (audio.js) ─────────────────────────────────
   Inline pronunciation trigger — appears next to hanzi in every mode.
   Designed to be small enough not to dominate the UI but still
   tap-friendly on mobile (min 28×28). */
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 8px;
  background: var(--surface2);
  color: var(--ink2);
  border: 1px solid var(--border2);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: transform .12s, background .15s, color .15s;
  flex-shrink: 0;
  /* Default size; per-instance size set via inline style from speakBtn() */
  min-width: 28px;
  min-height: 28px;
}

.speak-btn:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.speak-btn:active {
  transform: scale(.92);
}

.speak-btn.speak-active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  animation: speak-pulse .4s ease-out;
}

@keyframes speak-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, .6);
  }

  100% {
    box-shadow: 0 0 0 12px rgba(37, 99, 235, 0);
  }
}

/* Prevent the speak button from pushing hanzi off-baseline in headers */
.wfull,
.comphz,
.rhz,
.test-hz {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ─── TOASTS ─── */
.toast-wrap {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 24px;
  border-radius: 50px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sh-lg);
  border: 1px solid var(--border);
  animation: toastIn .3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  transition: .3s;
}

@keyframes toastIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.err {
  border-color: var(--red);
  color: var(--red);
}

.toast.ok {
  border-color: var(--green);
  color: var(--green);
}

/* ─── GOOGLE & AUTH EXTRA ─── */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--ink3);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider:not(:empty)::before {
  margin-right: .5em;
}

.auth-divider:not(:empty)::after {
  margin-left: .5em;
}

.btn-google {
  background: white;
  color: #374151;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  transition: .2s;
}

.btn-google:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-google svg {
  width: 18px;
  height: 18px;
}

.forgot-link {
  display: block;
  text-align: right;
  font-size: 12px;
  margin-top: -10px;
  margin-bottom: 15px;
  color: var(--ink3);
  text-decoration: none;
}

.forgot-link:hover {
  color: var(--blue);
}



/* ─── STATISTICS PREMIUM ─── */
.stats-header-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.vocab-card {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--blue), #7C3AED);
  color: white;
  padding: 25px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.2);
  position: relative;
  overflow: hidden;
}

.vocab-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
}

.vocab-card-val {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 4px;
}

.vocab-card-lbl {
  font-size: 13px;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.scard {
  background: var(--surface2);
  border: 1px solid var(--border2);
  padding: 16px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s;
}

.scard-v {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink1);
}

.scard-l {
  font-size: 10px;
  color: var(--ink3);
  text-transform: uppercase;
  margin-top: 4px;
}

.pbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pbar-lbl {
  width: 50px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink2);
}

.pbar-track {
  flex: 1;
  height: 8px;
  background: var(--border2);
  border-radius: 4px;
  overflow: hidden;
}

.pbar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pbar-pct {
  width: 55px;
  font-size: 11px;
  text-align: right;
  color: var(--ink3);
  font-family: monospace;
}

.hw-item {
  background: var(--surface1);
  border: 1px solid var(--border2);
  padding: 12px 15px;
  border-radius: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.hw-item:hover {
  border-color: var(--blue);
  transform: translateX(5px);
}

.hw-hz {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink1);
  min-width: 50px;
}

.hw-info {
  flex: 1;
}

.hw-rate {
  background: #fff1f0;
  color: #ff4d4f;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
}

.sreset {
  background: none;
  border: 1px solid var(--red-alpha);
  color: var(--red);
  opacity: 0.6;
  border-radius: 12px;
  padding: 10px;
  transition: all 0.2s;
}

.sreset:hover {
  opacity: 1;
  background: var(--red-alpha);
}

/* Header Actions & Support */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-support {
  background: #fff5e6;
  border: 1px solid #ffd9a3;
  color: #d48806;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-support:hover {
  background: #ffe7ba;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-kofi {
  background-color: #29abe0;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.btn-kofi:hover {
  background-color: #1e88b5;
}

.btn-profile {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink2);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px;
  transition: color 0.2s;
}

.btn-profile:hover {
  color: var(--ink);
}

@media (max-width: 650px) {
  .btn-support span {
    display: none;
  }

  .btn-profile span {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }
}

/* Profile Tabs */
.profile-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.p-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink3);
  cursor: pointer;
  border-radius: 8px;
  transition: all .2s;
}

.p-tab:hover {
  background: var(--surface2);
  color: var(--ink);
}

.p-tab.active {
  background: var(--surface2);
  color: var(--blue);
}

.pview {
  animation: pviewFadeIn .2s ease-out;
}

@keyframes pviewFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Support QR */
@media (max-width: 768px) {
  .qr-desktop-only {
    display: none !important;
  }
}

.qr-box {
  margin-top: 15px;
  padding: 15px;
  background: white;
  border-radius: 12px;
  display: inline-block;
  border: 1px solid var(--border);
}

@media (max-width: 480px) {
  .modal-card {
    padding: 24px 16px;
  }
}

.active-pill {
  background: var(--blue) !important;
  color: white !important;
  box-shadow: 0 4px 12px var(--blue-alpha);
}
/* ─── TEST SYSTEM RE-DESIGN ────────────────────────────── */

.test-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 440px;
}

.test-menu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
}

.test-menu-card:hover {
  transform: translateY(-4px);
  border-color: var(--blue);
  box-shadow: 0 12px 24px rgba(30, 80, 255, 0.12);
}

.test-menu-card:active {
  transform: scale(0.96);
}

.tmc-icon {
  font-size: 32px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

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

/* Container & Header */
.test-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.3s ease-out;
}

.test-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.tpb-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.4s ease;
}

.test-stats-row {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.tsr-item {
  font-size: 13px;
  color: var(--ink3);
  font-weight: 500;
}

.tsr-item b {
  color: var(--blue);
}

/* Main Cards */
.test-main-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 24px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tmc-hz {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 8px;
}

.tmc-py {
  font-size: 18px;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tmc-tr {
  font-size: 16px;
  color: var(--ink2);
  margin-top: 12px;
  font-weight: 500;
}

/* Options */
.test-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.test-opt-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--ink);
}

.test-opt-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.test-opt-btn.correct {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.test-opt-btn.wrong {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* MatchingBoard */
.test-instruction {
  font-size: 14px;
  color: var(--ink2);
  text-align: center;
  margin-bottom: -10px;
}

.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.match-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.match-item.char {
  flex-direction: column;
  font-size: 18px;
}

.match-py {
  font-size: 10px;
  color: var(--blue);
  opacity: 0.7;
  margin-top: 2px;
}

.match-item:hover:not(.matched) {
  border-color: var(--blue);
}

.match-item.selected {
  border-color: var(--blue);
  background: var(--blue-bg);
  box-shadow: 0 0 0 2px var(--blue-alpha);
}

.match-item.matched {
  opacity: 0.3;
  pointer-events: none;
  background: var(--surface2);
  border-color: transparent;
}

.match-item.error {
  border-color: var(--red);
  background: var(--red-bg);
  animation: shake 0.4s;
}

/* Input Group */
.test-input-group {
  position: relative;
  width: 100%;
}

.premium-input {
  width: 100%;
  padding: 18px 24px;
  border-radius: 18px;
  border: 2px solid var(--border);
  font-size: 18px;
  font-weight: 600;
  outline: none;
  background: var(--surface);
  transition: all 0.3s;
  text-align: center;
}

.premium-input:focus {
  border-color: var(--blue);
  box-shadow: 0 8px 16px var(--blue-alpha);
}
