* {
    box-sizing: border-box;
}

:root {
    --bg: #e9efe5;
    --surface: #f8f6ef;
    --surface-strong: #ffffff;
    --surface-muted: #edf2e7;
    --text: #1f2d1f;
    --muted: #5d6b5d;
    --line: rgba(31, 45, 31, 0.12);
    --primary: #214d32;
    --primary-strong: #173725;
    --accent: #b88b2d;
    --danger: #9d3d2f;
    --shadow: 0 18px 50px rgba(33, 77, 50, 0.08);
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(184, 139, 45, 0.12), transparent 26%),
        radial-gradient(circle at top right, rgba(33, 77, 50, 0.16), transparent 32%),
        linear-gradient(180deg, #eef4e9 0%, #e4ecdf 100%);
    color: var(--text);
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

img {
    display: block;
    max-width: 100%;
}

.app-shell {
    max-width: 1460px;
    margin: 0 auto;
    padding: 24px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    padding: 28px;
    background: linear-gradient(135deg, rgba(33, 77, 50, 0.95), rgba(59, 112, 61, 0.92));
    border-radius: 24px;
    color: #f9f8f1;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 8px 0 0;
    max-width: 720px;
    font-size: clamp(2rem, 4vw, 3.45rem);
    line-height: 1.03;
}

.eyebrow {
    margin: 0;
    color: rgba(249, 248, 241, 0.74);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.hero-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.user-chip,
.pill,
.selection-chip,
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 0.88rem;
}

.user-chip,
.pill {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.selection-chip {
    background: var(--surface-muted);
    color: var(--primary);
    border: 1px solid rgba(33, 77, 50, 0.18);
}

.flash {
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.flash-success {
    background: rgba(33, 77, 50, 0.08);
    color: var(--primary-strong);
}

.flash-error {
    background: rgba(157, 61, 47, 0.08);
    color: #6e241b;
}

.sync-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(33, 77, 50, 0.12);
    background: rgba(255, 247, 225, 0.92);
    color: #5b4a17;
}

.sync-banner strong {
    color: #6b5315;
}

.sync-banner.is-warning {
    background: rgba(157, 61, 47, 0.08);
    border-color: rgba(157, 61, 47, 0.16);
    color: #6e241b;
}

.sync-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(184, 139, 45, 0.16);
    color: #7c5b17;
    font-size: 0.84rem;
    font-weight: 700;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 24px;
    margin-top: 24px;
}

.feature-panel,
.auth-panel,
.panel,
.stat-card {
    background: rgba(248, 246, 239, 0.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: var(--shadow);
}

.feature-panel {
    display: grid;
    gap: 18px;
    padding: 24px;
    border-radius: 24px;
}

.feature-card {
    padding: 22px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(237, 242, 231, 0.9));
    border: 1px solid rgba(33, 77, 50, 0.08);
}

.feature-card h2,
.panel-heading h2,
.map-card h3,
.recorder-panel h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.feature-card p,
.map-card p,
.recorder-panel p,
.note-block {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.auth-panel {
    padding: 22px;
    border-radius: 24px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-tab,
.secondary-button,
.ghost-button,
.danger-button {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

.auth-tab.is-active,
.secondary-button:hover,
.ghost-button:hover {
    border-color: rgba(33, 77, 50, 0.28);
    background: rgba(33, 77, 50, 0.08);
}

.auth-form {
    display: none;
    gap: 16px;
}

.auth-form.is-active {
    display: grid;
}

.auth-note,
.security-copy,
.security-warning {
    margin: 0;
    line-height: 1.5;
}

.auth-note,
.security-copy {
    color: var(--muted);
}

.security-warning {
    color: #6e241b;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

input,
textarea,
select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
}

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

.primary-button {
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #d2a64a);
    color: #1f1705;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(184, 139, 45, 0.22);
}

.primary-button:hover,
.danger-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.species-item:hover {
    transform: translateY(-1px);
}

.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
}

.dashboard {
    margin-top: 24px;
}

.security-panel {
    margin-bottom: 18px;
}

.security-passkey-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin: 18px 0 12px;
}

.passkey-display {
    min-height: 56px;
    padding: 14px 18px;
    border: 1px solid rgba(33, 77, 50, 0.12);
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-strong);
    font-size: clamp(1.1rem, 2.3vw, 1.45rem);
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
}

.copy-button {
    min-width: 144px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.stat-card {
    padding: 20px;
    border-radius: 20px;
}

.stat-value {
    display: block;
    font-size: clamp(1.8rem, 3vw, 2.7rem);
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--muted);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
    gap: 20px;
    margin-top: 20px;
}

.panel {
    padding: 22px;
    border-radius: 24px;
}

.panel + .panel {
    margin-top: 20px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.panel-heading .eyebrow {
    color: var(--accent);
}

.panel-heading h2 {
    margin-bottom: 0;
}

.checklist-panel,
.composer-panel,
.map-panel,
.sightings-panel {
    min-width: 0;
}

.search-field span {
    color: var(--text);
}

.species-list {
    display: grid;
    gap: 10px;
    max-height: 740px;
    padding-right: 6px;
    overflow: auto;
}

.species-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(33, 77, 50, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(237, 242, 231, 0.82));
    text-align: left;
    cursor: pointer;
}

.species-item.is-selected {
    border-color: rgba(184, 139, 45, 0.7);
    box-shadow: inset 0 0 0 1px rgba(184, 139, 45, 0.3);
}

.species-item.is-seen .species-state {
    background: rgba(33, 77, 50, 0.1);
    color: var(--primary);
}

.species-item.is-hidden,
.sighting-card.is-hidden {
    display: none;
}

.species-meta {
    display: grid;
    gap: 4px;
}

.species-meta small {
    color: var(--muted);
}

.species-state {
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(184, 139, 45, 0.12);
    color: #825f18;
    white-space: nowrap;
    font-size: 0.82rem;
}

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

.field-actions,
.toggle-row,
.recorder-actions,
.record-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.field-actions {
    align-items: end;
}

.full-width {
    grid-column: 1 / -1;
}

.full-width-button {
    width: 100%;
    margin-top: 20px;
}

.form-action-row {
    margin-top: 20px;
    align-items: center;
}

.recorder-panel,
.map-card {
    margin-top: 20px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(237, 242, 231, 0.86));
    border: 1px solid rgba(33, 77, 50, 0.08);
}

