/* Typing Test - Majhi Naukri Tools */
:root {
  --tt-brand: #3d85c6;
  --tt-brand-dark: #2c6396;
  --tt-brand-light: #eaf4fb;
  --tt-border: rgba(61, 133, 198, 0.22);
  --tt-bg: #f4f8fc;
  --tt-surface: #ffffff;
  --tt-text: #1a2332;
  --tt-muted: #5c6b7a;
  --tt-ok: #16a34a;
  --tt-half: #d97706;
  --tt-err: #dc2626;
  --tt-timer: #f59e0b;
  --tt-shadow: 0 8px 28px rgba(61, 133, 198, 0.1);
  --tt-radius: 14px;
  --tt-font: 'DM Sans', system-ui, sans-serif;
  --tt-deva: 'Noto Sans Devanagari', 'Mangal', 'Lohit Devanagari', var(--tt-font);
}

#tool-main {
  font-family: var(--tt-font);
  color: var(--tt-text);
  background: var(--tt-bg);
  background-image: radial-gradient(ellipse 80% 45% at 50% -10%, rgba(61, 133, 198, 0.12), transparent);
  padding-bottom: 28px;
}

.tt-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px 20px;
}

.tt-hero {
  text-align: center;
  margin-bottom: 10px;
  padding: 2px 0 4px;
}

.tt-hero h1 {
  font-size: clamp(1.28rem, 3.5vw, 1.7rem);
  font-weight: 800;
  margin: 0;
  color: var(--tt-brand);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.tt-hero-mr {
  margin: 3px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tt-muted);
  font-family: var(--tt-deva);
  line-height: 1.35;
}

.tt-card {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius);
  box-shadow: var(--tt-shadow);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.tt-card h2 {
  font-size: 0.88rem;
  font-weight: 800;
  margin: 0;
  color: var(--tt-brand-dark);
}

.tt-setup {
  padding: 0;
  overflow: hidden;
}

.tt-setup-head {
  padding: 10px 14px;
  background: linear-gradient(180deg, #f3f8fd 0%, #eaf4fb 100%);
  border-bottom: 1px solid var(--tt-border);
}

.tt-focus-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  box-shadow: var(--tt-shadow);
}

.tt-focus-bar[hidden] {
  display: none !important;
}

.tt-focus-bar-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tt-focus-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tt-muted);
}

.tt-focus-bar-stats {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tt-muted);
}

.tt-focus-bar-stats strong {
  font-size: 1rem;
  font-weight: 800;
  color: var(--tt-brand-dark);
  font-variant-numeric: tabular-nums;
}

.tt-focus-edit {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.78rem;
}

body.tt-focus-mode .tt-hero,
body.tt-focus-mode .tt-setup,
body.tt-focus-mode .tt-tip,
body.tt-focus-mode .tt-kbd,
body.tt-focus-mode .tt-how-btn,
body.tt-focus-mode .tt-how {
  display: none !important;
}

body.tt-focus-mode .tt-passage {
  min-height: 180px;
  max-height: min(52vh, 400px);
  height: min(48vh, 380px);
}

body.tt-focus-mode .tt-type {
  min-height: 128px;
  height: 140px;
}

@media (max-width: 640px) {
  body.tt-focus-mode .tt-stats {
    display: none !important;
  }

  body.tt-focus-mode .tt-wrap {
    padding-top: 2px;
    padding-left: 10px;
    padding-right: 10px;
  }

  body.tt-focus-mode .tt-focus-bar {
    margin-bottom: 6px;
    padding: 6px 10px;
  }

  body.tt-focus-mode .tt-stage {
    margin-bottom: 8px;
  }

  body.tt-focus-mode .tt-passage,
  .tt-passage {
    height: 88px;
    min-height: 72px;
    max-height: 96px;
  }

  body.tt-focus-mode .tt-legend,
  .tt-legend {
    display: none !important;
  }

  body.tt-focus-mode .tt-type {
    min-height: 52px;
    height: 56px;
    margin-bottom: 8px;
  }
}

