:root {
    --bg-app: #e9edf2;
    --bg-window: #ffffff;
    --bg-menu: #edf3fb;
    --bg-toolbar: #f5f8fc;
    --bg-panel: #ffffff;
    --bg-panel-2: #fbfcfe;
    --bg-tab: #eef1f5;
    --bg-tab-active: #ffffff;
    --bg-tree-hover: #edf4ff;
    --bg-tree-selected: #d7e8ff;
    --bg-tree-selected-border: #7aa7e8;
    --bg-code: #ffffff;
    --bg-gutter: #f3f5f7;
    --border: #cfd5de;
    --border-strong: #b6bfca;
    --text: #1f2328;
    --muted: #687386;
    --accent: #2386db;
    --accent-soft: #d7ebff;
    --success: #2f855a;
    --danger: #b42318;
    --keyword: #0000ff;
    --type: #2b91af;
    --string: #a31515;
    --comment: #6f7682;
    --number: #7a3e00;
    --preprocessor: #af00db;
    --method: #795e26;
    --member: #001080;
    --explorer-width: 286px;
    --tree-namespace: #dcc22b;
    --tree-type: #48b19b;
    --tree-method: #d97007;
    --tree-member: #404040;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-app);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: clamp(13px, 0.72rem + 0.18vw, 16px);
}

body {
    overflow: auto;
}

button,
input {
    font: inherit;
}

.desktop {
    display: grid;
    grid-template-rows: 28px 42px 1fr 22px;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-window);
}

.menubar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 10px;
    background: linear-gradient(180deg, #4ba8f4 0%, #2386db 100%);
    border-bottom: 1px solid #1c6eb5;
}

.menu-brand {
    font-size: 0.79rem;
    font-weight: 600;
    color: #ffffff;
}

.menu-items {
    display: flex;
    gap: 2px;
}

.menu-item {
    border: 0;
    background: transparent;
    color: #f7fbff;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.14);
}

