* { box-sizing: border-box; }

/* Header */
.brand strong { font-weight: 800; }


/* Layout */
.layout { width: 100%; max-width: 900px; margin: 0 auto; padding: 0 16px; display: grid; gap: 16px; align-content: start; }

/* Hero: score, meters, badge */
.hero {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: grid; grid-template-columns: auto 1fr; gap: 18px 28px; align-items: center;
}
.score { display: flex; flex-direction: column; min-width: 130px; }
.score-label { font-size: .9rem; font-weight: 600; color: var(--muted); }
.score-value { font-size: 4.2rem; line-height: 1; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.score-target { font-size: .9rem; color: var(--muted); margin-top: 4px; }
.meters { display: grid; gap: 14px; }
.meter-head { display: flex; justify-content: space-between; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.meter-head span:last-child { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.track { position: relative; height: 12px; background: #e6eaf0; border-radius: 999px; overflow: visible; }
.fill { height: 100%; width: 0; border-radius: 999px; background: #c2362b; transition: width .25s ease, background-color .25s; }
.meter.met .fill { background: var(--ok); }
.tick { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--navy); border-radius: 2px; }

.badge {
  grid-column: 1 / -1; border: 1.5px solid; border-radius: 8px; padding: 12px 16px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px;
}
.badge-title { font-size: 1.3rem; font-weight: 800; }
.badge-reason { font-size: .95rem; }
.qualified { background: var(--ok-bg); border-color: var(--ok-line); color: #0e5a2b; }
.not-qualified { background: var(--bad-bg); border-color: var(--bad-line); color: #7a1a12; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stat .label { font-size: .85rem; color: var(--muted); }
.stat .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.value.ok { color: var(--ok); }
.value.bad { color: var(--bad); }

/* Editor */
.editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.btn { font: inherit; font-weight: 600; padding: 10px 22px; border-radius: 8px; border: 1.5px solid transparent; cursor: pointer; transition: background .15s, transform .05s; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1b4fc4; }
.btn.primary.resume { background: var(--amber); }
.btn.dark { background: var(--navy); color: #fff; }
.btn.dark:hover:not(:disabled) { background: #0d1c37; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f2f4f8; }
.pause-note { color: var(--amber); font-weight: 600; font-size: .95rem; }

.wrong-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.wrong-title { font-size: .9rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--bad-bg); border: 1px solid var(--bad-line); color: #7a1a12; border-radius: 6px; padding: 2px 9px; font-size: .95rem; font-family: "Source Sans 3", "Noto Sans Devanagari", sans-serif; }

/* Footer */

/* Result dialog */
dialog { border: 0; border-radius: 12px; padding: 24px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(10,20,40,.35); color: var(--ink); }
dialog::backdrop { background: rgba(10,20,40,.55); }
dialog h2 { margin: 0 0 4px; font-size: 1.5rem; }
.result-summary { margin: 0 0 16px; color: var(--muted); }
.result-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0 0 20px; }
.result-grid dt { color: var(--muted); }
.result-grid dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
dialog.pass h2 { color: var(--ok); }
dialog.fail h2 { color: var(--bad); }

@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; }
  .score-value { font-size: 3.4rem; }
  .stat .value { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Home / dashboard */
.seg { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg legend { float: left; margin-right: 12px; font-weight: 600; line-height: 40px; padding: 0; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 8px 16px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-weight: 600; }
.seg input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.card h3 { margin: 0; font-size: 1.15rem; }
.card .sub { color: var(--muted); font-size: .92rem; font-family: "Source Sans 3", "Noto Sans Devanagari", sans-serif; }
.card .big { font-size: 2.6rem; font-weight: 800; color: var(--navy); line-height: 1.1; margin-top: 6px; }
.card .big small { font-size: .95rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
.card .need { font-size: .92rem; }
.card .best { font-size: .88rem; color: var(--ok); font-weight: 600; min-height: 1.3em; }
.card .row { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.card .row .btn { flex: 1; }
.card.add { border-style: dashed; align-items: center; justify-content: center; text-align: center; color: var(--muted); cursor: pointer; min-height: 190px; background: transparent; font: inherit; }
.card.add:hover { background: #fff; color: var(--navy); border-color: var(--navy); }
.card.add b { font-size: 2rem; line-height: 1; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.link.danger { color: var(--bad); }

.history { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.history-head { display: flex; justify-content: space-between; align-items: baseline; }
.history h2 { margin: 0 0 8px; font-size: 1.1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
td.pass { color: var(--ok); font-weight: 700; }
td.fail { color: var(--bad); font-weight: 700; }

.test-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.test-head h1 { font-size: 1.4rem; }

.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; margin-bottom: 12px; flex: 1; }
.field input, .field select { font: inherit; font-weight: 400; padding: 9px 10px; border: 1.5px solid var(--line); border-radius: 8px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.field-row { display: flex; gap: 12px; }
[hidden] { display: none !important; }

/* Typing area with live wrong-word underline (mirror sits behind a transparent textarea) */
.ta-wrap { position: relative; border: 2px solid var(--line); border-radius: 8px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.ta-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.ta-wrap:has(textarea:disabled) { background: #f1f3f6; }
.ta-wrap textarea, .ta-wrap .mirror {
  display: block; width: 100%; min-height: 280px; margin: 0; padding: 16px; border: 0; box-sizing: border-box;
  font: 1.25rem/1.7 "Source Sans 3", "Noto Sans Devanagari", sans-serif; letter-spacing: normal;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4; scrollbar-gutter: stable; overflow: auto;
}
.ta-wrap textarea { position: relative; z-index: 1; background: transparent; color: var(--ink); resize: vertical; outline: none; border-radius: 8px; }
.ta-wrap textarea:disabled { color: var(--muted); cursor: not-allowed; }
.ta-wrap .mirror { position: absolute; inset: 0; height: 100%; color: transparent; pointer-events: none; }
.mirror .mis { background: rgba(180,35,24,.13); text-decoration: underline wavy #c2362b; text-decoration-thickness: 2px; text-underline-offset: 5px; border-radius: 3px; }
.caps-note { background: #fff3cd; color: #7a5300; border: 1px solid #f0d27a; border-radius: 6px; padding: 3px 10px; font-weight: 700; font-size: .9rem; }
.hint { margin: 10px 0 0; font-size: .88rem; color: var(--muted); }
kbd { background: #eef1f6; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font: inherit; font-size: .85em; }

.chart { width: 100%; height: auto; margin: 0 0 14px; }
.chart text { font: 11px "Source Sans 3", sans-serif; fill: #5d6879; }
.chart .axis { stroke: #d6dce5; stroke-width: 1; }
.chart .goal { stroke: #14274a; stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .line { fill: none; stroke: #2563eb; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
dialog { width: min(480px, calc(100% - 32px)); }

.etitle { margin: 0; font: 800 1.35rem "Bricolage Grotesque", sans-serif; color: var(--navy); line-height: 1.2; }
.test-head p:not(.etitle) { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }
.test-head .seg { margin-left: auto; }
.seg.compact span { padding: 5px 12px; font-size: .9rem; }
.seg input:disabled + span { opacity: .45; cursor: not-allowed; }
.dict { margin: 6px 0 0; font-size: .85rem; color: var(--muted); }

/* Align app with the site container and keep brand buttons consistent */
.app-section .layout { max-width: 1080px; padding: 0 20px; }
.app-section .hero, .app-section .editor, .app-section .stats { max-width: 100%; }
.stats { grid-template-columns: repeat(6, 1fr); }
.exam-grid .btn.primary { background: var(--saffron); color: var(--ink); border-bottom: 4px solid var(--saffron-d); }
.exam-grid .btn.primary:hover:not(:disabled) { background: #ffbf4d; }
.exam-grid .btn.primary:active { transform: translateY(2px); border-bottom-width: 2px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 460px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat .value { font-size: 1.35rem; } .test-head .seg { margin-left: 0; } }