.tt-setup-grid {
  display: grid;
  gap: 0;
  padding: 2px 0;
}

.tt-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(61, 133, 198, 0.1);
}

.tt-setup-grid .tt-row:last-of-type {
  border-bottom: none;
}

.tt-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--tt-muted);
  min-width: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tt-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tt-seg--pill {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0;
  background: #f1f5f9;
  border: 1px solid var(--tt-border);
  border-radius: 999px;
  padding: 2px;
  max-width: 100%;
  overflow-x: auto;
}

.tt-seg--pill button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--tt-brand-dark);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.tt-seg--pill button:hover {
  background: rgba(255, 255, 255, 0.75);
}

.tt-seg--pill button.is-active {
  background: var(--tt-brand);
  color: #fff;
  box-shadow: 0 2px 6px rgba(61, 133, 198, 0.35);
}

.tt-seg--mins button {
  min-width: 40px;
  padding-left: 8px;
  padding-right: 8px;
}

.tt-seg:not(.tt-seg--pill) button {
  appearance: none;
  border: 1px solid var(--tt-border);
  background: #fff;
  color: var(--tt-brand-dark);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tt-seg:not(.tt-seg--pill) button:hover {
  border-color: var(--tt-brand);
}

.tt-seg:not(.tt-seg--pill) button.is-active {
  background: var(--tt-brand);
  border-color: var(--tt-brand);
  color: #fff;
}

.tt-field {
  flex: 1;
  min-width: 180px;
}

.tt-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tt-muted);
  margin-bottom: 4px;
}

.tt-select,
.tt-input-num,
.tt-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.86rem;
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--tt-text);
}

.tt-row--passage .tt-select {
  min-width: 0;
}

.tt-select:focus,
.tt-input-num:focus,
.tt-textarea:focus {
  outline: none;
  border-color: var(--tt-brand);
  box-shadow: 0 0 0 3px rgba(61, 133, 198, 0.15);
}

.tt-rules-wrap {
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--tt-border);
  background: #f8fbfe;
}

.tt-rules-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--tt-border);
  background: var(--tt-brand-light);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: inherit;
}

.tt-rules-main {
  min-width: 0;
  flex: 1;
}

.tt-rules-head strong {
  display: block;
  color: var(--tt-brand-dark);
  font-size: 0.78rem;
  margin-bottom: 4px;
  line-height: 1.2;
}

.tt-rules-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tt-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.2;
  color: var(--tt-brand-dark);
  background: #fff;
  border: 1px solid var(--tt-border);
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}

.tt-rules-change {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--tt-brand);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--tt-border);
}

.tt-rules-body {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--tt-border);
  border-radius: 8px;
  background: #fff;
}

.tt-rule-block {
  margin-bottom: 10px;
}

.tt-rule-block:last-child {
  margin-bottom: 0;
}

.tt-rule-block > span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tt-muted);
  margin-bottom: 4px;
}

.tt-rule-hint {
  font-size: 0.72rem;
  color: var(--tt-muted);
  margin: 6px 0 0;
}

.tt-qualify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tt-input-num {
  width: 88px;
  flex: 0 0 auto;
}

.tt-custom {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--tt-border);
  background: #fff;
}

.tt-custom p {
  font-size: 0.78rem;
  color: var(--tt-muted);
  margin: 0 0 8px;
  line-height: 1.45;
}

.tt-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.tt-custom-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.tt-btn {
  appearance: none;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.tt-btn-primary {
  background: var(--tt-brand);
  color: #fff;
}

.tt-btn-primary:hover {
  background: var(--tt-brand-dark);
}

.tt-btn-ghost {
  background: #eef2f7;
  color: var(--tt-text);
}

.tt-btn-ghost:hover {
  background: #e2e8f0;
}

.tt-tip {
  background: #fff8f0;
  border: 1px solid #f5d0a9;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 0.78rem;
  color: #7c4a12;
  line-height: 1.4;
  margin-bottom: 10px;
}

.tt-tip[hidden] {
  display: none !important;
}

.tt-tip p {
  margin: 0;
}

.tt-tip-mr {
  font-family: var(--tt-deva);
  opacity: 0.92;
}

.tt-progress {
  display: block;
  margin: 0;
  padding: 0 16px 10px;
}

.tt-progress-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(61, 133, 198, 0.14);
  overflow: hidden;
}

