*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 16px;
    height: 48px;
    background: #2d2d2d;
    border-bottom: none;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

#header-logo {
    height: 28px;
    width: auto;
    flex-shrink: 0;
}

header h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    flex-shrink: 0;
    color: #fff;
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #ccc;
    white-space: nowrap;
}

.controls input[type="text"]#api-key {
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 13px;
    background: #3d3d3d;
    color: #fff;
    outline: none;
    transition: border-color .15s, background .15s;
    width: 150px;
    -webkit-text-security: disc;
}

.controls input[type="text"]#api-key::placeholder { color: #888; }

.controls input[type="text"]#api-key:focus {
    background: #fff;
    color: #1a1a1a;
    border-color: #4f84c4;
}

/* ── Profile combobox ────────────────────────────────────────────────────── */

.combobox {
    position: relative;
}

.combobox input[type="text"] {
    padding: 5px 24px 5px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 13px;
    background: #3d3d3d url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E") no-repeat right 8px center;
    color: #fff;
    outline: none;
    width: 300px;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}

.combobox input[type="text"]::placeholder { color: #888; }

.combobox input[type="text"]:focus {
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 8px center;
    color: #1a1a1a;
    border-color: #4f84c4;
    cursor: text;
}

.combobox-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 340px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
}

.combobox-option {
    padding: 7px 10px;
    font-size: 13px;
    cursor: pointer;
    color: #1a1a1a;
    border-radius: 4px;
    margin: 2px 4px;
}

.combobox-option:hover,
.combobox-option.active {
    background: #eff6ff;
    color: #1d4ed8;
}

.combobox-option mark {
    background: none;
    color: #1d4ed8;
    font-weight: 700;
}

.combobox-empty {
    padding: 10px;
    font-size: 12px;
    color: #aaa;
    text-align: center;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .2s;
}
.status-dot.connected    { background: #22c55e; }
.status-dot.connecting   { background: #f59e0b; }
.status-dot.disconnected { background: #94a3b8; }
.status-dot.error        { background: #ef4444; }

/* ── Main layout ─────────────────────────────────────────────────────────── */

main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Editor wrapper ──────────────────────────────────────────────────────── */

#editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 34px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.editor-filename {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 11px;
    color: #888;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#upload-btn,
#validate-btn {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    color: #444;
    flex-shrink: 0;
    transition: border-color .15s, background .15s, opacity .15s;
}

#upload-btn {
    background: #f3f4f6;
    border-color: #d1d5db;
}

#upload-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

#validate-btn {
    background: #fff;
    border-color: #ccc;
}

#validate-btn:not(:disabled) {
    background: #fef9c3;
    border-color: #fde047;
    color: #444;
}

#validate-btn:hover:not(:disabled) {
    background: #fef08a;
    border-color: #facc15;
}


#validate-btn:disabled {
    opacity: .35;
    cursor: default;
}

.live-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #444;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.live-toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: #4f84c4;
    width: 13px;
    height: 13px;
}

.toolbar-sep {
    width: 1px;
    height: 18px;
    background: #e0e0e0;
    flex-shrink: 0;
}

#editor-container {
    flex: 1;
    overflow: hidden;
}

/* ── Drop zone (toolbar) ─────────────────────────────────────────────────── */

#drop-zone {
    font-size: 12px;
    color: #999;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 3px 12px;
    cursor: default;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
}

#drop-zone.drag-over {
    border-color: #4f84c4;
    color: #2563eb;
    background: #f0f6ff;
}

/* ── Split divider ───────────────────────────────────────────────────────── */

#split-divider {
    width: 5px;
    flex-shrink: 0;
    background: #e0e0e0;
    cursor: col-resize;
    transition: background .15s;
    position: relative;
}

#split-divider:hover,
#split-divider.dragging {
    background: #4f84c4;
}

/* ── Results panel ───────────────────────────────────────────────────────── */

#results-panel {
    overflow-y: auto;
    background: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#results-placeholder p {
    color: #999;
    font-size: 13px;
    line-height: 1.5;
}

#results-toolbar {
    display: flex;
    align-items: center;
    height: 34px;
    border-bottom: 1px solid #e0e0e0;
    margin: -16px -16px 16px -16px;
    padding: 0 12px;
    background: #fafafa;
    flex-shrink: 0;
}

#validating-indicator {
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #888;
}

#stopwatch {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 11px;
    color: #aaa;
    min-width: 3ch;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-top-color: #4f84c4;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Overall badge */
.badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 5px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 16px;
}
.badge.valid   { background: #dcfce7; color: #15803d; }
.badge.invalid { background: #fee2e2; color: #b91c1c; }

/* Section headings */
#results-content section {
    margin-bottom: 16px;
}

#results-content h3 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #aaa;
    margin-bottom: 8px;
}

/* Passed */
.passed {
    font-size: 13px;
    color: #16a34a;
}

/* Failure / warning items */
.failure,
.warning {
    font-size: 12px;
    line-height: 1.45;
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    word-break: break-word;
}
.failure { background: #fef2f2; color: #7f1d1d; border-left: 3px solid #ef4444; }
.warning { background: #fefce8; color: #713f12; border-left: 3px solid #eab308; }

.sch-location {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 10px;
    opacity: .65;
    margin-top: 3px;
    word-break: break-all;
}

.rule-id {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 10px;
    font-weight: 700;
    margin-right: 5px;
    opacity: .75;
}

/* Schematron block per file */
.sch-block {
    margin-bottom: 12px;
}

.sch-name {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 10px;
    color: #aaa;
    margin-bottom: 6px;
    word-break: break-all;
}

.muted {
    font-size: 12px;
    color: #bbb;
}

.error-msg {
    font-size: 13px;
    color: #dc2626;
}

/* ── Summary section separator ───────────────────────────────────────────── */

#results-content section:last-child {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

/* ── Summary table ───────────────────────────────────────────────────────── */

#summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#summary-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    border-bottom: 1px solid #e0e0e0;
    padding: 4px 6px;
}

#summary-table thead th:not(:first-child) {
    text-align: center;
}

#summary-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f0f0f0;
}

.sum-name {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 11px;
    color: #555;
    padding: 5px 6px;
    word-break: break-all;
}

#summary-table tbody td:not(.sum-name) {
    text-align: center;
    padding: 5px 6px;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.sum-zero { color: #ccc; }
.sum-warn { color: #b45309; }
.sum-err  { color: #b91c1c; }
