/* GCSE topic library (gcse-maths-topics.html): tier choice, search, grade dropdowns, topic rows */
.topic-library .tool-wrap { max-width: 920px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


.tl-tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.tl-tier-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; padding: 0.9rem 1.1rem; border: 2px solid var(--line); border-radius: var(--r); background: var(--paper); font-family: var(--font-sans); text-align: left; cursor: pointer; transition: 0.15s; min-height: 44px; }
.tl-tier-btn strong { font-size: 1.15rem; color: var(--ink); }
.tl-tier-btn span { font-size: 0.88rem; color: var(--text-soft); }
.tl-tier-btn:hover { border-color: var(--accent); }
.tl-tier-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tl-tier-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.tl-search { position: relative; margin-bottom: 0.5rem; }
.tl-search input { width: 100%; box-sizing: border-box; min-height: 48px; padding: 0.7rem 5.5rem 0.7rem 1rem; border: 1.5px solid var(--line); border-radius: var(--r-pill); font: inherit; font-size: 1rem; background: #fff; }
.tl-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: var(--cream-2); color: var(--ink); border-radius: var(--r-pill); padding: 0.35rem 0.8rem; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.tl-hint { font-size: 0.88rem; color: var(--text-soft); margin-bottom: 1.25rem; }

.tl-grade { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); margin-bottom: 0.6rem; box-shadow: var(--shadow-sm); overflow: hidden; }
.tl-grade summary { display: flex; align-items: center; gap: 0.9rem; padding: 0.75rem 1rem; cursor: pointer; list-style: none; min-height: 56px; }
.tl-grade summary::-webkit-details-marker { display: none; }
.tl-grade summary:hover { background: var(--cream); }
.tl-grade summary:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.tl-gnum { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 800; font-size: 1.15rem; flex: none; }
.tl-grade[data-grade="1"] .tl-gnum, .tl-grade[data-grade="2"] .tl-gnum { background: #1e9e5a; }
.tl-grade[data-grade="3"] .tl-gnum { background: #2a9d8f; }
.tl-grade[data-grade="4"] .tl-gnum, .tl-grade[data-grade="5"] .tl-gnum { background: var(--accent); }
.tl-grade[data-grade="6"] .tl-gnum { background: #3f55c9; }
.tl-grade[data-grade="7"] .tl-gnum { background: #2f3f9e; }
.tl-grade[data-grade="8"] .tl-gnum, .tl-grade[data-grade="9"] .tl-gnum { background: var(--ink); }
.tl-gtitle { font-weight: 700; font-size: 1.08rem; color: var(--ink); }
.tl-gcount { margin-left: auto; font-size: 0.88rem; color: var(--text-soft); white-space: nowrap; }
.tl-chev { width: 10px; height: 10px; border-right: 2px solid var(--text-soft); border-bottom: 2px solid var(--text-soft); transform: rotate(45deg); transition: transform 0.15s; margin: 0 0.3rem 0.3rem 0; flex: none; }
.tl-grade[open] .tl-chev { transform: rotate(-135deg); margin: 0.3rem 0.3rem 0 0; }

.tl-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tl-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--line-cool); }
.tl-row:last-child { border-bottom: 0; }
.tl-row.done .tl-name { color: var(--text-soft); text-decoration: line-through; text-decoration-color: #1e9e5a; }
.tl-tick { position: relative; flex: none; width: 26px; height: 26px; cursor: pointer; }
.tl-tick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tl-tick span { display: block; width: 24px; height: 24px; border: 2px solid #b8c4d6; border-radius: 7px; background: #fff; transition: 0.12s; }
.tl-tick input:checked + span { background: #1e9e5a; border-color: #1e9e5a; }
.tl-tick input:checked + span::after { content: ""; position: absolute; left: 8px; top: 4px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.tl-tick input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 2px; }
.tl-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.tl-name { font-weight: 600; color: var(--ink); }
.tl-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; font-size: 0.8rem; color: var(--text-soft); }
.tl-grade .tl-meta .tl-g { display: none; }           /* grade shown only in search results */
.tl-tier { font-weight: 600; }
.tl-tier--F { color: #1e9e5a; } .tl-tier--H { color: #2f3f9e; } .tl-tier--FH { color: var(--accent); }
.tl-links { display: flex; gap: 0.4rem; flex: none; }
.tl-btn { padding: 0.45rem 0.85rem; font-size: 0.85rem; min-height: 40px; white-space: nowrap; }
.tl-results { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 1.25rem; }
.tl-results .tl-row .tl-g { display: inline; font-weight: 700; color: var(--ink); }
.tl-empty { color: var(--text-soft); margin-bottom: 1.25rem; }
.tl-hidden { display: none !important; }

@media (max-width: 640px) {
  .tl-tiers { grid-template-columns: 1fr; }
  .tl-row { flex-wrap: wrap; }
  .tl-main { flex-basis: calc(100% - 26px - 0.75rem); }
  .tl-links { width: 100%; padding-left: calc(26px + 0.75rem); }
  .tl-btn { flex: 1 1 0; text-align: center; justify-content: center; }
  .tl-gcount { font-size: 0.8rem; }
}
@media print { .tl-tiers, .tl-search, .tl-hint, .tl-links { display: none; } .tl-grade { break-inside: avoid; } }

/* ---------- row extras ---------- */
a.tl-name { text-decoration: none; } a.tl-name:hover { text-decoration: underline; color: var(--accent); }
.tl-ans { align-self: center; font-size: 0.85rem; font-weight: 600; color: var(--text-soft); padding: 0.45rem 0.5rem; min-height: 40px; display: inline-flex; align-items: center; white-space: nowrap; }
.tl-ans:hover { color: var(--accent); }
@media (max-width: 640px) { .tl-ans { flex: 0 0 auto; } }

/* ---------- single topic page ---------- */
.topic-single .tool-wrap { max-width: 860px; }
.tp-crumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.88rem; color: var(--text-soft); margin-bottom: 1rem; }
.tp-crumbs a { color: var(--text-soft); } .tp-crumbs a:hover { color: var(--accent); }
.tp-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 0.75rem; }
.tp-actions .btn { min-height: 44px; }
.tp-done { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0.25rem 0 1.5rem; font-weight: 600; color: var(--ink); cursor: pointer; }
.tp-done input { width: 22px; height: 22px; accent-color: #1e9e5a; cursor: pointer; }
.tp-questions h2, .tp-more h2 { font-size: 1.3rem; margin: 0.5rem 0 0.75rem; }
.tp-q { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; margin-bottom: 0.8rem; }
.tp-qh { display: flex; gap: 0.75rem; align-items: flex-start; }
.tp-qh .qn { background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; min-width: 2rem; text-align: center; padding: 0.15rem 0.4rem; flex: none; }
.tp-qt { flex: 1 1 auto; min-width: 0; } .tp-qt p { margin: 0 0 0.4rem; } .tp-qt ol { margin: 0.3rem 0 0 1.2rem; padding: 0; } .tp-qt li { margin-bottom: 0.3rem; }
.tp-qt table { border-collapse: collapse; margin: 0.4rem 0; } .tp-qt td, .tp-qt th { border: 1px solid #8e99b3; padding: 0.2rem 0.6rem; }
.tp-qt .fig { margin: 0.5rem 0 0.25rem; } .tp-qt .fig svg { max-width: 100%; height: auto; display: block; }
.tp-marks { color: var(--text-soft); font-size: 0.85rem; white-space: nowrap; flex: none; }
.tp-a { margin: 0.6rem 0 0 2.75rem; } .tp-a summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 0.92rem; min-height: 32px; display: inline-flex; align-items: center; }
.tp-ans { margin-top: 0.3rem; padding: 0.5rem 0.8rem; background: #e8f7ee; border-radius: 10px; display: inline-block; font-weight: 600; color: #0f6b3b; }
.tp-ans .part { display: inline-block; margin-right: 1rem; }
.tp-near { display: flex; justify-content: space-between; gap: 1rem; margin: 1.5rem 0; font-weight: 600; }
.tp-near a { text-decoration: none; } .tp-near a:hover { text-decoration: underline; }
.tp-more ul { columns: 2; column-gap: 2rem; padding-left: 1.2rem; margin: 0 0 1.5rem; } .tp-more li { margin-bottom: 0.3rem; break-inside: avoid; }
@media (max-width: 640px) { .tp-more ul { columns: 1; } .tp-qh { flex-wrap: wrap; } .tp-a { margin-left: 0; } .tp-actions .btn { flex: 1 1 100%; } }
@media print { .tp-actions, .tp-done, .tp-near, .tp-more, .tp-crumbs { display: none; } .tp-a { display: block; } .tp-q { break-inside: avoid; box-shadow: none; } }

/* ---------- A-level units ---------- */
.tl-unit .tl-unum { border-radius: 12px; font-size: 1.1rem; }
.tl-unit[data-grade="pure"] .tl-unum { background: var(--ink); }
.tl-unit[data-grade="stats"] .tl-unum { background: #1e9e5a; }
.tl-unit[data-grade="mech"] .tl-unum { background: #3f55c9; }
.tl-unit .tl-gtitle small { font-weight: 500; color: var(--text-soft); font-size: 0.85rem; margin-left: 0.4rem; }
