body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding-top: 70px; /* reserve space for fixed topbar */
}

/* Bird details and full-image viewer */
.bird-panel-open { overflow: hidden; }
.info-panel, .image-viewer { box-sizing:border-box; font-family:system-ui, -apple-system, 'Segoe UI', sans-serif; color:#20332e; }
.info-panel *, .image-viewer * { box-sizing:border-box; }
.info-panel [hidden], .image-viewer [hidden] { display:none !important; }
.info-panel button, .image-viewer button { font:inherit; cursor:pointer; }
.info-panel button:disabled, .image-viewer button:disabled { opacity:.4; cursor:default; }
.info-panel :focus-visible, .image-viewer :focus-visible { outline:3px solid #51a58b; outline-offset:3px; }
.info-panel-overlay { position:fixed; inset:0; background:rgba(15,30,25,.42); backdrop-filter:blur(3px); z-index:1900; }
.info-panel { position:fixed; top:6vh; left:max(12px, calc(50vw - 290px)); width:580px; height: min(820px, 88vh); max-width:calc(100vw - 24px); max-height:calc(100dvh - 24px); min-width:min(360px, calc(100vw - 24px)); min-height:min(440px, calc(100dvh - 24px)); background:#fff; border:1px solid #d8e2dc; border-radius:18px; box-shadow:0 24px 80px #10281d40; z-index:2000; display:flex; flex-direction:column; overflow:hidden; }
.info-panel.is-maximized { inset:12px !important; width:calc(100vw - 24px) !important; height:calc(100dvh - 24px) !important; }
.info-panel:focus { outline:none; }
.info-panel-header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:18px 22px; border-bottom:1px solid #e9eeeb; flex-shrink:0; cursor:move; touch-action:none; user-select:none; }
.panel-heading { min-width:0; }
.panel-eyebrow { display:block; color:#638174; font-size:10px; letter-spacing:.14em; font-weight:700; margin-bottom:5px; }
.info-panel h2, .image-viewer h2 { font-size:20px; line-height:1.25; font-weight:650; margin:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.panel-header-actions { display:flex; gap:6px; }
.icon-button { width:36px; height:36px; display:inline-flex; align-items:center; justify-content:center; border:1px solid transparent; background:transparent; color:inherit; border-radius:9px; font-size:23px !important; flex-shrink:0; }
.icon-button:hover { background:#eaf0ed; }
.primary-button, .secondary-button { border-radius:8px; padding:8px 12px; font-size:12px !important; font-weight:600 !important; white-space:nowrap; }
.primary-button { background:#24694e; color:white; border:1px solid #24694e; }
.primary-button:hover { background:#194d39; }
.secondary-button { background:#f5f8f6; color:#355448; border:1px solid #dce5df; }
.secondary-button:hover { background:#e8f0eb; }
.text-button { border:0; background:transparent; color:#24694e; font-size:12px !important; font-weight:600 !important; padding:6px 0; }
.text-button:hover { text-decoration:underline; }
.info-panel-content { flex:1; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
.bird-image-wrapper { flex:0 0 45%; min-height:110px; display:flex; flex-direction:column; padding:14px 20px 0; }
.bird-image-container { flex:1; min-height:0; width:100%; display:flex; align-items:center; justify-content:center; background:#f1f4f2; border:1px solid #e9eeeb; border-radius:12px; overflow:hidden; }
.bird-image-container img { display:block; width:100%; height:100%; object-fit:contain; cursor:default; }
.image-caption { display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:32px; font-size:11px; color:#77887e; flex-shrink:0; }
.image-empty { text-align:center; color:#667b70; font-size:14px; padding:12px; }
.image-empty span { display:block; font-size:12px; margin-top:7px; color:#849389; }
.bird-details-scroll { min-height:0; flex:1; overflow:auto; overscroll-behavior:contain; padding:4px 22px 20px; }
.review-status-container { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 0 14px; }
.review-status-text { color:#6b7b72; font-size:12px; }
.review-status-text.needs-review { color:#996322; }
.image-editor-panel { border-top:1px solid #e7ede9; border-bottom:1px solid #e7ede9; }
.image-editor-panel summary { padding:13px 0; cursor:pointer; font-size:13px; font-weight:600; }
.image-editor-panel summary span { margin-left:8px; color:#809087; font-size:11px; font-weight:400; }
.image-editor-body { padding:0 0 14px; }
.image-editor-body label { display:block; margin:8px 0; font-size:12px; color:#4d6357; }
.image-input-row { display:flex; align-items:center; gap:8px; }
.image-input-row input { min-width:0; flex:1; width:100%; font:inherit; font-size:12px; }
.image-input-row input[type=text] { border:1px solid #d6e0d9; padding:9px 10px; border-radius:8px; }
.image-input-row input::file-selector-button { border:1px solid #d6e0d9; border-radius:7px; padding:7px; background:#f4f7f5; cursor:pointer; margin-right:8px; }
.image-editor-body p { color:#819087; font-size:11px; line-height:1.5; }
.image-editor-footer { display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding-top:10px; font-size:12px; }
.danger-button { color:#a04f48; }
.notes-heading { display:flex; justify-content:space-between; align-items:center; padding:14px 0 8px; }
.notes-heading h3 { margin:0; font-size:14px; font-weight:650; }
.notes-edit-toolbar { display:flex; flex-wrap:wrap; gap:4px; padding:7px; background:#f4f7f5; border-radius:8px 8px 0 0; }
.notes-edit-toolbar button { background:transparent; border:0; border-radius:5px; padding:6px 8px; font-size:12px; color:#486252; }
.notes-edit-toolbar button:hover { background:#dfeae3; }
.bird-notes-container { min-height:70px; padding:6px 0; font-size:13px; line-height:1.7; overflow-wrap:anywhere; }
.bird-notes-container[contenteditable=true] { min-height:130px; border:1px solid #bdd2c5; border-radius:0 0 8px 8px; padding:12px; }
.bird-notes-container p { margin:0 0 8px; }
.bird-notes-container.placeholder { color:#89968e; }
.bird-notes-container img { max-width:100%; height:auto; }
.bird-notes-container table { max-width:100%; }
.notes-actions { display:flex; gap:8px; margin-top:10px; }
.notes-status { font-size:12px; margin-top:6px; }
.panel-resize-handle { position:absolute; right:0; bottom:0; width:18px; height:18px; cursor:nwse-resize; touch-action:none; background:linear-gradient(135deg, transparent 55%, #a2b9ac 56%, #a2b9ac 62%, transparent 63%, transparent 72%, #a2b9ac 73%, #a2b9ac 79%, transparent 80%); }
.is-maximized .panel-resize-handle { display:none; }
.image-viewer { width: min(1200px, 94vw); height:92dvh; max-width:calc(100vw - 16px); max-height:calc(100dvh - 16px); padding:0; border:1px solid #3d5048; border-radius:16px; background:#14221c; color:#e8f0eb; box-shadow:0 24px 100px #0008; overflow:hidden; }
.image-viewer[open] { display:flex; flex-direction:column; }
.image-viewer::backdrop { background:rgba(5,12,8,.8); backdrop-filter:blur(5px); }
.viewer-header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:16px 22px; flex-shrink:0; }
.viewer-header > div { min-width:0; }
.image-viewer .panel-eyebrow { color:#90b29f; }
.image-viewer .icon-button:hover { background:#31473a; }
.viewer-viewport { flex:1; min-height:0; position:relative; overflow:hidden; background:#0c1510; touch-action:none; user-select:none; }
.viewer-viewport.is-ready { cursor:zoom-in; }
.viewer-viewport.at-max-zoom { cursor:default; }
.viewer-viewport.can-pan { cursor:grab; }
.viewer-viewport.is-panning { cursor:grabbing; }
#viewerImage { position:absolute; left:50%; top:50%; max-width:none; max-height:none; transform-origin:center; user-select:none; pointer-events:none; }
.viewer-message { position:absolute; inset:0; display:grid; place-items:center; margin:0; color:#aec1b5; font-size:14px; }
.viewer-toolbar { display:flex; align-items:center; justify-content:center; gap:18px; flex-shrink:0; flex-wrap:wrap; padding:12px 20px; border-top:1px solid #293d31; }
.viewer-zoom-controls { display:flex; gap:8px; align-items:center; }
#viewerZoomLabel { font-size:12px; font-variant-numeric:tabular-nums; min-width:44px; text-align:center; }
.image-viewer .secondary-button { background:#253b2e; border-color:#3c5747; color:#d9e7de; }
.pan-button { display:inline-flex; align-items:center; gap:7px; }
.pan-button[aria-pressed=true] { border-color:#8daf9b; background:#375742; }
.viewer-hint { font-size:11px; color:#90a598; }
@media(max-width:600px) {
    .info-panel-header { padding:12px 16px; }
    .bird-image-wrapper { padding:10px 12px 0; }
    .bird-details-scroll { padding:4px 16px 16px; }
    .image-viewer { width:calc(100vw - 16px); height:calc(100dvh - 16px); }
    .viewer-toolbar { gap:8px; padding:10px; }
    .viewer-hint { display:none; }
    .image-caption > span { font-size:10px; }
}

.topbar {
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 55px;
    background: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    padding: 8px 36px 8px 20px; /* extra right padding to avoid overlap with scrollbars */
    font-size: 16px;
    font-weight: bold;
    z-index: 1000;
    gap: 10px;
    flex-wrap: wrap; /* allow items to wrap rather than overflow */
}

.topbar-left { display:flex; align-items:center; gap:8px; min-width:0; }
.site-title { font-weight: bold; font-size: 2em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.my-count { color: #fff8; white-space:nowrap; font-weight: bold; font-size: 2em; }
.separator { font-weight: bold; font-size: 1.2em; }

.family {
    margin: 20px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
}

.family h2 {
    margin-top: 0;
    color: #2980b9;
}

.species {
    margin-left: 20px;
}

.count {
    color: aquamarine;
}

label {
    margin-left: 8px;
}

/* --- Review icon styles --- */
.review-icon {
    border: 0;
    font-family: inherit;
    vertical-align: text-top;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    font-weight: bold;
    font-size: 12px;
    transition: visibility 0.2s, opacity 0.2s;
    opacity: 0;
}

.review-icon.active {
    opacity: 1;
    color: white;
    background: orange;
}

.review-icon-area {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.review-icon-area:hover .review-icon:not(.active) {
    opacity: 1;
}
.review-icon:focus-visible { opacity:1; outline:2px solid #2980b9; outline-offset:2px; }

.species-info-btn {
    margin-left: 8px;
    background: #2980b9;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
}

.search-container { position: relative; display:inline-block; }
#searchBox { padding-right: 28px; height: 30px; }
.clear-btn {
    border: 0;
    background: transparent;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: rgba(0,0,0,0.4);
    cursor: pointer;
    display: none;
    user-select: none;
}

/* Filter controls in topbar */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    min-width: 0;
    max-width: 100%;
    margin-right: 12px; /* ensure a small gap from right edge */
    position: static;
    flex-wrap: wrap;
    white-space: nowrap; /* keep checkbox+label+download on same line */
}

.filter-controls > a[href="/auth/login"] { color: #a9d9fa; font-size: 14px; }
.filter-controls > button { cursor: pointer; padding: 5px 9px; }
.filter-controls > [hidden] { display:none !important; }
.owner-menu-toggle { order:10; align-self:stretch; border:0; border-left:1px solid #ffffff55; background:transparent; color:#d9ecff; padding:0 8px; cursor:pointer; font-size:16px; }
.owner-menu-toggle[aria-expanded="true"] { background:#1f3040; }
.owner-menu-panel { position:fixed; top:55px; right:0; z-index:1100; display:flex; align-items:center; gap:12px; padding:12px 18px; background:#2c3e50; color:white; border:1px solid #ffffff33; border-top:0; border-radius:0 0 0 8px; box-shadow:0 8px 20px #0004; }
.owner-menu-panel[hidden] { display:none; }
[data-owner-control]:disabled { cursor: default; opacity: .5; }

.filter-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: white;
    font-weight: normal;
    font-size: 14px;
    margin: 0;
}

.filter-controls input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

#downloadCsvLink {
    text-decoration: none;
    color: #5dade2;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
    display: inline-block;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.02);
    white-space: nowrap; /* keep link text on one line */
    margin-left: -20px; /* move link left by ~5mm (approx 20px) */
}

/* Keep the checkbox and its label position stable even if the label text changes */
.filter-controls .notseen-label {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    grid-template-rows: 20px 14px;
    column-gap: 6px;
    row-gap: 1px;
    align-items: center;
}
.filter-controls .notseen-label input { grid-column:1; grid-row:1; }
.filter-controls .notseen-label #notSeenLabel { grid-column:2; grid-row:1; }
.filter-controls #filterBirdCount { grid-column:2; grid-row:2; margin:0; color:#b7c0c8; font-size:11px; font-weight:normal; line-height:1; visibility:hidden; }
.filter-controls .notseen-label span {
    display: inline-block;
    width: 160px; /* fixed width so label changes don't push the download link */
    min-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#downloadCsvLink:hover {
    color: #85c1e9;
    text-decoration: underline;
}

/* Keep the familiar desktop header, but let each group fit before wrapping. */
.topbar-left { flex-wrap:wrap; }
.search-container { min-width:0; max-width:100%; }
#searchBox { box-sizing:border-box; max-width:100%; }

@media (max-width:760px), (max-height:500px) {
    /* A tall fixed header would consume most of a phone in landscape or with the keyboard open. */
    body { padding-top:0; }
    .topbar { position:sticky; top:0; padding:8px 16px 6px; gap:4px; font-size:14px; }
    .owner-menu-toggle { position:absolute; top:4px; right:4px; width:36px; height:36px; border-left:0; padding:0; font-size:14px; }
    .owner-menu-panel { top:44px; right:0; border-radius:0 0 0 8px; }
    .topbar-left { width:100%; gap:4px 10px; justify-content:flex-start; align-items:baseline; padding-right:40px; }
    .site-title { font-size:24px; white-space:normal; }
    .my-count { min-width:0; font-size:16px; line-height:1.5; }
    .separator { display:none; }
    .search-container { display:block; width:100%; }
    #searchBox { width:100%; height:44px; padding:10px 48px 10px 12px; font-size:16px; border:1px solid #b9c6d0; border-radius:6px; }
    .clear-btn { right:0; width:44px; height:44px; font-size:24px; }
    .filter-controls { width:100%; margin:0; gap:2px 12px; align-items:flex-start; justify-content:flex-start; white-space:normal; }
    .filter-controls > a, .filter-controls > button, .filter-controls label { min-height:44px; display:inline-flex; align-items:center; }
    .filter-controls .notseen-label { display:grid; grid-template-columns:16px auto; grid-template-rows:20px 14px; min-height:44px; flex:0 1 auto; }
    .filter-controls > button { font:inherit; border-radius:6px; border:1px solid #bac9d3; padding:8px 12px; }
    .filter-controls .notseen-label span { width:auto; white-space:normal; overflow:visible; }
    #downloadCsvLink { margin-left:0; padding:0; display:inline-flex; align-items:center; align-self:center; }
    .family { margin:8px 12px 12px; padding:12px; }
    .family h2 { font-size:19px; line-height:1.35; overflow-wrap:anywhere; margin-bottom:8px; }
    .species { margin-left:0; }
    .bird-row { display:flex; align-items:center; gap:8px; min-height:48px; padding:4px 0; }
    .bird-row > input { flex:0 0 auto; width:22px; height:22px; margin:0; }
    .bird-row > label { flex:1; min-width:0; margin:0; line-height:1.45; overflow-wrap:anywhere; }
    .bird-row em { display:block; font-size:13px; }
    .review-icon-area { width:44px; height:44px; flex:0 0 44px; display:flex; align-items:center; justify-content:center; }
    .review-icon { opacity:1; width:44px; height:44px; font-size:16px; border:8px solid #f9f9f9; padding:0; }
}

@media (hover:none) {
    .review-icon { opacity:1; }
}

/* Override saved desktop drag coordinates when rotating or resizing into a compact viewport. */
@media (max-width:760px), (max-height:500px) {
    .info-panel, .info-panel.is-maximized { inset:8px !important; width:calc(100vw - 16px) !important; height:calc(100dvh - 16px) !important; max-width:none; max-height:none; min-width:0; min-height:0; border-radius:12px; }
    .info-panel-header { cursor:default; touch-action:auto; padding:10px 12px; }
    #panelMaximizeBtn, .panel-resize-handle { display:none; }
    .info-panel h2, .image-viewer h2 { font-size:18px; white-space:normal; overflow-wrap:anywhere; }
    .info-panel .icon-button, .image-viewer .icon-button { width:44px; height:44px; }
    .info-panel .primary-button, .info-panel .secondary-button, .info-panel .text-button,
    .notes-edit-toolbar button, .image-viewer .secondary-button { min-height:44px; }
    .image-input-row { flex-wrap:wrap; }
    .image-input-row input { flex-basis:100%; font-size:16px; }
    .bird-notes-container[contenteditable=true] { font-size:16px; }
    .review-status-container { flex-wrap:wrap; }
    .image-caption > span { display:none; }
    .image-caption { justify-content:flex-end; }
    .viewer-header { padding:10px 12px; }
    .viewer-toolbar { padding:8px; gap:4px 8px; }
    .viewer-zoom-controls { gap:4px; flex-wrap:wrap; justify-content:center; }
    .viewer-hint { display:none; }
}

@media (max-height:500px) and (min-width:601px) {
    /* Side-by-side details leave room for notes and editing in phone landscape. */
    .info-panel-content { flex-direction:row; }
    .bird-image-wrapper { flex:0 0 42%; padding:10px 12px; min-width:0; }
    .bird-details-scroll { min-width:0; padding:4px 12px 12px; }
}


