/* ==========================================================================
   The Melody Sticker — stylesheet
   Palette: yellow + white + black
   Typeface: Special Elite (typewriter, Apache License 2.0)
   ========================================================================== */

@font-face {
    font-family: "Special Elite";
    src: url("fonts/SpecialElite-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --yellow: #f6f511;
    --yellow-dark: #ffd400;
    --yellow-soft: #fffbdc;
    --yellow-pale: #fffbdc;
    --black: #0a0a0a;
    --ink: #1a1a1a;
    --ink-muted: #555;
    --ink-faint: #8a8a8a;
    --paper: #ffffff;
    --paper-soft: #fafaf7;
    --paper-line: #ececec;
    --border: #e6e6e6;
    --danger: #c0392b;
    --success: #1f7a3a;

    /* Soft, modern shadows — no more neo-brutalist offsets. */
    --shadow-card:  0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-float: 0 2px 4px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.12);
    --shadow-pop:   0 2px 6px rgba(0, 0, 0, 0.08), 0 14px 36px rgba(0, 0, 0, 0.14);

    --topbar-h: 140px;
    --sidebar-w: 360px;

    /* Bigger, friendlier radii — matches the mockup. */
    --radius-sm:  8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-typewriter: "Special Elite", "Courier New", ui-monospace, monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper-soft);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: var(--ink); }

/* ---------- A11y helpers ---------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--black);
    color: var(--yellow);
    padding: 8px 12px;
    z-index: 2000;
    text-decoration: none;
    font-weight: 700;
}
.skip-link:focus { top: 0; }

:focus-visible {
    outline: 3px solid var(--black);
    outline-offset: 2px;
}

/* Hidden honeypot — off-screen, not display:none (bots skip display:none) */
.honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    pointer-events: none;
}

/* ---------- Top bar (yellow banner) ---------- */
.topbar {
    position: relative;
    z-index: 1000;
    height: var(--topbar-h);
    background: var(--yellow);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.brand-title {
    font-family: var(--font-typewriter);
    font-size: 34px;
    font-weight: 400;
    line-height: 1;
    margin-left: 60px;
    color: var(--black);
    margin: 0;
    letter-spacing: -0.01em;
    /* Slight offset like typewriter printing */
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.06);
}

/* ---------- Counter badge (map overlay) ---------- */
.counter-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 500;
    background: var(--yellow);
    border-radius: var(--radius-md);
    padding: 14px 22px 16px;
    text-align: center;
    font-family: var(--font-typewriter);
    line-height: 1;
    box-shadow: var(--shadow-float);
    /* Never intercept map gestures (pan, click-to-place-pin, zoom). */
    pointer-events: none;
    user-select: none;
    /* The label decides the badge width (single line, no wrapping). */
    white-space: nowrap;
}
.counter-number {
    font-family: var(--font-typewriter);
    font-size: 64px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--black);
    line-height: 0.95;
}
.counter-label {
    font-family: var(--font-typewriter);
    font-size: 15px;
    font-weight: 400;
    color: var(--black);
    margin-top: 6px;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* ---------- Main layout ---------- */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: calc(100vh - var(--topbar-h) - 36px);
    min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    overflow-y: auto;
    background: var(--paper-soft);
    border-right: 1px solid var(--paper-line);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
    position: relative;
}

.panel-title {
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--ink);
    line-height: 1.3;
}

.panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-size: 22px;
    line-height: 1;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.panel-close:hover { background: var(--paper-soft); color: var(--black); }

/* ---------- Sidebar CTA (opens the add form) ---------- */
.sidebar-cta {
    font-size: 15px;
    height: 52px;
    gap: 10px;
    padding: 0 20px;
}
.sidebar-cta[hidden] { display: none; }
.sidebar-cta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--paper);
    color: var(--black);
    font-weight: 700;
    font-size: 18px;
    line-height: 1;
}

/* ---------- Form ---------- */
.sticker-form { display: flex; flex-direction: column; gap: 14px; }

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

.field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.field-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.field-inline .input { flex: 1; min-width: 160px; }

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 13px;
    color: var(--ink-muted);
    cursor: pointer;
    white-space: nowrap;
}
.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--black);
    cursor: pointer;
}

.input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--ink);
    background: var(--yellow-soft);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input-textarea {
    height: auto;
    padding: 12px 14px;
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}
.input::placeholder { color: var(--ink-muted); opacity: 0.7; }
.input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(255, 229, 0, 0.55);
    background: var(--yellow-pale);
}
.input:disabled { opacity: 0.6; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--danger); background: #fff1ee; }

.field-hint {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--ink-faint);
}
.field-error {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--danger);
    min-height: 0;
}
.field-error:empty { display: none; }

