/* ==========================================================
   WEAK-KEY COACH + SMART REVIEW v17.4.0
========================================================== */

.weak-key-coach {
    display: grid;
    gap: 18px;
    margin-top: 20px;
}

.weak-key-coach-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 22px;
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 22px;
    background:
        radial-gradient(circle at 100% 0, rgba(23, 105, 255, .12), transparent 38%),
        var(--surface, #fff);
}

.weak-key-coach-header h2 {
    margin: 4px 0 8px;
    font-size: clamp(24px, 2.4vw, 34px);
}

.weak-key-coach-header p {
    max-width: 760px;
    margin: 0;
    color: var(--muted, #64748b);
    line-height: 1.65;
}

.coach-local-badge {
    flex: 0 0 auto;
    padding: 8px 12px;
    border: 1px solid rgba(23, 105, 255, .2);
    border-radius: 999px;
    color: #1358d3;
    background: rgba(23, 105, 255, .08);
    font-size: 12px;
    font-weight: 800;
}

.coach-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.coach-balance-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 14px;
    color: var(--muted, #64748b);
    background: var(--surface, #fff);
    font-size: 13px;
}

.coach-balance-note strong {
    color: var(--text, #0f172a);
}

.coach-main-grid,
.coach-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
    gap: 16px;
}

.coach-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.coach-heatmap-card,
.coach-focus-card {
    min-width: 0;
}

.coach-heatmap {
    display: grid;
    gap: 7px;
    overflow: hidden;
    margin-top: 16px;
    padding: 13px;
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 16px;
    background: var(--background, #f5f7fb);
}

.coach-key-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(34px, 1fr);
    gap: 6px;
}

.coach-key {
    min-width: 0;
    min-height: 48px;
    padding: 5px 3px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #334155;
    background: #e7edf5;
    box-shadow: inset 0 -2px 0 rgba(15, 23, 42, .08);
    cursor: help;
}

.coach-key strong,
.coach-key small {
    display: block;
    line-height: 1.1;
}

.coach-key strong {
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
}

.coach-key small {
    margin-top: 5px;
    font-size: 9px;
    font-weight: 800;
    opacity: .78;
}

.coach-key:hover,
.coach-key:focus-visible {
    position: relative;
    z-index: 2;
    outline: 3px solid rgba(23, 105, 255, .25);
    transform: translateY(-1px);
}

.coach-key-strong {
    color: #075f35;
    border-color: rgba(16, 185, 129, .34);
    background: #c8f3de;
}

.coach-key-improving {
    color: #6b4d00;
    border-color: rgba(234, 179, 8, .35);
    background: #fff0a8;
}

.coach-key-attention {
    color: #873c04;
    border-color: rgba(249, 115, 22, .38);
    background: #fed7aa;
}

.coach-key-weak {
    color: #8e1837;
    border-color: rgba(244, 63, 94, .38);
    background: #fecdd3;
}

.coach-key-learning {
    color: #334155;
    border-color: rgba(100, 116, 139, .22);
    background: #e7edf5;
}

.coach-key-unseen {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, .15);
    background: #f1f5f9;
    box-shadow: none;
}

.coach-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 9px 15px;
    margin-top: 13px;
    color: var(--muted, #64748b);
    font-size: 11px;
    font-weight: 700;
}

.coach-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.coach-legend i {
    width: 11px;
    height: 11px;
    border-radius: 3px;
}

.coach-legend-strong { background: #6ee7b7; }
.coach-legend-improving { background: #fde047; }
.coach-legend-attention { background: #fb923c; }
.coach-legend-weak { background: #fb7185; }
.coach-legend-learning { background: #cbd5e1; }

.coach-focus-list {
    display: grid;
    gap: 9px;
    margin-top: 15px;
}

.coach-focus-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 2px 11px;
    align-items: center;
    padding: 11px;
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 13px;
    background: var(--background, #f8fafc);
}

.coach-focus-item > strong {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    color: #fff;
    background: #1769ff;
    font-family: "JetBrains Mono", monospace;
    font-size: 19px;
}

.coach-focus-item span,
.coach-focus-item small {
    min-width: 0;
}

.coach-focus-item span {
    color: var(--text, #0f172a);
    font-size: 13px;
}

.coach-focus-item small {
    color: var(--muted, #64748b);
    font-size: 11px;
}

.coach-combination-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    margin-top: 14px;
}

.coach-combination-list > span {
    display: grid;
    gap: 3px;
    padding: 11px;
    border: 1px solid var(--border, #dbe4f0);
    border-radius: 12px;
    background: var(--background, #f8fafc);
}

.coach-combination-list strong {
    font-family: "JetBrains Mono", monospace;
    font-size: 16px;
}

.coach-combination-list b {
    color: #d9485f;
    font-size: 13px;
}

.coach-combination-list small {
    color: var(--muted, #64748b);
    font-size: 10px;
}

.coach-weekly-card dl {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
}

.coach-weekly-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border, #dbe4f0);
}

.coach-weekly-card dl div:last-child {
    border-bottom: 0;
}

.coach-weekly-card dt {
    color: var(--muted, #64748b);
    font-size: 12px;
}

.coach-weekly-card dd {
    margin: 0;
    color: var(--text, #0f172a);
    font-size: 12px;
    font-weight: 800;
    text-align: right;
}

.coach-action-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 22px;
    border: 1px solid rgba(23, 105, 255, .28);
    border-radius: 20px;
    background:
        linear-gradient(135deg, rgba(23, 105, 255, .09), rgba(34, 197, 94, .07)),
        var(--surface, #fff);
}

.coach-action-card h3 {
    margin: 5px 0 7px;
    font-size: 20px;
}

.coach-action-card p {
    max-width: 700px;
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 13px;
    line-height: 1.55;
}

.coach-action-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: end;
    gap: 9px;
    flex: 0 0 auto;
}

.coach-action-controls label {
    display: grid;
    gap: 5px;
    color: var(--muted, #64748b);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.coach-action-controls select,
.coach-action-controls button {
    min-height: 42px;
    border-radius: 11px;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.coach-action-controls select {
    min-width: 126px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--border, #cbd5e1);
    color: var(--text, #0f172a);
    background: var(--surface, #fff);
}

.coach-action-controls button {
    padding: 0 15px;
    cursor: pointer;
}

.coach-primary-action {
    border: 1px solid #1769ff;
    color: #fff;
    background: #1769ff;
    box-shadow: 0 7px 18px rgba(23, 105, 255, .22);
}

.coach-primary-action:hover {
    background: #0f5ce0;
}

.coach-secondary-action {
    border: 1px solid var(--border, #cbd5e1);
    color: var(--text, #0f172a);
    background: var(--surface, #fff);
}

.coach-secondary-action:hover {
    border-color: #1769ff;
    color: #1769ff;
}

html[data-theme="dark"] .weak-key-coach-header,
html[data-theme="dark"] .coach-balance-note,
html[data-theme="dark"] .coach-action-card {
    background:
        radial-gradient(circle at 100% 0, rgba(47, 127, 255, .16), transparent 38%),
        var(--surface, #111827);
    border-color: var(--border, #263244);
}

html[data-theme="dark"] .coach-local-badge {
    color: #a9c9ff;
    background: rgba(47, 127, 255, .14);
    border-color: rgba(96, 165, 250, .3);
}

html[data-theme="dark"] .coach-heatmap,
html[data-theme="dark"] .coach-focus-item,
html[data-theme="dark"] .coach-combination-list > span {
    background: #0d1422;
    border-color: #263244;
}

html[data-theme="dark"] .coach-key-unseen,
html[data-theme="dark"] .coach-key-learning {
    color: #94a3b8;
    background: #202a3a;
    border-color: #334155;
}

html[data-theme="dark"] .coach-key-strong {
    color: #d1fae5;
    background: #0d5b42;
}

html[data-theme="dark"] .coach-key-improving {
    color: #fff7c2;
    background: #715b08;
}

html[data-theme="dark"] .coach-key-attention {
    color: #ffedd5;
    background: #8a4212;
}

html[data-theme="dark"] .coach-key-weak {
    color: #ffe4e6;
    background: #8f2441;
}

html[data-theme="dark"] .coach-action-controls select,
html[data-theme="dark"] .coach-secondary-action {
    color: var(--text, #e5e7eb);
    background: #111827;
    border-color: #334155;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .weak-key-coach-header,
    html[data-theme="system"] .coach-balance-note,
    html[data-theme="system"] .coach-action-card {
        background:
            radial-gradient(circle at 100% 0, rgba(47, 127, 255, .16), transparent 38%),
            #111827;
        border-color: #263244;
    }

    html[data-theme="system"] .coach-heatmap,
    html[data-theme="system"] .coach-focus-item,
    html[data-theme="system"] .coach-combination-list > span {
        background: #0d1422;
        border-color: #263244;
    }
}

@media (max-width: 980px) {
    .coach-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .coach-main-grid,
    .coach-detail-grid {
        grid-template-columns: 1fr;
    }

    .coach-action-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .coach-action-controls {
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 660px) {
    .weak-key-coach-header {
        flex-direction: column;
        padding: 17px;
    }

    .coach-summary-grid {
        grid-template-columns: 1fr;
    }

    .coach-key-row {
        grid-auto-columns: minmax(25px, 1fr);
        gap: 4px;
    }

    .coach-key {
        min-height: 42px;
        padding: 4px 1px;
        border-radius: 7px;
    }

    .coach-key strong {
        font-size: 11px;
    }

    .coach-key small {
        font-size: 7px;
    }

    .coach-combination-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .coach-action-controls,
    .coach-action-controls label,
    .coach-action-controls select,
    .coach-action-controls button {
        width: 100%;
    }
}

.coach-action-card .coach-mix-note {
    margin-top: 7px;
    color: #1769ff;
    font-weight: 700;
}

html[data-theme="dark"] .coach-action-card .coach-mix-note {
    color: #8db8ff;
}


/* ==========================================================
   HEATMAP CLARITY AND RESTORED KEYBOARD PRESENTATION v17.4.2
========================================================== */

.coach-heatmap-help {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    color: var(--text-light, #475569);
    background: var(--surface-alt, #f8fafc);
    border: 1px solid var(--border-soft, #e2e8f0);
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.45;
}

.coach-heatmap-help strong {
    flex: 0 0 auto;
    color: var(--text, #0f172a);
}

.coach-legend-unseen {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
}

.coach-key-row:nth-child(2) {
    padding-left: 1.6%;
    padding-right: 2.2%;
}

.coach-key-row:nth-child(3) {
    padding-left: 3.6%;
    padding-right: 6.2%;
}

.coach-key-row:nth-child(4) {
    padding-left: 7.2%;
    padding-right: 10.5%;
}

.coach-key {
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
}

.coach-key strong {
    font-size: 15px;
}

.coach-key small {
    font-size: 10px;
}

html[data-theme="dark"] .coach-heatmap-help {
    color: #aebbd0;
    background: #0d1422;
    border-color: #263244;
}

html[data-theme="dark"] .coach-heatmap-help strong {
    color: #f8fafc;
}

html[data-theme="dark"] .coach-legend-unseen {
    background: #334155;
    border-color: #475569;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] .coach-heatmap-help {
        color: #aebbd0;
        background: #0d1422;
        border-color: #263244;
    }

    html[data-theme="system"] .coach-heatmap-help strong {
        color: #f8fafc;
    }

    html[data-theme="system"] .coach-legend-unseen {
        background: #334155;
        border-color: #475569;
    }
}

@media (max-width: 660px) {
    .coach-key-row:nth-child(2),
    .coach-key-row:nth-child(3),
    .coach-key-row:nth-child(4) {
        padding-left: 0;
        padding-right: 0;
    }

    .coach-heatmap {
        overflow-x: auto;
    }

    .coach-key-row {
        min-width: 560px;
    }

    .coach-heatmap-help {
        flex-direction: column;
        gap: 3px;
    }
}
