/* ==========================================================================
   MatrixHanzi Speaking — Popup luyện phát âm (redesign v3)
   ---------------------------------------------------------------------------
   Hai màn hình trong một dialog:
     1. Practice  — thẻ luyện đọc một cột, tập trung vào từ mục tiêu & mic.
     2. Result    — bố cục riêng: score hero, dải chỉ số, âm tiết + phân tích.
   Prefix: .mspk-. Hỗ trợ light/dark qua [data-theme='dark'].
   ========================================================================== */

/* ------------------------------- Design Tokens ------------------------------- */
.mspk-scope {
  --mspk-bg: #ffffff;
  --mspk-bg-card: #fbf8f1;
  --mspk-bg-card-subtle: #f5eee1;
  --mspk-stage-1: #fcfaf4;
  --mspk-stage-2: #f7efe1;
  --mspk-surface-tint: rgba(31, 92, 77, 0.04);

  --mspk-ink: #18211b;
  --mspk-ink-secondary: #44524a;
  --mspk-muted: #748077;
  --mspk-faint: #97a199;

  --mspk-line: #e8e1d2;
  --mspk-line-light: rgba(24, 33, 27, 0.065);
  --mspk-line-glow: rgba(31, 92, 77, 0.18);

  --mspk-green: #1f5c4d;
  --mspk-green-strong: #124234;
  --mspk-green-vibrant: #1fa87b;
  --mspk-green-soft: #e9f4ee;
  --mspk-green-glow: rgba(31, 168, 123, 0.24);

  --mspk-amber: #c07a10;
  --mspk-amber-strong: #8a5606;
  --mspk-amber-soft: #fdf1d4;
  --mspk-amber-glow: rgba(192, 122, 16, 0.2);

  --mspk-danger: #d33b3b;
  --mspk-danger-strong: #a71f1f;
  --mspk-danger-soft: #fdeceb;
  --mspk-danger-glow: rgba(211, 59, 59, 0.24);

  --mspk-good: #0d8a66;
  --mspk-blue: #256ba8;
  --mspk-blue-soft: #e6f1fb;

  --mspk-radius-card: 26px;
  --mspk-radius-panel: 18px;

  --mspk-shadow-overlay: 0 48px 120px -32px rgba(11, 20, 15, 0.55), 0 12px 32px -18px rgba(11, 20, 15, 0.25);
  --mspk-shadow-card: 0 1px 2px rgba(24, 33, 27, 0.035);
  --mspk-shadow-lift: 0 16px 36px -18px rgba(24, 33, 27, 0.22);
  --mspk-shadow-primary: 0 10px 24px -10px rgba(31, 92, 77, 0.55);
}

[data-theme='dark'] .mspk-scope {
  --mspk-bg: #151b17;
  --mspk-bg-card: #1a231d;
  --mspk-bg-card-subtle: #202b23;
  --mspk-stage-1: #1e2721;
  --mspk-stage-2: #181e1a;
  --mspk-surface-tint: rgba(95, 211, 168, 0.06);

  --mspk-ink: #eef4ef;
  --mspk-ink-secondary: #c2cec4;
  --mspk-muted: #8b9a8f;
  --mspk-faint: #6d7d71;

  --mspk-line: #2b3930;
  --mspk-line-light: rgba(255, 255, 255, 0.06);
  --mspk-line-glow: rgba(95, 211, 168, 0.22);

  --mspk-green: #5fd3a8;
  --mspk-green-strong: #a7f3d0;
  --mspk-green-vibrant: #34d399;
  --mspk-green-soft: #193025;
  --mspk-green-glow: rgba(52, 211, 153, 0.26);

  --mspk-amber: #efb45f;
  --mspk-amber-strong: #fcd9a2;
  --mspk-amber-soft: #332812;
  --mspk-amber-glow: rgba(239, 180, 95, 0.24);

  --mspk-danger: #f47878;
  --mspk-danger-strong: #fca5a5;
  --mspk-danger-soft: #3a1e1e;
  --mspk-danger-glow: rgba(244, 120, 120, 0.26);

  --mspk-good: #4ade80;
  --mspk-blue: #7ab8ec;
  --mspk-blue-soft: #172a3a;

  --mspk-shadow-overlay: 0 48px 120px -32px rgba(0, 0, 0, 0.8), 0 12px 32px -18px rgba(0, 0, 0, 0.5);
  --mspk-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
  --mspk-shadow-lift: 0 18px 40px -20px rgba(0, 0, 0, 0.6);
  --mspk-shadow-primary: 0 12px 26px -12px rgba(0, 0, 0, 0.65);
}

/* --------------------------------- Overlay ---------------------------------- */
.mspk-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: rgba(13, 19, 15, 0.56);
  backdrop-filter: blur(14px) saturate(0.92);
  -webkit-backdrop-filter: blur(14px) saturate(0.92);
  animation: mspk-fade 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.mspk-overlay[hidden] {
  display: none;
}

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

