:root {
    color-scheme: dark;
    --background: #05030d;
    --surface: rgba(10, 7, 24, 0.96);
    --surface-soft: rgba(19, 10, 40, 0.9);
    --border: rgba(178, 92, 255, 0.34);
    --primary: #a23cff;
    --primary-bright: #d946ef;
    --secondary: #7c4dff;
    --cyan: #48d7ff;
    --text: #f8f4ff;
    --text-muted: #b8aecb;
    --danger: #ff4d7d;
    --success: #56f09f;
    --shadow: 0 18px 58px rgba(0, 0, 0, 0.56);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button,
input,
textarea,
select {
    font: inherit;
    letter-spacing: 0;
}

button {
    min-height: 44px;
    border: 0;
    border-radius: 7px;
    color: var(--text);
    cursor: pointer;
    font-weight: 750;
}

button:hover:not(:disabled) {
    filter: brightness(1.1);
}

button:disabled {
    cursor: default;
    opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(72, 215, 255, 0.78);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    background: var(--background);
}

.map-loading {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    padding: 24px;
    background: #05030d;
    color: var(--text-muted);
    text-align: center;
}

.map-loading.is-error {
    color: #ffd4e1;
}

.loading-logo {
    width: 112px;
    height: auto;
}

.loading-brand-name {
    color: #ffffff;
    font-size: 1rem;
}

.loading-signal {
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-bright);
    border-radius: 50%;
    box-shadow: 0 0 18px var(--primary-bright);
    animation: loading-pulse 1.4s ease-in-out infinite;
}

.app-identity {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 8;
    display: flex;
    align-items: center;
    gap: 9px;
    pointer-events: none;
    text-shadow: 0 2px 8px #05030d;
}

.identity-mark {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 0 9px rgba(217, 70, 239, 0.46));
}

.identity-horizontal {
    display: none;
    width: 320px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(217, 70, 239, 0.35));
}

.identity-copy {
    display: grid;
    line-height: 1.1;
}

.identity-copy strong {
    font-size: 0.84rem;
}

.identity-copy span {
    margin-top: 3px;
    color: #ceb5ec;
    font-size: 0.68rem;
}

.active-zone {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 54px);
    left: max(12px, env(safe-area-inset-left));
    z-index: 8;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(5, 3, 13, 0.86);
    color: #d9c9ec;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
    font-size: 0.7rem;
    font-weight: 760;
    pointer-events: none;
}

.active-zone span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-bright);
    box-shadow: 0 0 9px var(--primary-bright);
}

.map-mode-control {
    position: fixed;
    top: calc(max(10px, env(safe-area-inset-top)) + 126px);
    right: max(10px, env(safe-area-inset-right));
    z-index: 9;
    display: grid;
    grid-template-columns: repeat(2, 38px);
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(5, 3, 13, 0.9);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
}

.map-mode-control button {
    min-height: 34px;
    padding: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.map-mode-control button[aria-pressed="true"] {
    background: #8f26d8;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(217, 70, 239, 0.4);
}

.empty-state {
    position: fixed;
    right: 16px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 56px);
    left: 16px;
    z-index: 8;
    width: fit-content;
    max-width: calc(100vw - 32px);
    margin: auto;
    padding: 8px 11px;
    border: 1px solid rgba(178, 92, 255, 0.3);
    border-radius: 6px;
    background: rgba(5, 3, 13, 0.84);
    color: #d9cfea;
    font-size: 0.76rem;
    text-align: center;
    pointer-events: none;
}

.safety-notice {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    z-index: 8;
    max-width: 650px;
    margin: 0 auto;
    padding: 7px 10px;
    color: #c5bad4;
    background: rgba(5, 3, 13, 0.78);
    border-top: 1px solid rgba(178, 92, 255, 0.22);
    font-size: 0.68rem;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
}

.safety-notice strong {
    margin-right: 5px;
    color: #ff9d55;
}

.sheet-open .safety-notice {
    display: none;
}

.sheet-open .empty-state {
    display: none;
}