.tt-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tt-brand), var(--tt-brand-dark));
  transition: width 0.18s ease;
}

.tt-word-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--tt-border);
  background: #f3f8fd;
  font-variant-numeric: tabular-nums;
}

.tt-word-counter-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tt-muted);
}

.tt-word-counter strong,
#ttWordCount {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--tt-brand-dark);
  letter-spacing: 0.01em;
}

.tt-kbd {
  background: var(--tt-brand-light);
  border: 1px solid var(--tt-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--tt-text);
  line-height: 1.5;
  margin-bottom: 12px;
}

.tt-kbd strong {
  color: var(--tt-brand-dark);
}

.tt-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin-bottom: 14px;
  color: var(--tt-text);
}

.tt-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(61, 133, 198, 0.08);
  min-width: 0;
}

.tt-stat-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.tt-stat-icon svg {
  width: 20px;
  height: 20px;
}

.tt-stat-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tt-stat strong {
  display: block;
  font-size: clamp(1.15rem, 2.8vw, 1.4rem);
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.tt-stat span {
  font-size: 0.72rem;
  color: var(--tt-muted);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt-stat span em {
  font-style: normal;
  font-weight: 500;
  opacity: 0.85;
}

.tt-stat--time .tt-stat-icon {
  background: #fff7ed;
  color: #c2410c;
}
.tt-stat--time strong { color: #c2410c; }

.tt-stat--wpm .tt-stat-icon {
  background: var(--tt-brand-light);
  color: var(--tt-brand-dark);
}
.tt-stat--wpm strong { color: var(--tt-brand); }

.tt-stat--acc .tt-stat-icon {
  background: #ecfdf5;
  color: #15803d;
}
.tt-stat--acc strong { color: #15803d; }

.tt-stat--err .tt-stat-icon {
  background: #fef2f2;
  color: #b91c1c;
}
.tt-stat--err strong { color: #b91c1c; }

.tt-stage {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: 14px;
  box-shadow: var(--tt-shadow);
  overflow: hidden;
  margin-bottom: 14px;
}

.tt-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px;
  background: linear-gradient(180deg, #f3f8fd 0%, #eaf4fb 100%);
  border-bottom: 1px solid var(--tt-border);
}

.tt-stage-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--tt-brand-dark);
  letter-spacing: 0.01em;
}

.tt-passage {
  background: #fbfcfe;
  border: none;
  border-radius: 0;
  padding: 18px 20px 14px;
  min-height: 200px;
  height: min(40vh, 340px);
  max-height: 400px;
  overflow-y: auto;
  font-size: 1.18rem;
  line-height: 1.95;
  margin-bottom: 0;
  word-break: break-word;
}

body.tt-devanagari .tt-passage,
body.tt-devanagari .tt-type,
body.tt-devanagari .tt-textarea {
  font-family: var(--tt-deva);
  font-size: 1.22rem;
  line-height: 2;
}

.tt-empty-hint {
  color: var(--tt-muted);
  font-size: 0.95rem;
  font-style: italic;
}

.tt-word {
  display: inline;
  margin-right: 0.35em;
  border-radius: 4px;
  padding: 2px 3px;
}

.tt-word.is-current {
  background: rgba(61, 133, 198, 0.18);
  box-shadow: inset 0 -2px 0 var(--tt-brand);
}

.tt-word.is-ok {
  color: var(--tt-ok);
}

.tt-word.is-half {
  color: var(--tt-half);
  text-decoration: underline dotted;
}

.tt-word.is-err {
  color: var(--tt-err);
  text-decoration: underline;
}

.tt-word.is-miss {
  color: #e11d48;
  background: rgba(225, 29, 72, 0.1);
  text-decoration: underline;
}

.tt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  list-style: none;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--tt-border);
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--tt-muted);
}

