:root {
    --ink: #1c2733;
    --muted: #5c6b7a;
    --bg: #f4f6f8;
    --card: #ffffff;
    --accent: #2563eb;
    --line: #d9e0e7;
    --idea: #64748b;
    --planned: #d97706;
    --completed: #15803d;
    --danger: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
main { padding: 1rem; max-width: 64rem; margin: 0 auto; }
.narrow { max-width: 26rem; margin: 3rem auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: .6rem 1rem; margin: .75rem auto 0; max-width: 64rem; border-radius: 8px; }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.error-text { color: var(--danger); }
label { display: block; margin: .75rem 0 .25rem; font-weight: 600; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=email], select, textarea {
    width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
textarea { min-height: 7rem; }
button, .btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: .55rem 1rem; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; vertical-align: middle; }
.badge.idea { background: var(--idea); }
.badge.planned { background: var(--planned); }
.badge.completed { background: var(--completed); }
.badge.nomap { background: var(--muted); }
.muted { color: var(--muted); }
@media (min-width: 48rem) {
    main { padding: 1.5rem; }
}

/* Home: filter bar + map/list */
.filterbar { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .75rem; padding: .75rem; }
.filterbar input[type=search] { grid-column: 1 / -1; }
.view-toggle { grid-column: 1 / -1; display: flex; gap: .4rem; }
.view-toggle button { flex: 1; background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.view-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mapview { height: 65vh; border-radius: 10px; border: 1px solid var(--line); }
.pin { display: block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.listview { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.listrow { display: flex; flex-direction: column; gap: .2rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.listrow:last-child { border-bottom: none; }
.listrow:hover { background: var(--bg); }
.listrow-title { font-weight: 600; }
.listrow-meta { font-size: .85rem; }
.minimap { height: 14rem; border-radius: 10px; border: 1px solid var(--line); margin: .5rem 0 1rem; }
@media (min-width: 48rem) {
    .filterbar { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
    .filterbar input[type=search] { grid-column: auto; }
    .view-toggle { grid-column: auto; }
    .mapview { height: 70vh; }
}

/* Item detail */
.item-detail h2 { margin-top: 1.75rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.statusform { display: flex; flex-wrap: wrap; gap: .5rem; }
.statusform select, .statusform input { flex: 1 1 10rem; width: auto; }
.linklist { list-style: none; padding: 0; }
.linklist li { padding: .3rem 0; }
.note { border-left: 3px solid var(--line); padding-left: .75rem; margin: .75rem 0; }

/* Add/edit idea form */
.idea-form .draftbox { border: 1px dashed var(--line); border-radius: 10px; padding: .9rem; margin-bottom: 1.25rem; background: var(--bg); }
.geocode-row, .coord-row { display: flex; gap: .5rem; }
.geocode-row input, .coord-row input { flex: 1; }
.geocode-results { list-style: none; padding: .25rem .5rem; margin: .25rem 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.geocode-results li { padding: .25rem 0; }
label.check { display: block; font-weight: 400; margin: .35rem 0; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; font-weight: normal; }
.checkbox-row input { width: auto; margin: 0; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-actions form { margin-right: .5rem; }
.admin-actions input { width: 9rem; padding: .25rem .4rem; }

/* Progress header + empty state */
.site-intro { margin: 0 0 .75rem; }
.progress { padding: .75rem 1rem; margin-bottom: .75rem; }
.progress-line { margin: 0 0 .5rem; }
.progress-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--completed); border-radius: 999px; transition: width .3s; }
.empty-state { text-align: center; padding: 2.5rem 1rem; margin-bottom: .75rem; }
.empty-state p { margin: .5rem 0; }

/* Relation typeahead */
.typeahead { position: relative; flex: 1 1 14rem; }
.typeahead-results { position: absolute; z-index: 500; left: 0; right: 0; margin: .15rem 0 0;
    list-style: none; padding: .25rem; background: var(--card); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.12); max-height: 16rem; overflow-y: auto; }
.typeahead-results li { padding: .4rem .5rem; cursor: pointer; border-radius: 6px; }
.typeahead-results li:hover { background: var(--bg); }

/* Photo gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; margin: .5rem 0 1rem; }
.gallery-item { margin: 0; }
.gallery-item img { width: 100%; height: 9rem; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.gallery-actions { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; padding: .25rem 0; }
.photo-upload { align-items: center; }

/* Cover thumbnails in list + popups */
.popup-thumb { display: block; width: 100%; max-width: 220px; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: .4rem; }
.listrow.has-thumb { flex-direction: row; align-items: center; gap: .75rem; }
.listrow-thumb { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: 8px; flex: none; }
.listrow-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }

/* Completion moment: gentle shimmer on a completed badge */
.badge.completed { position: relative; overflow: hidden; }
.badge.completed::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
    transform: translateX(-100%); animation: badge-shimmer 2.2s ease-in-out 2;
}
@keyframes badge-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .badge.completed::after { animation: none; } }

/* Memories wall */
.memories-wall { columns: 2 12rem; column-gap: .75rem; }
.memory-card { display: block; break-inside: avoid; margin: 0 0 .75rem; padding: 0; overflow: hidden; text-decoration: none; color: var(--ink); }
.memory-cover { width: 100%; display: block; }
.memory-body { padding: .6rem .75rem; display: flex; flex-direction: column; gap: .2rem; }
.memory-title { font-weight: 600; }
.memory-meta { font-size: .85rem; }
@media (min-width: 48rem) { .memories-wall { columns: 3 14rem; } }

/* Capture setup: the one-time token display + Shortcut recipe */
.token { display: block; padding: .6rem; background: #f4f4f4; border-radius: 4px; word-break: break-all; font-size: .85rem; }
.steps li { margin-bottom: .5rem; }
