body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

html {
    height: -webkit-fill-available;
}

main {
    display: flex;
    flex-wrap: nowrap;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
}

#view {
    font-size: var(--tree-font-size, 0.9rem);
}

.sidebar {
    width: 240px;
    max-height: 100vh;
    overflow-y: auto;
    font-size: 0.9rem;
}

#property-editor-modal .property-editor-dialog {
    max-width: none;
    width: min(900px, 75vw);
    min-width: 420px;
    min-height: 40vh;
    max-height: 90vh;
    overflow: visible;
}

#property-editor-modal {
    font-size: 0.9rem;
}

#property-editor-modal .property-editor-dialog .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 40vh;
    overflow: hidden;
}

.property-editor-body {
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: clamp(280px, 40vh, 600px);
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.property-editor-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.property-editor-key-display {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    text-decoration: none;
    line-height: 1.2;
}

.property-editor-key-display.property-editor-key-clickable {
    cursor: pointer;
    text-decoration: underline;
}

.append-data-count {
    font-weight: 600;
    color: #0f172a;
}

body.theme-dark .append-data-count {
    color: #e2e8f0;
}

.append-data-error {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
}

.append-data-status {
    margin-top: 0.5rem;
    padding: 0.25rem 0.1rem;
}

.append-data-status.append-data-status-warning {
    color: #b91c1c;
    font-weight: 600;
}

.append-data-force {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0;
}

#append-data-text {
    font-size: 0.8rem;
}

body.theme-dark .append-data-status.append-data-status-warning {
    color: #fecaca;
}

.property-editor-key-edit {
    flex: 1 1 220px;
    max-width: 460px;
}

.property-editor-key-error {
    margin-top: -0.4rem;
}

.property-editor-input {
    flex: 1;
    min-height: 240px;
    font-size: var(--editor-font-size, 0.9rem);
    font-family: inherit;
    line-height: 1.5;
    padding: 0.375rem 0.75rem;
    box-sizing: border-box;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    tab-size: 4;
    -moz-tab-size: 4;
    resize: none;
    width: 100%;
    height: 100%;
    display: block;
    letter-spacing: normal;
    word-spacing: normal;
    font-variant-ligatures: none;
}

.property-editor-input-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: 100%;
    background-color: var(--bs-body-bg, #fff);
    border-radius: 0.375rem;
    font-family: var(--bs-font-monospace, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
    font-size: var(--editor-font-size, 0.9rem);
}

body.theme-dark .property-editor-input-wrapper {
    background-color: #0b1220;
}

.property-editor-highlight {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0.375rem 0.75rem;
    overflow: auto;
    pointer-events: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    box-sizing: border-box;
    tab-size: 4;
    -moz-tab-size: 4;
    letter-spacing: normal;
    word-spacing: normal;
    font-variant-ligatures: none;
    z-index: 1;
}

.property-editor-highlight code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: transparent;
    padding: 0;
    margin: 0;
    display: block;
    white-space: inherit;
}

.property-editor-input-wrapper.syntax-enabled .property-editor-input {
    /* Avoid fully transparent text in the textarea: some engines (notably macOS WebKit/WKWebView)
       can glitch caret placement at line ends when the text is fully transparent.
       Use an almost-transparent tokenized color instead so the caret/selection model stays stable. */
    color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.02);
    caret-color: var(--bs-body-color, #212529);
    -webkit-text-fill-color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.02);
    background-color: transparent;
    position: relative;
    z-index: 2;
}

body.theme-dark .property-editor-input-wrapper.syntax-enabled .property-editor-input {
    caret-color: #f8fafc;
}

.property-editor-input-wrapper.syntax-enabled .property-editor-highlight {
    display: block;
}

.property-editor-input-wrapper:not(.syntax-enabled) .property-editor-highlight {
    display: none;
}

.property-editor-highlight,
.property-editor-highlight code,
.property-editor-highlight .hljs {
    text-shadow: none !important;
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
}

.property-editor-highlight .hljs {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent;
}

