/* Practice workspace styles. Shared typography, buttons, nav, and tables live in styles.css. */

.practice-status,
.button-row,
.library-stats,
.prompt-meta,
.focus-row,
.problem-row-tags,
.quiz-card-header,
.quiz-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.status-pill,
.result-badge,
.focus-row span,
.library-stats span,
.problem-row-tags span,
.problem-set-count {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.practice-body {
    min-height: 100vh;
    overflow: auto;
}

#root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.practice-choice,
.practice-library,
.quiz-page {
    flex: 1 0 auto;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0 42px;
}

.practice-workspace {
    flex: 1 0 auto;
}

.practice-footer {
    flex: 0 0 auto;
}

.library-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.library-header h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.08;
    letter-spacing: 0;
}

.track-picker-copy {
    max-width: 720px;
    margin: 10px 0 0;
    color: #394654;
    line-height: 1.55;
}

.track-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}

.track-card {
    display: grid;
    gap: 10px;
    min-height: 190px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.track-card:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.track-card-label,
.track-card-meta {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: 0;
    text-transform: uppercase;
}

.track-card strong {
    max-width: 520px;
    font-size: 22px;
    line-height: 1.12;
}

.track-card span:not(.track-card-label):not(.track-card-meta) {
    color: #394654;
    line-height: 1.5;
}

.track-card-meta {
    align-self: end;
    color: var(--muted);
}

.library-panel,
.category-summary,
.problem-panel,
.editor-panel,
.workspace-bar {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.library-panel {
    overflow: hidden;
}

.topic-panel {
    margin-bottom: 14px;
}

.db-track-panel {
    margin-bottom: 14px;
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
}

.section-row h2,
.editor-toolbar h2,
.result-header h2,
.panel-header h2 {
    margin: 0;
    font-size: 17px;
    letter-spacing: 0;
}

.topic-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
    gap: 8px;
    padding: 0 16px 16px;
}

.db-focus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
    gap: 8px;
    padding: 0 16px 16px;
}

.db-focus-grid span {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface-muted);
    color: #394654;
    font-size: 12px;
    font-weight: 900;
}

.topic-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--surface);
    color: #394654;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.topic-filter:hover,
.topic-filter.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.topic-filter-name {
    min-width: 0;
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 26px;
    min-height: 22px;
    border-radius: 999px;
    padding: 2px 7px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 11px;
    font-weight: 950;
}

.topic-filter.active .topic-filter-count {
    background: var(--accent);
    color: #ffffff;
}

.category-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.category-summary {
    display: grid;
    gap: 4px;
    min-height: 86px;
    padding: 14px;
}

.category-summary strong {
    color: var(--ink);
    font-size: 15px;
}

.category-summary span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.category-summary.muted {
    border-style: dashed;
    box-shadow: none;
}

.problem-directory {
    margin-top: 0;
}

.quiz-header {
    align-items: flex-start;
}

.quiz-description {
    max-width: 620px;
    margin: 8px 0 0;
    color: #394654;
    line-height: 1.55;
}

.quiz-panel,
.quiz-list {
    display: grid;
    gap: 12px;
}

.quiz-picker-panel {
    margin-bottom: 14px;
}

.quiz-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 8px;
    padding: 0 16px 16px;
}

.quiz-picker {
    display: grid;
    gap: 6px;
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.quiz-picker:hover,
.quiz-picker.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.quiz-picker-title {
    overflow: hidden;
    font-size: 13px;
    font-weight: 950;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-picker-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

.quiz-picker.active .quiz-picker-count {
    color: var(--accent-strong);
}

.quiz-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.quiz-card.correct {
    border-color: rgba(22, 112, 72, 0.32);
    background: #f5fbf8;
}

.quiz-card.incorrect {
    border-color: rgba(180, 35, 24, 0.28);
    background: #fff8f6;
}

.quiz-card-header {
    align-items: flex-start;
    flex-wrap: nowrap;
}

.quiz-card-header h2 {
    min-width: 0;
    margin: 4px 0 0;
    font-size: 17px;
    line-height: 1.35;
    letter-spacing: 0;
}

.quiz-example {
    min-height: 0;
    max-height: none;
    background: #172229;
    color: #e9eef4;
}

.quiz-answer-field {
    display: grid;
    gap: 7px;
}

.quiz-answer-field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.quiz-answer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.quiz-answer-field input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 11px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    font-weight: 800;
}

.quiz-answer-field input:focus {
    border-color: var(--accent);
    outline: 3px solid var(--accent-soft);
}

.quiz-check-button {
    min-width: 86px;
}

.quiz-feedback {
    display: grid;
    gap: 4px;
    border-radius: 7px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
}

.quiz-feedback.correct {
    background: #e7f5ee;
    color: #174f35;
}

.quiz-feedback.incorrect {
    background: #fff0ed;
    color: #652017;
}

.quiz-feedback strong {
    font-size: 13px;
}

.quiz-actions {
    justify-content: flex-end;
    padding-top: 4px;
}

.category-groups {
    display: grid;
    border-top: 1px solid var(--line);
}

.category-group + .category-group {
    border-top: 1px solid var(--line);
}

.category-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 8px;
}