/* ---------- Geocoding suggestions ---------- */
.location-input-wrap { position: relative; }
.suggest-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 4px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
}
.suggest-list[hidden] { display: none; }
.suggest-item {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--ink);
}
.suggest-item:hover, .suggest-item[aria-selected="true"] {
    background: var(--yellow-soft);
}

/* ---------- File upload ---------- */
input[type="file"]#fieldPhoto {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.file-dropzone {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--yellow);
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    user-select: none;
}
.file-dropzone:hover { background: var(--yellow-dark); box-shadow: var(--shadow-card); }
.file-dropzone-icon {
    font-size: 18px;
    line-height: 1;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    color: var(--black);
    border-radius: 50%;
    flex-shrink: 0;
    font-weight: 700;
}

#fieldPhoto:focus-visible + .file-dropzone {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 229, 0, 0.55);
}

.photo-preview {
    margin-top: 10px;
    position: relative;
    display: inline-block;
}
/* Native `hidden` attribute defaults to `display: none` but any explicit
   `display` rule (like `inline-block` above) silently overrides it, which
   leaves an empty <img> rendering the browser's broken-image placeholder
   before the user picks a file. Force it back off when `hidden` is set. */
.photo-preview[hidden] { display: none; }
.photo-preview img {
    max-width: 140px;
    max-height: 140px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}
.photo-remove {
    position: absolute;
    top: 6px; right: 6px;
    background: rgba(10, 10, 10, 0.8);
    color: var(--paper);
    border: none;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.photo-remove:hover { background: var(--black); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 22px;
    border: none;
    border-radius: 999px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
    background: var(--paper);
    color: var(--black);
    box-shadow: var(--shadow-card);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-float); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-card); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--yellow);
    color: var(--black);
}
.btn-primary:hover:not(:disabled) { background: var(--yellow-dark); }

.btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--paper-soft);
}
.btn-secondary:hover:not(:disabled) { background: var(--paper-soft); }

.btn-block { width: 100%; }

.btn.is-loading {
    position: relative;
    color: transparent !important;
}
.btn.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--black);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Success modal ---------- */
/*
 * Fullscreen overlay that celebrates a successful submission. The card
 * scales/fades in, the checkmark draws itself, and a ring of yellow
 * sparks bursts outward. Built with a wrapper that owns display:flex
 * centering and the [hidden] attribute for show/hide — animations live
 * on inner elements so we can key them off class toggles without
 * fighting the show/hide state.
 */
.success-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: auto;
}
.success-modal[hidden] { display: none; }

.success-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 24, 24, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: success-fade 0.25s ease both;
}

.success-modal__card {
    position: relative;
    width: min(420px, 100%);
    background: var(--paper, #fff);
    border-radius: var(--radius-lg, 16px);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.25),
        0 6px 14px rgba(0, 0, 0, 0.1);
    padding: 40px 32px 28px;
    text-align: center;
    animation: success-pop 0.38s cubic-bezier(0.2, 1.4, 0.3, 1) both;
    overflow: hidden;
}

@keyframes success-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes success-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Animated checkmark drawn via stroke-dasharray. Svg sits inside a
 * yellow circle badge that itself scales on entrance. */
