/*
 * Learning, Training & Settings visual migration
 *
 * Normative owner for the shared product canvas and for Learning, user-facing
 * Training, Settings and puzzle presentation. It intentionally does not own
 * the Material Board, Profile/Replay, game engine or Service Worker.
 */

body:not(.game-active) > .app-container.tp-shell {
    background:
        radial-gradient(900px 540px at 56% -16%, color-mix(in srgb, var(--tp-product-surface-raised) 36%, transparent), transparent 67%),
        radial-gradient(760px 540px at 4% 42%, color-mix(in srgb, var(--tp-product-surface-soft) 30%, transparent), transparent 70%),
        var(--tp-product-canvas) !important;
}

body:not(.game-active) .tp-shell-main {
    background: transparent !important;
}

/* Product themes are defined once on html[data-theme] in rewards-themes.css.
 * This owner consumes those aliases and never declares page-local palette
 * values or a fourth/light mode. */

/* Legacy screen rules use !important backgrounds. These scoped declarations
 * are deliberately narrow and keep the new pages on the one product canvas. */
body:not(.game-active) #screen-learn.tp-product-page,
body:not(.game-active) #screen-training.tp-product-page,
body:not(.game-active) #screen-settings.tp-product-page,
body:not(.game-active) #screen-help.tp-product-page,
body:not(.game-active) #screen-puzzles.tp-product-page {
    width: 100%;
    min-height: calc(100dvh - var(--tp-topbar-height));
    height: auto;
    max-height: none;
    flex: 1 0 auto;
    overflow: visible;
    color: var(--tp-product-text);
    background: transparent !important;
    font-family: var(--tp-font-sans);
}

.tp-product-content {
    width: min(100%, 1240px);
    margin: 0 auto;
    padding: 28px clamp(20px, 3.4vw, 40px) calc(56px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.tp-product-page .tp-button {
    border-color: var(--tp-product-border-strong);
    color: var(--tp-product-text);
    font-weight: 650;
}

.tp-product-page .tp-button--primary {
    border-color: var(--tp-product-gold);
    background: var(--tp-product-gold);
    color: var(--tp-product-gold-ink);
}

.tp-product-page .tp-button--primary:hover { background: var(--tp-product-gold-hover); border-color: var(--tp-product-gold-hover); }
.tp-product-page .tp-button--secondary { background: var(--tp-product-surface-raised); }
.tp-product-page .tp-button--secondary:hover { border-color: var(--tp-product-gold); background: color-mix(in srgb, var(--tp-product-surface-raised) 86%, var(--tp-product-gold)); }
.tp-product-page .tp-button--ghost { border-color: transparent; background: transparent; color: var(--tp-product-gold); }
.tp-product-page .tp-button--ghost:hover { background: color-mix(in srgb, var(--tp-product-gold) 11%, transparent); color: var(--tp-product-gold-hover); }

.tp-product-page button:focus-visible,
.tp-product-page select:focus-visible,
.tp-product-page [role="tab"]:focus-visible {
    outline: 2px solid var(--tp-product-gold);
    outline-offset: 3px;
}

.tp-page-heading { max-width: 690px; margin-bottom: 25px; }
.tp-page-heading--compact { margin-bottom: 20px; }
.tp-page-heading__eyebrow,
.tp-product-page .tp-section-heading__kicker {
    margin: 0 0 7px;
    color: var(--tp-product-gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.065em;
    text-transform: uppercase;
}
.tp-page-heading h1,
.tp-learning-hero h1 {
    margin: 0;
    color: var(--tp-product-text);
    font-family: var(--tp-font-sans);
    font-size: clamp(30px, 3vw, 43px);
    font-weight: 720;
    line-height: 1.08;
    letter-spacing: -0.045em;
}
.tp-page-heading > p:last-child,
.tp-learning-hero__copy > p {
    max-width: 570px;
    margin: 12px 0 0;
    color: var(--tp-product-muted);
    font-size: 15px;
    line-height: 1.52;
}
.tp-product-page .tp-section-heading { margin-bottom: 13px; align-items: end; }
.tp-product-page .tp-section-heading h2,
.tp-settings-panel h2,
.tp-training-card h2,
.tp-learning-continue h2 {
    margin: 0;
    color: var(--tp-product-text);
    font-size: 19px;
    font-weight: 680;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

/* Learning */
.tp-learning-hero {
    min-height: 310px;
    padding: clamp(28px, 3.4vw, 44px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.78fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    gap: 28px;
    overflow: hidden;
    border: 1px solid var(--tp-product-border);
    border-radius: 18px;
    background:
        linear-gradient(108deg, color-mix(in srgb, var(--tp-product-surface) 95%, var(--tp-product-canvas)) 0%, color-mix(in srgb, var(--tp-product-surface) 86%, var(--tp-product-canvas)) 100%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--tp-product-text) 3%, transparent), var(--tp-product-shadow);
}
.tp-learning-hero__copy { position: relative; z-index: 1; min-width: 0; }
.tp-learning-hero__copy > p { margin-top: 15px; }
.tp-learning-hero__actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.tp-learning-hero__visual {
    position: relative;
    height: 230px;
    min-height: 230px;
    margin: 0;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--tp-product-border-strong) 84%, transparent);
    border-radius: 20px;
    background: var(--tp-product-canvas);
    box-shadow: 0 24px 44px rgba(0,0,0,0.32), inset 0 1px color-mix(in srgb, var(--tp-product-text) 5%, transparent);
    transform: perspective(900px) rotateX(3deg) rotateZ(-2.5deg);
}
.tp-learning-hero__visual::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(100deg, color-mix(in srgb, var(--tp-product-canvas) 8%, transparent), color-mix(in srgb, var(--tp-product-canvas) 72%, transparent)), linear-gradient(0deg, color-mix(in srgb, var(--tp-product-canvas) 52%, transparent), transparent 60%);
}
.tp-learning-hero__visual img { width: 100%; height: 100%; min-height: 0; display: block; object-fit: cover; object-position: 54% 46%; filter: saturate(0.58) brightness(0.52) contrast(1.1); }
.tp-learning-hero__book,
.tp-learning-hero__cap {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    color: var(--tp-product-text);
    text-shadow: 0 8px 18px rgba(0,0,0,0.52);
}
.tp-learning-hero__book { left: 18%; bottom: 17%; font-size: clamp(56px, 6vw, 90px); }
.tp-learning-hero__cap { right: 14%; top: 13%; font-size: clamp(38px, 4vw, 62px); color: var(--tp-product-gold); }

.tp-learning-continue {
    min-height: 106px;
    margin-top: 18px;
    padding: 19px 20px;
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--tp-product-border);
    border-radius: 15px;
    background: var(--tp-product-surface);
    box-shadow: var(--tp-shadow-xs);
}
.tp-learning-continue__icon,
.tp-practice-card__icon,
.tp-learning-category__icon,
.tp-learning-lesson__icon,
.tp-settings-row__icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--tp-product-gold) 28%, var(--tp-product-border));
    border-radius: 13px;
    background: color-mix(in srgb, var(--tp-product-gold) 9%, transparent);
    color: var(--tp-product-gold);
    font-size: 19px;
}
.tp-learning-continue p:last-child { margin: 4px 0 0; color: var(--tp-product-muted); font-size: 13px; }
.tp-learning-section,
.tp-learning-practice,
.tp-learning-lessons { margin-top: 28px; }
.tp-learning-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tp-learning-category,
.tp-learning-lesson {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--tp-product-border);
    color: var(--tp-product-text);
    text-align: left;
    cursor: pointer;
    font: inherit;
}
.tp-learning-category {
    min-height: 116px;
    padding: 18px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 13px;
    border-radius: 15px;
    background: var(--tp-product-surface);
    transition: border-color var(--tp-motion-fast) var(--tp-ease-standard), background var(--tp-motion-fast) var(--tp-ease-standard), transform var(--tp-motion-fast) var(--tp-ease-standard);
}
.tp-learning-category:hover { border-color: color-mix(in srgb, var(--tp-product-gold) 64%, var(--tp-product-border)); background: var(--tp-product-surface-raised); transform: translateY(-1px); }
.tp-learning-category strong,
.tp-learning-lesson strong { display: block; font-size: 15px; font-weight: 680; }
.tp-learning-category small,
.tp-learning-lesson small { display: block; margin-top: 4px; color: var(--tp-product-muted); font-size: 12px; line-height: 1.4; }
.tp-learning-category > i { color: var(--tp-product-subtle); }
.tp-learning-practice__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tp-practice-card { min-height: 132px; padding: 19px; display: grid; grid-template-columns: 46px minmax(0, 1fr); grid-template-rows: auto auto; gap: 0 13px; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); }
.tp-practice-card__icon { grid-row: span 2; }
.tp-practice-card h3 { margin: 1px 0 0; font-size: 15px; font-weight: 680; }
.tp-practice-card p { margin: 5px 0 14px; color: var(--tp-product-muted); font-size: 12px; line-height: 1.45; }
.tp-practice-card .tp-button { width: fit-content; align-self: end; }
.tp-learning-lesson-list { display: grid; gap: 8px; }
.tp-learning-lesson { min-height: 68px; padding: 10px 14px; display: grid; grid-template-columns: 42px minmax(0, 1fr) 34px; align-items: center; gap: 12px; border-radius: 13px; background: var(--tp-product-surface); transition: border-color var(--tp-motion-fast) var(--tp-ease-standard), background var(--tp-motion-fast) var(--tp-ease-standard); }
.tp-learning-lesson:hover { border-color: color-mix(in srgb, var(--tp-product-gold) 58%, var(--tp-product-border)); background: var(--tp-product-surface-raised); }
.tp-learning-lesson__icon { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }
.tp-learning-lesson > i { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--tp-product-gold) 38%, transparent); border-radius: 50%; color: var(--tp-product-gold); font-size: 11px; }