/* --------------------------------- Dialog ----------------------------------- */
.mspk-card {
  position: relative;
  width: min(640px, calc(100vw - 32px));
  max-height: min(92vh, 880px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--mspk-bg);
  color: var(--mspk-ink);
  border: 1px solid var(--mspk-line-light);
  border-radius: var(--mspk-radius-card);
  box-shadow: var(--mspk-shadow-overlay);
  padding: 18px 22px 20px;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  animation: mspk-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.mspk-card[data-view='result'] {
  width: min(1000px, calc(100vw - 48px));
}

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

@keyframes mspk-rise {
  from {
    transform: translateY(18px) scale(0.975);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* Ẩn scrollbar nhưng vẫn cuộn được */
.mspk-card,
.mspk-card * {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.mspk-card::-webkit-scrollbar,
.mspk-card *::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

.mspk-scope [hidden] {
  display: none !important;
}

.mspk-scope button {
  font-family: inherit;
}

.mspk-scope button:focus-visible,
.mspk-scope [tabindex]:focus-visible {
  outline: 2px solid var(--mspk-green-vibrant);
  outline-offset: 2px;
}

.mspk-view {
  animation: mspk-view-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.mspk-scope .mspk-view:focus,
.mspk-scope .mspk-view:focus-visible {
  outline: none;
}

@keyframes mspk-view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------- Header ----------------------------------- */
.mspk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--mspk-line-light);
  flex: none;
}

.mspk-heading {
  min-width: 0;
  display: flex;
  align-items: center;
}

.mspk-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.25;
  white-space: nowrap;
}

.mspk-eyebrow-tail {
  font-weight: 800;
}

.mspk-spark {
  display: inline-flex;
  align-items: center;
  color: var(--mspk-green);
}

.mspk-head-right {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.mspk-usage-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--mspk-green);
  background: var(--mspk-green-soft);
  border: 1px solid var(--mspk-line-glow);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
  line-height: 1.3;
}

.mspk-usage-pill.is-low {
  color: var(--mspk-danger);
  background: var(--mspk-danger-soft);
  border-color: var(--mspk-danger-glow);
}

.mspk-close-x {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--mspk-line);
  background: var(--mspk-bg);
  color: var(--mspk-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s, color 0.2s, border-color 0.2s;
}

.mspk-close-x:hover {
  background: var(--mspk-bg-card);
  color: var(--mspk-ink);
  border-color: var(--mspk-line-glow);
  transform: rotate(90deg);
}

.mspk-close-x:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ================================ PRACTICE ================================== */
.mspk-view-practice {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mspk-stage {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 22px;
  border: 1px solid var(--mspk-line);
  background:
    radial-gradient(120% 70% at 50% -16%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, var(--mspk-stage-1) 0%, var(--mspk-stage-2) 100%);
  padding: 26px 24px 24px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

[data-theme='dark'] .mspk-stage {
  background:
    radial-gradient(120% 70% at 50% -16%, rgba(95, 211, 168, 0.05) 0%, rgba(95, 211, 168, 0) 62%),
    linear-gradient(180deg, var(--mspk-stage-1) 0%, var(--mspk-stage-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mspk-stage-glow {
  position: absolute;
  top: -210px;
  left: 50%;
  width: 520px;
  height: 420px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 68%);
  pointer-events: none;
}

[data-theme='dark'] .mspk-stage-glow {
  background: radial-gradient(circle, rgba(95, 211, 168, 0.06) 0%, rgba(95, 211, 168, 0) 68%);
}

.mspk-read {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.mspk-read-label {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--mspk-amber-soft);
  color: var(--mspk-amber);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.35;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(192, 122, 16, 0.1);
}

.mspk-pinyin {
  margin-top: 9px;
  min-height: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--mspk-amber);
  text-transform: lowercase;
  line-height: 1.4;
}

.mspk-pinyin:empty {
  display: none;
}

.mspk-hanzi {
  margin: 10px 0 0;
  font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  font-weight: 600;
  font-size: clamp(68px, 9.5vw, 104px);
  line-height: 1.06;
  letter-spacing: 0.035em;
  color: var(--mspk-ink);
  word-break: break-word;
  text-wrap: balance;
}

.mspk-hanzi.is-m { font-size: clamp(46px, 6.6vw, 68px); }
.mspk-hanzi.is-l { font-size: clamp(34px, 4.8vw, 48px); }
.mspk-hanzi.is-xl { font-size: clamp(26px, 3.8vw, 34px); line-height: 1.35; }

.mspk-translation {
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 500;
  font-style: italic;
  color: var(--mspk-muted);
  max-width: 46ch;
}

.mspk-listen-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
}

.mspk-listen {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--mspk-line);
  background: var(--mspk-bg);
  color: var(--mspk-ink);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--mspk-shadow-card);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, border-color 0.2s, background 0.2s;
}

.mspk-listen svg {
  color: var(--mspk-green);
  flex: none;
}

.mspk-listen:hover {
  transform: translateY(-1px);
  border-color: var(--mspk-line-glow);
  box-shadow: 0 8px 18px -10px rgba(24, 33, 27, 0.22);
}

.mspk-listen:active {
  transform: translateY(0);
}

.mspk-mic-zone {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
  width: 100%;
}

.mspk-mic-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mspk-mic-glow {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, rgba(31, 168, 123, 0.3) 0%, rgba(31, 168, 123, 0) 70%);
  filter: blur(4px);
  transition: background 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.mspk-mic-ripple {
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 1.5px solid rgba(224, 62, 62, 0.42);
  opacity: 0;
  pointer-events: none;
}

.mspk-mic-wrap.is-recording .ripple-1 {
  animation: mspk-ripple-expand 2.2s cubic-bezier(0.16, 0.84, 0.44, 1) infinite;
}

.mspk-mic-wrap.is-recording .ripple-2 {
  animation: mspk-ripple-expand 2.2s cubic-bezier(0.16, 0.84, 0.44, 1) 1s infinite;
}

@keyframes mspk-ripple-expand {
  0% { transform: scale(1); opacity: 0.55; }
  70% { opacity: 0; }
  100% { transform: scale(1.72); opacity: 0; }
}

.mspk-level {
  position: absolute;
  inset: 19px;
  border-radius: 50%;
  border: 2px solid rgba(224, 62, 62, var(--mspk-level-alpha, 0.24));
  transform: scale(var(--mspk-level-scale, 1));
  transition: transform 0.09s ease-out, border-color 0.09s ease-out;
  opacity: 0;
  pointer-events: none;
}

.mspk-mic-wrap.is-recording .mspk-level {
  opacity: 1;
}

.mspk-mic-progress {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.mspk-mic-wrap.is-recording .mspk-mic-progress {
  opacity: 1;
}

.mspk-mic-progress .track {
  fill: none;
  stroke: rgba(224, 62, 62, 0.14);
  stroke-width: 2.5;
}

.mspk-mic-progress .bar {
  fill: none;
  stroke: #e04a4a;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 364.42;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear;
}

.mspk-mic {
  position: relative;
  z-index: 2;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(155deg, #2fbf8f 0%, #15926d 52%, #0b7055 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow:
    0 16px 32px -10px rgba(16, 140, 100, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s, background 0.22s;
}

.mspk-mic svg {
  width: 30px;
  height: 30px;
}

.mspk-mic:hover:not(:disabled) {
  transform: scale(1.045);
  box-shadow:
    0 20px 38px -10px rgba(16, 140, 100, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.mspk-mic:active:not(:disabled) {
  transform: scale(0.985);
}

.mspk-mic:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.mspk-mic.is-recording {
  background: linear-gradient(155deg, #ef5555 0%, #d32626 55%, #b01c1c 100%);
  box-shadow:
    0 16px 34px -10px rgba(200, 30, 30, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: mspk-pulse-record 1.9s ease-in-out infinite;
}

.mspk-mic-wrap.is-recording .mspk-mic-glow {
  background: radial-gradient(circle at 50% 46%, rgba(224, 62, 62, 0.32) 0%, rgba(224, 62, 62, 0) 70%);
}

@keyframes mspk-pulse-record {
  0%, 100% {
    box-shadow:
      0 16px 34px -10px rgba(200, 30, 30, 0.55),
      0 0 0 0 rgba(224, 62, 62, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
  }
  50% {
    box-shadow:
      0 18px 38px -10px rgba(200, 30, 30, 0.62),
      0 0 0 14px rgba(224, 62, 62, 0),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
  }
}

.mspk-mic.is-processing {
  background: linear-gradient(155deg, #1c8977 0%, #116153 100%);
  cursor: progress;
}

.mspk-mic.is-processing svg {
  animation: mspk-spin 0.9s linear infinite;
}

@keyframes mspk-spin {
  to { transform: rotate(360deg); }
}

.mspk-helper {
  margin-top: 13px;
  min-height: 20px;
  max-width: 430px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--mspk-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mspk-helper.is-recording {
  color: var(--mspk-danger);
  font-weight: 700;
}

/* --------------------------------- Actions ---------------------------------- */
.mspk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}

.mspk-view-practice .mspk-actions,
.mspk-view-result .mspk-actions {
  margin-top: 2px;
  padding-top: 15px;
  border-top: 1px solid var(--mspk-line-light);
}

.mspk-actions-left,
.mspk-actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mspk-actions-right {
  margin-left: auto;
}

.mspk-action {
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--mspk-line);
  background: var(--mspk-bg);
  color: var(--mspk-ink);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(24, 33, 27, 0.03);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.mspk-action svg {
  width: 15px;
  height: 15px;
  color: var(--mspk-green);
  flex: none;
}

.mspk-action:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--mspk-bg-card);
  border-color: var(--mspk-line-glow);
  box-shadow: 0 8px 18px -12px rgba(24, 33, 27, 0.25);
}

.mspk-action:active:not(:disabled) {
  transform: translateY(0);
}

.mspk-action:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.mspk-action.is-playing {
  border-color: var(--mspk-green);
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
}

.mspk-action-primary {
  background: linear-gradient(150deg, #276d59 0%, #184b3d 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: var(--mspk-shadow-primary);
}

.mspk-action-primary svg {
  color: #d9f0e6;
}

.mspk-action-primary:hover:not(:disabled) {
  background: linear-gradient(150deg, #2c7a64 0%, #1b5444 100%);
  color: #ffffff;
  box-shadow: 0 14px 28px -12px rgba(31, 92, 77, 0.6);
}

.mspk-dismiss {
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.mspk-dismiss:hover {
  background: var(--mspk-green-vibrant);
  color: #ffffff;
}

[data-theme='dark'] .mspk-dismiss:hover {
  color: #0d1b13;
}

/* ================================= RESULT =================================== */
.mspk-view-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mspk-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* -------------------------------- Hero -------------------------------------- */
.mspk-result-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  padding: 20px 22px;
  border-radius: 20px;
  border: 1px solid var(--mspk-line);
  background:
    radial-gradient(90% 140% at 100% 0%, rgba(31, 168, 123, 0.09) 0%, rgba(31, 168, 123, 0) 58%),
    linear-gradient(135deg, var(--mspk-stage-1) 0%, var(--mspk-stage-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

[data-theme='dark'] .mspk-result-hero {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mspk-result-hero.has-coverage {
  grid-template-columns: auto minmax(0, 1fr) minmax(180px, 210px);
}

.mspk-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: none;
}

.mspk-ring {
  --ring-color: var(--mspk-good);
  position: relative;
  width: 118px;
  height: 118px;
  flex: none;
  filter: drop-shadow(0 10px 20px var(--mspk-green-glow));
}

.mspk-ring.tier-mid {
  filter: drop-shadow(0 10px 20px var(--mspk-amber-glow));
}

.mspk-ring.tier-low {
  filter: drop-shadow(0 10px 20px var(--mspk-danger-glow));
}

.mspk-ring.tier-none {
  filter: none;
}

.mspk-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.mspk-ring .track {
  fill: none;
  stroke: var(--mspk-line);
  stroke-width: 8.5;
  opacity: 0.75;
}

.mspk-ring .arc {
  fill: none;
  stroke: url(#mspkGradGood);
  stroke-width: 8.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.mspk-ring.tier-mid .arc { stroke: url(#mspkGradMid); }
.mspk-ring.tier-low .arc { stroke: url(#mspkGradLow); }
.mspk-ring.tier-none .arc { stroke: var(--mspk-line); }

.mspk-ring .value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--mspk-ink);
  line-height: 1;
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.mspk-ring.tier-mid .value { color: var(--mspk-amber); }
.mspk-ring.tier-low .value { color: var(--mspk-danger); }
.mspk-ring.tier-none .value { color: var(--mspk-muted); }

.mspk-ring .value small {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mspk-muted);
}

.mspk-ring-caption {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mspk-muted);
}

.mspk-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mspk-summary-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.mspk-summary-eyebrow {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mspk-muted);
  white-space: nowrap;
}

.mspk-result-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--mspk-green-soft);
  border: 1px solid var(--mspk-line-glow);
  color: var(--mspk-green);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
}

.mspk-result-status .status-icon {
  display: inline-flex;
  width: 13px;
  height: 13px;
  align-items: center;
  justify-content: center;
}

.mspk-result-status .status-icon svg {
  width: 12px;
  height: 12px;
}

.mspk-result-status.tier-mid {
  background: var(--mspk-amber-soft);
  border-color: rgba(192, 122, 16, 0.26);
  color: var(--mspk-amber);
}

.mspk-result-status.tier-low {
  background: var(--mspk-danger-soft);
  border-color: var(--mspk-danger-glow);
  color: var(--mspk-danger);
}

.mspk-result-status.tier-none {
  background: var(--mspk-bg-card);
  border-color: var(--mspk-line);
  color: var(--mspk-muted);
}

.mspk-result-target {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
}

.mspk-result-target[hidden] {
  display: none !important;
}

.mspk-result-target .rt-hanzi {
  font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  font-size: clamp(26px, 2.8vw, 34px);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--mspk-ink);
}

.mspk-result-target .rt-hanzi.is-m { font-size: 25px; }
.mspk-result-target .rt-hanzi.is-l { font-size: 20px; }
.mspk-result-target .rt-hanzi.is-xl { font-size: 17px; line-height: 1.4; }

.mspk-result-target .rt-pinyin {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--mspk-amber);
  line-height: 1.4;
}

.mspk-verdict {
  margin: 3px 0 0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--mspk-ink-secondary);
  max-width: 58ch;
}

.mspk-result-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.mspk-transcript-base {
  font-size: 11px;
  font-weight: 600;
  color: var(--mspk-muted);
  line-height: 1.4;
}

.mspk-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--mspk-bg);
  border: 1px solid var(--mspk-line-light);
  color: var(--mspk-muted);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
}

/* ------------------------------- Coverage ----------------------------------- */
.mspk-coverage {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--mspk-line);
  min-width: 0;
}

[data-theme='dark'] .mspk-coverage {
  background: rgba(255, 255, 255, 0.045);
}

.mspk-coverage-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.mspk-coverage-title {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mspk-muted);
  white-space: nowrap;
}

.mspk-coverage-count {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--mspk-green);
  white-space: nowrap;
}

.mspk-coverage-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(31, 92, 77, 0.12);
  overflow: hidden;
}

[data-theme='dark'] .mspk-coverage-track {
  background: rgba(255, 255, 255, 0.1);
}

.mspk-coverage-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35c493 0%, #0c8a67 100%);
  transform-origin: left center;
  animation: mspk-grow 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mspk-coverage-hint {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--mspk-muted);
}

/* -------------------------------- Metrics ----------------------------------- */
.mspk-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--mspk-line);
  border-radius: var(--mspk-radius-panel);
  background: var(--mspk-bg);
  overflow: hidden;
  box-shadow: var(--mspk-shadow-card);
}

.mspk-metric {
  min-width: 0;
  padding: 13px 15px 12px;
  border-left: 1px solid var(--mspk-line-light);
}

.mspk-metric:first-child {
  border-left: 0;
}

.mspk-metric .m-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mspk-metric .m-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
  display: grid;
  place-items: center;
  flex: none;
}