.category-group-header h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0;
}

.category-group-header span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

.problem-list {
    display: grid;
    padding: 0 10px 10px;
}

.problem-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) minmax(150px, 0.7fr) 74px;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 66px;
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
}

.problem-row:hover {
    background: var(--surface-muted);
}

.problem-row.solved {
    background: #f7fbf8;
}

.question-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 950;
}

.problem-row-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.problem-row-copy strong {
    overflow: hidden;
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.problem-row-copy span {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.problem-row-tags {
    justify-content: flex-end;
    min-width: 0;
}

.problem-row-tags span {
    min-height: 26px;
    max-width: 150px;
    overflow: hidden;
    padding: 4px 8px;
    font-size: 11.5px;
    text-overflow: ellipsis;
}

.problem-row-action {
    display: inline-flex;
    justify-content: flex-end;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.challenge-empty {
    display: grid;
    gap: 4px;
    margin: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fbfcfd;
    color: var(--muted);
    font-size: 13px;
}

.challenge-empty strong {
    color: var(--ink);
    font-size: 14px;
}

.practice-workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    flex: 1;
    min-height: 0;
    padding: 14px;
}

.workspace-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
}

.workspace-title {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.workspace-title span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.workspace-title strong {
    overflow: hidden;
    font-size: 17px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.workspace-nav-count {
    min-width: 54px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-align: center;
    white-space: nowrap;
}

.nav-button {
    min-width: 86px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
}

.db-workspace-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
}

.problem-panel,
.editor-panel {
    min-width: 0;
    min-height: 0;
}

.problem-panel {
    overflow: auto;
    padding: 18px;
}

.problem-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.prompt-meta {
    margin-bottom: 10px;
}

.prompt-meta span,
.return-type span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.problem-header h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.12;
    letter-spacing: 0;
}

.problem-header p {
    margin: 12px 0 0;
    color: #394654;
}

.return-type {
    display: grid;
    gap: 6px;
    margin-top: 16px;
}

.return-type code,
.challenge-return {
    display: block;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 10px;
    background: #fbfcfd;
    color: var(--accent-strong);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    white-space: nowrap;
}

.focus-row {
    margin-top: 14px;
}

.article-toggle-row {
    margin-top: 16px;
}

.article-panel {
    margin-top: 12px;
    border: 1px solid rgba(14, 79, 71, 0.22);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--accent-soft);
}

.article-panel p {
    margin: 0 0 10px;
    color: #234742;
    font-size: 13.5px;
    line-height: 1.6;
}

.article-panel p:last-child {
    margin-bottom: 0;
}

.article-panel strong {
    color: var(--accent-strong);
}

.db-hint-panel {
    display: grid;
    gap: 6px;
}

.data-block {
    margin-top: 22px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px;
}

.panel-header.flush {
    padding: 0 0 10px;
}

.dataset-input-type {
    align-self: flex-end;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 8px;
    background: var(--surface);
    color: var(--accent-strong);
    font-size: 12px;
    white-space: nowrap;
}

.schema-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.schema-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 9px;
    background: var(--surface);
    font-size: 12px;
}

.schema-pill span {
    color: var(--ink);
    font-weight: 700;
}

.schema-pill code,
.field-type {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field-name,
.field-type {
    display: block;
}

.field-type {
    margin-top: 2px;
    font-weight: 600;
}

.db-schema-list {
    display: grid;
    gap: 14px;
}

.db-table-card {
    display: grid;
    gap: 10px;
}

.db-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.db-table-header h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0;
}

.db-table-header span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}

.db-column-grid {
    margin-bottom: 0;
}

.editor-panel {
    display: grid;
    grid-template-rows: auto minmax(360px, 1fr) auto auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.sql-editor-panel {
    grid-template-rows: auto 210px auto;
}

.db-workspace .sql-editor-panel {
    min-height: 0;
}

.db-workspace .problem-panel {
    min-height: 0;
    overflow: visible;
}

.editor-toolbar,
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    background: var(--surface);
}