.success-modal__check {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    position: relative;
    z-index: 1;
}
.success-modal__check svg {
    width: 100%;
    height: 100%;
    color: var(--black, #181818);
}
.success-modal__check-circle {
    stroke: var(--yellow, #ffd400);
    stroke-width: 4;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: success-circle-draw 0.5s 0.1s ease-out forwards;
    transform-origin: 50% 50%;
}
.success-modal__check-path {
    stroke: var(--black, #181818);
    stroke-width: 4.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: success-check-draw 0.35s 0.5s ease-out forwards;
}
@keyframes success-circle-draw {
    to { stroke-dashoffset: 0; }
}
@keyframes success-check-draw {
    to { stroke-dashoffset: 0; }
}

/* Ring of sparks that shoot outward. Each span is positioned at the
 * centre of the check and then animated outward via individual delays /
 * angles written inline with CSS custom properties below. */
.success-modal__burst {
    position: absolute;
    top: 74px;           /* aligned with the check circle center */
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 0;
}
.success-modal__burst span {
    position: absolute;
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    background: var(--yellow, #ffd400);
    border-radius: 50%;
    opacity: 0;
    --angle: 0deg;
    --distance: 90px;
    animation: success-spark 0.75s 0.25s ease-out forwards;
    transform: rotate(var(--angle)) translateY(0) scale(0.5);
}
.success-modal__burst span:nth-child(1) { --angle: 0deg;   }
.success-modal__burst span:nth-child(2) { --angle: 45deg;  }
.success-modal__burst span:nth-child(3) { --angle: 90deg;  }
.success-modal__burst span:nth-child(4) { --angle: 135deg; }
.success-modal__burst span:nth-child(5) { --angle: 180deg; }
.success-modal__burst span:nth-child(6) { --angle: 225deg; }
.success-modal__burst span:nth-child(7) { --angle: 270deg; }
.success-modal__burst span:nth-child(8) { --angle: 315deg; }

@keyframes success-spark {
    0%   { opacity: 0; transform: rotate(var(--angle)) translateY(0)                  scale(0.4); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: rotate(var(--angle)) translateY(calc(var(--distance) * -1)) scale(1); }
}

.success-modal__title {
    margin: 0 0 8px;
    font-family: var(--font-typewriter);
    font-size: 22px;
    color: var(--black);
    letter-spacing: 0.01em;
}
.success-modal__serial {
    font-family: var(--font-typewriter);
    font-size: 28px;
    color: var(--black);
    margin: 0 0 10px;
    letter-spacing: 0.06em;
}
.success-modal__message {
    margin: 0 0 22px;
    color: var(--ink-muted);
    font-size: 14px;
    line-height: 1.55;
}
.success-modal__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.success-modal__actions .btn { width: 100%; }

.success-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.success-modal__close:hover {
    background: var(--paper-soft);
    color: var(--black);
}

@media (prefers-reduced-motion: reduce) {
    .success-modal__backdrop,
    .success-modal__card,
    .success-modal__check-circle,
    .success-modal__check-path,
    .success-modal__burst span {
        animation-duration: 0.001s !important;
        animation-delay: 0s !important;
    }
}

.form-actions { margin-top: 4px; }
.form-note {
    margin: 8px 0 0;
    font-size: 13px;
    min-height: 0;
    color: var(--ink-muted);
}
.form-note.is-success { color: var(--success); font-weight: 500; }
.form-note.is-error { color: var(--danger); font-weight: 500; }

/* ---------- Details panel ---------- */
.details-serial {
    font-family: var(--font-typewriter);
    font-size: 24px;
    color: var(--black);
    letter-spacing: 0.02em;
}

.details-photo {
    margin-bottom: 14px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--paper-soft);
    box-shadow: var(--shadow-card);
}
.details-photo img { width: 100%; height: auto; display: block; }

.details-list {
    margin: 0 0 14px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 13px;
}
.details-list dt {
    color: var(--ink-faint);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    padding-top: 2px;
}
.details-list dd {
    margin: 0;
    color: var(--ink);
    font-size: 14px;
    word-break: break-word;
}
.details-coords {
    font-family: var(--font-typewriter);
    font-size: 12px !important;
    color: var(--ink-muted) !important;
}

.details-story-title {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
    padding-top: 10px;
    border-top: 1px solid var(--paper-line);
}
.details-story p {
    margin: 0;
    white-space: pre-wrap;
    font-size: 14px;
    color: var(--ink);
}

/* ---------- Map area ---------- */
.map-wrap {
    position: relative;
    overflow: hidden;
    min-width: 0;
}
#map {
    width: 100%;
    height: 100%;
    background: #dce5ed;
}
.map-coords {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    padding: 6px 12px;
    font-family: var(--font-typewriter);
    font-size: 12px;
    color: var(--ink-muted);
    border-radius: 999px;
    box-shadow: var(--shadow-card);
    z-index: 500;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

/* ---------- Leaflet marker override (yellow pin) ---------- */
.melody-pin {
    width: 28px;
    height: 28px;
    background: var(--yellow);
    border: 2px solid var(--black);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    cursor: pointer;
}
.melody-pin:hover {
    transform: scale(1.18);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.melody-pin.is-active {
    background: var(--black);
    box-shadow: 0 0 0 6px rgba(255, 229, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.3);
}
.melody-pin.is-preview {
    background: var(--yellow-soft);
    border-style: dashed;
    box-shadow: none;
    animation: preview-pulse 1.2s ease-in-out infinite;
    cursor: pointer;
}
@keyframes preview-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* Fine-tune mode: activated by double-clicking the preview pin. */
.melody-pin.is-preview.is-editing {
    background: var(--yellow);
    border-style: solid;
    border-width: 3px;
    box-shadow: 0 0 0 6px rgba(255, 229, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.3);
    animation: editing-pulse 0.9s ease-in-out infinite;
    cursor: grab;
}
.leaflet-marker-draggable.leaflet-drag-target .melody-pin.is-preview.is-editing,
.melody-pin.is-preview.is-editing:active {
    cursor: grabbing;
    animation: none;
}
@keyframes editing-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 229, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.3); }
    50%      { box-shadow: 0 0 0 10px rgba(255, 229, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.3); }
}

/* ---------- Permanent photo bubble (Google Maps-style label) ---------- */
.photo-bubble-icon {
    background: transparent;
    border: none;
    pointer-events: none; /* children re-enable for the bubble itself */
}

.photo-bubble {
    position: relative;
    /* width/height are set inline by map.js based on the real photo aspect
       ratio; these are fallbacks for the first paint before measurement. */
    width: 80px;
    height: 80px;
    margin: 0 auto;
    border-radius: var(--radius-md);
    background: var(--paper);
    padding: 3px;
    overflow: visible;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    animation: photo-bubble-in 0.2s ease-out;
}
.photo-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}
.photo-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--radius-md) - 3px);
    user-select: none;
    -webkit-user-drag: none;
}
/* Triangle tail pointing down to the pin (white body + subtle shadow) */
.photo-bubble::before,
.photo-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}
.photo-bubble::before {
    bottom: -9px;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 10px solid rgba(0, 0, 0, 0.12);
    filter: blur(2px);
}
.photo-bubble::after {
    bottom: -7px;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 9px solid var(--paper);
}