.recorder-actions {
    margin-top: 14px;
}

.recording-status {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(33, 77, 50, 0.08);
    color: var(--primary);
}

.map-card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 14px;
}

.map-style-control {
    min-width: 180px;
}

.map-style-control span {
    color: var(--text);
}

.map-surface {
    width: 100%;
    height: 360px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(33, 77, 50, 0.12);
}

.history-map {
    height: 480px;
}

.entry-pin-icon {
    background: transparent;
    border: 0;
}

.entry-pin-core {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    background: linear-gradient(135deg, #d9872b, #b63a2b);
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 18px rgba(33, 77, 50, 0.24);
    transform: rotate(-45deg);
}

.entry-pin-core::after {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.toggle-row {
    align-items: end;
}

.map-summary-grid,
.meta-tag-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.map-summary-grid {
    margin-bottom: 14px;
}

.summary-chip,
.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(33, 77, 50, 0.1);
    background: rgba(255, 255, 255, 0.72);
}

.summary-chip strong {
    color: var(--primary);
}

.summary-chip span,
.meta-tag {
    color: var(--muted);
    font-size: 0.88rem;
}

.meta-tag-row {
    margin-top: 14px;
}

.meta-tag-accent {
    background: rgba(184, 139, 45, 0.14);
    color: #7b5a16;
}

.meta-tag-pending {
    background: rgba(184, 139, 45, 0.18);
    color: #7b5a16;
    font-weight: 700;
}

.map-footnote {
    margin: 0 0 14px;
    color: var(--muted);
}

.sightings-list {
    display: grid;
    gap: 16px;
}

.sighting-card {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(243, 247, 237, 0.92));
    border: 1px solid rgba(33, 77, 50, 0.08);
}

.sighting-card.is-focused {
    border-color: rgba(184, 139, 45, 0.7);
    box-shadow: inset 0 0 0 1px rgba(184, 139, 45, 0.26), 0 14px 34px rgba(33, 77, 50, 0.08);
}

.sighting-card.is-pending {
    border-style: dashed;
    border-color: rgba(184, 139, 45, 0.52);
}

.sighting-topline,
.sighting-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.sighting-topline h3 {
    margin: 0;
}

.sighting-topline p,
.sighting-meta {
    margin: 6px 0 0;
    color: var(--muted);
}

.count-badge {
    background: rgba(184, 139, 45, 0.16);
    color: #7c5b17;
}

.note-block {
    margin-top: 14px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.media-thumb {
    display: block;
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(33, 77, 50, 0.08);
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sighting-card audio,
#recording-preview {
    width: 100%;
    margin-top: 12px;
}

.locate-button {
    margin-top: 16px;
}

.record-action-row {
    margin-top: 16px;
    align-items: center;
}

.delete-form {
    margin-top: 16px;
}

.inline-delete-form {
    margin-top: 0;
}

.danger-button {
    min-width: 100px;
    background: rgba(157, 61, 47, 0.08);
    color: var(--danger);
    border-color: rgba(157, 61, 47, 0.22);
}

.empty-state {
    padding: 26px;
    border-radius: 20px;
    border: 1px dashed rgba(33, 77, 50, 0.18);
    background: rgba(255, 255, 255, 0.55);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #f8f6ef;
}

@media (max-width: 1180px) {
    .workspace,
    .auth-layout,
    .security-passkey-row,
    .stats-grid,
    .filters-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        padding: 14px;
    }

    .hero {
        padding: 22px;
        border-radius: 20px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .panel,
    .auth-panel,
    .feature-panel,
    .stat-card {
        border-radius: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .map-card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .species-list {
        max-height: 420px;
    }

    .map-surface,
    .history-map {
        height: 320px;
    }
}

.profile-panel {
    margin-top: 24px;
    padding: 24px;
    border-radius: 24px;
}

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.meta-tag-shared {
    background: rgba(33, 77, 50, 0.08);
    color: var(--primary-strong);
}

@media (max-width: 820px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}