.toolbar-row {
    display: grid;
    grid-template-columns: auto auto minmax(200px, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: linear-gradient(180deg, #fafdff 0%, #edf4fb 100%);
    border-bottom: 1px solid var(--border);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-stretch {
    min-width: 0;
}

.toolbar-identity {
    min-width: 180px;
    text-align: right;
}

.identity-title {
    font-size: 0.84rem;
    font-weight: 600;
}

.identity-subtitle {
    color: var(--muted);
    font-size: 0.68rem;
}

.tool-button {
    border: 1px solid var(--border-strong);
    background: linear-gradient(180deg, #ffffff 0%, #eceff3 100%);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    padding: 6px 11px;
}

.tool-button:hover {
    background: linear-gradient(180deg, #ffffff 0%, #e7edf8 100%);
}

.tool-button.primary {
    border-color: #7fb4e8;
    background: linear-gradient(180deg, #ffffff 0%, #dcebff 100%);
}

.view-mode-group {
    display: flex;
    align-items: center;
    gap: 0;
}

.mode-button {
    border-radius: 0;
    min-width: 42px;
    padding-inline: 10px;
}

.mode-button:first-child {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.mode-button:last-child {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.mode-button.active {
    background: linear-gradient(180deg, #fff8df 0%, #ffe6a6 100%);
    border-color: #d9b866;
}

.tool-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.search-box {
    width: 100%;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text);
    border-radius: 4px;
    padding: 6px 9px;
}

.file-input {
    display: none;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(190px, var(--explorer-width)) 5px minmax(0, 1fr);
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.explorer-pane {
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-width: 0;
    min-height: 0;
    background: var(--bg-panel-2);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.explorer-pane.hidden {
    display: none;
}

.dock-title {
    padding: 6px 10px;
    border-bottom: 1px solid #1e6cab;
    background: linear-gradient(180deg, #4ba8f4 0%, #2386db 100%);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
}

.drop-banner {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.74rem;
}

.drop-banner.drag-active {
    background: var(--accent-soft);
    color: var(--text);
}

.tree-scroll {
    overflow: auto;
    padding: 3px;
    background: #ffffff;
    min-height: 0;
    height: 100%;
}

.tree-node {
    margin: 0;
}

.tree-children {
    margin-left: 14px;
    padding-left: 6px;
}

.tree-row {
    width: 100%;
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 5px;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 1px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    padding: 0 3px;
}

.tree-row:hover {
    background: var(--bg-tree-hover);
}

.tree-row.selected {
    background: var(--bg-tree-selected);
    border-color: var(--bg-tree-selected-border);
}

.tree-toggle-button,
.tree-toggle-spacer {
    text-align: center;
    font-size: 0.66rem;
}

.tree-toggle-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    height: 16px;
}

.tree-toggle-spacer {
    display: inline-block;
    height: 16px;
}

.tree-main {
    min-width: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.tree-label,
.tree-subtitle,
.tree-tag {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-label {
    font-size: 0.79rem;
    line-height: 1.2;
}

.tree-subtitle {
    display: none;
    color: var(--muted);
    font-size: 0.67rem;
    line-height: 1.1;
}

.tree-tag {
    display: inline-block;
    margin-top: 2px;
    padding: 0 4px;
    border: 1px solid #cfd5de;
    border-radius: 3px;
    background: #f6f8fb;
    color: #596579;
    font-size: 0.63rem;
    line-height: 1.3;
    max-width: fit-content;
}

.tree-row.kind-namespace .tree-label {
    color: var(--tree-namespace);
}

.tree-row.kind-type .tree-label {
    color: var(--tree-type);
}

.tree-row.kind-method .tree-label,
.tree-row.kind-constructor .tree-label {
    color: var(--tree-method);
}

.tree-row.kind-field .tree-label,
.tree-row.kind-property .tree-label,
.tree-row.kind-event .tree-label,
.tree-row.kind-info .tree-label,
.tree-row.kind-assembly .tree-label,
.tree-row.kind-folder .tree-label,
.tree-row.kind-reference .tree-label,
.tree-row.kind-resource .tree-label,
.tree-row.kind-pe .tree-label {
    color: var(--tree-member);
}

.splitter {
    background: linear-gradient(180deg, #d7dce4 0%, #c7ced8 100%);
    border-left: 1px solid #e7ebf0;
    border-right: 1px solid #b6bfca;
    cursor: col-resize;
}

.document-pane {
    display: grid;
    grid-template-rows: auto 28px 1fr;
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--bg-window);
    overflow: hidden;
}

.tabstrip {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    align-content: flex-end;
    gap: 6px;
    padding: 8px 10px 6px;
    overflow-x: auto;
    overflow-y: auto;
    background: linear-gradient(180deg, #f5f6f8 0%, #ebeff4 100%);
    border-bottom: 1px solid var(--border);
    max-height: 7.5rem;
}

.tab {
    min-width: 150px;
    max-width: 320px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    background: var(--bg-tab);
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px 7px;
    min-height: 46px;
}

.tab.active {
    background: var(--bg-tab-active);
    box-shadow: inset 0 1px 0 #ffffff;
}

.tab-main {
    min-width: 0;
}

.tab-title,
.tab-subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-title {
    font-size: 0.84rem;
    font-weight: 600;
}

.tab-subtitle {
    color: var(--muted);
    font-size: 0.7rem;
}

.tab-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

.tab-close:hover {
    background: rgba(35, 134, 219, 0.12);
}

.document-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 8px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fbfcfd 0%, #f0f3f7 100%);
}

.breadcrumbs {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.78rem;
}

.document-status {
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--success);
    font-size: 0.76rem;
}

.document-status.error {
    color: var(--danger);
}

.document-body {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.code-surface {
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--bg-code);
    overflow: hidden;
}

.code-scroll {
    height: 100%;
    overflow: auto;
    min-height: 0;
    outline: none;
}

.code-scroll:focus {
    box-shadow: inset 0 0 0 1px #7aa7e8;
}

.code-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    min-width: max-content;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.55;
}

.property-host {
    min-width: max-content;
}

.loading-view {
    display: grid;
    place-items: center;
    min-height: 100%;
    min-width: 100%;
    background: #ffffff;
}

.loading-card {
    min-width: min(24rem, calc(100vw - 3rem));
    padding: 18px 22px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: linear-gradient(180deg, #fbfcfe 0%, #f3f6fa 100%);
    box-shadow: 0 10px 24px rgba(21, 32, 47, 0.08);
    text-align: center;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.loading-title {
    font-size: 0.96rem;
    font-weight: 600;
}

.loading-text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
}

.loading-bar {
    position: relative;
    margin-top: 14px;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #e4ebf4;
    border: 1px solid #d5dde8;
}

.loading-bar-track {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #f6f9fc 0%, #e8eef6 100%);
}

.loading-bar-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -32%;
    width: 32%;
    border-radius: inherit;
    background: linear-gradient(90deg, #7ec0ff 0%, #2386db 100%);
    box-shadow: 0 0 8px rgba(35, 134, 219, 0.3);
    animation: loading-bar-slide 1.2s ease-in-out infinite;
}

@keyframes loading-bar-slide {
    0% {
        left: -34%;
    }

    100% {
        left: 102%;
    }
}

.hex-view {
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-width: max-content;
    min-height: 100%;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.84rem;
    line-height: 1.5;
    background: #ffffff;
}

.hex-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 8px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fafbfd 0%, #f1f4f8 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.hex-toolbar-title {
    font-size: 0.88rem;
    font-weight: 600;
}

.hex-toolbar-meta {
    color: var(--muted);
    font-size: 0.75rem;
}

.hex-header,
.hex-row {
    display: grid;
    grid-template-columns: 104px auto 172px;
    align-items: center;
}

.hex-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 16px;
    border-bottom: 1px solid var(--border);
    background: #f5f7fa;
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.hex-header-bytes,
.hex-bytes {
    display: grid;
    grid-template-columns: repeat(16, minmax(24px, 24px));
    gap: 4px;
}

.hex-header-ascii,
.hex-ascii {
    display: grid;
    grid-template-columns: repeat(16, minmax(9px, 9px));
    gap: 1px;
    justify-content: start;
}

.hex-body {
    display: grid;
    align-content: start;
}

.hex-row {
    padding: 2px 16px;
    border-bottom: 1px solid #f2f4f7;
}

.hex-row:hover {
    background: #f8fbff;
}

.hex-offset {
    color: #6a7788;
}

.hex-byte,
.hex-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    color: #1f2328;
}

.hex-byte.empty,
.hex-char.empty {
    color: transparent;
}

.hex-empty {
    padding: 18px;
    color: var(--muted);
}

.code-line-number {
    padding: 0 10px 0 16px;
    background: var(--bg-gutter);
    color: #8b949e;
    text-align: right;
    user-select: none;
    border-right: 1px solid #e1e5ea;
    min-width: 52px;
}

.code-line-content {
    padding: 0 18px;
    white-space: pre;
}

.code-empty {
    grid-column: 1 / -1;
    padding: 18px;
    color: var(--muted);
}

.property-view {
    padding: 12px;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    min-width: 540px;
}

.property-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.property-view-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.property-apply-button {
    margin-bottom: 12px;
}

.property-group {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fbfcfe;
}

.property-group-title {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: #f1f5fa;
    font-size: 0.8rem;
    font-weight: 600;
}

.property-grid {
    display: grid;
    grid-template-columns: 180px minmax(280px, 1fr);
    gap: 6px 10px;
    padding: 10px;
}

.property-label {
    color: var(--muted);
    font-size: 0.78rem;
    align-self: center;
}

.property-value {
    border: 1px solid var(--border);
    background: #ffffff;
    border-radius: 3px;
    padding: 6px 8px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.property-input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #ffffff;
    color: var(--text);
    padding: 6px 8px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
}

.property-input:focus {
    outline: none;
    border-color: #7aa7e8;
    box-shadow: 0 0 0 1px rgba(122, 167, 232, 0.28);
}

.tok-keyword { color: var(--keyword); }
.tok-type { color: var(--type); }
.tok-string { color: var(--string); }
.tok-comment { color: var(--comment); }
.tok-number { color: var(--number); }
.tok-preprocessor { color: var(--preprocessor); }
.tok-method { color: var(--method); }
.tok-member { color: var(--member); }

.empty-state {
    padding: 12px 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

.statusbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 10px;
    background: linear-gradient(180deg, #eff2f6 0%, #e2e7ee 100%);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.74rem;
}

.desktop.compact-width {
    grid-template-rows: 28px auto 1fr 22px;
}

.desktop.compact-width .toolbar-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
}

.desktop.compact-width .toolbar-group {
    flex-wrap: wrap;
}

.desktop.compact-width .toolbar-identity {
    min-width: 0;
    text-align: left;
}

.desktop.compact-width .document-toolbar {
    flex-wrap: wrap;
    justify-content: flex-start;
    padding-block: 4px;
}

.desktop.compact-width .document-status {
    max-width: 100%;
}

.desktop.tight-width .workspace {
    grid-template-columns: minmax(160px, var(--explorer-width)) 5px minmax(0, 1fr);
}

.desktop.tight-width .tab {
    min-width: 120px;
    max-width: min(100%, 240px);
    min-height: 40px;
    padding: 6px 8px 5px;
}

.desktop.tight-width .tabstrip {
    gap: 4px;
    padding-inline: 8px;
}

.desktop.tight-width .hex-header,
.desktop.tight-width .hex-row {
    grid-template-columns: 88px auto 148px;
}

.desktop.short-height .tabstrip {
    max-height: 5.5rem;
}

.desktop.short-height .drop-banner {
    display: none;
}

.statusbar-item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-popup,
.context-menu {
    position: fixed;
    z-index: 30;
    display: grid;
    min-width: 180px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(28, 38, 54, 0.18);
    overflow: hidden;
}

.menu-popup {
    top: 0;
    left: 0;
}

.menu-popup-item,
.context-menu-item {
    border: 0;
    background: #ffffff;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
}

.menu-popup-item:hover,
.context-menu-item:hover {
    background: #edf4ff;
}

.hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(19, 30, 44, 0.26);
}

.modal-window {
    width: min(980px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    display: grid;
    grid-template-rows: auto 1fr auto;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(21, 32, 47, 0.24);
    overflow: hidden;
}

.modal-titlebar {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: #f2f6fb;
}

.modal-title {
    font-size: 0.92rem;
    font-weight: 600;
}

.modal-body {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    padding: 12px;
    min-height: 0;
}

.modal-note,
.modal-status {
    font-size: 0.78rem;
    color: var(--muted);
}

.il-editor-shell {
    display: grid;
    grid-template-columns: 52px 1fr;
    min-height: 520px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background: #ffffff;
}

.il-editor-gutter {
    overflow: hidden;
    padding: 10px 8px 10px 0;
    background: #f3f5f7;
    border-right: 1px solid #e1e5ea;
    color: #8b949e;
    text-align: right;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.84rem;
    line-height: 1.5;
    user-select: none;
}

.il-editor-text {
    width: 100%;
    min-height: 520px;
    resize: none;
    border: 1px solid var(--border);
    border: 0;
    padding: 10px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.84rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

@media (max-width: 1100px) {
    .toolbar-row {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .toolbar-identity {
        text-align: left;
    }
}

@media (max-width: 800px) {
    body {
        overflow: auto;
    }

    .desktop {
        height: auto;
        min-height: 100vh;
        grid-template-rows: auto auto auto auto;
    }

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

    .splitter {
        display: none;
    }

    .explorer-pane {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        min-height: 320px;
    }

    .document-pane {
        min-height: 520px;
    }
}
