/* Assessment-ready Diagram Builder */

.dh-builder {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dh-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.dh-builder-header h3 {
    margin: 0 0 4px;
    font-size: 1.125rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.dh-builder-sub {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted, #828997);
    max-width: 62ch;
    line-height: 1.45;
}

.dh-builder-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dh-builder-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 14px;
    min-height: 520px;
}

.dh-builder-panel {
    background: var(--bg-secondary, #21252b);
    border: 1px solid var(--border-color, #3e4452);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dh-builder-panel-head {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, #3e4452);
    font-size: 0.75rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #828997);
}

.dh-builder-panel-body {
    padding: 10px;
    overflow: auto;
    flex: 1;
}

.dh-template-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color, #3e4452);
    background: var(--bg-tertiary, #2c313a);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    color: inherit;
}

.dh-template-card:hover,
.dh-template-card.is-active {
    border-color: var(--accent-blue, #6c8aff);
    background: color-mix(in srgb, var(--accent-blue, #6c8aff) 10%, var(--bg-tertiary, #2c313a));
}

.dh-template-card strong {
    display: block;
    font-size: 0.8125rem;
    margin-bottom: 4px;
}

.dh-template-card span {
    font-size: 0.6875rem;
    color: var(--text-muted, #828997);
    line-height: 1.35;
}

.dh-template-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    background: rgba(198, 120, 221, 0.15);
    color: #c678dd;
}

.dh-builder-center {
    display: grid;
    grid-template-rows: auto 1fr 1fr;
    gap: 10px;
    min-height: 0;
}

.dh-builder-meta {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.dh-builder-meta label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted, #828997);
}

.dh-input,
.dh-builder-meta select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #3e4452);
    background: var(--bg-tertiary, #2c313a);
    color: var(--text-primary, #abb2bf);
    font-size: 0.8125rem;
}

.dh-builder-editor-wrap,
.dh-builder-preview-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border-color, #3e4452);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary, #21252b);
}

.dh-builder-editor-label,
.dh-builder-preview-label {
    padding: 8px 12px;
    font-size: 0.6875rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #828997);
    border-bottom: 1px solid var(--border-color, #3e4452);
    background: var(--bg-tertiary, #2c313a);
}

#dh-studio-code {
    flex: 1;
    min-height: 180px;
    border: none;
    border-radius: 0;
    resize: vertical;
    font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

#dh-studio-preview {
    flex: 1;
    min-height: 180px;
    overflow: auto;
    padding: 12px;
}

.dh-readiness-score {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-tertiary, #2c313a);
    margin-bottom: 10px;
}

.dh-readiness-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 3px solid var(--border-color, #3e4452);
}

.dh-readiness-ring.is-good {
    border-color: #22c55e;
    color: #22c55e;
}

.dh-readiness-ring.is-warn {
    border-color: #f59e0b;
    color: #f59e0b;
}

.dh-readiness-ring.is-bad {
    border-color: #ef4444;
    color: #ef4444;
}

.dh-readiness-copy strong {
    display: block;
    font-size: 0.8125rem;
}

.dh-readiness-copy span {
    font-size: 0.6875rem;
    color: var(--text-muted, #828997);
}

.dh-checklist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dh-checklist li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color, #3e4452) 60%, transparent);
    font-size: 0.75rem;
    line-height: 1.35;
}

.dh-checklist li:last-child {
    border-bottom: none;
}

.dh-check-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.625rem;
    font-weight: 700;
}

.dh-check-icon.pass {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.dh-check-icon.fail {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.dh-checklist .hint {
    display: block;
    margin-top: 2px;
    font-size: 0.625rem;
    color: var(--text-muted, #828997);
}

.dh-legend-key {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, #3e4452);
}

.dh-legend-key h4 {
    margin: 0 0 8px;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #828997);
}

.dh-legend-items {
    display: grid;
    gap: 6px;
}

.dh-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.6875rem;
}

.dh-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

@media (max-width: 1100px) {
    .dh-builder-layout {
        grid-template-columns: 1fr;
    }

    .dh-builder-meta {
        grid-template-columns: 1fr;
    }
}