.tt-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tt-legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}

.tt-legend-swatch--ok {
  background: var(--tt-ok);
}

.tt-legend-swatch--half {
  background: var(--tt-half);
}

.tt-legend-swatch--err {
  background: var(--tt-err);
}

.tt-legend-swatch--miss {
  background: #fda4af;
  box-shadow: inset 0 0 0 1px #e11d48;
}

.tt-type-label {
  display: block;
  padding: 0 16px 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--tt-brand-dark);
  letter-spacing: 0.01em;
}

.tt-type {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  min-height: 112px;
  height: 128px;
  font-family: inherit;
  font-size: 1.22rem;
  line-height: 1.65;
  padding: 14px 16px;
  border: 2px solid var(--tt-border);
  border-radius: 12px;
  background: #fff;
  color: var(--tt-text);
  resize: vertical;
  box-shadow: inset 0 1px 2px rgba(26, 35, 50, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.tt-type::placeholder {
  color: #94a3b8;
  font-size: 0.95em;
}

.tt-type:hover {
  border-color: rgba(61, 133, 198, 0.45);
}

.tt-type:focus {
  outline: none;
  border-color: var(--tt-brand);
  background: #fcfeff;
  box-shadow:
    0 0 0 4px rgba(61, 133, 198, 0.16),
    inset 0 1px 2px rgba(26, 35, 50, 0.03);
}

.tt-type:disabled {
  background: #f1f5f9;
  color: var(--tt-muted);
  cursor: not-allowed;
}

.tt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 4px;
}

.tt-result {
  margin-top: 14px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--tt-border);
  background: var(--tt-surface);
  box-shadow: var(--tt-shadow);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.tt-result *,
.tt-result *::before,
.tt-result *::after {
  box-sizing: border-box;
}

.tt-result.is-pass {
  border-color: #86efac;
}

.tt-result.is-fail {
  border-color: #fecaca;
}

.tt-result-top {
  padding: 14px 16px 12px;
  text-align: center;
}

.tt-result-summary {
  padding: 16px 16px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--tt-border);
}

.tt-result.is-pass .tt-result-summary {
  background: linear-gradient(180deg, #ecfdf5 0%, #f8fafc 100%);
}

.tt-result.is-fail .tt-result-summary {
  background: linear-gradient(180deg, #fff5f5 0%, #f8fafc 100%);
}

.tt-result-summary-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tt-result-score {
  min-width: 0;
  flex: 1 1 auto;
}

.tt-result-score strong {
  display: block;
  font-size: clamp(1.5rem, 7vw, 2.35rem);
  font-weight: 800;
  color: var(--tt-brand-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
  word-break: break-word;
}

.tt-result-score span {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tt-muted);
}

.tt-result-checks {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.tt-result-checks li {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.tt-result-checks li.is-ok {
  color: #15803d;
}

.tt-result-checks li.is-bad {
  color: #dc2626;
}

.tt-result.is-pass .tt-result-top {
  background: linear-gradient(180deg, #ecfdf5 0%, #fff 100%);
}

.tt-result.is-fail .tt-result-top {
  background: linear-gradient(180deg, #fef2f2 0%, #fff 100%);
}

.tt-result-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  max-width: 100%;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  gap: 1px;
}

.tt-result-badge-mr {
  font-size: 0.72em;
  font-weight: 700;
  font-family: var(--tt-deva);
  opacity: 0.9;
}

.tt-result.is-pass .tt-result-badge {
  color: #166534;
  background: #dcfce7;
}

.tt-result.is-fail .tt-result-badge {
  color: #991b1b;
  background: #fee2e2;
}

.tt-result-sub {
  margin: 10px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tt-muted);
}

.tt-result-hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px;
}

.tt-result-hero-item {
  background: #f8fafc;
  border: 1px solid var(--tt-border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  min-width: 0;
}

.tt-result.is-pass .tt-result-hero-item:first-child {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.tt-result.is-fail .tt-result-hero-item:first-child {
  background: #fff1f2;
  border-color: #fecdd3;
}

.tt-result-hero-item span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--tt-muted);
  margin-bottom: 4px;
  line-height: 1.3;
  word-break: break-word;
}

.tt-result-hero-item strong {
  display: block;
  font-size: clamp(1.1rem, 3.5vw, 1.55rem);
  font-weight: 800;
  color: var(--tt-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
  word-break: break-word;
}

.tt-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 12px;
}

.tt-result-grid div {
  background: #f8fafc;
  border: 1px solid rgba(61, 133, 198, 0.12);
  border-radius: 10px;
  padding: 9px 10px;
  min-width: 0;
}

.tt-result-grid span {
  display: block;
  font-size: 0.68rem;
  color: var(--tt-muted);
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.3;
  word-break: break-word;
}

.tt-result-grid strong {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--tt-text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.tt-result-actions {
  display: flex;
  justify-content: center;
  padding: 0 14px 14px;
}

.tt-result-actions .tt-btn {
  width: 100%;
  max-width: 320px;
}

.tt-mistakes {
  margin: 0 14px 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--tt-border);
  background: #fff;
}

.tt-mistakes-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--tt-brand-dark);
}

.tt-mistakes-wrap {
  overflow-x: auto;
  border: 1px solid rgba(61, 133, 198, 0.14);
  border-radius: 8px;
}

.tt-mistakes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 0;
}

