:root {
    --bg-0: #f5f7fa;
    --bg-1: #ffffff;
    --bg-2: #eef1f6;
    --bg-3: #e2e7ef;
    --bg-4: #d8dee8;
    --border: #d0d7e2;
    --border-light: #bcc5d3;
    --text-primary: #1a2332;
    --text-secondary: #4a5a72;
    --text-dim: #8895a7;
    --accent: #0a9b80;
    --accent-dim: #d0f0ea;
    --accent-glow: rgba(10,155,128,0.08);
    --orange: #d96830;
    --orange-dim: #fef0e8;
    --blue: #2b7de0;
    --blue-dim: #e8f0fc;
    --purple: #7c4ddb;
    --yellow: #b8900a;
    --red: #d93848;
    --green: #1a9960;
    --radius: 6px;
    --radius-sm: 3px;
    --mono: 'Fira Code', monospace;
    --ui: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--ui);
    background: var(--bg-0);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
}

/* === HEADER === */
#header {
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent), #007a6a);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff; letter-spacing: -0.5px;
}

.logo-text { font-size: 15px; font-weight: 600; letter-spacing: 0.5px; }
.logo-text span { color: var(--accent); }
.logo-version {
    font-size: 10px; font-weight: 500; background: var(--bg-3);
    border: 1px solid var(--border); border-radius: 3px;
    padding: 1px 5px; color: var(--text-secondary); font-family: var(--mono);
}

#search-bar {
    flex: 1;
    max-width: 400px;
    position: relative;
}

#search-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 12px 7px 34px;
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-dim); }

.search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-dim); font-size: 14px;
}

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

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius);
    font-family: var(--ui); font-size: 13px; font-weight: 500;
    cursor: pointer; border: none; transition: all 0.15s;
}

.btn-primary {
    background: var(--accent); color: #000;
}
.btn-primary:hover { background: #00e8c0; }

.btn-ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-disabled {
    opacity: 0.4; cursor: not-allowed; pointer-events: none;
}

/* === EMAIL INPUT === */
#email-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
#email-input-row {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
    overflow: hidden;
}
#email-input-row:focus-within { border-color: var(--accent); }
#email-input-row.error { border-color: var(--red); }
#email-input-row.valid { border-color: var(--green); }

.email-icon {
    padding: 0 8px 0 10px;
    color: var(--text-dim);
    font-size: 13px;
    flex-shrink: 0;
    line-height: 1;
}
.email-required {
    color: var(--red);
    font-size: 13px;
    padding-right: 6px;
    flex-shrink: 0;
}
#email-input {
    background: transparent;
    border: none;
    outline: none;
    padding: 7px 10px 7px 0;
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 13px;
    width: 210px;
}
#email-input::placeholder { color: var(--text-dim); }

.email-valid-icon {
    padding-right: 8px;
    font-size: 12px;
    color: var(--green);
    flex-shrink: 0;
    display: none;
}
#email-input-row.valid .email-valid-icon { display: block; }

#email-error {
    font-size: 10.5px;
    color: var(--red);
    padding-left: 2px;
    display: none;
    position: absolute;
    bottom: -16px;
    left: 0;
    white-space: nowrap;
}

/* Back button */
#back-btn { display: none; }
#back-btn.visible { display: inline-flex; }

.file-info-badge {
    font-size: 12px; color: var(--text-dim);
    font-family: var(--mono);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 300px;
}

/* === MAIN LAYOUT === */
#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === LEFT SIDEBAR === */
#sidebar {
    width: 300px;
    min-width: 220px;
    max-width: 480px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    resize: horizontal;
}

#sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-0);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-dim);
    cursor: pointer;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.sidebar-tab:hover { color: var(--text-secondary); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#tree-container, #search-results-container {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
#tree-container::-webkit-scrollbar,
#search-results-container::-webkit-scrollbar { width: 5px; }
#tree-container::-webkit-scrollbar-track,
#search-results-container::-webkit-scrollbar-track { background: transparent; }
#tree-container::-webkit-scrollbar-thumb,
#search-results-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Sidebar group dividers */
.tree-group-label {
    padding: 10px 12px 4px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tree-group-label:first-child { border-top: none; margin-top: 0; }
.tree-group-label::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.tree-group-label.group-definitions { color: var(--blue); }
.tree-group-label.group-collected { color: var(--red); }
.tree-group-label.group-admin { color: var(--purple); }

.tree-section {
    margin-bottom: 2px;
}

/* Colored left accent on sections */
.tree-section.section-definitions .tree-section-header { border-left: 3px solid var(--blue); }
.tree-section.section-collected .tree-section-header { border-left: 3px solid var(--red); }
.tree-section.section-admin .tree-section-header { border-left: 3px solid var(--purple); }

.tree-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.tree-section-header:hover { color: var(--accent); }

.tree-section-header .arrow {
    font-size: 10px;
    transition: transform 0.2s;
    flex-shrink: 0;
    transform: rotate(90deg);
}
.tree-section-header.collapsed .arrow { transform: rotate(0deg); }

.tree-section-body { padding-left: 16px; }
.tree-section-body.collapsed { display: none; }

.tree-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 0;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.1s;
    position: relative;
    user-select: none;
}
.tree-item:hover { background: var(--bg-2); }
.tree-item.active {
    background: var(--accent-glow);
    border-right: 2px solid var(--accent);
}

.tree-indent { width: 18px; flex-shrink: 0; }
.tree-toggle {
    width: 16px; height: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--text-dim);
    font-size: 10px;
    transition: transform 0.2s;
}
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { cursor: default; color: transparent; }

.tree-icon {
    width: 18px; height: 18px;
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700;
    flex-shrink: 0;
    margin-right: 6px;
}

.tree-label {
    flex: 1;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-oid {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    padding-right: 10px;
    flex-shrink: 0;
}

.tree-count {
    font-size: 10px; color: var(--text-dim);
    background: var(--bg-3); border-radius: 10px;
    padding: 1px 6px; margin-right: 8px; flex-shrink: 0;
}

/* === DETAIL PANE === */
#detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-0);
}

#breadcrumb {
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 36px;
}

.breadcrumb-item { color: var(--text-dim); cursor: pointer; }
.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-dim); }
.breadcrumb-item.current { color: var(--text-primary); cursor: default; }

#detail-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
}

#detail-content::-webkit-scrollbar { width: 6px; }
#detail-content::-webkit-scrollbar-track { background: transparent; }
#detail-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === WELCOME SCREEN === */
#welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-dim);
}

.welcome-logo {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--bg-3), var(--bg-4));
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    margin-bottom: 8px;
}

.welcome-title { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.welcome-sub { font-size: 13px; text-align: center; max-width: 380px; line-height: 1.6; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.drop-zone p { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.drop-zone .drop-icon { font-size: 28px; }

/* === DETAIL ELEMENTS === */
.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.detail-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
    flex-shrink: 0;
}

.detail-title-block { flex: 1; min-width: 0; }
.detail-element-name {
    font-size: 22px; font-weight: 700; line-height: 1.2;
    word-break: break-all;
}
.detail-element-type {
    font-size: 12px; color: var(--text-dim);
    font-family: var(--mono); margin-top: 4px;
}

.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
    font-family: var(--mono);
}

.section-title {
    font-size: 11px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-dim);
    margin-bottom: 12px; margin-top: 24px;
    display: flex; align-items: center; gap: 8px;
}
.section-title::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* === ATTRIBUTES TABLE === */
.attr-grid {
    display: grid;
    grid-template-columns: minmax(140px, auto) 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 4px;
}

.attr-key {
    background: var(--bg-2);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-secondary);
    display: flex; align-items: center;
}

.attr-val {
    background: var(--bg-1);
    padding: 8px 12px;
    font-size: 13px;
    word-break: break-all;
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}

.attr-val.mono { font-family: var(--mono); font-size: 12px; }

