:root {
    --brown: #6b4a2f;
    --tan: #d9c2a3;
    --tan-hover: #cdb894;
    --cream: #faf6f0;
    --ink: #2b241d;
    --green: #3f6b3f;
    --red: #a83232;
    --text-link: var(--brown);
    --surface: #ffffff;
    --surface-glass: rgba(255,255,255,0.88);
    --border: #cccccc;
    --table-border: #eeeeee;
    --muted: #666666;
}

[data-theme="dark"] {
    --brown: #1b1b1b;
    --tan: #2a2a2a;
    --tan-hover: #383838;
    --cream: #121212;
    --ink: #e8e8e8;
    --green: #4caf50;
    --red: #ff6b6b;
    --text-link: #e0a458;
    --surface: #1e1e1e;
    --surface-glass: rgba(24,24,24,0.82);
    --border: #3a3a3a;
    --table-border: #333333;
    --muted: #a0a0a0;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--cream);
    color: var(--ink);
}

.topnav {
    background: var(--brown);
    color: white;
}
.nav-inner {
    max-width: 920px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    flex-wrap: wrap;
}
.topnav .brand { color: white; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; align-items: center; }
.nav-links a { color: white; text-decoration: none; margin-left: 20px; font-size: 0.95rem; }
.nav-links a:hover { text-decoration: underline; }
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    border-radius: 6px;
    padding: 4px 10px;
    margin-left: 20px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); }

main { max-width: 920px; margin: 0 auto; padding: 24px; }
/* Plain links in page content follow the theme (amber in dark mode) rather
   than the browser's default blue. More specific classes still override this. */
main a { color: var(--text-link); }

h1 { margin-top: 0; }

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.page-header-row h1 { margin: 0; }
.btn-add-find {
    background: var(--green);
    color: white;
    text-decoration: none;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    white-space: nowrap;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.btn-add-find:active { transform: translateY(1px); }

.conditions-panel {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.condition-block {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.condition-icon { font-size: 1.6rem; line-height: 1; }
.condition-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.condition-value { font-size: 0.95rem; font-weight: 600; margin-top: 2px; }

.login-page { margin: 0; }
.login-fullbleed {
    min-height: 100vh;
    background-size: cover;
    background-position: 25% center;
    background-color: #e2965a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 24px;
}
.login-fullbleed-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(20,15,10,0.28) 0%, rgba(15,10,8,0.55) 100%);
}
.login-box {
    position: relative;
    z-index: 1;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 36px;
    border-radius: 14px;
    box-shadow: 0 12px 45px rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.25);
    text-align: center;
    max-width: 340px;
    width: 100%;
}
.login-box h1 {
    font-size: 1.5rem;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}
.login-tagline {
    margin: 0 0 20px;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}
.login-box form { display: flex; flex-direction: column; gap: 10px; }
.login-box input { padding: 12px; width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 1rem; }
.login-box button { padding: 12px 20px; background: var(--brown); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 1rem; font-weight: 600; }

@media (max-width: 760px) {
    .login-fullbleed { padding: 16px; }
    .login-box { padding: 28px 24px; }
}

.find-form { background: var(--surface); padding: 24px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.find-form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 0.9rem; }
.find-form input, .find-form select, .find-form textarea {
    display: block; width: 100%; margin-top: 4px; padding: 9px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 1rem; font-weight: 400; background: var(--surface); color: var(--ink);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

button.secondary {
    background: var(--surface); border: 1px solid var(--text-link); color: var(--text-link);
    padding: 8px 14px; border-radius: 6px; cursor: pointer; margin: 10px 0;
}
button.primary {
    background: var(--green); color: white; border: none; padding: 12px 20px;
    border-radius: 6px; font-size: 1rem; cursor: pointer; margin-top: 16px;
}

.hint { font-size: 0.85rem; color: var(--muted); margin: 4px 0; }
.error { color: var(--red); font-weight: 600; }
.success { color: var(--green); font-weight: 600; }

.finds-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--surface); border-radius: 8px; overflow: hidden; }
.finds-table th, .finds-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--table-border); font-size: 0.9rem; }
.finds-table th { background: var(--tan); }
.finds-table th.sortable { cursor: pointer; user-select: none; }
.finds-table th.sortable:hover { background: var(--tan-hover); }
.sort-arrow { font-size: 0.7rem; margin-left: 4px; opacity: 0.7; }
.col-show { width: 46px; text-align: center; }
.finds-table td.col-show { text-align: center; }
.show-toggle { width: 16px; height: 16px; cursor: pointer; }

.link-btn { background: none; border: none; color: var(--text-link); text-decoration: underline; cursor: pointer; font-size: 0.85rem; padding: 0; margin-right: 8px; }
.link-btn.danger { color: var(--red); }

.current-photo { margin-bottom: 14px; }
.current-photo img { max-width: 220px; border-radius: 8px; display: block; margin-bottom: 6px; }
.find-form label.checkbox-label { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 0.85rem; margin-bottom: 14px; }
.checkbox-label input { width: auto; margin: 0; }

/* Fixed-height box so the editor is the same size whichever way the photo
   is turned. Sizing it from the photo (the old max-height) meant a rotated
   landscape shot overflowed and got clipped. */
.crop-container {
    width: 100%;
    height: min(420px, 70vh);
    overflow: hidden;
    border-radius: 8px;
    background: #222;
    margin-top: 8px;
}
.crop-container img { display: block; max-width: 100%; max-height: 100%; }
.crop-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.crop-controls button { padding: 8px 14px; margin: 0; }

.secondary-link { display: inline-block; margin-left: 12px; color: var(--text-link); font-size: 0.9rem; }

.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img {
    max-width: 92%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.lightbox-close {
    position: absolute;
    top: 18px;
    right: 28px;
    color: white;
    font-size: 2.2rem;
    line-height: 1;
    cursor: pointer;
    font-weight: 300;
}

/* Popups now open beside the pin rather than above it (see popupAnchor in
   app.js), so the default downward-pointing tip no longer lines up — hide
   it and rely on a soft shadow instead for a clean floating card look. */
.leaflet-popup.find-popup .leaflet-popup-tip-container {
    display: none;
}
.leaflet-popup.find-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    background: var(--surface);
    color: var(--ink);
}
.leaflet-popup.find-popup .leaflet-popup-content {
    max-height: 360px;
    overflow-y: auto;
    margin: 12px 16px;
}
.leaflet-popup.find-popup a { color: var(--text-link); }

/* Note: the OpenStreetMap map tiles themselves stay light in dark mode —
   they're pre-rendered images from OpenStreetMap, not something our CSS can
   recolour without a different (often paid) dark tile provider. */

/* Show/hide toggle inside the login password field */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.login-box .password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}
.login-box .password-toggle:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .login-box .password-toggle:hover { background: rgba(255,255,255,0.08); }

/* Second line under a table cell / popup line (period, grid reference) */
.sub { font-size: 0.78rem; color: var(--muted); }
.finds-header-row { margin-top: 24px; margin-bottom: 0; }
.finds-header-row h2 { margin: 0; }
.export-links { margin: 0; }
@media (max-width: 600px) {
    .finds-table .col-site { display: none; }
}
