:root {
    --bg: #ffffff;
    --bg-subtle: #f6f8fa;
    --bg-inset: #eaeef2;
    --border: #d0d7de;
    --border-muted: #d8dee4;
    --fg: #1f2328;
    --fg-muted: #656d76;
    --accent: #0969da;
    --success: #1f883d;
    --success-hover: #1a7f37;
    --danger: #cf222e;
    --danger-bg: rgba(207, 34, 46, 0.5);
    --success-bg: rgba(31, 136, 61, 0.5);
    --btn-bg: #f6f8fa;
    --btn-hover: #eef1f4;
    --btn-border: rgba(31, 35, 40, 0.15);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --bg-subtle: #161b22;
        --bg-inset: #010409;
        --border: #30363d;
        --border-muted: #21262d;
        --fg: #e6edf3;
        --fg-muted: #7d8590;
        --accent: #2f81f7;
        --success: #238636;
        --success-hover: #2ea043;
        --danger: #f85149;
        --danger-bg: rgba(248, 81, 73, 0.5);
        --success-bg: rgba(46, 160, 67, 0.5);
        --btn-bg: #21262d;
        --btn-hover: #30363d;
        --btn-border: rgba(240, 246, 252, 0.1);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 14px;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

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

.brand {
    font-weight: 600;
    font-size: 14px;
    color: var(--fg);
}

.repo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    opacity: 0.45;
    transition: opacity 0.15s, background 0.15s;
}

.repo-link:hover {
    opacity: 0.9;
    background: var(--btn-hover);
}

.repo-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    opacity: 0.9;
}

.repo-link-icon {
    display: block;
    width: 18px;
    height: 18px;
}

.help-link {
    text-decoration: none;
}

.help-link-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    line-height: 18px;
}

.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 105, 218, 0.08);
    border: 3px dashed var(--accent);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drop-overlay.active { display: flex; }

.drop-overlay-inner {
    background: var(--bg);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 16px 24px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.btn {
    padding: 5px 16px;
    font-size: 14px;
    font-family: var(--sans);
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--fg);
    cursor: pointer;
    transition: background 0.15s;
    line-height: 20px;
}

.btn:hover { background: var(--btn-hover); }

.btn-primary {
    background: var(--success);
    color: #ffffff;
    border-color: rgba(31, 35, 40, 0.15);
}

.btn-primary:hover { background: var(--success-hover); }

.main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pane-left { border-right: 1px solid var(--border); }

.pane-header {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.editor-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
    background: var(--bg);
}

.highlight,
#editor {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 12px;
    border: 0;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 20px;
    white-space: pre;
    overflow: auto;
    tab-size: 4;
}

.highlight {
    pointer-events: none;
    color: transparent;
    background: transparent;
    z-index: 1;
}

.highlight > div {
    min-height: 20px;
}

.highlight .line-bad { background: var(--danger-bg); }
.highlight .line-good { background: var(--success-bg); }

#editor {
    z-index: 2;
    background: transparent;
    color: var(--fg);
    resize: none;
    outline: none;
    caret-color: var(--fg);
}

#editor:focus { outline: none; }

#jsonView {
    flex: 1;
    margin: 0;
    padding: 12px;
    border: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 20px;
    white-space: pre;
    resize: none;
    outline: none;
    min-height: 0;
}

.bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-subtle);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.status {
    font-size: 12px;
    color: var(--fg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.bottombar-actions {
    display: flex;
    gap: 10px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
}

.modal.active { display: block; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-dialog {
    position: relative;
    margin: 6vh auto;
    max-width: 760px;
    max-height: 85vh;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    flex-shrink: 0;
}

.modal-title {
    font-weight: 600;
    font-size: 14px;
}

.modal-close {
    padding: 0 10px;
    font-size: 20px;
    line-height: 24px;
}

.service-grid {
    padding: 16px;
    overflow: auto;
}

.service-section + .service-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.service-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.service-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.service-loading,
.service-empty {
    padding: 24px;
    color: var(--fg-muted);
    text-align: center;
    grid-column: 1 / -1;
}

.service-card {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-subtle);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: var(--sans);
    color: var(--fg);
}

.service-card:hover {
    border-color: var(--accent);
    background: var(--bg-inset);
}

.service-card-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.service-card-desc {
    font-size: 12px;
    color: var(--fg-muted);
    line-height: 1.4;
}
