* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f6f7f3;
    color: #1f2933;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: #25636f;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

button,
input,
select {
    font: inherit;
}

code,
pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
}

.site-header {
    background: #ffffff;
    border-bottom: 1px solid #d8ded7;
}

.site-header__inner,
.page {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
}

.site-header__inner {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    color: #17222b;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.site-nav a,
.button,
.preset-btn,
.profile-btn {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid #c6cec7;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2933;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.site-nav a:hover,
.button:hover,
.preset-btn:hover,
.profile-btn:hover {
    background: #eef2ed;
}

.site-nav a[aria-current="page"],
.preset-btn.active,
.profile-btn.active {
    background: #2f6f58;
    border-color: #2f6f58;
    color: #ffffff;
}

.page {
    padding: 32px 0 44px;
}

.action-row,
.nav-row,
.btn-row,
.profile-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.action-row {
    margin-top: 20px;
}

.button--primary {
    background: #2f6f58;
    border-color: #2f6f58;
    color: #ffffff;
}

.button--primary:hover {
    background: #285e4b;
}

.doc-block {
    max-width: 920px;
    padding: 18px 0;
    border-top: 1px solid #d8ded7;
}

.doc-block--lead {
    padding-top: 10px;
    border-top: 0;
}

.doc-block h1,
.doc-block h2 {
    margin: 0 0 10px;
    color: #17222b;
    letter-spacing: 0;
}

.doc-block h1 {
    font-size: 28px;
    line-height: 1.15;
}

.doc-block h2 {
    font-size: 17px;
}

.doc-block p {
    margin: 0;
    max-width: 780px;
    color: #46535f;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    border-top: 1px solid #d8ded7;
    background: #ffffff;
}

.doc-table th,
.doc-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #d8ded7;
    text-align: left;
    vertical-align: top;
}

.doc-table th {
    width: 280px;
    color: #17222b;
    font-size: 13px;
    font-weight: 700;
}

.doc-table td {
    color: #46535f;
}

.doc-table code,
.doc-block code {
    color: #24313d;
    font-size: 12px;
}

.code-block {
    margin: 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid #d8ded7;
    border-radius: 6px;
    background: #ffffff;
    color: #24313d;
    font-size: 12px;
    line-height: 1.55;
}

.doc-note {
    margin-top: 8px !important;
    font-size: 13px;
}

.request-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.request-card {
    min-width: 0;
    padding: 12px;
    border: 1px solid #d8ded7;
    border-radius: 8px;
    background: #ffffff;
}

.request-card h3 {
    margin: 0 0 6px;
    color: #17222b;
    font-size: 14px;
}

.request-card p {
    min-height: 58px;
    margin: 0 0 10px;
    color: #52616e;
    font-size: 13px;
}

.request-output {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.request-output__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    color: #17222b;
}

#request-status {
    color: #52616e;
    font-size: 12px;
}

.app-body {
    height: 100vh;
    overflow: hidden;
    background: #17222b;
}

#map {
    position: absolute;
    inset: 0;
}

#panel {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: min(336px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 14px;
    border: 1px solid rgba(31, 41, 51, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 40px rgba(23, 34, 43, 0.22);
    font-size: 13px;
}

.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.panel-title h1,
.panel h1 {
    margin: 0;
    color: #17222b;
    font-size: 17px;
    line-height: 1.2;
}

.panel-kicker {
    margin: 3px 0 0;
    color: #667480;
    font-size: 12px;
}

#info {
    color: #46535f;
    margin-bottom: 8px;
}

#route-info {
    min-height: 20px;
    margin-top: 6px;
    color: #17222b;
    font-weight: 700;
}

#link-msg {
    color: #2f6f58;
    font-size: 12px;
    margin-top: 4px;
}

.preset-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dde3dc;
}

.params,
.controls {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dde3dc;
}

.params-hint,
.bucket-hint {
    color: #667480;
    font-size: 11px;
}

.params-hint {
    margin-bottom: 10px;
}

.param-group {
    margin-bottom: 12px;
}

.param-group + .param-group {
    padding-top: 10px;
    border-top: 1px solid #edf0ec;
}

