:root {
    --bg: #0f1e1b;
    --card: rgba(18, 34, 30, 0.9);
    --accent: #f4c27a;
    --accent-2: #f2a653;
    --text: #f6f1e8;
    --muted: #ffffff;
    --shadow: rgba(0, 0, 0, 0.35);
    --font: "Avenir Next", "Futura", "Gill Sans", "Trebuchet MS", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: #0f1e1b;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 1000;
    background: linear-gradient(172deg, #5eee98, color(srgb 0 0.3119 0.2237) 47.06%), rgb(46, 89, 39);
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
}

.auth-status {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-status.is-auth {
    color: #d6f3e2;
    background: rgba(99, 215, 138, 0.2);
    border: 1px solid rgba(99, 215, 138, 0.45);
    padding: 4px 8px;
    border-radius: 999px;
}

.actions-toggle {
    display: none;
}

.actions-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo img {
    height: 35px;
    width: auto;
    display: block;
}

.brand-mark {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
}

.brand-name {
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    padding: 16px;
    min-height: calc(100vh - 70px);
}

.map-panel {
    position: relative;
    height: calc(100vh - 70px - 32px);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 20px 40px var(--shadow);
    z-index: 1;
}

@media (min-width: 980px) {
    .map-panel {
        position: sticky;
        top: 16px;
        align-self: start;
    }
}

.map {
    width: 100%;
    height: 100%;
}

.map-panel.placing-hito .map,
.map-panel.placing-guide .map {
    cursor: crosshair;
}

.map-panel .help-anchor {
    align-self: flex-start;
    margin-left: 16px;
    margin-top: 8px;
}

.map-toolbar {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 30, 27, 0.8);
    padding: 10px;
    border-radius: 12px;
    z-index: 1000;
}

.map-panel .leaflet-control-layers {
    color: #1b1b1f;
}

.map-panel .leaflet-control-layers-expanded {
    background: rgba(255, 255, 255, 0.95);
}

.map-panel .leaflet-control-layers-expanded label {
    color: #1b1b1f;
}

.geo-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.help-anchor {
    display: none;
}

.toolbar-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.search.hidden {
    display: none;
}

.search {
    display: flex;
    gap: 6px;
}

.search input {
    min-width: 180px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
}

.geo-active {
    border-color: rgba(120, 214, 198, 0.7);
    color: #78d6c6;
}

.user-marker {
    animation: userPulse 1.2s ease-in-out infinite;
}

@keyframes userPulse {
    0% {
        opacity: 1;
    }

    70% {
        opacity: 0.2;
    }

    100% {
        opacity: 1;
    }
}

.search-result {
    font-size: 12px;
    color: var(--text);
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.search-result:hover {
    background: rgba(255, 255, 255, 0.12);
}

.map-hint {
    font-size: 11px;
    color: #ffffff;
    font-weight: 700;
}

.admin-banner {
    background: #fff1f1;
    border: 1px solid #d95b5b;
    color: #7e1d1d;
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 12px;
    margin-bottom: 12px;
}

.map-toast[hidden] {
    display: none;
}

.map-toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #f5b400;
    color: #1b1400;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.02em;
    z-index: 3000;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.map-toast.error {
    background: #f26b4f;
    color: #ffffff;
}

.back-to-top {
    position: fixed;
    right: 18px;
    bottom: 86px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(15, 18, 18, 0.2);
    background: #ffffff;
    color: #0f1212;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
    z-index: 2200;
}

.back-to-top[hidden] {
    display: none;
}

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 12, 12, 0.7);
    z-index: 2000;
    padding: 16px;
}

.modal-card {
    width: min(360px, 100%);
    max-height: min(80vh, 520px);
    background: #0f1b18;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    overflow-y: auto;
}

