﻿:root {
    --background: oklch(0.9818 0.0054 95.0986);
    --foreground: oklch(0.3438 0.0269 95.7226);
    --card: oklch(0.9818 0.0054 95.0986);
    --popover: oklch(1 0 0);
    --primary: #65a30d;
    --primary-foreground: oklch(0.22 0.03 130);
    --secondary: oklch(0.9245 0.0138 92.9892);
    --muted: oklch(0.9341 0.0153 90.239);
    --muted-foreground: oklch(0.6059 0.0075 97.4233);
    --accent: oklch(0.9245 0.0138 92.9892);
    --destructive: #e54d2e;
    --border: oklch(0.8847 0.0069 97.3627);
    --input: oklch(0.7621 0.0156 98.3528);
    --ring: #65a30d;
    --ok: #65a30d;
    /* Not derived from --destructive: some palettes use the same destructive
       shade for both light and dark, which would make error text a fixed
       color regardless of theme. */
    --sev-error: #e54d2e;
    --sidebar: oklch(0.9663 0.008 98.8792);
    --sh-keyword: oklch(0.52 0.13 45);
    --sh-string: oklch(0.52 0.09 115);
    --sh-number: oklch(0.58 0.12 70);
    --sh-property: oklch(0.5 0.07 215);
    --sh-function: oklch(0.55 0.11 90);
    --sh-constant: oklch(0.52 0.11 20);
    --sh-variable: oklch(0.4 0.035 60);
    --sh-comment: oklch(0.6 0.025 70);
    --sh-regexp: oklch(0.53 0.16 28);
    --sh-operator: oklch(0.52 0.03 60);
    --font-sans: "Geist Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius: 8px;
    color-scheme: light;
}

:root[data-theme='dark'] {
    --background: oklch(0.2679 0.0036 106.6427);
    --foreground: oklch(0.8074 0.0142 93.0137);
    --card: oklch(0.2679 0.0036 106.6427);
    --popover: oklch(0.3085 0.0035 106.6039);
    --primary: #81ca14;
    --primary-foreground: oklch(0.22 0.03 130);
    --secondary: oklch(0.213 0.0078 95.4245);
    --muted: oklch(0.2213 0.0038 106.707);
    --muted-foreground: oklch(0.7713 0.0169 99.0657);
    --accent: oklch(0.213 0.0078 95.4245);
    --destructive: oklch(0.6368 0.2078 25.3313);
    --border: oklch(0.3618 0.0101 106.8928);
    --input: oklch(0.4336 0.0113 100.2195);
    --ring: #81ca14;
    --ok: #81ca14;
    --sev-error: oklch(0.6368 0.2078 25.3313);
    --sidebar: oklch(0.2357 0.0024 67.7077);
    --sh-keyword: oklch(0.75 0.11 50);
    --sh-string: oklch(0.75 0.09 115);
    --sh-number: oklch(0.8 0.11 75);
    --sh-property: oklch(0.74 0.07 215);
    --sh-function: oklch(0.78 0.1 95);
    --sh-constant: oklch(0.74 0.1 25);
    --sh-variable: oklch(0.82 0.02 70);
    --sh-comment: oklch(0.55 0.02 70);
    --sh-regexp: oklch(0.72 0.14 30);
    --sh-operator: oklch(0.62 0.02 70);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 14px;
}

a {
    color: var(--primary);
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

.loading-shell {
    padding: 1rem;
}

.topbar,
.toolbar {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--sidebar);
}

.topbar {
    justify-content: space-between;
}

.toolbar {
    min-height: 46px;
    justify-content: space-between;
    background: var(--background);
}

.brand,
.topbar-actions,
.toolbar-group,
.split-button,
.rule-item-header,
.tag-list,
.input-row,
.toast-card header,
.modal-footer {
    display: flex;
    align-items: center;
}

.brand {
    min-width: 0;
    gap: 10px;
    color: var(--foreground);
    font-weight: 600;
    text-decoration: none;
}

.brand-logo {
    width: 28px;
    height: 28px;
    flex: none;
    color: var(--primary);
}

.topbar-actions,
.toolbar-group,
.modal-footer {
    gap: 6px;
}

.nav-action,
.button,
.icon-button,
.menu-item,
.choice {
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-foreground);
    font: inherit;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.nav-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 9px;
}

.nav-action:hover,
.icon-button:hover,
.menu-item:hover,
.choice:hover {
    background: var(--accent);
    color: var(--foreground);
}

.nav-action.disabled,
.button:disabled,
.icon-button:disabled {
    pointer-events: none;
    opacity: 0.45;
}