.mspk-metric .m-icon svg {
  width: 12px;
  height: 12px;
}

.mspk-metric .m-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mspk-ink-secondary);
}

.mspk-metric .m-figure {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin: 8px 0 6px;
}

.mspk-metric .m-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--mspk-good);
}

.mspk-metric .m-figure small {
  font-size: 9px;
  font-weight: 600;
  color: var(--mspk-muted);
}

.mspk-metric .m-bar {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: var(--mspk-line);
  overflow: hidden;
}

.mspk-metric .m-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35c493 0%, #0c8a67 100%);
  transform-origin: left center;
  animation: mspk-grow 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mspk-metric .m-hint {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--mspk-muted);
}

.mspk-metric.tier-mid .m-icon { background: var(--mspk-amber-soft); color: var(--mspk-amber); }
.mspk-metric.tier-mid .m-value { color: var(--mspk-amber); }
.mspk-metric.tier-mid .m-bar i { background: linear-gradient(90deg, #f0b64f 0%, #c07a10 100%); }

.mspk-metric.tier-low .m-icon { background: var(--mspk-danger-soft); color: var(--mspk-danger); }
.mspk-metric.tier-low .m-value { color: var(--mspk-danger); }
.mspk-metric.tier-low .m-bar i { background: linear-gradient(90deg, #f08585 0%, #cd3535 100%); }

.mspk-metric.is-missing {
  background: var(--mspk-bg-card);
}

.mspk-metric.is-missing .m-icon {
  background: var(--mspk-bg-card-subtle);
  color: var(--mspk-muted);
}

.mspk-metric.is-missing .m-value {
  color: var(--mspk-muted);
}

[data-theme='dark'] .mspk-metric.tier-mid .m-bar i { background: linear-gradient(90deg, #efb45f 0%, #d9942c 100%); }
[data-theme='dark'] .mspk-metric.tier-low .m-bar i { background: linear-gradient(90deg, #f47878 0%, #d34a4a 100%); }

@keyframes mspk-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* --------------------------- Syllables + Analysis --------------------------- */
.mspk-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.mspk-panel {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--mspk-line);
  border-radius: var(--mspk-radius-panel);
  background: var(--mspk-bg);
}

.mspk-units-wrap {
  background: linear-gradient(180deg, var(--mspk-bg-card) 0%, var(--mspk-bg) 100%);
}

.mspk-detail-wrap {
  display: flex;
  flex-direction: column;
}

.mspk-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--mspk-line-light);
}

.mspk-section-title {
  min-width: 0;
}

.mspk-section-head h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -0.005em;
  color: var(--mspk-ink);
  line-height: 1.3;
}

.mspk-units-hint {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--mspk-muted);
}

.mspk-units-hint:empty {
  display: none;
}

.mspk-detail-hint {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--mspk-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

.mspk-units {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.mspk-unit {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 10px 8px 8px;
  border: 1px solid var(--mspk-line);
  border-radius: 13px;
  background: var(--mspk-bg);
  font: inherit;
  color: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(24, 33, 27, 0.025);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.mspk-unit:hover {
  transform: translateY(-2px);
  border-color: var(--mspk-line-glow);
  box-shadow: var(--mspk-shadow-lift);
}

.mspk-unit .u-char {
  font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--mspk-ink);
}

.mspk-unit .u-pinyin {
  margin-top: 1px;
  min-height: 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.015em;
  color: var(--mspk-amber);
}

.mspk-unit .u-number {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--mspk-good);
}

.mspk-unit .u-number small {
  font-size: 8px;
  font-weight: 600;
  color: var(--mspk-muted);
}

.mspk-unit .u-score {
  width: 100%;
  height: 3px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--mspk-line);
  overflow: hidden;
}

.mspk-unit .u-score i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35c493 0%, #0c8a67 100%);
  transform-origin: left center;
  animation: mspk-grow 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mspk-unit .u-error {
  margin-top: 5px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--mspk-danger-soft);
  color: var(--mspk-danger);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.4;
}

.mspk-unit.tier-mid .u-number { color: var(--mspk-amber); }
.mspk-unit.tier-mid .u-score i { background: linear-gradient(90deg, #f0b64f 0%, #c07a10 100%); }

.mspk-unit.tier-low .u-number { color: var(--mspk-danger); }
.mspk-unit.tier-low .u-score i { background: linear-gradient(90deg, #f08585 0%, #cd3535 100%); }

.mspk-unit.tier-none .u-number {
  font-size: 9px;
  font-weight: 600;
  color: var(--mspk-muted);
}

.mspk-unit.is-unheard {
  border-style: dashed;
  background: var(--mspk-bg-card);
}

.mspk-unit.is-wrong {
  border-color: rgba(211, 59, 59, 0.34);
}

.mspk-unit.is-selected {
  border-color: var(--mspk-green);
  background: var(--mspk-green-soft);
  box-shadow: 0 0 0 1.5px var(--mspk-green), 0 10px 22px -14px rgba(31, 168, 123, 0.55);
  transform: translateY(-2px);
}

.mspk-unit.is-selected .u-char {
  color: var(--mspk-green-strong);
}

.mspk-units-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px 14px;
  border: 1px dashed var(--mspk-line);
  border-radius: 12px;
  background: var(--mspk-bg);
  color: var(--mspk-muted);
  font-size: 11.5px;
  line-height: 1.55;
  text-align: center;
}

.mspk-units-empty p {
  margin: 0;
}

.mspk-units-empty .mspk-link-btn {
  margin-top: 10px;
}

.mspk-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border: 1px solid var(--mspk-line-glow);
  border-radius: 999px;
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mspk-link-btn:hover {
  background: var(--mspk-green-vibrant);
  color: #ffffff;
}

/* ------------------------------ Detail inspector ----------------------------- */
.mspk-detail {
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--mspk-line-light);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--mspk-bg-card) 0%, var(--mspk-bg) 100%);
  animation: mspk-detail-slide 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mspk-detail-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.mspk-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 128px;
  margin: 0;
  padding: 0 20px;
  color: var(--mspk-muted);
  font-size: 11.5px;
  line-height: 1.6;
  text-align: center;
}

.mspk-detail-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--mspk-line-light);
}