.tt-mistakes-table th,
.tt-mistakes-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(61, 133, 198, 0.12);
  vertical-align: top;
}

.tt-mistakes-table th {
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tt-muted);
  white-space: nowrap;
}

.tt-mistakes-table tbody tr:last-child td {
  border-bottom: none;
}

.tt-mistakes-table td:first-child {
  width: 36px;
  color: var(--tt-muted);
  font-variant-numeric: tabular-nums;
}

.tt-m-correct {
  color: var(--tt-ok);
  font-weight: 700;
  font-family: var(--tt-deva);
}

.tt-m-typed {
  color: var(--tt-err);
  font-weight: 700;
  font-family: var(--tt-deva);
}

.tt-mtype {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  margin-right: 4px;
  white-space: nowrap;
}

.tt-mtype--full {
  background: #fee2e2;
  color: #b91c1c;
}

.tt-mtype--half {
  background: #ffedd5;
  color: #c2410c;
}

.tt-mtype--miss {
  background: #ffe4e6;
  color: #be123c;
}

.tt-mistakes-more {
  margin: 8px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tt-muted);
}

.tt-mistakes--none {
  text-align: center;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.tt-mistakes--none p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #166534;
}

.tt-result-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--tt-muted);
}

@media (max-width: 640px) {
  .tt-result {
    margin-top: 10px;
    border-radius: 12px;
  }

  .tt-result-summary {
    padding: 12px;
  }

  .tt-result-summary-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tt-result-score strong {
    font-size: 1.65rem;
  }

  .tt-result-badge {
    align-self: flex-start;
    font-size: 0.72rem;
    padding: 5px 10px;
  }

  .tt-result-checks {
    gap: 8px;
  }

  .tt-result-checks li {
    font-size: 0.76rem;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
  }

  .tt-result-checks li.is-ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
  }

  .tt-result-checks li.is-bad {
    background: #fff1f2;
    border-color: #fecdd3;
  }

  .tt-result-hero {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 12px;
  }

  .tt-result-hero-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .tt-result-hero-item span {
    font-size: 0.72rem;
    margin-bottom: 0;
  }

  .tt-result-hero-item strong {
    font-size: 1.15rem;
  }

  .tt-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 0 12px 10px;
  }

  .tt-result-grid div {
    padding: 8px;
  }

  .tt-result-grid span {
    font-size: 0.62rem;
  }

  .tt-result-grid strong {
    font-size: 0.88rem;
  }

  .tt-mistakes {
    margin: 0 12px 10px;
    padding: 10px;
  }

  .tt-mistakes-title {
    font-size: 0.88rem;
    margin-bottom: 8px;
  }

  .tt-mistakes-wrap {
    border: none;
    overflow: visible;
  }

  .tt-mistakes-table,
  .tt-mistakes-table thead,
  .tt-mistakes-table tbody,
  .tt-mistakes-table tr,
  .tt-mistakes-table th,
  .tt-mistakes-table td {
    display: block;
    width: 100%;
  }

  .tt-mistakes-table {
    min-width: 0;
    font-size: 0.78rem;
  }

  .tt-mistakes-table thead {
    display: none;
  }

  .tt-mistakes-table tr {
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid rgba(61, 133, 198, 0.16);
    border-radius: 10px;
    background: #f8fafc;
  }

  .tt-mistakes-table td {
    border: none;
    padding: 2px 0;
  }

  .tt-mistakes-table td:first-child {
    width: auto;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 4px;
  }

  .tt-mistakes-table td:first-child::before {
    content: '#';
  }

  .tt-mistakes-table td:nth-child(2) {
    margin-bottom: 6px;
  }

  .tt-mistakes-table td:nth-child(3)::before {
    content: 'Correct: ';
    color: var(--tt-muted);
    font-weight: 600;
    font-size: 0.68rem;
  }

  .tt-mistakes-table td:nth-child(4)::before {
    content: 'You typed: ';
    color: var(--tt-muted);
    font-weight: 600;
    font-size: 0.68rem;
  }

  .tt-result-actions {
    padding: 0 12px 12px;
  }

  .tt-result-actions .tt-btn {
    max-width: none;
  }

  .tt-stage-head {
    padding: 7px 12px;
  }

  .tt-passage {
    height: 96px;
    min-height: 80px;
    max-height: 110px;
    font-size: 1rem;
    line-height: 1.55;
    padding: 10px 12px;
  }

  body.tt-devanagari .tt-passage,
  body.tt-devanagari .tt-type {
    font-size: 1.05rem;
    line-height: 1.6;
  }

  .tt-word-counter,
  .tt-progress,
  .tt-type-label {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tt-word-counter {
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 0.72rem;
  }

  .tt-progress {
    padding-bottom: 6px;
  }

  .tt-type-label {
    padding-bottom: 4px;
    font-size: 0.68rem;
  }

  .tt-type {
    width: calc(100% - 24px);
    margin: 0 12px 10px;
    min-height: 64px;
    height: 72px;
    font-size: 1.05rem;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .tt-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }

  .tt-stat {
    padding: 8px 10px;
    gap: 8px;
  }

  .tt-stat-icon {
    width: 30px;
    height: 30px;
  }

  .tt-stat-icon svg {
    width: 15px;
    height: 15px;
  }

  .tt-stat strong {
    font-size: 1.05rem;
  }

  .tt-stat span {
    font-size: 0.62rem;
  }

  .tt-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 12px;
  }

  .tt-seg--pill {
    width: 100%;
  }

  .tt-seg--pill button {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
  }
}

.tt-how-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-top: 1px solid var(--tt-border);
  padding: 12px 4px 4px;
  margin-top: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--tt-brand-dark);
  cursor: pointer;
}

.tt-how {
  font-size: 0.82rem;
  color: var(--tt-muted);
  line-height: 1.55;
  padding: 4px 2px 8px;
}

.tt-how h3 {
  font-size: 0.85rem;
  color: var(--tt-text);
  margin: 12px 0 6px;
}

.tt-how code {
  display: block;
  background: #f1f5f9;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #0f172a;
  margin: 4px 0 8px;
  overflow-x: auto;
}

.tt-how ul {
  margin: 4px 0 8px;
  padding-left: 1.2em;
}

.tt-how li {
  margin-bottom: 2px;
}
