:root {
    /* https://material-foundation.github.io/material-theme-builder/ */
    --md-sys-color-primary: rgb(170 199 255);
    --md-sys-color-surface-tint: rgb(170 199 255);
    --md-sys-color-on-primary: rgb(10 48 95);
    --md-sys-color-primary-container: rgb(40 71 119);
    --md-sys-color-on-primary-container: rgb(214 227 255);
    --md-sys-color-secondary: rgb(190 198 220);
    --md-sys-color-on-secondary: rgb(40 49 65);
    --md-sys-color-secondary-container: rgb(62 71 89);
    --md-sys-color-on-secondary-container: rgb(218 226 249);
    --md-sys-color-tertiary: rgb(221 188 224);
    --md-sys-color-on-tertiary: rgb(63 40 68);
    --md-sys-color-tertiary-container: rgb(87 62 92);
    --md-sys-color-on-tertiary-container: rgb(250 216 253);
    --md-sys-color-error: rgb(255 180 171);
    --md-sys-color-on-error: rgb(105 0 5);
    --md-sys-color-error-container: rgb(147 0 10);
    --md-sys-color-on-error-container: rgb(255 218 214);
    --md-sys-color-background: rgb(17 19 24);
    --md-sys-color-on-background: rgb(226 226 233);
    --md-sys-color-surface: rgb(17 19 24);
    --md-sys-color-on-surface: rgb(226 226 233);
    --md-sys-color-surface-variant: rgb(68 71 78);
    --md-sys-color-on-surface-variant: rgb(196 198 208);
    --md-sys-color-outline: rgb(142 144 153);
    --md-sys-color-outline-variant: rgb(68 71 78);
    --md-sys-color-shadow: rgb(0 0 0);
    --md-sys-color-scrim: rgb(0 0 0);
    --md-sys-color-inverse-surface: rgb(226 226 233);
    --md-sys-color-inverse-on-surface: rgb(46 48 54);
    --md-sys-color-inverse-primary: rgb(65 95 145);
    --md-sys-color-primary-fixed: rgb(214 227 255);
    --md-sys-color-on-primary-fixed: rgb(0 27 62);
    --md-sys-color-primary-fixed-dim: rgb(170 199 255);
    --md-sys-color-on-primary-fixed-variant: rgb(40 71 119);
    --md-sys-color-secondary-fixed: rgb(218 226 249);
    --md-sys-color-on-secondary-fixed: rgb(19 28 43);
    --md-sys-color-secondary-fixed-dim: rgb(190 198 220);
    --md-sys-color-on-secondary-fixed-variant: rgb(62 71 89);
    --md-sys-color-tertiary-fixed: rgb(250 216 253);
    --md-sys-color-on-tertiary-fixed: rgb(40 19 46);
    --md-sys-color-tertiary-fixed-dim: rgb(221 188 224);
    --md-sys-color-on-tertiary-fixed-variant: rgb(87 62 92);
    --md-sys-color-surface-dim: rgb(17 19 24);
    --md-sys-color-surface-bright: rgb(55 57 62);
    --md-sys-color-surface-container-lowest: rgb(12 14 19);
    --md-sys-color-surface-container-low: rgb(25 28 32);
    --md-sys-color-surface-container: rgb(29 32 36);
    --md-sys-color-surface-container-high: rgb(40 42 47);
    --md-sys-color-surface-container-highest: rgb(51 53 58);
}

body {
    margin: 85px 0px 0px 0px;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    font-family: "Segoe UI", Roboto, sans-serif;
}

.ribbon-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 80px;
    background-color: var(--md-sys-color-surface-container-low);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    box-sizing: border-box;
    z-index: 9999;
    box-shadow: 0 2px 4px var(--md-sys-color-shadow);
}

.ribbon-head {
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.ribbon-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.1;
    text-align: center;
    color: var(--md-sys-color-primary);
    text-shadow: 0px 6px 14px var(--md-sys-color-shadow);
    user-select: none;
    white-space: nowrap;
}

.ribbon-divider {
    width: 1px;
    height: 36px;
    background-color: var(--md-sys-color-outline-variant);
    margin: 0 8px;
    flex-shrink: 0;
}

.ribbon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 0 12px;
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-background);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.ribbon-btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: currentColor;
}

.ribbon-btn:hover:not(:disabled) {
    background-color: var(--md-sys-color-surface-container-highest);
    border-color: var(--md-sys-color-outline);
}

.ribbon-btn:active:not(:disabled) {
    background-color: var(--md-sys-color-surface-container);
    box-shadow: inset 0 1px 2px var(--md-sys-color-shadow);
}

.ribbon-btn:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 1px;
}

.ribbon-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    background-color: var(--md-sys-color-surface-container-highest);
    border-color: var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    box-shadow: none;
}

.ribbon-btn:disabled svg {
    opacity: 0.38;
}

.tab-container {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    overflow-x: auto;
    position: sticky;
    top: 80px;
    z-index: 10;
    background-color: var(--md-sys-color-background);
}

.tab-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-button:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}

.tab-button.active {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-outline);
    font-weight: 600;
}