.mspk-detail-hero .dh-char {
  min-width: 42px;
  font-family: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  color: var(--mspk-ink);
  text-align: center;
}

.mspk-detail-hero .dh-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mspk-detail-hero .dh-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.mspk-detail-hero .dh-pinyin {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--mspk-amber);
  line-height: 1.3;
}

.mspk-detail-hero .dh-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--mspk-green-soft);
  color: var(--mspk-green);
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1.4;
}

.mspk-detail-hero .dh-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--mspk-line);
  overflow: hidden;
}

.mspk-detail-hero .dh-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35c493 0%, #0c8a67 100%);
  transform-origin: left center;
  animation: mspk-grow 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mspk-detail-hero .dh-score {
  flex: none;
  font-size: 15px;
  font-weight: 800;
  color: var(--mspk-ink);
  white-space: nowrap;
}

.mspk-detail-hero .dh-score small {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--mspk-muted);
}

.mspk-detail-hero.tier-mid .dh-badge { background: var(--mspk-amber-soft); color: var(--mspk-amber); }
.mspk-detail-hero.tier-mid .dh-score { color: var(--mspk-amber); }
.mspk-detail-hero.tier-mid .dh-bar i { background: linear-gradient(90deg, #f0b64f 0%, #c07a10 100%); }

.mspk-detail-hero.tier-low .dh-badge { background: var(--mspk-danger-soft); color: var(--mspk-danger); }
.mspk-detail-hero.tier-low .dh-score { color: var(--mspk-danger); }
.mspk-detail-hero.tier-low .dh-bar i { background: linear-gradient(90deg, #f08585 0%, #cd3535 100%); }

.mspk-detail-hero.tier-none .dh-badge { background: var(--mspk-bg-card-subtle); color: var(--mspk-muted); }

.mspk-parts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.mspk-part {
  min-width: 0;
  padding: 8px 9px 9px;
  border: 1px solid var(--mspk-line);
  border-top-width: 2px;
  border-radius: 10px;
  background: var(--mspk-bg);
}

.mspk-part .p-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.mspk-part .p-tag {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.4;
}

.mspk-part .p-label {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--mspk-muted);
  line-height: 1.3;
}

.mspk-part .p-value {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--mspk-ink);
}

.mspk-part.is-initial { border-top-color: var(--mspk-blue); }
.mspk-part.is-initial .p-tag { background: var(--mspk-blue-soft); color: var(--mspk-blue); }
.mspk-part.is-initial .p-value { color: var(--mspk-blue); }

.mspk-part.is-final { border-top-color: var(--mspk-green-vibrant); }
.mspk-part.is-final .p-tag { background: var(--mspk-green-soft); color: var(--mspk-green); }
.mspk-part.is-final .p-value { color: var(--mspk-green); }

.mspk-part.is-tone { border-top-color: var(--mspk-amber); }
.mspk-part.is-tone .p-tag { background: var(--mspk-amber-soft); color: var(--mspk-amber); }
.mspk-part.is-tone .p-value {
  color: var(--mspk-amber);
  font-size: 12.5px;
}

.mspk-detail-row {
  display: grid;
  grid-template-columns: minmax(100px, 1.2fr) minmax(56px, 2fr) 52px;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
  padding: 7px 9px;
  border: 1px solid var(--mspk-line);
  border-radius: 9px;
  background: var(--mspk-bg);
}

.mspk-detail-row .sound {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mspk-ink);
}

.mspk-detail-row .sound small {
  font-size: 9px;
  font-weight: 600;
  color: var(--mspk-amber);
}

.mspk-detail-row .mspk-detail-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--mspk-line);
  overflow: hidden;
}