/* Puzzles */
.tp-puzzle-daily {
    width: 100%;
    min-height: 124px;
    padding: 22px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 15px;
    border: 1px solid color-mix(in srgb, var(--tp-product-gold) 54%, var(--tp-product-border));
    border-radius: 17px;
    background: linear-gradient(112deg, color-mix(in srgb, var(--tp-product-gold) 17%, var(--tp-product-surface)) 0%, var(--tp-product-surface) 62%);
    color: var(--tp-product-text);
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: border-color var(--tp-motion-fast) var(--tp-ease-standard), transform var(--tp-motion-fast) var(--tp-ease-standard);
}
.tp-puzzle-daily:hover { border-color: var(--tp-product-gold); transform: translateY(-1px); }
.tp-puzzle-daily__icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--tp-product-gold) 15%, transparent); color: var(--tp-product-gold); font-size: 21px; }
.tp-puzzle-daily__copy { min-width: 0; display: grid; gap: 5px; }
.tp-puzzle-daily__copy strong { font-size: 18px; font-weight: 700; }
.tp-puzzle-daily__copy span { color: var(--tp-product-muted); font-size: 13px; line-height: 1.42; }
.tp-puzzle-daily__action { display: inline-flex; align-items: center; gap: 8px; color: var(--tp-product-gold); font-size: 13px; font-weight: 680; white-space: nowrap; }
.tp-puzzle-campaign { margin-top: 27px; }
.tp-puzzle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tp-puzzle-item { min-height: 92px; padding: 14px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 11px; border: 1px solid var(--tp-product-border); border-radius: 13px; background: var(--tp-product-surface); color: var(--tp-product-text); text-align: left; font: inherit; }
button.tp-puzzle-item { cursor: pointer; }
button.tp-puzzle-item:hover:not(:disabled) { border-color: color-mix(in srgb, var(--tp-product-gold) 62%, var(--tp-product-border)); background: var(--tp-product-surface-raised); }
.tp-puzzle-item:disabled { opacity: 0.64; cursor: not-allowed; }
.tp-puzzle-item__icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--tp-product-gold) 9%, transparent); color: var(--tp-product-gold); }
.tp-puzzle-item__copy { min-width: 0; }
.tp-puzzle-item__copy strong { display: block; font-size: 14px; font-weight: 680; }
.tp-puzzle-item__copy span { display: block; margin-top: 3px; overflow: hidden; color: var(--tp-product-muted); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.tp-puzzle-item__lock { color: var(--tp-product-subtle); font-size: 13px; }

/* Training */
.tp-training-layout,
.tp-settings-layout { display: grid; grid-template-columns: 218px minmax(0, 1fr); align-items: start; gap: 18px; }
.tp-section-nav { display: grid; gap: 5px; padding: 8px; border: 1px solid var(--tp-product-border); border-radius: 15px; background: color-mix(in srgb, var(--tp-product-surface) 88%, transparent); }
.tp-section-nav button { min-height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--tp-product-muted); text-align: left; cursor: pointer; font: inherit; font-size: 13px; font-weight: 620; }
.tp-section-nav button:hover { color: var(--tp-product-text); background: color-mix(in srgb, var(--tp-product-surface-soft) 70%, transparent); }
.tp-section-nav button.is-active { border-color: color-mix(in srgb, var(--tp-product-gold) 38%, transparent); background: color-mix(in srgb, var(--tp-product-gold) 12%, var(--tp-product-surface)); color: var(--tp-product-gold); }
.tp-section-nav button i { width: 16px; text-align: center; }
.tp-training-content { min-width: 0; }
.tp-training-panel:not(.is-active) { display: none; }
.tp-training-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tp-training-metric { min-height: 126px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); }
.tp-training-metric span { color: var(--tp-product-muted); font-size: 12px; font-weight: 600; }
.tp-training-metric strong { margin-top: 13px; color: var(--tp-product-text); font-size: clamp(22px, 2.5vw, 31px); font-weight: 700; letter-spacing: -0.045em; }
.tp-training-metric:first-child strong { color: var(--tp-product-gold); }
.tp-training-metric strong.is-empty { color: var(--tp-product-muted); font-size: 21px; letter-spacing: -0.025em; }
.tp-training-metric small { color: var(--tp-product-subtle); font-size: 11px; }
.tp-training-columns { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tp-training-card { min-height: 244px; padding: 20px; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); }
.tp-training-card header { margin-bottom: 18px; }
.tp-training-card--wide { min-height: 210px; }
.tp-training-card--wide > p:not(.tp-section-heading__kicker) { max-width: 560px; margin: 10px 0 18px; color: var(--tp-product-muted); line-height: 1.5; }
.tp-training-empty { min-height: 126px; padding: 15px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px; border: 1px dashed color-mix(in srgb, var(--tp-product-border-strong) 90%, transparent); border-radius: 12px; color: var(--tp-product-muted); font-size: 13px; line-height: 1.5; }
.tp-training-empty strong { color: var(--tp-product-text); }
.tp-training-empty .tp-button { width: fit-content; }

