* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
body { display: flex; flex-direction: column; background: #1e1e1e; color: #eaeaea; }

header {
    padding: 8px 16px;
    background: #232323;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
}
header h1 { font-size: 18px; margin: 0; font-weight: 600; line-height: 1.1; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { height: 42px; width: auto; display: block; border-radius: 4px; }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.subtitle { margin: 0; font-size: 11px; color: #aaa; letter-spacing: 0.2px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.legend-label { color: #aaa; }
.dot {
    display: inline-block;
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.85);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
    margin-left: 6px;
}
.dot.d1 { background: #3498db; }
.dot.d2 { background: #1e8449; }
.dot.d3 { background: #f1c40f; }
.dot.d4 { background: #e74c3c; }
.dot.d5 { background: #2e2e2e; }

/* Legende als Schwierigkeits-Filter (klickbare Chips) */
.legend-item {
    display: inline-flex; align-items: center; gap: 5px;
    background: transparent; color: #eaeaea;
    border: 1px solid transparent; border-radius: 12px;
    padding: 2px 9px 2px 5px; font: inherit; font-size: 13px;
    cursor: pointer; line-height: 1.4;
}
.legend-item .dot { margin: 0; width: 13px; height: 13px; }
.legend-item:hover { background: #303030; border-color: #4a4a4a; }
.legend-item.off { opacity: 0.45; }
.legend-item.off .dot { filter: grayscale(0.75); }
.legend-item.off .label { text-decoration: line-through; }
.legend-reset {
    background: #3a3a3a; color: #eaeaea;
    border: 1px solid #555; border-radius: 12px;
    padding: 2px 10px; font: inherit; font-size: 12px;
    cursor: pointer;
}
.legend-reset:hover { background: #4a4a4a; }
.header-btn {
    background: #3a3a3a; color: #eaeaea;
    border: 1px solid #555; border-radius: 4px;
    padding: 4px 12px; font: inherit; font-size: 13px;
    cursor: pointer;
}
.header-btn:hover { background: #4a4a4a; }
.header-btn.active { background: #2980b9; border-color: #3498db; }
.header-btn.active:hover { background: #3498db; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Edit-UI nur fuer eingeloggte Mitglieder */
body:not(.logged-in) .edit-only { display: none; }
body:not(.logged-in) .leaflet-popup-content .edit-btn,
body:not(.logged-in) .leaflet-popup-content .delete-btn { display: none; }

dialog#login-dialog {
    border: none; border-radius: 8px; padding: 0;
    width: min(380px, 92vw);
    background: #2a2a2a; color: #eaeaea;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
dialog#login-dialog::backdrop { background: rgba(0,0,0,0.5); }
#login-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#login-form h2 { margin: 0; font-size: 18px; }
#login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #ccc; }
#login-form input[type="password"] {
    background: #1a1a1a; color: #eaeaea;
    border: 1px solid #444; border-radius: 4px;
    padding: 6px 8px; font: inherit; font-size: 14px;
}
#login-form .login-hint { margin: 0; font-size: 12px; color: #888; line-height: 1.4; }
#login-ok-btn { background: #27ae60; border-color: #2ecc71; }
#login-ok-btn:hover { background: #2ecc71; }

/* Locate-Control (Knopf unter den +/- Zoom-Buttons) */
.leaflet-control-locate {
    color: #333;
    font: 0/0 a; /* hide whitespace inside the anchor */
}
.leaflet-control-locate svg {
    width: 18px; height: 18px;
    vertical-align: middle; margin-top: 3px;
    display: inline-block;
}
.leaflet-control-locate.active { color: #2980b9; }
.leaflet-control-locate.loading {
    opacity: 0.6; cursor: wait;
}
.leaflet-control-locate.loading svg {
    animation: locate-spin 1.2s linear infinite;
}
@keyframes locate-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* User location marker (blue dot) */
.location-marker {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #3498db;
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 1px #2c3e50, 0 0 8px rgba(52, 152, 219, 0.7);
}
.hint { color: #888; font-size: 13px; }

#map-area { flex: 1 1 auto; display: flex; min-height: 0; }
#map { flex: 1 1 auto; }

/* Baum-Liste-Panel (links neben der Karte, ausklappbar) */
#tree-list-panel {
    width: min(320px, 80vw);
    background: #232323;
    border-right: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#tree-list-panel[hidden] { display: none; }
.tree-list-header {
    padding: 8px 12px;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#tree-list-count { font-size: 12px; color: #aaa; }
#tree-list-search {
    background: #1a1a1a; color: #eaeaea;
    border: 1px solid #444; border-radius: 4px;
    padding: 4px 8px; font: inherit; font-size: 13px;
}
#tree-list {
    list-style: none; margin: 0; padding: 0;
    overflow-y: auto; flex: 1 1 auto;
}
.tree-list-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid #2c2c2c;
    cursor: pointer;
    font-size: 13px;
    color: #eaeaea;
}
.tree-list-item:hover { background: #2c2c2c; }
.tree-list-item .dot { margin: 0; width: 12px; height: 12px; flex-shrink: 0; }
.tree-icon-list {
    width: 22px; height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    transition: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}
.tree-icon-list:hover { transform: none; }
.tree-list-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-list-empty {
    padding: 12px; color: #888; font-size: 13px; font-style: italic; text-align: center;
}

/* Permanente Namen-Tooltips neben Marker (per Button getoggelt).
   visibility statt display: damit Leaflet beim initialen Positionieren
   die korrekte Tooltip-Hoehe sieht (display:none -> offsetHeight=0
   -> Tooltips landen ca. 9px zu tief). */
.leaflet-tooltip.tree-name-label {
    visibility: hidden;
    background: rgba(35,35,35,0.88);
    color: #fff;
    border: 1px solid rgba(0,0,0,0.5);
    border-radius: 3px;
    font-size: 11px;
    padding: 1px 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.45);
    white-space: nowrap;
    pointer-events: none;
}
.leaflet-tooltip.tree-name-label::before { display: none; }
body.show-names .leaflet-tooltip.tree-name-label { visibility: visible; }

/* Tree marker (SVG icon) */
.tree-icon {
    width: 27px; height: 27px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.55));
    cursor: pointer;
    transition: transform 0.12s ease-out;
}
.tree-icon:hover { transform: translateY(-2px) scale(1.05); }

/* "Geschafft" Krone als Overlay auf Baum-Marker.
   Leaflet setzt am Wrapper selbst position:absolute; nicht ueberschreiben! */
.tree-marker-wrap { overflow: visible; }
.climbed-crown {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 13px;
    pointer-events: none;
    filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.55));
}

/* Popup */
.leaflet-popup-content {
    margin: 12px 14px;
    min-width: 220px;
    max-width: 280px;
    color: #222;
}
.leaflet-popup-content h3 { margin: 0 0 4px 0; font-size: 16px; }
.leaflet-popup-content .meta {
    font-size: 12px; color: #666; margin: 0 0 8px 0;
    display: flex; align-items: center; gap: 6px;
}
.leaflet-popup-content .meta .dot { margin: 0; width: 12px; height: 12px; }
.leaflet-popup-content p { margin: 0 0 8px 0; font-size: 14px; line-height: 1.4; }
.leaflet-popup-content .first-ascender { font-size: 13px; color: #444; }
.leaflet-popup-content .first-ascender .label { color: #777; }
.leaflet-popup-content img {
    width: 100%; max-height: 200px;
    object-fit: cover; border-radius: 4px;
    cursor: zoom-in;
}
.leaflet-popup-content .edit-btn,
.leaflet-popup-content .delete-btn {
    color: #000; border: none;
    padding: 4px 10px; font-size: 12px; border-radius: 3px;
    cursor: pointer; margin-top: 4px;
}
.leaflet-popup-content .edit-btn { background: #2980b9; margin-right: 6px; }
.leaflet-popup-content .edit-btn:hover { background: #2471a3; }
.leaflet-popup-content .delete-btn { background: #c0392b; }
.leaflet-popup-content .delete-btn:hover { background: #a93226; }
.leaflet-popup-content .climbed-btn {
    color: #000; background: #1e8449; border: 1px solid #145a32;
    padding: 4px 10px; font-size: 12px; font-weight: 600;
    border-radius: 3px; cursor: pointer;
    margin-top: 4px; margin-right: 6px;
}
.leaflet-popup-content .climbed-btn:hover { background: #196f3d; }
.leaflet-popup-content .climbed-btn.done {
    background: #7f7f7f; color: #000; border-color: #555;
}
.leaflet-popup-content .climbed-btn.done:hover { background: #969696; }

#current-photo-section {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 13px; color: #ccc;
}
#current-photo-preview {
    max-width: 200px; max-height: 150px; object-fit: cover;
    border-radius: 4px; align-self: flex-start;
    border: 1px solid #444;
}
#current-photo-section .remove-photo-label {
    display: flex; flex-direction: row; align-items: center; gap: 6px;
    color: #ccc; cursor: pointer;
}

/* Dialog */
dialog#tree-dialog {
    border: none; border-radius: 8px; padding: 0;
    width: min(440px, 92vw);
    background: #2a2a2a; color: #eaeaea;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
dialog#tree-dialog::backdrop { background: rgba(0,0,0,0.5); }
#tree-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#tree-form h2 { margin: 0; font-size: 18px; }
#tree-form .coords { margin: 0; font-size: 12px; color: #999; font-family: ui-monospace, monospace; }
#tree-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #ccc; }
#tree-form input[type="text"],
#tree-form textarea {
    background: #1a1a1a; color: #eaeaea;
    border: 1px solid #444; border-radius: 4px;
    padding: 6px 8px; font: inherit; font-size: 14px;
    resize: vertical;
}
.coords-fields { display: flex; gap: 8px; }
.coords-fields label { flex: 1; }
.coords-fields input[type="text"] {
    font-family: ui-monospace, monospace;
    font-size: 13px;
}
#tree-form input[type="file"] { font-size: 13px; color: #ccc; }
#tree-form fieldset {
    border: 1px solid #444; border-radius: 4px;
    padding: 8px 12px; margin: 0;
}
#tree-form legend { padding: 0 6px; font-size: 13px; color: #ccc; }
.difficulty-row { display: flex; gap: 14px; }
.difficulty-row label { flex-direction: row; align-items: center; gap: 4px; color: #eaeaea; cursor: pointer; }
.form-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-buttons button {
    background: #3a3a3a; color: #eaeaea;
    border: 1px solid #555; border-radius: 4px;
    padding: 6px 16px; font: inherit; font-size: 14px;
    cursor: pointer;
}
.form-buttons button:hover { background: #4a4a4a; }
#submit-btn,
#coords-ok-btn { background: #27ae60; border-color: #2ecc71; }
#submit-btn:hover,
#coords-ok-btn:hover { background: #2ecc71; }
.error { color: #ff7676; font-size: 13px; margin: 0; min-height: 1em; }

/* Coords dialog (reuses tree-dialog look) */
dialog#coords-dialog {
    border: none; border-radius: 8px; padding: 0;
    width: min(380px, 92vw);
    background: #2a2a2a; color: #eaeaea;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
dialog#coords-dialog::backdrop { background: rgba(0,0,0,0.5); }
#coords-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#coords-form h2 { margin: 0; font-size: 18px; }
#coords-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #ccc; }
#coords-form input[type="text"] {
    background: #1a1a1a; color: #eaeaea;
    border: 1px solid #444; border-radius: 4px;
    padding: 6px 8px; font: inherit; font-size: 14px;
    font-family: ui-monospace, monospace;
}
#coords-form .coords-hint { margin: 0; font-size: 12px; color: #888; line-height: 1.4; }

/* Climber-Dialog */
dialog#climbers-dialog {
    border: none; border-radius: 8px; padding: 0;
    width: min(400px, 92vw);
    background: #2a2a2a; color: #eaeaea;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
dialog#climbers-dialog::backdrop { background: rgba(0,0,0,0.5); }
#climbers-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#climbers-form h2 { margin: 0; font-size: 18px; }
#climbers-form .climbers-hint { margin: 0; font-size: 12px; color: #888; line-height: 1.4; }
#climbers-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #ccc; }
#climbers-list {
    list-style: none; margin: 0; padding: 0;
    max-height: 240px; overflow-y: auto;
    border: 1px solid #444; border-radius: 4px;
    background: #1a1a1a;
}
.climber-item {
    padding: 8px 12px;
    border-bottom: 1px solid #2c2c2c;
    cursor: pointer;
    font-size: 14px;
    color: #eaeaea;
    display: flex; justify-content: space-between; align-items: center;
}
.climber-item:last-child { border-bottom: none; }
.climber-item:hover { background: #2c2c2c; }
.climber-item.selected { background: #2980b9; color: #fff; }
.climber-item.selected:hover { background: #3498db; }
.climber-item .climber-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.climber-item .climber-count {
    font-size: 12px; color: #aaa;
    font-variant-numeric: tabular-nums;
    margin-left: 8px;
}
.climber-item.selected .climber-count { color: #e0e0e0; }
.climber-item .check { color: #ffd700; font-weight: bold; font-size: 16px; margin-left: 6px; }
.climbers-empty {
    padding: 12px; color: #888; font-size: 13px; font-style: italic; text-align: center;
}
.climber-add-row { display: flex; gap: 8px; }
.climber-add-row input {
    flex: 1;
    background: #1a1a1a; color: #eaeaea;
    border: 1px solid #444; border-radius: 4px;
    padding: 6px 8px; font: inherit; font-size: 14px;
}
.climber-add-row button {
    background: #3a3a3a; color: #eaeaea;
    border: 1px solid #555; border-radius: 4px;
    padding: 6px 12px; font: inherit; font-size: 13px;
    cursor: pointer;
}
.climber-add-row button:hover { background: #4a4a4a; }
#climbers-current-name { color: #ffd700; font-weight: 600; }

/* Lightbox */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
}
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; }