.icon-only {
    width: 32px;
    justify-content: center;
    padding: 0;
}

.icon-button {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    cursor: pointer;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 11px;
    cursor: pointer;
    font-weight: 500;
}

.button-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
}

.button-secondary {
    border-color: var(--border);
    background: var(--secondary);
    color: var(--foreground);
}

.button-toolbar {
    min-height: 34px;
    border-color: color-mix(in oklab, var(--border) 78%, var(--foreground));
    background: color-mix(in oklab, var(--muted) 82%, var(--foreground) 8%);
    color: var(--foreground);
    box-shadow: inset 0 1px 0 color-mix(in oklab, white 10%, transparent);
}

.button-toolbar:hover {
    border-color: color-mix(in oklab, var(--border) 72%, var(--foreground));
    background: color-mix(in oklab, var(--accent) 86%, var(--foreground) 6%);
}

.button-toolbar:focus-visible {
    outline: 2px solid color-mix(in oklab, var(--ring) 38%, transparent);
    outline-offset: 2px;
}

.button-split {
    min-width: 30px;
    padding: 0 8px;
    border-left-color: color-mix(in oklab, var(--border) 72%, var(--foreground) 12%);
}

.split-button {
    position: relative;
}

.split-button .button-toolbar:first-child {
    border-radius: 7px 0 0 7px;
}

.split-button .button-toolbar:last-of-type {
    border-radius: 0 7px 7px 0;
    margin-left: -1px;
}

.menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 30;
    min-width: 170px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--popover);
    box-shadow: 0 12px 32px rgb(0 0 0 / 16%);
}

.menu-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    cursor: pointer;
    text-align: left;
}

.menu-item.active {
    background: var(--accent);
    color: var(--foreground);
}

.modal-backdrop,
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgb(0 0 0 / 34%);
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-shell-wide .modal-card {
    width: min(920px, 100%);
}

.modal-card,
.sheet,
.toast-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--popover);
    box-shadow: 0 18px 48px rgb(0 0 0 / 22%);
}

.modal-card {
    width: min(560px, 100%);
    max-height: min(760px, 90vh);
    overflow: hidden;
}

.modal-header,
.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
}

.modal-header h2,
.sheet-header h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.modal-header p,
.sheet-header p {
    margin: 2px 0 0;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

.modal-body {
    max-height: calc(90vh - 116px);
    overflow: auto;
    padding: 14px;
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding: 10px 14px;
}

.prose {
    line-height: 1.55;
}

.prose h3 {
    margin: 1.1rem 0 0.4rem;
    font-size: 0.9rem;
}

.prose p,
.prose ul {
    margin: 0 0 0.85rem;
}

.sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: min(380px, 100%);
    border-radius: 0;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    overflow-y: auto;
}

.sheet-section {
    padding: 16px;
}

.sheet-section h3 {
    margin: 0 0 10px;
    color: var(--muted-foreground);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.segmented {
    display: inline-flex;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--muted);
    padding: 2px;
}

.segmented.compact {
    flex: none;
}

.segment {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font: inherit;
    padding: 0 9px;
}

.segment.active {
    background: var(--background);
    color: var(--foreground);
    box-shadow: 0 1px 2px rgb(0 0 0 / 10%);
}

.mono {
    font-family: var(--font-mono);
}

.choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px;
    border-color: var(--border);
    cursor: pointer;
    text-align: left;
}

.choice.active {
    border-color: var(--primary);
    background: color-mix(in oklch, var(--primary), transparent 88%);
    color: var(--foreground);
}

.choice strong,
.choice small {
    display: block;
}

.choice small,
.field-description,
.muted {
    color: var(--muted-foreground);
}

.palette-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    padding: 10px;
}

.palette-preview-header,
.palette-choice,
.setting-row {
    display: flex;
    align-items: center;
}

.palette-preview-header {
    gap: 8px;
}

.palette-preview-header small {
    margin-left: auto;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    text-transform: uppercase;
}

.swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.preview-token {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.preview-token div {
    height: 28px;
}

.preview-token span {
    display: block;
    overflow: hidden;
    padding: 4px 6px;
    color: var(--muted-foreground);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.palette-list {
    display: flex;
    max-height: 320px;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding-right: 3px;
}

.palette-choice {
    width: 100%;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    font: inherit;
    padding: 8px 10px;
    text-align: left;
}

.palette-choice:hover {
    background: var(--muted);
}

.palette-choice.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.palette-choice strong,
.palette-choice small,
.setting-row strong,
.setting-row small {
    display: block;
}

.palette-choice small,
.setting-row small {
    color: var(--muted-foreground);
    font-size: 0.72rem;
}

.setting-row {
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
}

.setting-row+.setting-row {
    border-top: 1px solid var(--border);
}

.setting-button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.switch {
    display: inline-flex;
    width: 34px;
    height: 20px;
    flex: none;
    align-items: center;
    border-radius: 999px;
    background: var(--input);
    padding: 2px;
    transition: background 120ms ease;
}

.switch span {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--background);
    transition: transform 120ms ease;
}

.switch.active {
    background: var(--primary);
}

.switch.active span {
    transform: translateX(14px);
}

.input-control {
    width: 100%;
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font: inherit;
    outline: none;
    padding: 6px 9px;
}

.input-control:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px color-mix(in oklch, var(--ring), transparent 75%);
}

.input-row {
    align-items: stretch;
}

.input-row span {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 6px 0 0 6px;
    background: var(--muted);
    padding: 0 10px;
    color: var(--muted-foreground);
    white-space: nowrap;
}

.input-row .input-control {
    border-radius: 0 6px 6px 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 14px;
}

.field label {
    font-weight: 500;
}

.field-description {
    font-size: 0.75rem;
}

.alert-panel {
    margin-top: 10px;
    border: 1px solid color-mix(in oklch, var(--destructive), transparent 55%);
    border-radius: 6px;
    background: color-mix(in oklch, var(--destructive), transparent 90%);
    padding: 10px;
}

.library-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.library-card {
    max-height: min(760px, 90vh);
}

.rule-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.rule-item {
    display: block;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    text-decoration: none;
}

.rule-item:last-child {
    border-bottom: 0;
}

.rule-item:hover {
    background: var(--muted);
}

.rule-item h3 {
    margin: 0;
    font-size: 0.94rem;
}

.rule-item p {
    margin: 6px 0;
    color: var(--muted-foreground);
}

.rule-item-header {
    justify-content: space-between;
    gap: 12px;
}

.badge,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.72rem;
    line-height: 1;
    padding: 4px 7px;
}

.tag-list {
    flex-wrap: wrap;
    gap: 5px;
    color: var(--muted-foreground);
    font-size: 0.76rem;
}

.toast-container {
    position: fixed;
    top: 14px;
    left: 50%;
    z-index: 70;
    width: min(520px, calc(100vw - 28px));
    transform: translateX(-50%);
}

.toast-card {
    overflow: hidden;
}

.toast-card header {
    gap: 10px;
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
}

.toast-card strong {
    flex: 1;
}

.toast-body {
    padding: 10px;
}

.toast-body pre {
    max-height: 340px;
    margin: 0;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.76rem;
}

.table-wrap {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table caption {
    caption-side: bottom;
    padding-top: 8px;
    text-align: left;
}

.data-table th,
.data-table td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
}

.data-table th {
    background: var(--muted);
    font-weight: 600;
}

.maintenance {
    display: grid;
    min-height: 100vh;
    place-items: center;
    text-align: center;
}

.maintenance h1 {
    margin: 0;
    font-size: 4rem;
}

.maintenance h2 {
    margin: 0.5rem 0;
}

.maintenance p {
    color: var(--muted-foreground);
}

.spinner {
    display: grid;
    place-items: center;
    padding: 16px;
}

.spinner::before {
    width: 24px;
    height: 24px;
    content: '';
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: spin 800ms linear infinite;
}

.spinner span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

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

.CodeMirror,
.cm-s-studio.CodeMirror {
    background: var(--background) !important;
    color: var(--foreground);
    font-family: var(--font-mono);
    font-size: var(--editor-font-size, 13px);
}

.CodeMirror-gutters,
.cm-s-studio .CodeMirror-gutters {
    border-right: 1px solid var(--border) !important;
    background: color-mix(in oklab, var(--background) 94%, var(--muted)) !important;
}

.cm-s-studio .CodeMirror-sizer {
    border-left-color: transparent !important;
}

.cm-s-studio .CodeMirror-gutter {
    background: transparent !important;
}

.CodeMirror-linenumber,
.cm-s-studio .CodeMirror-linenumber {
    color: var(--muted-foreground) !important;
    opacity: 0.82;
    padding-right: 0.65rem;
}

.cm-s-studio .CodeMirror-lines {
    padding: 10px 0;
}

.cm-s-studio .CodeMirror-cursor {
    border-left-color: var(--foreground);
}