.bottom-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    width: 100%;
    max-height: 80dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 16px max(18px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sheet-handle {
    width: 48px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 4px;
    background: #7c4dff;
}

.sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.sheet-kicker {
    margin: 0 0 3px;
    color: #c78cff;
    font-size: 0.7rem;
    font-weight: 800;
}

.sheet-header h1 {
    margin: 0;
    max-width: 28ch;
    color: #ffffff;
    font-size: 1.2rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.icon-button {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    padding: 0;
    border: 1px solid var(--border);
    background: #171126;
    font-size: 1.4rem;
    line-height: 1;
}

.sheet-view {
    min-width: 0;
}

form {
    display: grid;
    gap: 9px;
}

label {
    color: #ded5eb;
    font-size: 0.8rem;
    font-weight: 720;
}

label span {
    color: var(--text-muted);
    font-weight: 500;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(184, 174, 203, 0.28);
    border-radius: 6px;
    background: #080512;
    color: var(--text);
    padding: 10px 11px;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
}

.category-fieldset {
    min-width: 0;
    margin: 2px 0;
    padding: 0;
    border: 0;
}

.category-fieldset legend {
    margin-bottom: 8px;
    color: #ded5eb;
    font-size: 0.8rem;
    font-weight: 720;
}

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

.category-option {
    position: relative;
    min-width: 0;
}

.category-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 1px;
    opacity: 0;
}

.category-card {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-height: 82px;
    padding: 7px;
    border: 1px solid rgba(184, 174, 203, 0.24);
    border-radius: 6px;
    background: #080512;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.category-card img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.category-card-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.category-card-copy strong {
    color: #ffffff;
    font-size: 0.72rem;
    line-height: 1.2;
}

.category-card-copy small {
    color: var(--text-muted);
    font-size: 0.61rem;
    font-weight: 500;
    line-height: 1.22;
}

.category-check {
    position: absolute;
    top: 4px;
    right: 5px;
    display: grid;
    place-items: center;
    width: 17px;
    height: 17px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    background: #d52fba;
    color: #ffffff;
    font-size: 0.66rem;
    opacity: 0;
}

.category-option input:checked + .category-card {
    z-index: 1;
    border-color: #f4d9ff;
    box-shadow: 0 0 18px rgba(217, 70, 239, 0.48), inset 0 0 0 1px #d946ef;
    transform: scale(1.025);
}

.category-option input:checked + .category-card .category-check {
    opacity: 1;
}

.category-option input:focus-visible + .category-card {
    outline: 3px solid rgba(72, 215, 255, 0.82);
    outline-offset: 2px;
}

.panel-safety-note {
    margin: 5px 0 0;
    padding-top: 9px;
    border-top: 1px solid rgba(178, 92, 255, 0.18);
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.35;
}

.date-fields {
    display: grid;
    gap: 9px;
}

.date-fields > div {
    display: grid;
    gap: 9px;
}

.sheet-actions,
.detail-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: 6px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.manage-toggle {
    padding: 10px 13px;
}

.primary-button {
    background: #8f26d8;
    box-shadow: 0 8px 24px rgba(162, 60, 255, 0.24);
}

.secondary-button {
    border: 1px solid var(--border);
    background: #1a122b;
}

.danger-button {
    background: #a92b50;
}

.text-button,
.manage-toggle {
    background: transparent;
    color: var(--text-muted);
}

.inline-message {
    display: none;
    margin-bottom: 9px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.inline-message.is-visible {
    display: block;
}

.inline-message.is-error {
    border-color: rgba(255, 77, 125, 0.58);
    color: #ffd2df;
}

.category-chip {
    width: fit-content;
    margin: 0 0 10px;
    padding: 4px 8px;
    border: 1px solid rgba(217, 70, 239, 0.42);
    border-radius: 5px;
    color: #eea7fa;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-description {
    margin: 0 0 14px;
    color: #ded6e9;
    overflow-wrap: anywhere;
}

.detail-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px 16px;
    margin: 0;
    padding: 13px 0;
    border-top: 1px solid rgba(178, 92, 255, 0.18);
    border-bottom: 1px solid rgba(178, 92, 255, 0.18);
}

.detail-meta dt,
.management-result dt {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 780;
    text-transform: uppercase;
}

.detail-meta dd,
.management-result dd {
    margin: 3px 0 0;
    color: var(--text);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.manage-toggle {
    width: 100%;
    margin-top: 8px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.manage-form {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid rgba(178, 92, 255, 0.18);
}

.success-view {
    display: grid;
    justify-items: stretch;
    gap: 12px;
}

.success-view > p {
    margin: 0;
}

.success-signal {
    justify-self: center;
    width: 28px;
    height: 28px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 24px rgba(86, 240, 159, 0.8);
}

.success-warning {
    color: #d6c9e7;
    font-size: 0.86rem;
}

.management-result {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #070410;
}

#created-management-code {
    display: block;
    padding: 8px 9px;
    border-radius: 5px;
    background: #020106;
    color: #ffffff;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.95rem;
    user-select: all;
}

.toast {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 104px);
    left: 50%;
    z-index: 40;
    transform: translateX(-50%);
    width: min(420px, calc(100vw - 24px));
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--cyan);
    border-radius: 7px;
    background: rgba(7, 4, 16, 0.96);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 0.8rem;
    text-align: center;
}

.toast[data-type="success"] {
    border-left-color: var(--success);
}

.toast[data-type="error"] {
    border-left-color: var(--danger);
    color: #ffd3df;
}

.temporary-energy-point {
    position: relative;
    width: 126px;
    height: 84px;
    min-height: 84px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}

.event-category-marker {
    --marker-size: 36px;
    position: relative;
    display: grid;
    place-items: center;
    width: var(--marker-size);
    height: var(--marker-size);
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    filter: drop-shadow(0 0 6px rgba(217, 70, 239, 0.62));
    overflow: visible;
    transition: transform 140ms ease, filter 140ms ease;
}

.event-category-marker > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.event-category-marker:hover,
.event-category-marker:focus-visible {
    z-index: 3;
    filter: drop-shadow(0 0 9px rgba(255, 71, 193, 0.9));
    transform: scale(1.08);
}

