/* ============================================================================
   Shared parts of the generated tool pages: fields, the result panel, the
   questions and the sources. Every colour is a theme variable from style.css,
   so both themes are covered by the same rules and text-visibility measures
   them like everything else.
   ============================================================================ */

.tk-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.6rem; align-items: start; text-align: left; }
.tk-card { border: 1px solid var(--border-color); border-radius: 12px; background: var(--surface-card); padding: 1.1rem 1.15rem; }
.tk-fields { display: flex; flex-wrap: wrap; margin: 0 -0.35rem; }
.tk-f { flex: 1 1 9rem; min-width: 8rem; padding: 0 0.35rem 0.85rem; box-sizing: border-box; }
.tk-f.tk-wide { flex: 1 1 100%; }
.tk-label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin: 0 0 0.3rem; }
.tk-hint { display: block; font-size: 0.72rem; color: var(--text-muted); margin: 0.3rem 0 0; line-height: 1.45; }
.tk-in, .tk-sel {
    width: 100%; box-sizing: border-box; font: inherit; font-size: 0.9rem;
    padding: 0.55rem 0.65rem; border-radius: 8px; border: 1px solid var(--border-color);
    background: var(--bg-page); color: var(--text-primary);
}
.tk-in:focus-visible, .tk-sel:focus-visible { outline: 2px solid var(--accent-solid); outline-offset: 1px; }
.tk-in::placeholder { color: var(--text-muted); }
.tk-in[aria-invalid="true"] { border-color: var(--bad-text); }
.tk-check { display: flex; align-items: flex-start; font-size: 0.84rem; color: var(--text-secondary); line-height: 1.45; cursor: pointer; }
.tk-check input { margin: 0.2rem 0.5rem 0 0; accent-color: var(--accent-solid); flex: none; }
[dir="rtl"] .tk-check input { margin: 0.2rem 0 0 0.5rem; }
.tk-seg { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tk-seg button {
    font: inherit; font-size: 0.8rem; padding: 0.38rem 0.75rem; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border-color); background: transparent; color: var(--text-secondary);
}
.tk-seg button[aria-pressed="true"] { background: var(--accent-deep); color: var(--accent-on-fill); border-color: var(--accent-deep); }
.tk-seg button:focus-visible { outline: 2px solid var(--accent-solid); outline-offset: 1px; }
.tk-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }

.tk-out { position: sticky; top: 4.5rem; }
.text-content .tk-out p { font-weight: 400; }
.text-content .tk-big, .tk-big { font-size: 2rem; line-height: 1.1; color: var(--text-primary); font-weight: 600; margin: 0.1rem 0 0.35rem; letter-spacing: -0.5px; }
.text-content .tk-sub, .tk-sub { font-size: 0.86rem; line-height: 1.6; color: var(--text-secondary); margin: 0 0 0.9rem; }
.text-content .tk-empty, .tk-empty { font-size: 0.86rem; line-height: 1.6; color: var(--text-muted); margin: 0; }
.tk-row { display: flex; align-items: baseline; padding: 0.5rem 0; border-top: 1px solid var(--border-color); font-size: 0.88rem; }
.tk-row:first-of-type { border-top: none; }
.tk-row .tk-k { flex: 1; color: var(--text-secondary); min-width: 0; }
.tk-row .tk-v { color: var(--text-primary); margin-left: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
[dir="rtl"] .tk-row .tk-v { margin-left: 0; margin-right: 0.8rem; }
.tk-row.tk-total .tk-k, .tk-row.tk-total .tk-v { color: var(--text-primary); font-weight: 600; }
.text-content .tk-note, .tk-note { font-size: 0.8rem; line-height: 1.6; color: var(--text-secondary); margin: 0.9rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--border-color); }
.text-content .tk-flag, .tk-flag { font-size: 0.84rem; line-height: 1.55; color: var(--text-primary); margin: 0.8rem 0 0; padding: 0.7rem 0.8rem; border-radius: 9px; background: var(--overlay-soft); border-left: 3px solid var(--warn-text); }
[dir="rtl"] .tk-flag { border-left: none; border-right: 3px solid var(--warn-text); }
.text-content .tk-good, .tk-good { border-left-color: var(--ok-text); }
[dir="rtl"] .tk-good { border-right-color: var(--ok-text); }
.text-content .tk-said, .tk-said { font-size: 0.78rem; color: var(--text-muted); min-height: 1.1em; margin: 0.5rem 0 0; }

.tk-faq { border-top: 1px solid var(--border-color); padding: 0.75rem 0; }
.tk-faq:last-of-type { border-bottom: 1px solid var(--border-color); }
.tk-faq summary { cursor: pointer; color: var(--text-primary); font-size: 0.95rem; line-height: 1.5; }
.tk-faq summary:focus-visible { outline: 2px solid var(--accent-solid); outline-offset: 2px; border-radius: 4px; }
.tk-faq div { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; margin-top: 0.5rem; }
.text-content .tk-faq div p { margin: 0 0 0.6rem; font-size: inherit; line-height: inherit; font-weight: inherit; }
.tk-sources { margin: 0; padding-left: 1.2rem; }
[dir="rtl"] .tk-sources { padding-left: 0; padding-right: 1.2rem; }
.tk-sources li { font-size: 0.86rem; line-height: 1.6; color: var(--text-secondary); margin-bottom: 0.35rem; }
.tk-sources a { color: var(--accent-text); }

.tk-letter {
    width: 100%; box-sizing: border-box; min-height: 18rem; font: inherit; font-size: 0.86rem; line-height: 1.65;
    padding: 0.9rem 1rem; border-radius: 10px; border: 1px solid var(--border-color);
    background: var(--bg-page); color: var(--text-primary); resize: vertical; white-space: pre-wrap;
}

@media (max-width: 900px) {
    .tk-grid { grid-template-columns: 1fr; }
    .tk-out { position: static; }
}
@media (max-width: 780px) {
    .tk-in, .tk-sel, .tk-seg button, .tk-actions button { scroll-margin-bottom: calc(78px + env(safe-area-inset-bottom)); }
}
@media print {
    .head-tools, .main-nav, .bottom-bar, .game-cta, .tk-actions, footer { display: none !important; }
}