/* Settings */
.tp-settings-panels { min-width: 0; }
.tp-settings-panel:not(.is-active) { display: none; }
.tp-settings-panel { min-width: 0; }
.tp-settings-row[data-feature-status="coming_soon"] { opacity: .68; }
.tp-settings-row[data-feature-status="coming_soon"] select:disabled,
.tp-settings-row[data-feature-status="coming_soon"] input:disabled { cursor: not-allowed; }
.tp-settings-panel__header { min-height: 44px; margin: 2px 0 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tp-settings-profile-card,
.tp-settings-card { border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); box-shadow: var(--tp-shadow-xs); }
.tp-settings-profile-card { min-height: 148px; padding: 22px; display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: 18px; }
.tp-settings-profile-card__avatar { width: 78px; height: 78px; display: grid; place-items: center; overflow: hidden; border: 1px solid color-mix(in srgb, var(--tp-product-gold) 38%, var(--tp-product-border)); border-radius: 50%; background: color-mix(in srgb, var(--tp-product-gold) 9%, var(--tp-product-surface)); color: var(--tp-product-gold); font-size: 26px; }
.tp-settings-profile-card__avatar .profile-avatar-image { width: 100%; height: 100%; object-fit: cover; }
.tp-settings-profile-card strong { display: block; color: var(--tp-product-text); font-size: 17px; font-weight: 700; }
.tp-settings-profile-card span:not(.tp-settings-profile-card__avatar) { display: block; margin-top: 4px; color: var(--tp-product-muted); font-size: 13px; }
.tp-settings-profile-card p { max-width: 530px; margin: 10px 0 0; color: var(--tp-product-subtle); font-size: 12px; line-height: 1.45; }
.tp-settings-card { overflow: hidden; }
.tp-settings-row { min-height: 74px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--tp-product-border); }
.tp-settings-row:last-child { border-bottom: 0; }
.tp-settings-row__copy { min-width: 0; display: flex; align-items: center; gap: 12px; }
.tp-settings-row__icon { width: 38px; height: 38px; border-radius: 11px; font-size: 15px; }
.tp-settings-row strong { display: block; color: var(--tp-product-text); font-size: 14px; font-weight: 660; }
.tp-settings-row small { display: block; max-width: 470px; margin-top: 4px; color: var(--tp-product-muted); font-size: 12px; line-height: 1.4; }
.tp-toggle { width: 44px; height: 26px; position: relative; display: inline-flex; flex: 0 0 auto; }
.tp-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tp-toggle > span { width: 44px; height: 26px; position: relative; display: block; border: 1px solid var(--tp-product-border-strong); border-radius: 999px; background: color-mix(in srgb, var(--tp-product-surface-soft) 88%, var(--tp-product-canvas)); transition: background var(--tp-motion-fast) var(--tp-ease-standard), border-color var(--tp-motion-fast) var(--tp-ease-standard); }
.tp-toggle > span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--tp-product-text); box-shadow: 0 1px 4px rgba(0,0,0,0.32); transition: transform var(--tp-motion-fast) var(--tp-ease-standard); }
.tp-toggle input:checked + span { border-color: var(--tp-product-gold); background: var(--tp-product-gold); }
.tp-toggle input:checked + span::after { transform: translateX(18px); background: var(--tp-product-gold-ink); }
.tp-toggle input:disabled + span { opacity: 0.48; cursor: not-allowed; }
.tp-toggle:has(input:focus-visible) > span { outline: 2px solid var(--tp-product-gold); outline-offset: 3px; }
.tp-theme-picker,
.tp-settings-page .theme-picker-grid { display: flex; align-items: center; gap: 10px; }
.tp-settings .theme-swatch-item { min-height: 42px; padding: 5px 7px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--tp-product-border); border-radius: 10px; background: transparent; color: var(--tp-product-muted); cursor: pointer; font: inherit; font-size: 12px; }
.tp-settings .theme-swatch-item:hover { border-color: var(--tp-product-gold); color: var(--tp-product-text); }
.tp-settings .theme-swatch-circle { width: 16px; height: 16px; display: block; border: 1px solid var(--tp-product-border-strong); border-radius: 50%; }
.tp-settings .theme-swatch-circle.active { box-shadow: 0 0 0 2px var(--tp-product-gold); }
.tp-settings select { min-width: 128px; min-height: 42px; padding: 0 11px; border: 1px solid var(--tp-product-border-strong); border-radius: 10px; background: var(--tp-product-surface-raised); color: var(--tp-product-text); font: inherit; font-size: 13px; }
.tp-settings .lang-picker { display: inline-flex; gap: 5px; }
.tp-settings .lang-btn { min-width: 42px; min-height: 40px; border: 1px solid var(--tp-product-border); border-radius: 9px; background: transparent; color: var(--tp-product-muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.tp-settings .lang-btn.active { border-color: var(--tp-product-gold); background: color-mix(in srgb, var(--tp-product-gold) 14%, transparent); color: var(--tp-product-gold); }

@media (max-width: 1000px) {
    .tp-learning-hero { grid-template-columns: minmax(0, 1fr) minmax(270px, 0.72fr); }
    .tp-training-layout,
    .tp-settings-layout { grid-template-columns: 178px minmax(0, 1fr); gap: 14px; }
    .tp-training-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tp-training-metric { padding: 15px; }
}

@media (max-width: 900px) {
    body:not(.game-active) #screen-learn.tp-product-page,
    body:not(.game-active) #screen-training.tp-product-page,
    body:not(.game-active) #screen-settings.tp-product-page,
    body:not(.game-active) #screen-puzzles.tp-product-page { min-height: calc(100dvh - var(--tp-topbar-height)); }
    .tp-product-content { padding: 18px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
    .tp-page-heading { margin-bottom: 18px; }
    .tp-page-heading h1,
    .tp-learning-hero h1 { font-size: clamp(28px, 8vw, 35px); }
    .tp-page-heading > p:last-child,
    .tp-learning-hero__copy > p { font-size: 14px; }
    .tp-learning-hero { min-height: 0; padding: 21px; grid-template-columns: 1fr; gap: 0; border-radius: 16px; }
    .tp-learning-hero__visual { display: none; }
    .tp-learning-hero__visual img { min-height: 0; object-position: 54% 50%; }
    .tp-learning-hero__book { bottom: 15%; left: 16%; font-size: 56px; }
    .tp-learning-hero__cap { top: 12%; right: 13%; font-size: 39px; }
    .tp-learning-hero__actions { margin-top: 17px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .tp-learning-hero__actions .tp-button { min-width: 0; padding-inline: 12px; font-size: 13px; }
    .tp-learning-continue { min-height: 0; padding: 16px; grid-template-columns: 42px minmax(0, 1fr); gap: 11px; }
    .tp-learning-continue__icon { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
    .tp-learning-continue .tp-button { grid-column: 1 / -1; width: 100%; margin-top: 3px; }
    .tp-learning-categories,
    .tp-learning-practice__grid { grid-template-columns: 1fr; }
    .tp-learning-category { min-height: 92px; padding: 14px; }
    .tp-practice-card { min-height: 118px; padding: 15px; }
    .tp-learning-section,
    .tp-learning-practice,
    .tp-learning-lessons { margin-top: 24px; }
    .tp-puzzle-daily { min-height: 112px; padding: 17px; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; }
    .tp-puzzle-daily__icon { width: 42px; height: 42px; border-radius: 12px; font-size: 17px; }
    .tp-puzzle-daily__action { grid-column: 1 / -1; justify-self: start; }
    .tp-puzzle-grid { grid-template-columns: 1fr; }
    .tp-training-layout,
    .tp-settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .tp-section-nav { display: flex; max-width: 100%; padding: 5px; overflow-x: auto; scrollbar-width: none; }
    .tp-section-nav::-webkit-scrollbar { display: none; }
    .tp-section-nav button { min-width: max-content; min-height: 44px; white-space: nowrap; }
    .tp-training-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tp-training-metric { min-height: 112px; padding: 14px; }
    .tp-training-metric:last-child { grid-column: 1 / -1; }
    .tp-training-columns { grid-template-columns: 1fr; }
    .tp-training-card { min-height: 0; padding: 17px; }
    .tp-settings-panel__header { align-items: flex-start; flex-direction: column; }
    .tp-settings-profile-card { min-height: 0; padding: 17px; grid-template-columns: 58px minmax(0, 1fr); gap: 13px; }
    .tp-settings-profile-card__avatar { width: 56px; height: 56px; font-size: 20px; }
    .tp-settings-row { min-height: 68px; padding: 12px 14px; gap: 10px; }
    .tp-settings-row__icon { width: 36px; height: 36px; }
    .tp-settings-row small { max-width: none; }
    .tp-settings .theme-swatch-item span:last-child { display: none; }
    .tp-settings .theme-swatch-item { min-width: 42px; justify-content: center; }
    .tp-settings select { min-width: 106px; max-width: 122px; }
}

@media (max-width: 390px) {
    .tp-product-content { padding-inline: 12px; }
    .tp-learning-hero { padding: 19px; }
    .tp-learning-hero__actions { grid-template-columns: 1fr; }
    .tp-learning-hero__actions .tp-button { width: 100%; }
    .tp-training-metrics { grid-template-columns: 1fr; }
    .tp-training-metric:last-child { grid-column: auto; }
    .tp-settings-row { align-items: flex-start; }
    .tp-settings-row > select { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
    .tp-product-page *,
    .tp-product-page *::before,
    .tp-product-page *::after { scroll-behavior: auto !important; transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
/* AI Trainer is a routed product workspace, not a transient overlay. */
#screen-ai-coach.active {
    position: fixed !important;
    inset: 0 0 0 260px !important;
    z-index: 9998 !important;
    width: auto !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    overflow: hidden !important;
    background: var(--product-bg) !important;
    color: var(--text-primary) !important;
}

#screen-ai-coach .ai-coach-header {
    position: relative !important;
    z-index: 3 !important;
    min-height: calc(68px + env(safe-area-inset-top, 0px)) !important;
    display: grid !important;
    grid-template-columns: minmax(84px, auto) minmax(0, 1fr) 44px !important;
    align-items: center !important;
    gap: 14px !important;
    padding: max(10px, env(safe-area-inset-top, 0px)) 20px 10px !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    background: var(--surface-1) !important;
}

#screen-ai-coach .ai-coach-back {
    min-width: 84px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 12px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 10px !important;
    background: var(--surface-2) !important;
    color: inherit !important;
    font: 800 13px/1 var(--font-body) !important;
    cursor: pointer !important;
}

#screen-ai-coach .ai-coach-heading {
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 3px !important;
    text-align: center !important;
}

#screen-ai-coach .ai-coach-heading strong { font: 800 17px/1.15 var(--font-display) !important; }
#screen-ai-coach .ai-coach-heading span { color: var(--text-secondary) !important; font-size: 12px !important; }
#screen-ai-coach .ai-coach-status-dot {
    width: 10px !important;
    height: 10px !important;
    justify-self: center !important;
    border-radius: 50% !important;
    background: var(--success) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent) !important;
}

#screen-ai-coach .ai-coach-scroll {
    width: min(100%, 860px) !important;
    min-height: 0 !important;
    margin: 0 auto !important;
    padding: 24px 24px 18px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    scroll-behavior: smooth !important;
}

#screen-ai-coach .ai-coach-empty {
    min-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 30px 0 !important;
    text-align: center !important;
}