@keyframes photo-bubble-in {
    from { opacity: 0; transform: translateY(6px) scale(0.85); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Hover card (desktop only, attached to marker tooltip) ---------- */
.leaflet-tooltip.hover-card-tooltip {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    white-space: normal;
    pointer-events: none;
    animation: hover-card-in 0.12s ease-out;
}
.leaflet-tooltip.hover-card-tooltip::before { display: none; }

.hover-card {
    display: flex;
    gap: 10px;
    align-items: stretch;
    background: var(--paper);
    border-radius: var(--radius-md);
    padding: 10px;
    box-shadow: var(--shadow-float);
    max-width: 240px;
    min-width: 160px;
    font-family: var(--font-ui);
    color: var(--ink);
}

.hover-card-photo {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--paper-soft);
}
.hover-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hover-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    line-height: 1.3;
}
.hover-card-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hover-card-place {
    font-size: 12px;
    color: var(--ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hover-card-serial {
    font-family: var(--font-typewriter);
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 2px;
}

@keyframes hover-card-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Activity feed ---------- */
.panel-feed { padding: 18px 20px; }

.feed-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.feed-empty {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--ink-faint);
}

.feed-item {
    display: block;
    padding: 12px 10px;
    margin: 0 -10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--paper-line);
    /* Let the sentence wrap to two or three lines. Long words like a
       full Nominatim address can break mid-word so we never blow the
       sidebar width. */
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-muted);
    overflow-wrap: anywhere;
    word-break: break-word;
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover,
.feed-item:focus-visible {
    background: var(--paper-soft);
    outline: none;
}
.feed-item.is-active {
    background: var(--yellow-pale);
}

.feed-who {
    font-weight: 700;
    color: var(--ink);
}
.feed-serial {
    font-family: var(--font-typewriter);
    color: var(--ink);
    font-size: 12px;
}
.feed-where {
    color: var(--ink);
    font-weight: 500;
}
.feed-when {
    font-family: var(--font-typewriter);
    font-size: 11px;
    color: var(--ink-faint);
}

/* ---------- Footer ---------- */
.appfoot {
    height: 36px;
    padding: 0 24px;
    background: var(--black);
    color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    text-align: center;
}
.appfoot p { margin: 0; }
.appfoot a { color: var(--yellow); text-decoration: underline; }
.appfoot strong { color: var(--yellow); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    :root { --sidebar-w: 320px; }
    .brand-title { font-size: 26px; }
    .counter-badge { top: 14px; right: 14px; padding: 12px 18px 14px; }
    .counter-number { font-size: 44px; }
    .counter-label { font-size: 12px; margin-top: 6px; }
}

@media (max-width: 720px) {
    :root { --topbar-h: 56px; }
    body { overflow: auto; }
    .topbar { padding: 0 14px; }
    .brand-title { font-size: 22px; }

    .counter-badge {
        top: 10px;
        right: 10px;
        padding: 10px 14px 12px;
    }
    .counter-number { font-size: 30px; }
    .counter-label { font-size: 10px; margin-top: 4px; }

    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 50vh auto;
        height: auto;
    }
    .map-wrap { order: 1; min-height: 300px; }
    .sidebar {
        order: 2;
        border-right: none;
        border-top: 1px solid var(--paper-line);
        max-height: none;
    }
    .appfoot { height: auto; padding: 10px 14px; }
    .appfoot p { line-height: 1.4; }
}

@media (max-width: 480px) {
    .input, .btn { font-size: 16px; } /* Prevent iOS zoom */
    .btn { height: 44px; }
    .input { height: 40px; }
}
