/* The Hindi typing test and the Hindi keyboard (hindi-typing-test, hindi-keyboard and their Hindi twins). The colours are the page's (--bg, --bg-2, --border, --accent ...). */
:root { --ty-bad: #ff7b7b; --ty-warn: #ffb454; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --ty-bad: #c5221f; --ty-warn: #a85a00; } }
:root[data-theme="light"] { --ty-bad: #c5221f; --ty-warn: #a85a00; }

.ty { --ty-font: 'Noto Sans Devanagari','Mangal','Nirmala UI','Kohinoor Devanagari','Devanagari Sangam MN','Mukta',system-ui,sans-serif;
  margin-top: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-2); scroll-margin-top: 72px; }
@media (min-width: 700px) { .ty { padding: 22px; } }
@media (max-width: 480px) { .ty { margin-inline: -8px; padding: 10px 8px; } .ty-osk { --gap: 2px; } }     /* a phone: twelve keys in a row need the width */
.ty [hidden] { display: none !important; }
.ty-nojs { color: var(--text-2); }
.ty button { font-family: inherit; }

/* settings */
.ty-controls { display: flex; flex-direction: column; gap: 10px; }
.ty-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ty-label { min-width: 44px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
html[lang="hi"] .ty-label { text-transform: none; letter-spacing: 0; font-size: 13px; }
.ty-chip { min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; }
.ty-chip:hover { border-color: var(--accent); }
.ty-chip[aria-pressed="true"] { background: var(--accent-lo); border-color: var(--accent); color: var(--accent); }
.ty-chip[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.ty-custom { margin-top: 12px; display: grid; gap: 8px; }
.ty-custom label { font-size: 14px; color: var(--text-2); }
.ty-custom textarea, .ty-input, .ty-pad { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-family: var(--ty-font); }
.ty-custom textarea { padding: 10px 12px; font-size: 17px; line-height: 1.7; resize: vertical; }
.ty-custom .btn { justify-self: start; }

/* the numbers */
.ty-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; text-align: center; }
.ty-stats div { padding: 8px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); min-width: 0; }
.ty-stats b { display: block; font-family: 'Syne', sans-serif; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ty-stats span { display: block; font-size: 11px; color: var(--text-2); line-height: 1.3; padding-inline: 2px; }
.ty.running .ty-stats b { color: var(--accent); }

/* the text to type and the box */
.ty-boxname { display: block; margin: 12px 0 4px; font-size: 12px; font-weight: 700; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
html[lang="hi"] .ty-boxname { text-transform: none; letter-spacing: 0; font-size: 13px; }
label.ty-boxname { cursor: pointer; }
.ty-boxname + .ty-passage, .ty-boxname + .ty-input { margin-top: 0; }
.ty-passage { margin-top: 12px; padding: 0 14px; height: calc(1.9em * 3 + 2px); overflow: hidden; position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--ty-font); font-size: 20px; line-height: 1.9; user-select: none; -webkit-user-select: none; word-spacing: .05em; }
@media (min-width: 700px) { .ty-passage { font-size: 22px; height: calc(1.9em * 4 + 2px); } }
.ty-passage .w { border-radius: 4px; transition: color .1s; }
.ty-passage .w.ok { color: var(--accent); }
.ty-passage .w.bad { color: var(--ty-bad); text-decoration: underline wavy; text-decoration-thickness: 1px; }
.ty-passage .w.skip { color: var(--ty-warn); text-decoration: underline dotted; }
.ty-passage .w.cur { background: var(--accent-lo); box-shadow: 0 0 0 2px var(--accent-lo); }
.ty.finished .ty-passage { opacity: .92; }
.ty-input { margin-top: 10px; padding: 10px 14px; font-size: 20px; line-height: 1.6; min-height: 5em; resize: vertical; }
.ty-input:focus, .ty-pad:focus, .ty-custom textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ty-input[readonly] { opacity: .7; }
.ty-hint { margin-top: 8px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.ty-hint.warn { color: var(--ty-warn); font-weight: 600; }
.ty-opts { display: grid; gap: 2px; margin-top: 10px; }
.ty-check { display: flex; align-items: flex-start; gap: 8px; min-height: 36px; padding: 6px 0; font-size: 14px; cursor: pointer; }
.ty-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.ty-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ty .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; background: transparent; }
.ty .btn-primary { background: var(--accent); border: 0; color: #08080E; }
.ty .btn-ghost { border: 1px solid var(--border); color: var(--text); }
.ty .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* the keyboard on the screen */
.ty-osk { --gap: 3px; --kw: calc((100% - 11 * var(--gap)) / 12); margin: 12px auto 0; max-width: 680px; display: grid; gap: var(--gap); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.ty-row { display: flex; flex-wrap: nowrap; gap: var(--gap); justify-content: center; }
.ty-key { position: relative; flex: 0 0 var(--kw); min-width: 0; height: 46px; padding: 0; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-family: var(--ty-font); font-size: 17px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ty-key .b { line-height: 1; margin-top: 6px; }
.ty-key.mk .b { font-size: 14px; }
.ty-key .s { position: absolute; top: 1px; right: 2px; font-size: 9px; line-height: 1; color: var(--text-2); }
.ty-key:active, .ty-key.on { background: var(--accent-lo); border-color: var(--accent); }
.ty-key.next { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--accent-lo); }
.ty-fn { font-size: 16px; color: var(--text-2); }
.ty-wide { flex: 0 0 calc(var(--kw) * 1.5); }
.ty-space { flex: 1 1 auto; font-family: inherit; font-size: 13px; color: var(--text-2); }
.ty-last .ty-key { height: 48px; }
.ty-stack { display: grid; }
.ty-stack > * { grid-area: 1 / 1; }
.ty-rows { display: grid; gap: var(--gap); }
.ty-sym { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 46px; gap: var(--gap); align-content: start; visibility: hidden; }
.ty-sym .ty-key { height: auto; font-family: inherit; font-size: 20px; }
.ty-stack.sym-on .ty-sym { visibility: visible; }
.ty-stack.sym-on .ty-rows { visibility: hidden; }
@media (min-width: 700px) { .ty-osk { --gap: 5px; } .ty-key { height: 52px; font-size: 20px; } .ty-key .s { font-size: 11px; right: 4px; top: 3px; } .ty-last .ty-key { height: 52px; } .ty-sym { grid-auto-rows: 52px; } }

/* the result */
.ty-result { margin-top: 16px; padding: 16px; border: 1px solid var(--accent); border-radius: 12px; background: var(--bg); scroll-margin-top: 72px; outline: none; }
.ty-result h3 { font-family: 'Syne', sans-serif; font-size: 18px; margin-bottom: 8px; }
html[lang="hi"] .ty-result h3 { font-family: inherit; }
.ty-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ty-big b { font-family: 'Syne', sans-serif; font-size: 56px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.ty-big span { color: var(--text-2); font-size: 15px; }
.ty-note { margin-top: 8px; font-weight: 600; }
.ty-best { margin-top: 2px; font-size: 14px; color: var(--text-2); }
.ty-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
@media (min-width: 560px) { .ty-grid { grid-template-columns: repeat(3, 1fr); } }
.ty-grid div { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.ty-grid dt { font-size: 12px; color: var(--text-2); }
.ty-grid dd { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ty-result h4 { margin-top: 16px; font-size: 14px; color: var(--text-2); }
.ty-miss { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ty-miss li { padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); font-family: var(--ty-font); font-size: 16px; }

/* the Hindi keyboard page */
.ty-pad { height: 8em; padding: 12px 14px; font-size: 22px; line-height: 1.7; resize: vertical; }
@media (min-width: 700px) { .ty-pad { height: 10em; } }
.ty-padbar { margin-top: 6px; }
.ty-count { font-size: 13px; color: var(--text-2); }
.ty-status { min-height: 1.6em; margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.ty-status.warn { color: var(--ty-warn); }
.ty-chart { margin-top: 40px; }
.ty-chart h2 { font-family: 'Syne', sans-serif; font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; letter-spacing: -.01em; margin-bottom: 8px; }
html[lang="hi"] .ty-chart h2 { font-family: inherit; letter-spacing: 0; line-height: 1.4; }
.ty-chart p { color: var(--text-2); font-size: 14px; max-width: 640px; margin-bottom: 14px; }
.ty-chart summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 15px; font-weight: 600; }
.ty-chart summary::-webkit-details-marker { display: none; }
.ty-chart summary::after { content: "\25be"; color: var(--text-2); }
.ty-chart details[open] > summary { margin-bottom: 14px; }
.ty-chart details[open] > summary::after { content: "\25b4"; }
.ty-chart summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ty-chart details[open] .ty-show, .ty-chart details:not([open]) .ty-hide { display: none; }
.ty-chart-rows { display: grid; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.ty-chart-row { display: flex; gap: 6px; min-width: 620px; }
.ty-cell { flex: 1 0 44px; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); font-family: var(--ty-font); }
.ty-cell .k { grid-column: 1 / 3; font-family: 'DM Sans', system-ui, sans-serif; font-size: 11px; font-weight: 700; color: var(--text-2); }
.ty-cell .p { font-size: 20px; line-height: 1.4; }
.ty-cell .s { font-size: 14px; color: var(--accent); text-align: right; }