#screen-ai-coach .ai-coach-empty[hidden] { display: none !important; }
#screen-ai-coach .ai-coach-empty__icon {
    width: 58px !important;
    height: 58px !important;
    display: grid !important;
    place-items: center !important;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent) !important;
    border-radius: 18px !important;
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)) !important;
    color: var(--accent) !important;
    font-size: 24px !important;
}
#screen-ai-coach .ai-coach-empty h2 { margin: 4px 0 0 !important; font: 800 24px/1.2 var(--font-display) !important; }
#screen-ai-coach .ai-coach-empty > p { max-width: 540px !important; margin: 0 !important; color: var(--text-secondary) !important; }

#screen-ai-coach .ai-quick-prompts {
    width: min(100%, 620px) !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
    margin: 12px 0 0 !important;
}
#screen-ai-coach .ai-quick-prompts button {
    min-height: 44px !important;
    padding: 10px 12px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 11px !important;
    background: var(--surface-2) !important;
    color: var(--text-primary) !important;
    font: 700 13px/1.3 var(--font-body) !important;
    text-align: left !important;
    cursor: pointer !important;
}

#screen-ai-coach .ai-chat-messages { display: flex !important; flex-direction: column !important; gap: 12px !important; }
#screen-ai-coach .ai-msg { width: 100% !important; display: flex !important; align-items: flex-start !important; gap: 9px !important; margin: 0 !important; }
#screen-ai-coach .ai-msg.user { justify-content: flex-end !important; }
#screen-ai-coach .ai-avatar {
    width: 32px !important; height: 32px !important; min-width: 32px !important;
    display: grid !important; place-items: center !important; border-radius: 10px !important;
    background: var(--surface-2) !important; color: var(--accent) !important;
}
#screen-ai-coach .ai-bubble {
    width: auto !important;
    max-width: min(680px, calc(100% - 46px)) !important;
    padding: 12px 14px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 14px 14px 14px 4px !important;
    background: var(--surface-2) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
    line-height: 1.55 !important;
}
#screen-ai-coach .ai-msg.user .ai-bubble {
    border-color: color-mix(in srgb, var(--accent) 36%, transparent) !important;
    border-radius: 14px 14px 4px 14px !important;
    background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)) !important;
}