body.theme-dark .property-editor-highlight .hljs {
    background: transparent;
    color: #e2e8f0;
}

body.theme-dark .property-editor-highlight .hljs-comment,
body.theme-dark .property-editor-highlight .hljs-quote {
    color: #94a3b8;
}

body.theme-dark .property-editor-highlight .hljs-keyword,
body.theme-dark .property-editor-highlight .hljs-selector-tag,
body.theme-dark .property-editor-highlight .hljs-literal,
body.theme-dark .property-editor-highlight .hljs-name,
body.theme-dark .property-editor-highlight .hljs-built_in {
    color: #a78bfa;
}

body.theme-dark .property-editor-highlight .hljs-string,
body.theme-dark .property-editor-highlight .hljs-title,
body.theme-dark .property-editor-highlight .hljs-section,
body.theme-dark .property-editor-highlight .hljs-attr,
body.theme-dark .property-editor-highlight .hljs-attribute {
    color: #6ee7b7;
}

body.theme-dark .property-editor-highlight .hljs-number,
body.theme-dark .property-editor-highlight .hljs-type,
body.theme-dark .property-editor-highlight .hljs-symbol,
body.theme-dark .property-editor-highlight .hljs-bullet {
    color: #fbbf24;
}

body.theme-dark .property-editor-highlight .hljs-function,
body.theme-dark .property-editor-highlight .hljs-class,
body.theme-dark .property-editor-highlight .hljs-title.class_ {
    color: #f97316;
}

.property-editor-footer {
    padding-right: 1.5rem;
    padding-bottom: 1.5rem;
}

.property-editor-resize-handle {
    position: absolute;
    right: 0.35rem;
    bottom: 0.35rem;
    width: 18px;
    height: 18px;
    border-radius: 0.3rem;
    border: 1px solid rgba(108, 117, 125, 0.8);
    background: rgba(248, 249, 250, 0.95);
    cursor: nwse-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
    z-index: 5;
}

.property-editor-resize-handle::before {
    content: "";
    width: 80%;
    height: 80%;
    border-right: 2px solid rgba(108, 117, 125, 0.9);
    border-bottom: 2px solid rgba(108, 117, 125, 0.9);
}

.property-editor-resize-handle:hover {
    background: #fff;
    border-color: rgba(73, 80, 87, 0.95);
}

body.property-editor-resizing {
    cursor: nwse-resize;
    user-select: none;
}

body.property-editor-resizing * {
    user-select: none;
}