.modal-title {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.modal-text {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.modal-text.error {
    color: #f26b4f;
}

.modal-text a {
    color: var(--accent);
}

.brand-name {
    cursor: pointer;
}

.brand-caret {
    font-size: 14px;
    line-height: 1;
    opacity: 0.8;
}

@media (max-width: 780px) {
    .topbar {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 10px;
    }

    .brand {
        justify-content: flex-start;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .brand-name {
        font-size: 11px;
        letter-spacing: 0.06em;
        white-space: nowrap;
    }

    .actions {
        justify-content: flex-end;
        flex-wrap: nowrap;
        justify-self: end;
        position: static;
    }

    .auth-status {
        margin-right: 6px;
    }

    .actions {
        gap: 6px;
    }

    .actions-toggle {
        display: inline-flex;
    }

    .actions-menu {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 64px);
        right: 16px;
        background: #0f1b18;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 14px;
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        min-width: 220px;
        max-width: calc(100vw - 32px);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
        display: none;
        z-index: 1100;
    }

    .actions.is-open .actions-menu {
        display: flex;
    }

    .actions-menu .btn {
        width: 100%;
        justify-content: center;
    }
}

.route-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.route-item {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.route-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.route-item-title {
    font-weight: 600;
    font-size: 13px;
}

.route-item-meta {
    font-size: 12px;
    color: var(--muted);
}

.route-status {
    font-weight: 600;
}

.route-status--public {
    color: #61d28a;
}

.route-status--hidden {
    color: #f26b4f;
}

.modal input {
    font-size: 16px;
}

.map-hint.error {
    background: #f26b4f;
    color: #ffffff;
    padding: 6px 8px;
    border-radius: 8px;
}

.form-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(15, 30, 27, 0.95);
    box-shadow: 0 12px 24px var(--shadow);
}

.form-footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.form-footer-note {
    font-size: 12px;
    color: var(--muted);
}

.form-footer-meta {
    font-size: 11px;
    color: var(--muted);
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 24px var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hidden {
    display: none !important;
}

.editor-card--instructions {
    background: linear-gradient(140deg, rgba(33, 65, 58, 0.95), rgba(22, 38, 35, 0.95));
}

.editor-card--footer {
    background: linear-gradient(140deg, rgba(166, 166, 166, 0.95), rgba(22, 38, 35, 0.95));
}

.draft-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.draft-status {
    font-size: 12px;
    color: #d6f3e2;
    background: rgba(99, 215, 138, 0.2);
    border: 1px solid rgba(99, 215, 138, 0.45);
    padding: 4px 8px;
    border-radius: 999px;
}

.draft-buttons {
    display: flex;
    gap: 8px;
}

.editor-card--itinerary {
    background: linear-gradient(140deg, rgba(62, 55, 33, 0.95), rgba(32, 29, 20, 0.95));
}

.editor-card--hitos {
    background: linear-gradient(140deg, rgba(80, 48, 26, 0.95), rgba(36, 24, 14, 0.95));
}

.editor-card--guides {
    background: linear-gradient(140deg, rgba(30, 55, 82, 0.95), rgba(18, 28, 42, 0.95));
}

.editor-card--xml {
    background: linear-gradient(140deg, rgba(74, 32, 42, 0.95), rgba(36, 18, 22, 0.95));
}

.card h2 {
    margin: 0;
    font-size: 16px;
}

.editor-instructions {
    color: #ffffff;
    font-size: 12px;
    line-height: 1.45;
}

.editor-instructions p {
    margin: 0;
}

.editor-instructions .instruction-lead {
    font-weight: 600;
    margin-bottom: 6px;
}

.editor-instructions .instruction-note {
    opacity: 0.92;
    margin-bottom: 10px;
}

.editor-instructions .instruction-list {
    margin: 0 0 12px;
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-instructions li {
    line-height: 1.5;
    list-style: disc;
}

.editor-footer .footer-lead {
    color: black;
}

.editor-footer .footer-lead a {
    color: black;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

input,
textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
}

input[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
}

.status-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.field-hint {
    font-size: 11px;
    color: var(--muted);
}

.status-label {
    font-size: 12px;
    color: var(--muted);
}

.status-toggle {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 4px;
}

.status-btn {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.status-btn.active {
    background: rgba(244, 194, 122, 0.9);
    color: #1b1209;
    font-weight: 700;
}

.status-btn.active[data-status="public"] {
    background: rgba(99, 215, 138, 0.9);
    color: #072713;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

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

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

.list-item {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    font-size: 13px;
}

.list-item.active {
    border-color: var(--accent);
    color: var(--accent);
}

.subform {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    background: var(--accent);
    border: none;
    color: #1b1209;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}

.btn.is-active {
    background: #63d78a;
    color: #072713;
    box-shadow: 0 10px 20px rgba(99, 215, 138, 0.3);
}

.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.ghost {
    background: transparent;
    border: 1px solid rgba(244, 194, 122, 0.5);
    color: var(--accent);
}

.btn.primary {
    background: var(--accent-2);
}

.btn.danger {
    background: #d86b6b;
    color: #2a0c0c;
}

#xmlOutput {
    min-height: 200px;
    resize: vertical;
}

.hito-marker {
    background: #f4c27a;
    color: #1b1209;
    border-radius: 999px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(244, 194, 122, 0.6);
}

.hito-marker.active {
    outline: 2px solid rgba(120, 214, 198, 0.8);
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .map-panel {
        min-height: 360px;
    }

    .help-anchor {
        display: inline-flex;
        justify-content: center;
    }
}