#screen-ai-coach .ai-coach-error {
    margin-top: 12px !important; padding: 12px !important; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent) !important;
    border-radius: 12px !important; background: color-mix(in srgb, var(--danger) 10%, var(--surface-1)) !important;
}
#screen-ai-coach .ai-coach-error[hidden] { display: none !important; }
#screen-ai-coach .ai-coach-error p { margin: 0 0 8px !important; }
#screen-ai-coach .ai-coach-error button { min-height: 40px !important; padding: 0 14px !important; border: 1px solid currentColor !important; border-radius: 9px !important; background: transparent !important; color: inherit !important; }
#screen-ai-coach .ai-typing:not([hidden]) { position: static !important; width: auto !important; display: flex !important; align-items: center !important; gap: 5px !important; margin: 14px 0 0 !important; color: var(--text-secondary) !important; }
#screen-ai-coach .ai-typing[hidden] { display: none !important; }
#screen-ai-coach .ai-typing span { width: 6px !important; height: 6px !important; border-radius: 50% !important; background: currentColor !important; animation: ai-coach-dot 900ms ease-in-out infinite alternate; }
#screen-ai-coach .ai-typing span:nth-child(2) { animation-delay: 120ms; }
#screen-ai-coach .ai-typing span:nth-child(3) { animation-delay: 240ms; }
#screen-ai-coach .ai-typing b { margin-left: 4px !important; font-size: 12px !important; }
@keyframes ai-coach-dot { to { opacity: .35; transform: translateY(-2px); } }

#screen-ai-coach .ai-chat-input-wrap {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: min(calc(100% - 32px), 820px) !important;
    min-height: 60px !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 10px !important;
    margin: 0 auto !important;
    padding: 8px 8px 8px 14px !important;
    margin-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 16px !important;
    background: var(--surface-raised) !important;
    box-shadow: 0 10px 28px rgba(0,0,0,.2) !important;
}
/* Removed: superseded by the trainer's scoped owner, ai-coach-workspace.css.
   These `!important` sizes belonged to the old `.ai-chat-input-wrap` composer. */
#screen-ai-coach .ai-chat-send { width: 44px !important; height: 44px !important; min-width: 44px !important; border-radius: 12px !important; }
#screen-ai-coach .ai-chat-send:disabled { opacity: .5 !important; cursor: wait !important; }

.tp-settings-measurement { display: block; padding: 10px 14px; color: var(--text-secondary); font-size: 12px; }

@media (max-width: 767px) {
    #screen-ai-coach.active { inset: 0 !important; }
    #screen-ai-coach .ai-coach-header { grid-template-columns: 44px minmax(0, 1fr) 28px !important; gap: 8px !important; padding-inline: 10px !important; }
    #screen-ai-coach .ai-coach-back { min-width: 44px !important; width: 44px !important; padding: 0 !important; }
    #screen-ai-coach .ai-coach-back span { display: none !important; }
    #screen-ai-coach .ai-coach-heading strong { font-size: 15px !important; }
    #screen-ai-coach .ai-coach-heading span { max-width: 210px !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; font-size: 10px !important; }
    #screen-ai-coach .ai-coach-scroll { width: 100% !important; padding: 16px 12px 12px !important; }
    #screen-ai-coach .ai-coach-empty { padding-block: 18px !important; }
    #screen-ai-coach .ai-coach-empty h2 { font-size: 20px !important; }
    #screen-ai-coach .ai-quick-prompts { grid-template-columns: 1fr !important; width: 100% !important; margin-left: 0 !important; }
    #screen-ai-coach .ai-chat-input-wrap { width: calc(100% - 20px) !important; margin-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important; }
}