.param-group-title {
    margin-bottom: 6px;
    color: #667480;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.param-group-badge {
    margin-left: 4px;
    padding: 1px 5px;
    border-radius: 4px;
    background: #edf0ec;
    color: #75818b;
    font-size: 10px;
    font-weight: 600;
    text-transform: none;
}

.param-group--night .param-label,
.param-group--night .param-value {
    color: #98a3ad;
}

.param-group--night input[type="range"] {
    opacity: 0.35;
    cursor: not-allowed;
}

.param-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px 34px;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.param-row-full {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.param-label {
    min-width: 0;
    color: #34424e;
    font-size: 12px;
}

.param-value {
    color: #17222b;
    font-size: 12px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    width: 100%;
    accent-color: #2f6f58;
    cursor: pointer;
}

input[type="text"],
select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #c6cec7;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2933;
    font-size: 12px;
}

.controls {
    display: grid;
    gap: 8px;
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #34424e;
    cursor: pointer;
    font-size: 12px;
}

.dot-tree,
.dot-accident,
.dot-crime,
.dot-lamp {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
}

.dot-tree {
    background: #2f6f58;
}

.dot-accident {
    background: #c74e3f;
}

.dot-crime {
    background: #6d5aa8;
}

.dot-lamp {
    background: #e3a11b;
    box-shadow: 0 0 0 1px rgba(31, 41, 51, 0.18) inset;
}

.marker-start,
.marker-end {
    width: 28px;
    height: 28px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(23, 34, 43, 0.35);
}

.marker-start {
    background: #2f6f58;
}

.marker-end {
    background: #c74e3f;
}

.tree-popup .maplibregl-popup-content {
    padding: 8px 10px;
    color: #17222b;
    font-size: 12px;
    line-height: 1.4;
}

#debug-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    max-width: min(340px, calc(100vw - 24px));
    border: 1px solid rgba(31, 41, 51, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 40px rgba(23, 34, 43, 0.18);
    font-size: 12px;
}

#debug-panel summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    color: #667480;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
    list-style: none;
    text-transform: uppercase;
}

#debug-panel summary::before {
    content: ">";
    font-size: 10px;
}

#debug-panel[open] summary::before {
    transform: rotate(90deg);
}

#debug-panel pre,
#profile-json {
    margin: 0;
    overflow: auto;
    white-space: pre-wrap;
    color: #24313d;
    font-size: 11px;
    line-height: 1.5;
}

#debug-panel pre {
    max-height: calc(100vh - 80px);
    padding: 0 10px 10px;
}

.profiles-layout {
    display: grid;
    grid-template-columns: 336px minmax(0, 1fr);
    gap: 16px;
}

.panel {
    min-width: 0;
    padding: 16px;
    border: 1px solid #d8ded7;
    border-radius: 8px;
    background: #ffffff;
}

.panel h1 {
    margin-bottom: 6px;
}

.panel p {
    margin: 0 0 10px;
    color: #52616e;
}

.profile-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dde3dc;
}

.profile-btn {
    flex: 1 1 88px;
}

.status {
    min-height: 18px;
    margin-top: 8px;
    color: #52616e;
    font-size: 12px;
}

.status.ok {
    color: #2f6f58;
}

.status.error {
    color: #b42318;
}

#profile-json {
    min-height: calc(100vh - 148px);
    padding: 14px;
    border: 1px solid #d8ded7;
    border-radius: 8px;
    background: #ffffff;
}

@media (max-width: 860px) {
    .site-header__inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 0;
    }

    .site-nav {
        justify-content: flex-start;
    }

    .profiles-layout,
    .request-grid {
        grid-template-columns: 1fr;
    }

    #debug-panel {
        display: none;
    }
}

@media (max-width: 520px) {
    .site-header__inner,
    .page {
        width: min(100vw - 20px, 1120px);
    }

    .page {
        padding-top: 22px;
    }

    .doc-table,
    .doc-table tbody,
    .doc-table tr,
    .doc-table th,
    .doc-table td {
        display: block;
        width: 100%;
    }

    .doc-table th {
        padding-bottom: 2px;
        border-bottom: 0;
    }

    .doc-table td {
        padding-top: 2px;
    }

    #panel {
        inset: auto 10px 10px 10px;
        width: auto;
        max-height: 58vh;
    }

    .param-row {
        grid-template-columns: minmax(0, 1fr) 84px 32px;
    }
}