.cm-s-studio.CodeMirror-focused .CodeMirror-selected,
.cm-s-studio .CodeMirror-selected {
    background: color-mix(in oklab, var(--primary) 25%, transparent);
}

.cm-s-studio .CodeMirror-activeline-background {
    background: color-mix(in oklab, var(--muted) 40%, transparent);
}

.cm-s-studio .cm-comment {
    color: var(--sh-comment);
    font-style: italic;
}

.cm-s-studio .cm-keyword {
    color: var(--sh-keyword);
    font-weight: 500;
}

.cm-s-studio .cm-string,
.cm-s-studio .cm-string-2,
.cm-s-studio .cm-quote {
    color: var(--sh-string);
}

.cm-s-studio .cm-number {
    color: var(--sh-number);
}

.cm-s-studio .cm-atom,
.cm-s-studio .cm-builtin,
.cm-s-studio .cm-qualifier {
    color: var(--sh-constant);
}

.cm-s-studio .cm-property,
.cm-s-studio .cm-attribute,
.cm-s-studio .cm-tag {
    color: var(--sh-property);
}

.cm-s-studio .cm-def,
.cm-s-studio .cm-variable-2,
.cm-s-studio .cm-variable-3 {
    color: var(--sh-function);
    font-weight: 500;
}

.cm-s-studio .cm-variable {
    color: var(--sh-variable);
}

.cm-s-studio .cm-operator,
.cm-s-studio .cm-punctuation,
.cm-s-studio .cm-bracket {
    color: var(--sh-operator);
}

.cm-s-studio .cm-link {
    color: var(--sh-property);
    text-decoration: underline;
}

.cm-s-studio .cm-header {
    color: var(--sh-keyword);
    font-weight: 600;
}

.cm-s-studio .cm-hr {
    color: var(--sh-operator);
}

@media (max-width: 640px) {
    .nav-action span {
        display: none;
    }

    .input-row {
        flex-direction: column;
    }

    .input-row span,
    .input-row .input-control {
        border: 1px solid var(--border);
        border-radius: 6px;
    }
}

.nlp-token {
    background: rgba(67, 198, 252, 0.75);
    padding: 0.2em 0.3em;
    margin: 0 0.25em;
    line-height: 1;
    display: inline-block;
    border-radius: 0.25em;
}

[data-entity] {
    padding: 0.2em 0.3em;
    margin: 0.25em;
    line-height: 1;
    display: inline-block;
    border-radius: 0.25em;
}

[data-entity]:after {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    content: attr(data-entity);
    font-size: 0.8em;
    line-height: 1;
    padding: 0.35em 0.35em;
    border-radius: 0.35em;
    text-transform: uppercase;
    display: inline-block;
    vertical-align: middle;
    margin: 0 0 0.15rem 0.5rem;
    color: #212529;
    background: #fff;
    font-weight: bold;
}

.old-bv {
    font-size: 14px;
}

.CodeMirror-lint-tooltip {
    background-color: rgba(52, 58, 64, 0.95);
    border: 1px solid #343a40;
    border-radius: 4px 4px 4px 4px;
    color: white;
    font-family: monospace;
    font-size: 10pt;
    overflow: hidden;
    padding: 2px 5px;
    position: fixed;
    white-space: pre;
    white-space: pre-wrap;
    z-index: 100;
    max-width: 600px;
    opacity: 0;
    transition: opacity 0.4s;
    -moz-transition: opacity 0.4s;
    -webkit-transition: opacity 0.4s;
    -o-transition: opacity 0.4s;
    -ms-transition: opacity 0.4s;
}


/*
.CodeMirror-lint-mark-error {
    color: rgba(244, 77, 97, 0.8);
}

.CodeMirror-lint-mark-warning {
    color: rgba(255, 227, 159, 0.8);
}

.CodeMirror-lint-mark-info {
    color: rgba(91, 192, 222, 0.8);
}*/


.CodeMirror-lint-mark-error,
.CodeMirror-lint-mark-warning,
.CodeMirror-lint-mark-info {
    background-image: none;
    background-position: no-repeat;
    background-repeat: no-repeat;
}

.CodeMirror-lint-mark-error,
.CodeMirror-lint-mark-warning,
.CodeMirror-lint-mark-info {
    background: rgba(244, 77, 97, 0.8) !important;
}

/*
.CodeMirror-lint-mark-warning {
    background: rgba(255, 197, 92, 0.8) !important;
}

.CodeMirror-lint-mark-info {
    background: rgba(91, 192, 222, 0.8) !important;
}