/* Study Tools: hub and clinical calculators (night theme tokens from ph-theme.css). */
.pg-tools [hidden] { display: none !important; }
.pg-tools .input, .pg-tools .select { font-size: 16px; min-height: 48px; border-radius: 8px; }

/* Hub */
.tl-hub { display: grid; gap: 28px; }
.tl-search { position: relative; display: flex; align-items: center; gap: 12px; max-width: 640px; }
.tl-search > .icon { position: absolute; left: 14px; width: 20px; height: 20px; color: var(--ph-muted); pointer-events: none; }
.tl-search .input { padding-left: 44px !important; flex: 1 1 auto; min-width: 0; }
.tl-count { flex: none; color: var(--ph-muted); font-size: .9rem; }
.tl-hub h2 { color: var(--ph-ink); font-size: 1.2rem; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; }
.tl-hub h2 small { color: var(--ph-muted); font-size: .85rem; font-weight: 500; }

.tl-start-grid { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tl-tile { display: grid; gap: 6px; align-content: start; padding: 16px; border: 1px solid var(--ph-line2); border-radius: 10px; background: var(--ph-surface); color: var(--ph-text); text-decoration: none; transition: border-color .2s, transform .2s; }
.tl-tile:hover, .tl-tile:focus-visible { border-color: var(--ph-magenta); transform: translateY(-2px); }
.tl-tile strong { color: var(--ph-ink); font-size: 1.02rem; }
.tl-tile small { color: var(--ph-muted); font-size: .86rem; line-height: 1.45; }

.tl-ic { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: rgba(225, 28, 242, .1); color: #F08CFF; flex: none; }
.tl-ic .icon { width: 20px; height: 20px; }

.tl-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--ph-line); }
.tl-list li { border-bottom: 1px solid var(--ph-line); }
.tl-list li:nth-child(odd) { border-right: 1px solid var(--ph-line); }
.tl-row { display: flex; align-items: center; gap: 14px; padding: 14px 12px; min-height: 64px; color: var(--ph-text); text-decoration: none; transition: background .2s; }
.tl-row:hover, .tl-row:focus-visible { background: rgba(225, 28, 242, .06); }
.tl-row-t { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.tl-row-t strong { color: var(--ph-ink); font-weight: 600; }
.tl-row-t small { color: var(--ph-muted); font-size: .86rem; overflow-wrap: anywhere; }
.tl-go { width: 18px; height: 18px; color: var(--ph-muted); flex: none; transition: transform .2s; }
.tl-row:hover .tl-go { transform: translateX(3px); color: var(--ph-ink); }

/* Calculator page */
.tl-layout { display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.tl-main { display: grid; gap: 28px; min-width: 0; }
.tl-calc { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.tl-form { padding: 20px; border: 1px solid var(--ph-line2); border-radius: 10px; background: var(--ph-surface); min-width: 0; }
.tl-form-h { color: var(--ph-ink); font-size: 1.05rem; margin: 0 0 16px; }
.tl-field { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.tl-field > label, .tl-field > legend { display: block; color: var(--ph-ink); font-weight: 600; font-size: .95rem; margin-bottom: 8px; padding: 0; }
.tl-opt { color: var(--ph-muted); font-weight: 400; font-size: .82rem; }
.tl-input { display: flex; align-items: stretch; gap: 8px; }
.tl-input .input { flex: 1 1 auto; min-width: 0; }
.tl-unit { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--ph-line); border-radius: 8px; color: var(--ph-muted); font-size: .9rem; white-space: nowrap; }
.tl-unitsel { flex: 0 0 auto; width: auto; min-width: 96px; }
.tl-hint { margin: 6px 0 0; color: var(--ph-muted); font-size: .84rem; }
.tl-ferr { margin: 6px 0 0; color: var(--ph-red); font-size: .86rem; font-weight: 600; }
.tl-ferr:empty { display: none; }
.pg-tools .input.is-invalid { border-color: var(--ph-red); }
.tl-date { color-scheme: dark; }

.tl-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-seg-opt { position: relative; flex: 1 1 auto; }
.tl-seg-opt input, .tl-opt input, .tl-face input, .tl-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tl-seg-opt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 8px 12px; border: 1px solid var(--ph-line2); border-radius: 8px; color: var(--ph-text); font-size: .92rem; cursor: pointer; transition: border-color .15s, background .15s; }
.tl-seg-opt input:checked + span { border-color: var(--ph-magenta); background: rgba(225, 28, 242, .14); color: var(--ph-ink); font-weight: 600; }
.tl-seg-opt input:focus-visible + span, .tl-opt input:focus-visible ~ span, .tl-face input:focus-visible ~ b, .tl-check input:focus-visible ~ .tl-check-text { outline: 2px solid var(--ph-magenta); outline-offset: 2px; }

.tl-item { padding-top: 14px; border-top: 1px solid var(--ph-line); }
.tl-opts { display: grid; gap: 6px; }
.tl-opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--ph-line); border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.tl-opt:hover { border-color: var(--ph-line2); }
.tl-opt:has(input:checked) { border-color: var(--ph-magenta); background: rgba(225, 28, 242, .12); color: var(--ph-ink); }
.tl-pts { flex: none; display: inline-grid; place-items: center; min-width: 32px; height: 28px; padding: 0 6px; border-radius: 6px; background: var(--ph-surface2); color: var(--ph-ink); font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tl-opt:has(input:checked) .tl-pts { background: var(--ph-magenta); }

.tl-check { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--ph-line); border-radius: 8px; cursor: pointer; }
.tl-check-text { flex: 1 1 auto; min-width: 0; padding-left: 30px; position: relative; }
.tl-check-text::before { content: ""; position: absolute; left: 0; top: 50%; width: 20px; height: 20px; margin-top: -10px; border: 1.5px solid var(--ph-line2); border-radius: 4px; }
.tl-check:has(input:checked) { border-color: var(--ph-magenta); background: rgba(225, 28, 242, .12); color: var(--ph-ink); }
.tl-check:has(input:checked) .tl-check-text::before { background: var(--ph-magenta); border-color: var(--ph-magenta); box-shadow: inset 0 0 0 4px var(--ph-surface); }
.tl-check:has(input:checked) .tl-pts { background: var(--ph-magenta); }
.tl-pc, .is-child .tl-pa { display: none; }
.is-child .tl-pc { display: inline-grid; }

.tl-faces { display: grid; gap: 8px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tl-face { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--ph-line); border-radius: 8px; cursor: pointer; text-align: center; color: var(--ph-muted); }
.tl-face b { color: var(--ph-ink); font-size: 1.05rem; }
.tl-face span { font-size: .76rem; line-height: 1.3; }
.tl-face-svg { width: 44px; height: 44px; color: var(--ph-text); }
.tl-face:has(input:checked) { border-color: var(--ph-magenta); background: rgba(225, 28, 242, .12); }
.tl-face:has(input:checked) .tl-face-svg { color: #F08CFF; }
.tl-reset { margin-top: 4px; }

.tl-result { position: sticky; top: 96px; padding: 20px; border: 1px solid var(--ph-line2); border-left-width: 4px; border-radius: 10px; background: var(--ph-surface); min-width: 0; scroll-margin-top: 90px; }
.tl-result.is-ok { border-left-color: var(--ph-green); }
.tl-result.is-warn { border-left-color: var(--ph-yellow); }
.tl-result.is-bad { border-left-color: var(--ph-red); }
.tl-result.is-info { border-left-color: var(--ph-violet); }
.tl-res-k { margin: 0 0 8px; color: var(--ph-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.tl-idle { margin: 0; color: var(--ph-muted); }
.tl-res-v { margin: 0; color: var(--ph-ink); line-height: 1.15; overflow-wrap: anywhere; }
.tl-res-v b { font-size: clamp(1.8rem, 5vw, 2.5rem); font-variant-numeric: tabular-nums; }
.tl-res-v span { color: var(--ph-muted); font-size: 1rem; }
.tl-res-label { margin: 8px 0 0; font-weight: 700; font-size: 1.02rem; }
.is-ok .tl-res-label { color: var(--ph-green); }
.is-warn .tl-res-label { color: var(--ph-yellow); }
.is-bad .tl-res-label { color: var(--ph-red); }
.is-info .tl-res-label { color: var(--ph-ink); }
.tl-res-lines { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.tl-res-lines li { padding: 8px 0 0; border-top: 1px solid var(--ph-line); color: var(--ph-text); font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; }
.tl-res-lines li.strong { color: var(--ph-ink); font-weight: 600; }
.tl-res-lines li.warn { color: var(--ph-yellow); }
.tl-res-lines li.bad { color: var(--ph-red); }
.tl-res-lines li.done { color: var(--ph-muted); text-decoration: line-through; text-decoration-color: rgba(156, 143, 198, .5); }
.tl-res-lines li.now { color: var(--ph-ink); font-weight: 700; padding-left: 10px; border-left: 3px solid var(--ph-magenta); }
.tl-error { margin: 0; color: var(--ph-red); font-weight: 600; }
.tl-progress { width: 100%; height: 8px; margin-top: 12px; appearance: none; border: 0; border-radius: 4px; background: var(--ph-surface2); overflow: hidden; }
.tl-progress::-webkit-progress-bar { background: var(--ph-surface2); }
.tl-progress::-webkit-progress-value { background: var(--ph-magenta); }
.tl-progress::-moz-progress-bar { background: var(--ph-magenta); }
.tl-mini { display: none; }

.tl-sec { padding: 20px; border: 1px solid var(--ph-line); border-radius: 10px; background: var(--ph-surface); }
.tl-sec h2 { color: var(--ph-ink); font-size: 1.1rem; margin: 0 0 12px; }
.tl-sec p { color: var(--ph-text); line-height: 1.75; margin: 0 0 12px; max-width: 72ch; }
.tl-formula { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ph-text); line-height: 1.6; }
.tl-formula li::marker { color: var(--ph-magenta); }
.tl-source { color: var(--ph-muted) !important; font-size: .84rem; margin: 12px 0 0 !important; }
.tl-why p { font-size: 1.02rem; }

.tl-table-wrap { overflow-x: auto; }
.tl-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 460px; }
.tl-table th, .tl-table td { padding: 10px 12px; border-bottom: 1px solid var(--ph-line); text-align: left; color: var(--ph-text); vertical-align: top; }
.tl-table th { color: var(--ph-ink); font-weight: 600; }
.tl-table tr.is-ok td:first-child { box-shadow: inset 3px 0 0 var(--ph-green); }
.tl-table tr.is-warn td:first-child { box-shadow: inset 3px 0 0 var(--ph-yellow); }
.tl-table tr.is-bad td:first-child { box-shadow: inset 3px 0 0 var(--ph-red); }

.tl-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid rgba(255, 201, 74, .35); border-radius: 10px; background: rgba(255, 201, 74, .06); }
.tl-note > .icon { flex: none; width: 20px; height: 20px; color: var(--ph-yellow); margin-top: 2px; }
.tl-note p { margin: 0 0 4px; color: var(--ph-text); font-size: .92rem; }
.tl-privacy { color: var(--ph-muted) !important; font-size: .84rem !important; }

.tl-aside { position: sticky; top: 96px; display: grid; gap: 12px; }
.tl-aside h3 { color: var(--ph-ink); font-size: 1rem; margin: 0; }
.tl-mini-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ph-line); }
.tl-mini-list a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 4px; border-bottom: 1px solid var(--ph-line); color: var(--ph-text); text-decoration: none; }
.tl-mini-list a:hover { color: var(--ph-ink); }
.tl-mini-list .icon { width: 18px; height: 18px; color: #F08CFF; flex: none; }

@media (max-width: 1100px) {
  .tl-start-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tl-layout { grid-template-columns: minmax(0, 1fr); }
  .tl-aside { position: static; }
}
@media (max-width: 860px) {
  .tl-calc { grid-template-columns: minmax(0, 1fr); }
  .tl-result { position: static; }
  .tl-list { grid-template-columns: minmax(0, 1fr); }
  .tl-list li:nth-child(odd) { border-right: 0; }
  .tl-mini { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; display: flex; align-items: baseline; gap: 8px; padding: 12px 16px; border: 1px solid var(--ph-line2); border-left-width: 4px; border-radius: 10px; background: var(--ph-bg2); color: var(--ph-ink); text-decoration: none; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .8); }
  .tl-mini span { color: var(--ph-muted); font-size: .8rem; margin-right: auto; }
  .tl-mini b { font-size: 1.2rem; }
  .tl-mini small { color: var(--ph-muted); }
  .tl-mini.is-ok { border-left-color: var(--ph-green); }
  .tl-mini.is-warn { border-left-color: var(--ph-yellow); }
  .tl-mini.is-bad { border-left-color: var(--ph-red); }
  .tl-mini.is-info { border-left-color: var(--ph-violet); }
  .tl-main { padding-bottom: 64px; }
}
@media (max-width: 560px) {
  .tl-start-grid { grid-template-columns: minmax(0, 1fr); }
  .tl-tile { grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; }
  .tl-tile .tl-ic { grid-row: span 2; }
  .tl-form, .tl-result, .tl-sec { padding: 16px; }
  .tl-faces { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tl-seg-opt { flex-basis: 100%; }
  .tl-count { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-tile, .tl-go, .tl-row { transition: none; }
}