.primary-button:disabled,
.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.code-editor-shell {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    min-width: 0;
    min-height: 360px;
    height: 100%;
    border-bottom: 1px solid var(--line);
    background: var(--code-bg);
}

.sql-editor-panel .code-editor-shell {
    min-height: 210px;
    height: 210px;
}

.line-number-gutter {
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 18px;
    background: rgba(0, 0, 0, 0.18);
    color: rgba(233, 238, 244, 0.45);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.6;
    text-align: right;
    user-select: none;
}

.line-number-list {
    will-change: transform;
}

.line-number-list span {
    display: block;
    height: 22.4px;
    padding-right: 10px;
}

.line-number-list span.brace-line {
    background: rgba(112, 191, 166, 0.16);
    color: #d7fff1;
}

#codeEditor,
#sqlEditor {
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 360px;
    border: 0;
    outline: none;
    resize: none;
    padding: 18px;
    background: var(--code-bg);
    color: var(--code-ink);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.6;
    tab-size: 4;
}

#codeEditor:disabled,
#sqlEditor:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

#sqlEditor {
    min-height: 210px;
}

.sql-editor-panel .results-panel {
    max-height: none;
    padding: 12px;
}

.sql-editor-panel .result-message {
    min-height: 0;
    margin-top: 8px;
}

.sql-editor-panel .compare-grid {
    margin-top: 10px;
}

.sql-editor-panel pre {
    min-height: 58px;
    max-height: 130px;
}

.brace-match-status {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    border-bottom: 1px solid var(--line);
    padding: 7px 16px;
    background: #172229;
    color: rgba(233, 238, 244, 0.72);
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.brace-match-status span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(112, 191, 166, 0.45);
    border-radius: 6px;
    background: rgba(112, 191, 166, 0.14);
    color: #d7fff1;
    font-weight: 900;
}

.results-panel {
    max-height: 34vh;
    overflow: auto;
    padding: 16px;
}

.result-badge.passed {
    border-color: rgba(22, 112, 72, 0.28);
    background: #e7f5ee;
    color: var(--ok);
}

.result-badge.failed,
.result-badge.compile_error,
.result-badge.runtime_error,
.result-badge.timeout,
.result-badge.sql_error,
.result-badge.setup_error {
    border-color: rgba(180, 35, 24, 0.28);
    background: #fff0ed;
    color: var(--danger);
}

.result-badge.running {
    border-color: rgba(161, 72, 16, 0.28);
    background: #fff5e8;
    color: var(--warn);
}

.result-message {
    min-height: 20px;
    margin: 10px 0 0;
    color: #394654;
}

.diagnostics {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.diagnostic-line {
    overflow-wrap: anywhere;
    border-left: 3px solid var(--danger);
    border-radius: 4px;
    padding: 8px 10px;
    background: #fff7f5;
    color: #652017;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.compare-grid h3 {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0;
}

pre {
    min-height: 84px;
    max-height: 190px;
    margin: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
    color: #26313d;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 1060px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .problem-panel,
    .editor-panel {
        min-height: 520px;
    }

    .sql-editor-panel {
        min-height: 390px;
    }

    .db-workspace .sql-editor-panel {
        min-height: 0;
    }
}

@media (max-width: 760px) {
    .practice-choice,
    .practice-library,
    .quiz-page {
        width: min(100% - 24px, 1180px);
        padding: 16px 0 28px;
    }

    .library-header,
    .section-row,
    .workspace-bar,
    .editor-toolbar,
    .result-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .library-header h1 {
        font-size: 28px;
    }

    .quiz-card-header {
        flex-wrap: nowrap;
    }

    .problem-row {
        grid-template-columns: 44px minmax(0, 1fr) 64px;
        gap: 10px;
    }

    .problem-row-tags {
        display: none;
    }

    .practice-workspace {
        padding: 12px;
    }

    .workspace-title strong {
        white-space: normal;
    }

    .problem-panel,
    .results-panel {
        padding: 14px;
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .practice-status,
    .button-row,
    .library-stats,
    .quiz-actions {
        align-items: stretch;
        width: 100%;
    }

    .topic-filter-grid,
    .quiz-picker-grid,
    .track-card-grid,
    .db-focus-grid,
    .category-strip {
        grid-template-columns: 1fr;
    }

    .problem-row {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .problem-row-action {
        display: none;
    }

    .quiz-answer-row {
        grid-template-columns: 1fr;
    }

    .quiz-check-button {
        width: 100%;
    }
}
