:root {
  --navy: #14274a;
  --navy-2: #1e3a6e;
  --ink: #18212f;
  --muted: #5d6879;
  --line: #d6dce5;
  --bg: #e9edf2;
  --panel: #ffffff;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dff5e7;
  --ok-line: #8fd3a8;
  --bad: #b42318;
  --bad-bg: #fde6e3;
  --bad-line: #f0a9a2;
  --amber: #946200;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.topbar {
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 14px max(16px, calc((100% - 900px) / 2));
  display: flex; flex-wrap: wrap; gap: 12px 24px;
  justify-content: space-between; align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.brand p { margin: 0; font-size: .85rem; opacity: .75; }

.lang-switch { border: 0; margin: 0; padding: 3px; display: flex; gap: 3px; background: rgba(255,255,255,.12); border-radius: 10px; }
.lang-switch label { cursor: pointer; }
.lang-switch input { position: absolute; opacity: 0; }
.lang-switch span {
  display: flex; flex-direction: column; align-items: center; min-width: 104px; padding: 6px 14px;
  border-radius: 8px; font-weight: 600; line-height: 1.2;
  font-family: "Noto Sans Devanagari", "Source Sans 3", sans-serif;
  transition: background .15s, color .15s;
}
.lang-switch small { font-size: .72rem; font-weight: 400; opacity: .8; font-family: "Source Sans 3", sans-serif; }
.lang-switch input:checked + span { background: #fff; color: var(--navy); }
.lang-switch input:focus-visible + span { outline: 3px solid #9ec1ff; outline-offset: 2px; }

/* Layout */
.layout { width: 100%; max-width: 900px; margin: 22px auto 10px; padding: 0 16px; display: grid; gap: 16px; flex: 1; 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; }
textarea {
  width: 100%; min-height: 260px; resize: vertical; padding: 16px;
  font: 1.2rem/1.65 "Source Sans 3", "Noto Sans Devanagari", sans-serif;
  border: 2px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
textarea:disabled { background: #f1f3f6; color: var(--muted); cursor: not-allowed; }

.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 */
.foot { max-width: 900px; width: 100%; margin: 0 auto; padding: 14px 16px 26px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: .85rem; color: var(--muted); }

/* 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; } }