@media (prefers-reduced-motion: reduce) {
    #screen-ai-coach *, #screen-ai-coach *::before, #screen-ai-coach *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}

/* Settings IA and Help — one product-surface owner. */
.tp-settings-v2 { max-width: 1240px; }
.tp-settings-v2 .tp-settings-layout { grid-template-columns: 270px minmax(0, 1fr); gap: 24px; }
.tp-settings-v2 .tp-settings-nav { position: sticky; top: calc(var(--tp-topbar-height, 64px) + 18px); }
.tp-settings-v2 .tp-settings-nav button { min-height: 58px; align-items: flex-start; padding: 10px 12px; }
.tp-settings-v2 .tp-settings-nav button > span { min-width: 0; display: grid; gap: 3px; }
.tp-settings-v2 .tp-settings-nav button strong { color: inherit; font-size: 13px; line-height: 1.2; }
.tp-settings-v2 .tp-settings-nav button small { color: var(--tp-product-subtle); font-size: 10px; font-weight: 500; line-height: 1.25; white-space: normal; }
.tp-settings-mobile-back { display: none; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--tp-product-border); border-radius: 11px; background: var(--tp-product-surface); color: var(--tp-product-text); }
.tp-settings-action-row { width: 100%; min-height: 68px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 0; border-top: 1px solid var(--tp-product-border); background: transparent; color: var(--tp-product-text); text-align: left; cursor: pointer; }
.tp-settings-action-row span { display: grid; gap: 3px; }
.tp-settings-action-row small { color: var(--tp-product-muted); }
.tp-status-badge, .tp-roadmap-note > span, .tp-roadmap-card > span, .tp-draft-badge { display: inline-flex; width: fit-content; padding: 4px 8px; border: 1px solid color-mix(in srgb, var(--tp-product-gold) 35%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--tp-product-gold) 10%, transparent); color: var(--tp-product-gold); font-size: 10px; font-weight: 800; letter-spacing: .035em; }
.tp-roadmap-note { margin-top: 12px; padding: 14px 16px; border: 1px dashed var(--tp-product-border-strong); border-radius: 13px; background: color-mix(in srgb, var(--tp-product-surface) 78%, transparent); }
.tp-roadmap-note p { margin: 8px 0 0; color: var(--tp-product-muted); font-size: 12px; line-height: 1.5; }
.tp-roadmap-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tp-roadmap-card { padding: 16px; border: 1px dashed var(--tp-product-border-strong); border-radius: 13px; background: var(--tp-product-surface); }
.tp-roadmap-card strong { display: block; margin-top: 10px; }
.tp-roadmap-card p { margin: 6px 0 0; color: var(--tp-product-muted); font-size: 12px; line-height: 1.45; }
.tp-settings-link-list { overflow: hidden; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); }
.tp-settings-link-list a { min-height: 66px; padding: 11px 16px; display: grid; grid-template-columns: 36px minmax(0, 1fr) 18px; align-items: center; gap: 12px; border-bottom: 1px solid var(--tp-product-border); color: var(--tp-product-text); text-decoration: none; }
.tp-settings-link-list a:last-child { border-bottom: 0; }
.tp-settings-link-list a > i:first-child { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--tp-product-gold) 10%, transparent); color: var(--tp-product-gold); }
.tp-settings-link-list a span { display: grid; gap: 3px; }
.tp-settings-link-list a small { color: var(--tp-product-muted); font-size: 11px; }
.tp-version-row { margin: 12px 0 0; padding: 12px 15px; display: flex; justify-content: space-between; border: 1px solid var(--tp-product-border); border-radius: 12px; color: var(--tp-product-muted); }
.tp-version-row strong { color: var(--tp-product-text); }