.kv-button-group {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.bulk-checkbox-wrapper {
    display: none;
    align-items: center;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

body.bulk-mode-enabled .bulk-checkbox-wrapper {
    display: flex;
}

.bulk-checkbox-wrapper .form-check-input {
    margin: 0;
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.btn-text-small {
    font-size: 0.8rem;
}

.btn-wrap {
    white-space: normal;
    line-height: 1.1;
}

.search-property-options {
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: #fff;
}

.search-property-summary {
    text-decoration: underline;
    font-weight: 600;
}

.search-property-rules {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-property-rule {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.85fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.search-property-rule .form-control {
    min-width: 0;
}

.search-property-rule-remove {
    border: none;
    background: transparent;
    color: #dc3545;
    font-weight: 700;
    padding: 0 0.25rem;
}

body.theme-dark .search-property-rule-remove {
    color: #f87171;
}

.search-property-options:empty {
    display: none;
}

.search-property-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.25rem;
}

.search-property-option:last-child {
    margin-bottom: 0;
}

body.theme-dark .search-property-options {
    background: #0f1115;
    border-color: #334155;
}

.btn-icon {
    font-size: 1rem;
    line-height: 1.2;
}

.btn-icon.btn-icon-large {
    font-size: 1.25rem;
}

.settings-button {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.settings-glyph {
    font-size: 1.35rem;
    line-height: 1;
}

.toggle-button {
    padding: 0;
    text-align: center;
    vertical-align: middle;
    width: 1.75rem;
    height: 1.75rem;
    align-self: flex-start;
    flex-shrink: 0;
}

.bulk-selection-actions {
    display: flex;
    gap: 0.5rem;
}

.bulk-selection-button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bulk-action-buttons {
    display: flex;
    gap: 0.5rem;
}

.bulk-action-button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.kv.search-current {
    background-color: #fff3cd;
    border-radius: 0.25rem;
    padding: 0.1rem 0.25rem;
}

.match-highlight {
    background-color: #cfe2ff;
    border-radius: 0.15rem;
    padding: 0 0.15rem;
}

.top-level-focus {
    background-color: #ffe5a1 !important;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.6);
    border-radius: 0.25rem;
    transition: background-color 0.2s ease-out;
}

.top-level-focus-root {
    background-color: rgba(255, 229, 161, 0.4);
    border-radius: 0.5rem;
}

body.theme-dark {
    background-color: #0f1115;
    color: #f8fafc;
}

body.theme-dark main {
    background-color: #0f1115;
}

body.theme-dark #view {
    background-color: #0f1115;
    color: #f8fafc;
}

body.theme-dark .sidebar {
    background-color: #1b1f27 !important;
    color: #e2e8f0;
}

body.theme-dark .form-text {
    color: #ccd5ff;
}

body.theme-dark .sidebar hr {
    border-color: rgba(148, 163, 184, 0.35);
}

body.theme-dark .sidebar .form-label,
body.theme-dark .sidebar .form-check-label,
body.theme-dark .sidebar label {
    color: #e2e8f0;
}

body.theme-dark .sidebar .form-text,
body.theme-dark .text-muted {
    color: #94a3b8 !important;
}

body.theme-dark a.link-dark {
    color: #e2e8f0 !important;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark textarea {
    background-color: #111827;
    border-color: #374151;
    color: #f8fafc;
}

body.theme-dark .form-control::placeholder,
body.theme-dark textarea::placeholder {
    color: #94a3b8;
}

body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus,
body.theme-dark textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 0.15rem rgba(99, 102, 241, 0.25);
    color: #f8fafc;
}

body.theme-dark .form-check-input {
    background-color: #0f172a;
    border-color: #475569;
}

body.theme-dark .form-check-input:checked {
    background-color: #38bdf8;
    border-color: #38bdf8;
}

body.theme-dark .btn-light {
    background-color: #475569;
    border-color: #475569;
    color: #f8fafc;
}

body.theme-dark .btn-light:hover {
    background-color: #53607a;
    border-color: #53607a;
}

body.theme-dark .btn-outline-secondary,
body.theme-dark .btn-outline-primary,
body.theme-dark .btn-outline-success {
    color: #e2e8f0;
    border-color: #475569;
}

body.theme-dark .btn-outline-secondary:hover,
body.theme-dark .btn-outline-primary:hover,
body.theme-dark .btn-outline-success:hover {
    background-color: #1f2937;
    color: #f8fafc;
}

body.theme-dark .kv.search-current {
    background-color: #3b2d13;
}

body.theme-dark .match-highlight {
    background-color: #1d4ed8;
    color: #f8fafc;
}

body.theme-dark .top-level-focus {
    background-color: #3d2a0a !important;
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.4);
}

body.theme-dark .top-level-focus-root {
    background-color: rgba(250, 204, 21, 0.15);
}

body.theme-dark .modal-content {
    background-color: #111827;
    color: #f8fafc;
    border-color: #1f2937;
}

body.theme-dark .modal-header,
body.theme-dark .modal-footer {
    border-color: #1f2937;
}

body.theme-dark .modal-title {
    color: #f8fafc;
}

body.theme-dark .modal-body .text-muted,
body.theme-dark .modal-body label {
    color: #94a3b8 !important;
}

body.theme-dark .property-editor-resize-handle {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(148, 163, 184, 0.8);
    box-shadow: 0 2px 6px rgba(15, 17, 21, 0.7);
}

body.theme-dark .property-editor-resize-handle::before {
    border-right-color: #e2e8f0;
    border-bottom-color: #e2e8f0;
}