.tab-button.dragging {
    opacity: 0.5;
}

.tab-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 2px;
    opacity: 0.7;
}

.tab-close:hover {
    opacity: 1;
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.tab-content-wrapper {
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 12px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.tab-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--md-sys-color-on-surface);
    font-family: monospace;
}

.tab-comparison {
    color: var(--md-sys-color-on-surface);
    font-size: 13px;
    line-height: 1.6;
    max-width: 900px;
}

.tab-comparison p {
    margin: 0 0 4px 0;
}

.tab-comparison ul {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.tab-comparison li {
    margin: 2px 0;
    word-break: break-word;
}

.tab-warnings {
    color: var(--md-sys-color-on-surface);
    font-size: 13px;
    line-height: 1.6;
    max-width: 900px;
}

.tab-warnings p {
    margin: 0 0 4px 0;
}

.tab-warnings ul {
    margin: 0;
    padding-left: 24px;
}

.tab-warnings li {
    margin: 2px 0;
    word-break: break-word;
    font-family: monospace;
    color: var(--md-sys-color-error);
}

.bi-viewer {
    display: flex;
    gap: 12px;
}

.bi-list-panel,
.bi-edit-panel {
    overflow-y: auto;
    max-height: calc(100vh - 176px);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    background-color: var(--md-sys-color-surface-container-low);
}

.bi-list-panel {
    flex: 0 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bi-tree-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.bi-edit-panel {
    flex: 0 1 50%;
    min-width: 0;
}

.bi-tree {
    margin: 0;
    padding: 4px;
    list-style: none;
    font-size: 13px;
    user-select: none;
}

.bi-search-bar {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    flex: 0 0 auto;
}

.bi-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 28px;
    padding: 0 8px;
    background-color: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.bi-search-input::placeholder {
    color: var(--md-sys-color-outline);
}

.bi-search-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
}

.bi-search-clear {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 12px;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bi-search-clear:hover {
    border-color: var(--md-sys-color-outline);
}

.bi-search-clear:active {
    box-shadow: inset 0 1px 2px var(--md-sys-color-shadow);
}

.bi-search-clear:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 1px;
}

.bi-items {
    margin: 0;
    padding: 0 0 4px 18px;
    list-style: none;
}

.bi-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.bi-row:hover {
    background-color: var(--md-sys-color-surface-container-high);
}

.bi-group summary {
    list-style: none;
}

.bi-group summary::-webkit-details-marker {
    display: none;
}

.bi-group summary::before {
    content: "▸";
    display: inline-block;
    width: 1em;
    color: var(--md-sys-color-on-surface-variant);
    transition: transform 0.15s ease;
}

.bi-group details[open] > summary::before {
    transform: rotate(90deg);
}

.bi-group-row {
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

.bi-row.bi-selected,
.bi-row.bi-selected:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.bi-row.bi-dragging {
    opacity: 0.5;
}

.bi-row.bi-drop-above {
    box-shadow: inset 0 2px 0 var(--md-sys-color-primary);
}

.bi-row.bi-drop-below {
    box-shadow: inset 0 -2px 0 var(--md-sys-color-primary);
}

.bi-row.bi-drop-target {
    box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container-high);
}

.bi-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.bi-card {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    overflow: hidden;
    background-color: var(--md-sys-color-on-primary-fixed);
    font-size: 13px;
}

.bi-card-header {
    padding: 8px 10px;
}

.bi-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

.bi-card-short-help {
    color: var(--md-sys-color-on-surface-variant);
}

.bi-card-body {
    padding: 8px 10px;
    background-color: var(--md-sys-color-on-secondary);
    color: var(--md-sys-color-on-secondary-container);
    line-height: 1.5;
    word-break: break-word;
}

.bi-card-footer {
    padding: 8px 10px;
    background-color: var(--md-sys-color-on-secondary-fixed);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bi-card-tag {
    padding: 1px 8px;
    border-radius: 999px;
    background-color: var(--md-sys-color-on-primary);
    color: var(--md-sys-color-on-secondary-container);
    font-size: 12px;
    white-space: nowrap;
}

.import-dialog {
    min-width: 420px;
    max-width: 90vw;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    box-shadow: 0 8px 24px var(--md-sys-color-shadow);
}

.import-dialog::backdrop {
    background-color: var(--md-sys-color-scrim);
    opacity: 0.5;
}

.import-dialog-title {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--md-sys-color-primary);
}

.import-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.import-field-label {
    flex: 0 0 auto;
    min-width: 100px;
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
}

.import-file-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    font-family: monospace;
    color: var(--md-sys-color-on-surface);
}

.import-file-name:empty::before {
    content: attr(data-placeholder);
    color: var(--md-sys-color-outline);
}

.import-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.import-btn {
    height: 32px;
    padding: 0 16px;
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.import-btn:hover:not(:disabled) {
    border-color: var(--md-sys-color-outline);
}

.import-btn:active:not(:disabled) {
    box-shadow: inset 0 1px 2px var(--md-sys-color-shadow);
}

.import-btn:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 1px;
}

.import-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none;
}

.hidden {
    display: none;
}