.tp-help { min-height: 100%; }
.tp-help-shell { max-width: 1120px; }
.tp-help-header { margin-bottom: 24px; display: flex; align-items: center; gap: 14px; }
.tp-help-header h1 { margin: 3px 0 0; font: 750 clamp(25px, 4vw, 38px)/1.15 var(--font-display); }
.tp-help-back { width: 46px; height: 46px; flex: 0 0 46px; border: 1px solid var(--tp-product-border); border-radius: 12px; background: var(--tp-product-surface); color: var(--tp-product-text); cursor: pointer; }
.tp-help-hero { min-height: 190px; padding: clamp(22px, 4vw, 38px); display: flex; align-items: end; justify-content: space-between; gap: 24px; border: 1px solid var(--tp-product-border); border-radius: 20px; background: radial-gradient(circle at 88% 20%, color-mix(in srgb, var(--tp-product-gold) 12%, transparent), transparent 34%), var(--tp-product-surface); }
.tp-help-hero h2 { max-width: 650px; margin: 7px 0 8px; font: 750 clamp(25px, 4vw, 38px)/1.18 var(--font-display); }
.tp-help-hero p { margin: 0; color: var(--tp-product-muted); }
.tp-help-card-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tp-help-card-grid a { min-height: 150px; padding: 18px; display: flex; flex-direction: column; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); color: var(--tp-product-text); text-decoration: none; }
.tp-help-card-grid a:hover { border-color: color-mix(in srgb, var(--tp-product-gold) 55%, var(--tp-product-border)); }
.tp-help-card-grid i { color: var(--tp-product-gold); font-size: 20px; }
.tp-help-card-grid strong { margin-top: auto; font-size: 14px; }
.tp-help-card-grid span { margin-top: 5px; color: var(--tp-product-muted); font-size: 11px; line-height: 1.35; }
.tp-help-document-heading { max-width: 780px; margin-bottom: 22px; }
.tp-help-document-heading > span:not(.tp-draft-badge) { color: var(--tp-product-gold); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.tp-help-document-heading h2 { margin: 7px 0 8px; font: 750 clamp(27px, 4vw, 42px)/1.15 var(--font-display); }
.tp-help-document-heading p { margin: 0; color: var(--tp-product-muted); line-height: 1.55; }
.tp-rule-board { margin-bottom: 22px; padding: 14px; border: 1px solid color-mix(in srgb, var(--tp-product-gold) 28%, var(--tp-product-border)); border-radius: 16px; background: var(--tp-product-surface-raised); }
.tp-rule-board__row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.tp-rule-board__row span { min-height: 42px; display: grid; place-items: center; border: 1px solid var(--tp-product-border-strong); border-radius: 999px; background: var(--tp-product-canvas); color: var(--tp-product-text); font: 700 11px/1 var(--font-mono); }
.tp-rule-board__kazans { min-height: 50px; margin: 6px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tp-rule-board__kazans b { display: grid; place-items: center; border: 1px solid var(--tp-product-border-strong); border-radius: 12px; color: var(--tp-product-gold); font-size: 11px; }
.tp-rules-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tp-rules-sections section, .tp-legal section, .tp-license-list { padding: 18px; border: 1px solid var(--tp-product-border); border-radius: 14px; background: var(--tp-product-surface); }
.tp-rules-sections h3, .tp-legal h3, .tp-license-list h3 { margin: 0 0 8px; font-size: 15px; }
.tp-rules-sections p, .tp-rules-sections ul, .tp-legal p, .tp-license-list p { margin: 0; color: var(--tp-product-muted); font-size: 13px; line-height: 1.6; }
.tp-help-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
.tp-help-search { max-width: 620px; min-height: 48px; margin-bottom: 14px; padding: 0 14px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--tp-product-border); border-radius: 12px; background: var(--tp-product-surface); }
.tp-help-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--tp-product-text); font: inherit; }
.tp-faq-list { display: grid; gap: 8px; }
.tp-faq-list details { padding: 0 16px; border: 1px solid var(--tp-product-border); border-radius: 12px; background: var(--tp-product-surface); }
.tp-faq-list summary { min-height: 52px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.tp-faq-list p { margin: 0 0 16px; color: var(--tp-product-muted); line-height: 1.5; }
.tp-help-empty { padding: 18px; border: 1px dashed var(--tp-product-border); border-radius: 12px; color: var(--tp-product-muted); }
.tp-support-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.tp-support-form, .tp-support-contact { padding: 20px; border: 1px solid var(--tp-product-border); border-radius: 16px; background: var(--tp-product-surface); }
.tp-support-form { display: grid; gap: 13px; }
.tp-support-form label { display: grid; gap: 6px; color: var(--tp-product-muted); font-size: 12px; font-weight: 700; }
.tp-support-form input:not([type="checkbox"]), .tp-support-form select, .tp-support-form textarea, #support-request-preview { width: 100%; padding: 11px 12px; border: 1px solid var(--tp-product-border-strong); border-radius: 10px; background: var(--tp-product-surface-raised); color: var(--tp-product-text); font: inherit; }
.tp-support-form textarea, #support-request-preview { resize: vertical; }
.tp-support-form .tp-support-consent { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.tp-support-form > p { margin: 0; color: var(--tp-product-subtle); font-size: 11px; line-height: 1.45; }
.tp-support-contact h3 { margin-top: 0; }
.tp-support-contact > a { min-height: 58px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--tp-product-border); border-radius: 12px; color: var(--tp-product-text); text-decoration: none; }
.tp-support-contact > a i { color: var(--tp-product-gold); font-size: 24px; }
.tp-support-contact > a span { display: grid; }
.tp-support-contact small { color: var(--tp-product-muted); }
#support-request-result { margin-top: 16px; }
#support-request-result p { color: var(--tp-product-muted); font-size: 12px; }
#support-request-preview { margin-bottom: 9px; font-size: 11px; line-height: 1.45; }
#support-safe-diagnostics { margin: 16px 0 0; }
#support-safe-diagnostics div { padding: 7px 0; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--tp-product-border); font-size: 11px; }
#support-safe-diagnostics dt { color: var(--tp-product-muted); }
#support-safe-diagnostics dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.tp-about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tp-about-grid section { min-height: 170px; padding: 20px; border: 1px solid var(--tp-product-border); border-radius: 15px; background: var(--tp-product-surface); }
.tp-about-grid i { color: var(--tp-product-gold); font-size: 22px; }
.tp-about-grid h3 { margin: 35px 0 6px; }
.tp-about-grid p { margin: 0; color: var(--tp-product-muted); font-size: 13px; line-height: 1.5; }
.tp-license-list { margin-top: 10px; }
.tp-legal { max-width: 860px; }
.tp-legal section { margin-bottom: 10px; }

/* ── Published legal document ─────────────────────────────────────────────
   A policy is something people read, not a dashboard. `.tp-legal-document`
   overrides the card treatment `.tp-legal section` gives every block and
   restores one continuous reading column with thin separators. */
.tp-legal-document {
    /* ~70 characters at the body size below — comfortable for long prose. */
    max-width: 900px;
    margin-inline: auto;
    padding-bottom: 48px;
}

/* The shared help header owns an <h1> for every other help page. On a legal
   document the document title is the heading, so the generic one is removed
   from view and from the accessibility tree — exactly one h1 is exposed. */
.tp-help:has(.tp-legal-document:not([hidden])) .tp-help-header > div { display: none; }

.tp-legal-heading { margin: 0 0 14px; padding: 0; border: 0; background: none; }
.tp-legal-heading h1 {
    margin: 0;
    /* 22px keeps the longest Russian word — конфиденциальности — on one line at
       320-390px. break-word rather than anywhere: splitting a word is a last
       resort, not the default wrap. */
    font: 750 clamp(22px, 3.4vw, 34px)/1.2 var(--font-display);
    color: var(--text-primary);
    overflow-wrap: break-word;
    hyphens: none;
}
/* The date is supporting information, never a second title. */
.tp-legal-updated { margin: 8px 0 0; color: var(--tp-product-muted); font-size: 13px; }

.tp-legal-intro { margin: 0 0 22px; padding: 16px 18px; border: 1px solid var(--tp-product-border); border-radius: 14px; background: var(--tp-product-surface); }
.tp-legal-intro p { margin: 0; max-width: 76ch; color: var(--text-primary); font-size: 15px; line-height: 1.65; }
.tp-legal-intro p + p { margin-top: 8px; color: var(--tp-product-muted); }

.tp-legal-toc { margin: 0 0 26px; }
.tp-legal-toc h2 { margin: 0 0 8px; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--tp-product-muted); }
.tp-legal-toc ol { margin: 0; padding-left: 20px; display: grid; gap: 5px; }
.tp-legal-toc a { color: var(--tp-product-gold); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.tp-legal-toc a:hover, .tp-legal-toc a:focus-visible { text-decoration-thickness: 2px; }

/* One reading flow: sections are separated by a rule, not boxed into cards. */
.tp-legal-document .tp-legal-section {
    margin: 0;
    padding: 22px 0 0;
    border: 0;
    border-top: 1px solid var(--tp-product-border);
    border-radius: 0;
    background: none;
}
.tp-legal-document .tp-legal-section + .tp-legal-section { margin-top: 22px; }
.tp-legal-document .tp-legal-section h2 {
    margin: 0 0 10px;
    font-size: clamp(17px, 2.2vw, 20px);
    font-weight: 700;
    color: var(--text-primary);
    /* Anchor jumps must not hide the heading under the sticky product header. */
    scroll-margin-top: 84px;
}
.tp-legal-document .tp-legal-section p {
    margin: 0;
    /* ~70 characters per line. Font-relative, so it holds if the family or
       the body size changes; the container stays wider for headings and cards. */
    max-width: 76ch;
    color: var(--tp-product-muted);
    font-size: 15px;
    line-height: 1.72;
}
.tp-legal-document .tp-legal-section p + p { margin-top: 10px; }

.tp-legal-contact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 28px;
    padding: 16px 18px;
    border: 1px solid var(--tp-product-border);
    border-radius: 14px;
    background: var(--tp-product-surface);
}
.tp-legal-contact p { margin: 0; color: var(--text-primary); font-size: 15px; }
/* .tp-product-page .tp-button sets a 40px shell button height; a policy link
   is a reading-page tap target and needs the 44px minimum. */