.mspk-detail-row .mspk-detail-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35c493 0%, #0c8a67 100%);
}

.mspk-detail-row.tier-mid .mspk-detail-bar i { background: linear-gradient(90deg, #f0b64f 0%, #c07a10 100%); }
.mspk-detail-row.tier-low .mspk-detail-bar i { background: linear-gradient(90deg, #f08585 0%, #cd3535 100%); }

.mspk-detail-row .score {
  font-size: 11px;
  font-weight: 800;
  color: var(--mspk-ink);
  text-align: right;
}

.mspk-detail-tone {
  margin: 2px 0 6px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--mspk-muted);
}

.mspk-detail-tips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 9px;
}

.mspk-detail-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(192, 122, 16, 0.16);
  border-radius: 10px;
  background: var(--mspk-amber-soft);
  color: var(--mspk-ink-secondary);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
}

.mspk-detail-tip .tip-icon {
  display: inline-flex;
  flex: none;
  margin-top: 1px;
  color: var(--mspk-amber);
}

.mspk-detail-tip .tip-text {
  min-width: 0;
}

/* --------------------------------- Alerts ----------------------------------- */
.mspk-alert {
  padding: 12px 14px;
  border: 1px solid var(--mspk-line);
  border-radius: 14px;
  background: var(--mspk-bg-card);
  color: var(--mspk-ink-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.mspk-alert.is-error {
  border-color: rgba(211, 59, 59, 0.35);
  background: var(--mspk-danger-soft);
}

.mspk-alert b {
  display: block;
  margin-bottom: 2px;
  color: var(--mspk-ink);
  font-weight: 800;
}

.mspk-alert .mspk-alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mspk-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--mspk-line);
  border-radius: 10px;
  background: var(--mspk-bg);
  color: var(--mspk-ink);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mspk-pill:hover {
  background: var(--mspk-bg-card-subtle);
  border-color: var(--mspk-line-glow);
}

.mspk-btn-primary {
  padding: 7px 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(150deg, #276d59 0%, #184b3d 100%);
  color: #ffffff;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--mspk-shadow-primary);
  transition: transform 0.2s ease, background 0.2s ease;
}

.mspk-btn-primary:hover {
  background: linear-gradient(150deg, #2c7a64 0%, #1b5444 100%);
  transform: translateY(-1px);
}

/* ------------------------------- Responsive --------------------------------- */
@media (max-width: 900px) {
  .mspk-card[data-view='result'] {
    width: min(100%, calc(100vw - 32px));
  }

  .mspk-result-hero,
  .mspk-result-hero.has-coverage {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 18px;
  }

  .mspk-result-hero .mspk-coverage {
    grid-column: 1 / -1;
  }

  .mspk-analysis-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .mspk-units {
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  }
}

@media (max-width: 680px) {
  .mspk-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .mspk-card,
  .mspk-card[data-view='result'] {
    width: 100%;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    padding: 0 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .mspk-head {
    position: sticky;
    top: 0;
    z-index: 7;
    margin: 0 -14px 12px;
    padding: 14px 14px 12px;
    background: var(--mspk-bg);
    border-bottom: 1px solid var(--mspk-line-light);
  }

  .mspk-eyebrow {
    padding: 6px 10px;
    gap: 5px;
    font-size: 9.5px;
    letter-spacing: 0.08em;
  }

  .mspk-usage-pill {
    padding: 5px 9px;
    font-size: 9.5px;
  }

  .mspk-close-x {
    width: 32px;
    height: 32px;
  }

  .mspk-stage {
    padding: 22px 16px 22px;
    border-radius: 20px;
  }

  .mspk-hanzi {
    font-size: clamp(58px, 17vw, 84px);
  }

  .mspk-hanzi.is-m { font-size: clamp(42px, 11vw, 60px); }
  .mspk-hanzi.is-l { font-size: clamp(31px, 8vw, 44px); }
  .mspk-hanzi.is-xl { font-size: clamp(23px, 6vw, 31px); }

  .mspk-listen-row {
    margin-top: 17px;
  }

  .mspk-listen {
    height: 42px;
    padding: 0 16px;
    font-size: 12.5px;
  }

  .mspk-mic-zone {
    margin-top: 17px;
  }

  .mspk-mic-wrap {
    width: 120px;
    height: 120px;
  }

  .mspk-mic {
    width: 84px;
    height: 84px;
  }

  .mspk-mic-progress .bar,
  .mspk-mic-progress .track {
    stroke-width: 2.2;
  }

  .mspk-helper {
    max-width: 320px;
    font-size: 12px;
  }

  .mspk-actions {
    gap: 8px;
  }

  .mspk-actions-left,
  .mspk-actions-right {
    gap: 6px;
  }

  .mspk-action {
    height: 42px;
    gap: 5px;
    padding: 0 10px;
    font-size: 11.5px;
  }

  .mspk-action svg {
    width: 13px;
    height: 13px;
  }

  .mspk-dismiss {
    height: 42px;
    padding: 0 12px;
    font-size: 11.5px;
  }

  .mspk-result-hero,
  .mspk-result-hero.has-coverage {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .mspk-ring-wrap {
    justify-content: center;
    gap: 5px;
    margin-inline: auto;
  }

  .mspk-ring {
    width: 96px;
    height: 96px;
  }

  .mspk-ring .value {
    font-size: 27px;
  }

  .mspk-ring-caption {
    display: block;
  }

  .mspk-summary-top {
    align-items: flex-start;
  }

  .mspk-result-status {
    font-size: 10.5px;
    padding: 4px 10px;
  }

  .mspk-verdict {
    font-size: 12px;
  }

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

  .mspk-metric {
    padding: 12px 13px 11px;
  }

  .mspk-metric:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--mspk-line-light);
  }

  .mspk-metric:nth-child(4) {
    border-top: 1px solid var(--mspk-line-light);
  }

  .mspk-panel {
    padding: 13px 13px;
  }

  .mspk-units {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 7px;
  }

  .mspk-unit {
    padding: 9px 6px 7px;
  }

  .mspk-unit .u-char {
    font-size: 24px;
  }

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

  .mspk-view-result .mspk-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 2px -14px calc(-14px - env(safe-area-inset-bottom, 0px));
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--mspk-bg);
    border-top: 1px solid var(--mspk-line-light);
    box-shadow: 0 -18px 28px -26px rgba(0, 0, 0, 0.4);
  }

}

@media (max-width: 480px) {
  .mspk-eyebrow-tail {
    display: none;
  }

  .mspk-eyebrow {
    font-size: 9px;
    padding: 6px 9px;
  }

  .mspk-usage-pill {
    font-size: 9px;
    padding: 5px 8px;
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mspk-action svg {
    display: none;
  }

  .mspk-action {
    padding: 0 8px;
    font-size: 11px;
  }

  .mspk-dismiss {
    padding: 0 10px;
    font-size: 11px;
  }

  .mspk-listen {
    flex: 1 1 0;
    max-width: none;
    padding: 0 8px;
    white-space: nowrap;
  }

  .mspk-parts {
    grid-template-columns: minmax(0, 1fr);
  }

  .mspk-part {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
  }

  .mspk-part .p-header {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .mspk-part .p-value {
    margin-top: 0;
    font-size: 14px;
  }

  .mspk-part.is-tone .p-value {
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .mspk-actions,
  .mspk-actions-left,
  .mspk-actions-right {
    gap: 4px;
  }

  .mspk-action {
    font-size: 10.5px;
    padding: 0 4px;
    letter-spacing: -0.01em;
  }

  .mspk-dismiss {
    font-size: 10.5px;
    padding: 0 8px;
  }
}

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

/* ------------------------------ Traditional fonts --------------------------- */
.is-traditional .mspk-hanzi,
.mspk-hanzi.is-traditional,
.mspk-scope.is-traditional .mspk-hanzi,
.mspk-scope.is-traditional .mspk-unit .u-char,
.mspk-scope.is-traditional .rt-hanzi,
.mspk-scope.is-traditional .dh-char,
.mspk-scope[lang='zh-Hant'] .mspk-hanzi {
  font-family: 'Noto Serif TC', 'Songti TC', 'PingFang TC', 'Microsoft JhengHei', 'PMingLiU', 'BiauKai', 'Noto Serif SC', serif;
}
