:root {
    --bg: #fafaf7;
    --fg: #222;
    --muted: #6b6b6b;
    --accent: #2a6f3b;
    --accent-dark: #1d4f2a;
    --border: #e5e5e0;
    --error: #b3261e;
    --warning: #b35900;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

.site-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    color: var(--accent);
}
nav a, nav .link-button {
    margin-left: 1rem;
    color: var(--fg);
    text-decoration: none;
}
nav a:hover { text-decoration: underline; }
.inline { display: inline; }

.link-button {
    background: none; border: none; padding: 0;
    cursor: pointer; font: inherit; color: inherit;
}

.site-footer {
    margin-top: 4rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.875rem;
}

h1 { margin-top: 0; }

.trip-map {
    width: 100%;
    height: 500px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    background: #e9eef2;
}

.trip-image {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: 8px;
    margin: 1rem 0 1.5rem 0;
}

.image-fs { background: white; }
.image-fs input[type="file"] {
    margin-top: 0.4rem;
    font-family: inherit;
}
.existing-image {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.existing-image img {
    width: 200px;
    max-height: 140px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.existing-image .checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    flex-direction: row;
}

.trip-list { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.trip-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.trip-list a { font-weight: 600; text-decoration: none; }
.trip-list a:hover { text-decoration: underline; }
.meta { color: var(--muted); margin-left: 0.5rem; font-size: 0.9rem; font-weight: 400; }

.year-group { margin-bottom: 1.5rem; }
.year-group h3 {
    margin: 1.25rem 0 0.5rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--accent);
    color: var(--accent-dark);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.trip-form, .login-form {
    display: flex; flex-direction: column; gap: 1rem;
    max-width: 700px;
}
.trip-form label, .login-form label {
    display: flex; flex-direction: column; gap: 0.25rem;
    font-weight: 500;
}
.trip-form input, .trip-form textarea, .login-form input {
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
}
.trip-form input:focus, .trip-form textarea:focus, .login-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

button.primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    align-self: flex-start;
}
button.primary:hover { background: var(--accent-dark); }

button.secondary {
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}
button.secondary:hover { border-color: var(--accent); color: var(--accent); }

fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    background: white;
}
legend { font-weight: 600; padding: 0 0.5rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin-top: 0; }

.form-map {
    width: 100%;
    height: 420px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
    background: #e9eef2;
    cursor: crosshair;
}

.route-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
#route-status { font-size: 0.9rem; }

.place-rows { margin-top: 0.5rem; }

.place-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border);
}
.place-row:last-child { border-bottom: none; }

.place-num {
    width: 28px; height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.place-row[data-has-coords="0"] .place-num {
    background: var(--muted);
}

.place-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
}
.place-fields .place-coords-input {
    grid-column: 1 / -1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}
.place-fields .place-coords-input.invalid {
    border-color: var(--error);
    background: #fdecea;
}

.place-controls {
    display: flex;
    gap: 0.25rem;
}
.place-controls button {
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.place-controls button:hover { border-color: var(--accent); }
.place-controls .row-remove {
    color: var(--error);
    border-color: var(--error);
}
.place-controls .row-remove:hover { background: var(--error); color: white; }

.pin-numbered {
    width: 30px; height: 30px;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
}
.pin-numbered.pin-loop {
    background: var(--accent-dark);
    font-size: 1.15rem;
    font-weight: 400;
}

@media (max-width: 600px) {
    .place-row { grid-template-columns: auto 1fr; }
    .place-controls { grid-column: 1 / -1; justify-content: flex-end; }
    .place-fields { grid-template-columns: 1fr; }
}

.errors {
    background: #fdecea;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.75rem 1rem 0.75rem 2rem;
    border-radius: 4px;
}

.error { color: var(--error); }
.warning { color: var(--warning); font-size: 0.85rem; }

.places { padding-left: 1.5rem; }
.places .place-desc { color: var(--muted); margin-left: 0.5rem; font-size: 0.9rem; }

.description {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.admin-actions {
    margin-top: 2rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.secondary-link {
    display: inline-block;
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    color: var(--fg);
    font-size: 0.95rem;
}
.secondary-link:hover { border-color: var(--accent); color: var(--accent); }

.danger { margin: 0; }
.danger button {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}
.danger button:hover { background: var(--error); color: white; }

.pin {
    width: 18px; height: 18px;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.maplibregl-popup-content {
    font-family: inherit;
    padding: 0.75rem 1rem;
    border-radius: 6px;
}
.maplibregl-popup-content strong { color: var(--accent-dark); }