.tp-product-page .tp-legal-contact a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    text-decoration: none;
}

@media (max-width: 767.98px) {
    /* The shared help containers already reserve room for the floating glass
       nav, so this only needs a reading gap after the last block. */
    .tp-legal-document { padding-inline: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
    /* 16px minimum body text, and nothing narrower than a thumb to tap. */
    .tp-legal-document .tp-legal-section p,
    .tp-legal-intro p { font-size: 16px; }
    .tp-legal-toc ol { gap: 8px; }
    .tp-legal-toc a { display: inline-block; padding: 4px 0; font-size: 15px; }
    .tp-legal-contact { flex-direction: column; align-items: stretch; }
    .tp-legal-contact a { justify-content: center; width: 100%; }
}
.tp-legal-warning { padding: 14px; border: 1px solid color-mix(in srgb, var(--danger) 42%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--text-primary); }

#screen-ai-coach.active { grid-template-rows: auto auto minmax(0, 1fr) auto !important; }
#screen-ai-coach .ai-coach-header { grid-template-columns: minmax(84px, auto) minmax(0, 1fr) auto !important; }
#screen-ai-coach .ai-coach-header-actions { display: flex; align-items: center; gap: 7px; }
#screen-ai-coach .ai-coach-header-actions button { width: 40px; height: 40px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--surface-2); color: var(--text-primary); cursor: pointer; }
#screen-ai-coach .ai-coach-context { width: min(100%, 900px); min-height: 54px; margin: 0 auto; padding: 8px 20px; display: grid; grid-template-columns: auto minmax(180px, 260px) minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
#screen-ai-coach .ai-coach-context select, #screen-ai-coach .ai-coach-context button { min-height: 38px; padding: 0 10px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--surface-2); color: var(--text-primary); }
#screen-ai-coach .ai-coach-context-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body[data-text-size="small"] .tp-product-page, body[data-text-size="small"] #screen-ai-coach, body[data-text-size="small"] .ai-setup-screen { font-size: 14px; }
body[data-text-size="large"] .tp-product-page, body[data-text-size="large"] #screen-ai-coach, body[data-text-size="large"] .ai-setup-screen { font-size: 18px; }
body[data-high-contrast="true"] .tp-product-page, body[data-high-contrast="true"] #screen-ai-coach, body[data-high-contrast="true"] .ai-setup-screen { --tp-product-text: #fff; --tp-product-muted: #e2e2e2; --tp-product-subtle: #c8c8c8; --tp-product-border: #8f8f8f; --tp-product-border-strong: #d8d8d8; }
body[data-high-contrast="true"] .tp-product-page :is(button, a, input, select, textarea):focus-visible, body[data-high-contrast="true"] #screen-ai-coach :is(button, input, select, textarea):focus-visible, body[data-high-contrast="true"] .ai-setup-screen :is(button, input, select):focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
body[data-large-touch-targets="true"] .tp-product-page button, body[data-large-touch-targets="true"] .tp-product-page a, body[data-large-touch-targets="true"] #screen-ai-coach button { min-height: 50px; }
body[data-reduced-motion="true"] .tp-product-page *, body[data-reduced-motion="true"] #screen-ai-coach *, body[data-reduced-motion="true"] .ai-setup-screen * { animation: none !important; scroll-behavior: auto !important; transition: none !important; }

@media (max-width: 900px) {
    .tp-help-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    body:not(.game-active) #screen-help.tp-product-page { min-height: calc(100dvh - var(--tp-topbar-height)); }
    .tp-settings-v2 .tp-page-heading { margin-bottom: 14px; }
    .tp-settings-v2 .tp-settings-layout { display: block; }
    .tp-settings-v2 .tp-settings-nav { position: static; display: grid; padding: 6px; overflow: visible; }
    .tp-settings-v2 .tp-settings-nav button { min-width: 0; min-height: 64px; white-space: normal; }
    #screen-settings:not(.is-settings-index) .tp-settings-nav { display: none; }
    #screen-settings.is-settings-index .tp-settings-panels { display: none; }
    .tp-settings-mobile-back { display: inline-grid; place-items: center; }
    .tp-settings-panel__header { min-height: 52px; margin-bottom: 10px; display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; }
    .tp-settings-panel__header > div { min-width: 0; }
    .tp-settings-panel__header .tp-button { grid-column: 1 / -1; width: 100%; }
    .tp-settings-row { align-items: center; }
    .tp-settings-row__icon { display: none; }
    .tp-settings-row--theme { align-items: flex-start; flex-direction: column; }
    .tp-theme-picker { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tp-theme-choice { min-width: 0; }
    .tp-theme-choice > span:last-child { display: none; }
    .tp-roadmap-grid, .tp-rules-sections, .tp-support-layout, .tp-about-grid { grid-template-columns: 1fr; }
    .tp-help-header { margin-bottom: 15px; }
    .tp-help-header h1 { font-size: 24px; }
    .tp-help-hero { min-height: 0; padding: 20px; align-items: flex-start; flex-direction: column; }
    .tp-help-hero h2 { font-size: 27px; }
    .tp-help-card-grid { grid-template-columns: 1fr; }
    .tp-help-card-grid a { min-height: 94px; }
    .tp-rule-board { padding: 8px; }
    .tp-rule-board__row { gap: 2px; }
    .tp-rule-board__row span { min-height: 34px; }
    #screen-ai-coach .ai-coach-header { grid-template-columns: 44px minmax(0, 1fr) auto !important; }
    #screen-ai-coach .ai-coach-header-actions { gap: 4px; }
    #screen-ai-coach .ai-coach-header-actions button { width: 34px; height: 34px; }
    #screen-ai-coach .ai-coach-status-dot { display: none !important; }
    #screen-ai-coach .ai-coach-context { width: 100%; padding: 8px 10px; grid-template-columns: auto minmax(0, 1fr) auto; }
    #screen-ai-coach .ai-coach-context > span { grid-column: 1 / -1; grid-row: 2; }
    #screen-ai-coach .ai-coach-context button { grid-column: 3; grid-row: 1; }
}