.event-category-marker.is-selected {
    z-index: 5;
    filter: drop-shadow(0 0 13px rgba(255, 71, 193, 1));
    transform: scale(1.15);
    animation: marker-selected-pulse 1.5s ease-in-out infinite;
}

.event-category-marker.is-3d-base {
    opacity: 0.92;
}

.event-support-ring {
    position: absolute;
    inset: -2px;
    border: 1px solid rgba(86, 240, 159, 0.82);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(86, 240, 159, 0.54);
    pointer-events: none;
    opacity: 0;
}

.event-category-marker.is-supported .event-support-ring {
    opacity: 1;
}

.event-starting-soon {
    position: absolute;
    top: 0;
    right: 0;
    width: 7px;
    height: 7px;
    border: 1px solid #fff0d7;
    border-radius: 50%;
    background: #ff8b3d;
    box-shadow: 0 0 6px #ff8b3d;
    pointer-events: none;
    opacity: 0;
}

.event-category-marker.is-starting-soon .event-starting-soon {
    opacity: 1;
}

.event-marker-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    width: max-content;
    max-width: 190px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: rgba(5, 3, 13, 0.96);
    color: #ffffff;
    font-size: 0.66rem;
    font-weight: 650;
    line-height: 1.25;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    white-space: normal;
}

@media (hover: hover) {
    .event-category-marker:hover .event-marker-tooltip,
    .event-category-marker:focus-visible .event-marker-tooltip {
        opacity: 1;
    }
}

.temporary-beam,
.temporary-orb,
.temporary-ring,
.temporary-label {
    position: absolute;
    left: 50%;
    pointer-events: none;
}

.temporary-beam {
    bottom: 15px;
    width: 3px;
    height: 34px;
    transform: translateX(-50%);
    border-radius: 3px;
    background: rgba(162, 60, 255, 0.62);
    box-shadow: 0 0 12px rgba(162, 60, 255, 0.72);
}

.temporary-orb {
    bottom: 8px;
    width: 14px;
    height: 14px;
    transform: translateX(-50%);
    border: 2px solid #e0baff;
    border-radius: 50%;
    background: rgba(162, 60, 255, 0.82);
    box-shadow: 0 0 16px #a23cff;
}

.temporary-ring {
    bottom: 4px;
    width: 22px;
    height: 22px;
    transform: translateX(-50%);
    border: 1px dashed rgba(217, 70, 239, 0.75);
    border-radius: 50%;
    animation: temporary-pulse 2s ease-out infinite;
}

.temporary-label {
    top: 0;
    transform: translateX(-50%);
    width: max-content;
    max-width: 126px;
    padding: 3px 6px;
    border: 1px solid rgba(178, 92, 255, 0.34);
    border-radius: 4px;
    background: rgba(5, 3, 13, 0.86);
    color: #e6d3f8;
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
}

.maplibregl-ctrl-top-right {
    top: max(10px, env(safe-area-inset-top));
    right: max(4px, env(safe-area-inset-right));
}

.maplibregl-ctrl-group {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: rgba(5, 3, 13, 0.9);
}

.maplibregl-ctrl-group button {
    min-height: 36px;
    background-color: rgba(5, 3, 13, 0.9);
}

.maplibregl-ctrl-icon {
    filter: invert(1) hue-rotate(190deg);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes loading-pulse {
    0%, 100% { transform: scale(0.78); opacity: 0.55; }
    50% { transform: scale(1.1); opacity: 1; }
}

@keyframes temporary-pulse {
    from { transform: translateX(-50%) scale(0.8); opacity: 0.72; }
    to { transform: translateX(-50%) scale(1.8); opacity: 0; }
}

@keyframes marker-selected-pulse {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 71, 193, 0.78)); }
    50% { filter: drop-shadow(0 0 16px rgba(255, 71, 193, 1)); }
}

@media (prefers-reduced-motion: reduce) {
    .loading-signal,
    .temporary-ring,
    .event-category-marker.is-selected {
        animation: none;
    }

    .category-card,
    .event-category-marker {
        transition: none;
    }
}

@media (min-width: 721px) {
    .identity-horizontal {
        display: block;
    }

    .identity-mark,
    .identity-copy {
        display: none;
    }

    .active-zone {
        top: calc(max(12px, env(safe-area-inset-top)) + 84px);
    }

    .bottom-sheet {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        left: auto;
        width: min(440px, calc(100vw - 32px));
        max-height: calc(100dvh - 32px);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px 18px 18px;
    }

    .date-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .category-card {
        grid-template-columns: 42px minmax(0, 1fr);
        min-height: 92px;
        padding: 6px;
    }

    .category-card img {
        width: 42px;
        height: 42px;
    }

    .safety-notice {
        left: max(16px, env(safe-area-inset-left));
        right: auto;
        margin: 0;
        text-align: left;
    }
}

@media (max-width: 359px) {
    .identity-copy span {
        display: none;
    }

    .active-zone {
        top: calc(max(12px, env(safe-area-inset-top)) + 50px);
    }

    .sheet-actions,
    .detail-actions,
    .detail-meta {
        grid-template-columns: 1fr;
    }
}