/* === OID REF CHIP === */
.oid-ref {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 4px;
    background: var(--bg-3); border: 1px solid var(--border-light);
    font-family: var(--mono); font-size: 11px;
    color: var(--blue); cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.oid-ref:hover { background: var(--blue-dim); border-color: var(--blue); }

/* === CHILD LIST === */
.child-list {
    display: flex; flex-direction: column; gap: 6px;
}

.child-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.child-card:hover { border-color: var(--accent); background: var(--accent-glow); }

.child-card-icon {
    width: 32px; height: 32px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.child-card-info { flex: 1; min-width: 0; }
.child-card-name { font-size: 13px; font-weight: 500; }
.child-card-oid { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.child-card-arrow { color: var(--text-dim); font-size: 12px; }

/* === DATA TABLE === */
.data-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.data-table {
    width: 100%; border-collapse: collapse;
    font-size: 12.5px;
}

.data-table th {
    background: var(--bg-3); padding: 8px 12px;
    text-align: left; font-weight: 600;
    font-size: 11px; letter-spacing: 0.5px;
    color: var(--text-secondary); white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 7px 12px; border-bottom: 1px solid var(--border);
    background: var(--bg-1); vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-2); }

.data-table td.mono { font-family: var(--mono); font-size: 11px; }

/* === ELEMENT COLOR CODING === */
.type-study { background: #e0ecff; color: #1a5cc8; }
.type-meta { background: #ddeeff; color: #2870c0; }
.type-event-group { background: #f0e4ff; color: #6a3ab8; }
.type-event { background: #eedcff; color: #7b44cc; }
.type-itemgroup { background: #d8f5ef; color: #0a7a60; }
.type-item { background: #ddf5e8; color: #1a8050; }
.type-codelist { background: #fff0e4; color: #c05a20; }
.type-condition { background: #fff6d8; color: #8a6a00; }
.type-method { background: #d8f5f5; color: #1a8a90; }
.type-comment { background: #f5f0d0; color: #7a7020; }
.type-clinical { background: #ffe4e6; color: #c02040; }
.type-subject { background: #ffe8ea; color: #c03050; }
.type-admin { background: #e0e8ff; color: #3060c0; }
.type-workflow { background: #f4e0ff; color: #9040cc; }
.type-default { background: var(--bg-3); color: var(--text-secondary); }

/* === SEARCH RESULTS === */
.search-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px; cursor: pointer;
    border-radius: var(--radius); transition: background 0.1s;
    margin-bottom: 2px;
}
.search-result-item:hover { background: var(--bg-2); }

.search-result-type { font-size: 10px; color: var(--text-dim); font-family: var(--mono); }
.search-result-name { font-size: 13px; }
.search-result-match { color: var(--accent); }

/* TOOLTIP */
.tooltip {
    position: absolute; z-index: 100;
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px 10px;
    font-size: 11px; color: var(--text-secondary);
    pointer-events: none; white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* EMPTY STATE */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-dim); font-size: 13px;
}
.empty-state-icon { font-size: 32px; margin-bottom: 12px; }

/* STAT CARDS */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}

.stat-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.5px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-top: 4px; font-family: var(--mono); }
.stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Tags for mandatories, etc */
.tag {
    display: inline-flex; align-items: center;
    padding: 1px 6px; border-radius: 3px;
    font-size: 11px; font-weight: 600;
}
.tag-yes { background: #d8f5ea; color: var(--green); }
.tag-no { background: #ffe4e8; color: var(--red); }
.tag-warn { background: #fff6d8; color: var(--yellow); }

input[type=file] { display: none; }

.resizer {
    width: 4px; background: var(--border); cursor: col-resize;
    transition: background 0.2s;
    flex-shrink: 0;
}
.resizer:hover { background: var(--accent); }

/* Tabs in detail pane */
.detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
    padding: 0 20px;
}
.detail-tab {
    padding: 10px 14px;
    font-size: 12.5px; font-weight: 500;
    color: var(--text-dim); cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.detail-tab:hover { color: var(--text-primary); }
.detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* XML preview */
.xml-preview {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
}
.xml-tag { color: #1a5cc8; }
.xml-attr { color: #c05a20; }
.xml-val { color: #0a7a60; }
.xml-comment { color: var(--text-dim); font-style: italic; }

/* === STEP 1 OVERLAY === */
#step1-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-0);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#step1-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 44px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

#step1-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

#step1-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.step-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--bg-2);
    border: 1px solid var(--border);
    transition: all 0.25s;
    white-space: nowrap;
}
.step-pill.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: var(--accent-dim);
}
.step-pill.done {
    color: var(--green);
    background: #d8f5ea;
    border-color: #a0dcc0;
}

.step-num {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: currentColor;
    color: var(--bg-0);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
    flex-shrink: 0;
}

.step-connector {
    flex: 1;
    height: 1px;
    background: var(--border);
    margin: 0 10px;
}

.panel-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.panel-sub {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 22px;
    line-height: 1.5;
}

.s1-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.s1-input {
    width: 100%;
    background: var(--bg-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    color: var(--text-primary);
    font-family: var(--ui);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.s1-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.s1-input.error { border-color: var(--red); }
.s1-input.valid { border-color: var(--green); }

.s1-error {
    font-size: 11.5px;
    color: var(--red);
    margin-top: 6px;
    min-height: 16px;
}

.s1-btn-primary {
    width: 100%;
    padding: 12px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-family: var(--ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.15s, transform 0.1s;
}
.s1-btn-primary:hover { background: #00e8c0; }
.s1-btn-primary:active { transform: scale(0.98); }

.s1-btn-ghost {
    width: 100%;
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--ui);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.s1-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

#s1-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px 20px;
    text-align: center;
    transition: all 0.2s;
    cursor: default;
    background: var(--bg-2);
}
#s1-drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
#s1-drop-zone.has-file {
    border-color: var(--green);
    background: #e8f8ef;
}

.s1-field {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.s1-dz-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 7px 18px;
    background: var(--bg-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--ui);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.s1-dz-btn:hover { border-color: var(--accent); color: var(--accent); }

.s1-dz-btn-ghost {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: var(--ui);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.s1-dz-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.s1-btn-primary:disabled {
    background: var(--bg-3);
    color: var(--text-dim);
    cursor: not-allowed;
    border: 1px solid var(--border);
}
.s1-btn-primary:disabled:hover { background: var(--bg-3); }

.s1-back-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--ui);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-top: 16px;
    display: block;
    text-align: center;
    transition: color 0.15s;
}
.s1-back-link:hover { color: var(--accent); }

/* Sidebar toggle — hidden on desktop */
#sidebar-toggle { display: none; }

/* === RESPONSIVE — TABLET (<=900px) === */
@media (max-width: 900px) {
    #sidebar {
        width: 240px;
        min-width: 180px;
    }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    #step1-card {
        padding: 28px 24px;
    }

    #detail-content {
        padding: 16px;
    }

    .detail-header {
        gap: 12px;
    }

    .detail-element-name {
        font-size: 18px;
    }
}

/* === RESPONSIVE — MOBILE (<=640px) === */
@media (max-width: 640px) {
    /* Header */
    #header {
        height: 46px;
        padding: 0 12px;
        gap: 8px;
    }

    .logo-text { display: none; }
    .logo-version { display: none; }

    #search-bar { display: none; }
    .file-info-badge { display: none !important; }

    #sidebar-toggle { display: inline-flex; }

    .header-actions { gap: 4px; }

    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Sidebar — hidden by default, overlay when toggled */
    #sidebar {
        display: none;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .resizer { display: none; }

    body.sidebar-open #sidebar {
        display: flex;
        position: fixed;
        inset: 0;
        top: 46px;
        z-index: 50;
        width: 100%;
        max-width: 100%;
        background: var(--bg-1);
    }

    body.sidebar-open #detail {
        display: none;
    }

    /* Detail pane */
    #detail-content {
        padding: 12px;
    }

    #breadcrumb {
        padding: 6px 12px;
        font-size: 11px;
    }

    .detail-header {
        gap: 10px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .detail-icon {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .detail-element-name {
        font-size: 16px;
    }

    .section-title {
        margin-top: 16px;
        margin-bottom: 8px;
    }

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

    .attr-key {
        border-bottom: none;
        padding-bottom: 2px;
        font-weight: 700;
    }

    .attr-val {
        padding-top: 2px;
        padding-bottom: 10px;
    }

    /* Stat grid */
    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .stat-card {
        padding: 10px 12px;
    }

    .stat-value {
        font-size: 18px;
    }

    /* Gate screen */
    #step1-overlay {
        padding: 12px;
    }

    #step1-card {
        padding: 24px 18px;
        max-width: 100%;
        gap: 20px;
        border-radius: 12px;
    }

    .panel-title { font-size: 15px; }
    .panel-sub { font-size: 12px; margin-bottom: 14px; }

    .s1-input { padding: 10px 12px; font-size: 13px; }

    #s1-drop-zone { padding: 18px 14px; }

    .s1-btn-primary { margin-top: 14px; padding: 11px 16px; font-size: 13px; }

    /* Paste modal */
    #paste-modal > div {
        width: 95vw !important;
        padding: 16px !important;
    }

    #paste-area {
        height: 180px !important;
    }

    /* Data tables */
    .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 11px;
    }

    .data-table th,
    .data-table td {
        padding: 5px 8px;
    }

    /* Child cards */
    .child-card {
        padding: 8px 10px;
        gap: 8px;
    }

    .child-card-icon {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}
