@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Archivo:ital,wght@0,400;0,500;0,700;1,400&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────────────
   Bauhaus-inspired palette: white/near-black + the red/yellow/blue primary
   triad used sparingly as accents, not as big color fields. Dark mode
   (see the block at the very bottom) just swaps these same variable
   values — the near-black keyline borders become cream, the page flips
   to a warm near-black background — so everything defined against a
   variable here automatically follows the toggle in settings without
   needing its own dark-mode rule. */
:root {
    --bg:       #ffffff;
    --surface:  #ffffff;
    --surface2: #f1eee5;
    --border:   #14120f;
    --accent:   #d3392a;  /* red */
    --accent2:  #1d4e9b;  /* blue */
    --yellow:   #eeb111;
    --text:     #14120f;
    --muted:    #6f6a5e;
    --green:    #1d4e9b;  /* reuses blue for "open"/positive state */
    --red:      #d3392a;
}

/* ── Reset & Base ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Archivo', system-ui, sans-serif;
    font-weight: 400;
    line-height: 1.7;
    min-height: 100vh;
}

/* ── Page Wrapper ── */
.page-wrap {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    padding: 60px 32px 100px;
}

/* ── Typography ── */
h1 {
    font-family: 'Archivo Black', sans-serif;
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    font-weight: 400;
    line-height: 1.1;
    color: var(--text);
    text-align: left;
    letter-spacing: -0.01em;
}

h1 em {
    font-style: normal;
    color: var(--accent);
}

h2 {
    font-family: 'Archivo Black', sans-serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 20px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
}

h3 {
    font-family: 'Archivo', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    text-align: left;
}

p {
    margin-bottom: 12px;
    color: var(--text);
    font-size: 0.94rem;
    text-align: left;
}

a {
    color: var(--accent2);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Section number badge (for h2) ── */
.section-num {
    font-family: 'Archivo', monospace;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: 0.1em;
}

/* ── Label / Eyebrow text ── */
.label {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 16px;
}

/* ── Divider ── */
hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 40px 0;
}

/* ── Header ── */
header, .site-header {
    border-bottom: 2px solid var(--border);
    padding-bottom: 40px;
    margin-bottom: 56px;
}

.tagline {
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 520px;
}

/* ── Footer ── */
footer {
    margin-top: 72px;
    padding-top: 24px;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    position: static; /* override fixed positioning */
}

footer p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

/* ── Badges — solid geometric pills, not translucent tints, so they read
   as one of a small deliberate set of colors (red/yellow/blue/ink) rather
   than an arbitrary tint. Unmodified `.badge` (used for "Closed" and any
   notification type with no color match) is a solid ink pill — its
   background/text are var(--border)/var(--bg), so it inverts cleanly with
   the dark-mode toggle instead of needing its own override. ── */
.badge {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    padding: 4px 11px;
    border-radius: 99px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
    background: var(--border);
    color: var(--bg);
    border: 2px solid var(--border);
}

.badge-green  { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.badge-gold   { background: var(--yellow);  color: #14120f; border-color: var(--yellow); }
.badge-purple { background: var(--accent);  color: #fff; border-color: var(--accent); }
.badge-red    { background: var(--accent);  color: #fff; border-color: var(--accent); }

.meta-row {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0;
    padding: 18px 20px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--accent);
}

.card-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.card p {
    margin-bottom: 0;
    font-size: 0.87rem;
}

/* ── Highlight / info box ── */
.idea-box, .info-box {
    background: var(--surface);
    border: 2px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 0;
    padding: 20px 24px;
    font-size: 0.93rem;
    color: var(--text);
    line-height: 1.8;
}

/* ── Flash messages (login/register/settings) ──────────────────────────
   .flash was referenced in several views but never actually styled
   anywhere in this file, so a message like "Login failed" or "This
   username is already taken" rendered as plain, easy-to-miss text —
   nothing set it apart from the rest of the page. Reuses the same
   bordered/accent-striped look as .idea-box above so it reads as an
   important callout rather than a mistake to fix later. */
.flash {
    background: var(--surface);
    border: 2px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 0;
    padding: 14px 18px;
    margin: 0 0 20px;
    font-size: 0.93rem;
    color: var(--text);
    line-height: 1.6;
}

/* A .flash inserted client-side by frontend/events.ts (delete-entry /
   add-friend failures — there's no full-page reload afterward to show a
   server-set flash the normal way) — same look, just also removable by
   its own timeout rather than the next page load. */
.flash-transient {
    margin: 0 0 16px;
}

/* Visually hides an element while keeping it in the accessibility tree —
   used for form <label>s that exist for screen readers/autofill but would
   be visually redundant next to a placeholder-only input that already
   makes its purpose obvious on screen. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    display: table; /* override old flex */
    margin: 1em 0;
}

th {
    background: var(--surface2);
    border: none;
    border-bottom: 2px solid var(--border);
    color: var(--text);
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 14px;
    text-align: left;
}

td {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text);
    vertical-align: top;
}

tr:hover td {
    background: var(--surface2);
}

/* ── Forms ── */
input, textarea, select {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: 'Archivo', sans-serif;
    font-size: 0.94rem;
    padding: 10px 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent2);
}

input::placeholder, textarea::placeholder {
    color: var(--muted);
}

label {
    display: block;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-group {
    margin-bottom: 20px;
}

/* ── Buttons ── */
/* Just `button, .btn` — `.btn` alone already matches an <a class="btn">,
   so an extra `a.btn` here only added an unnecessary element+class
   specificity bump (0,1,1) that beat `.btn-primary`/`.btn-secondary`
   (0,1,0) for any *anchor* styled as a button (the explore sort tabs,
   the addSong "Back to your diary" link) — those never got their
   background/color overrides applied, silently falling back to this
   base rule's plain surface/text colors instead. A <button class="btn
   btn-primary"> was never affected (its highest-specificity matching
   selector here was plain "button" or ".btn", either of which loses to
   ".btn-primary" on source order), which is why this only ever showed
   up on link-shaped buttons — worst in dark mode, where the base
   text/background pair is low-contrast by design (this rule is meant to
   invert cleanly with the theme, not be read on its own). */
button, .btn {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 20px;
    border-radius: 0;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary, button[type="submit"] {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 700;
}

.btn-primary:hover, button[type="submit"]:hover {
    background: #ab2a1e;
    border-color: #ab2a1e;
    text-decoration: none;
}

.btn-secondary {
    background: transparent;
    color: var(--accent2);
    border-color: var(--accent2);
}

.btn-secondary:hover {
    background: var(--accent2);
    color: #fff;
    text-decoration: none;
}

/* ── Search page & user cards (views/search.handlebars,
   views/partials/userCard.handlebars) ── */
.search-form {
    display: flex;
    gap: 10px;
    max-width: 480px;
}

.search-result-count {
    margin: 20px 0 4px;
    font-size: 0.85rem;
}

#search-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 8px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0;
    padding: 14px 18px;
    transition: border-color 0.2s;
}

.user-card:hover {
    border-color: var(--accent);
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    display: block;
    font-family: 'Archivo Black', sans-serif;
    font-size: 1rem;
    color: var(--text);
}

.user-card-name:hover {
    color: var(--accent);
}

.user-card-fullname {
    font-size: 0.82rem;
    margin: 2px 0 0;
}

.user-card-action {
    flex-shrink: 0;
}

/* ── Notifications dropdown (nav) ── */
.notif-dropdown {
    position: relative;
}

.notif-dropdown summary {
    list-style: none;
    cursor: pointer;
}

.notif-dropdown summary::-webkit-details-marker {
    display: none;
}

.notif-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border-radius: 99px;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 10px;
    padding: 1px 7px;
    margin-left: 6px;
}

.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-width: 80vw;
    max-height: 400px;
    overflow-y: auto;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0;
    padding: 10px;
    z-index: 20;
    box-shadow: 5px 5px 0 rgba(20,18,15,0.15);
}

.notif-panel-item {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
}

.notif-panel-item:last-of-type {
    border-bottom: none;
}

.notif-panel-item p {
    margin-bottom: 2px;
    font-size: 0.85rem;
}

.notif-unread {
    background: rgba(29,78,155,0.08);
}

.notif-panel-item.notif-unread {
    border-left: 3px solid var(--accent2);
    padding-left: 8px;
}

.notif-panel-empty {
    padding: 12px 6px;
    margin-bottom: 0;
}

.notif-view-all {
    display: block;
    text-align: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 2px solid var(--border);
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
}

.notif-time {
    font-size: 0.75rem;
}

/* A notification with somewhere to go (see the `link` column —
   src/models/notification.ts createNotification) renders its content as
   a link instead of plain text, in both the full table
   (views/partials/notification-tr.handlebars) and the nav dropdown
   (views/layouts/main.handlebars). Styled to read as regular text until
   hovered, rather than looking like a generic blue link dropped into an
   otherwise plain row. */
.notif-content-link {
    color: inherit;
    text-decoration: none;
    display: block;
}

.notif-content-link:hover {
    text-decoration: underline;
}

.notif-type-cell {
    white-space: nowrap;
}

/* ── Friends list (profile page) ── */
.friends-list {
    margin: 16px 0 8px;
}

.friend-chip {
    display: inline-block;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 99px;
    padding: 6px 14px;
    margin: 0 8px 8px 0;
    font-size: 0.85rem;
    color: var(--text);
}

.friend-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

/* ── Vinyl box (views/box.handlebars) ── */
.box-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0 28px;
}

.box-toolbar #box-search {
    max-width: 320px;
}

.box-view-toggle {
    display: flex;
    gap: 8px;
}

.vinyl-box[data-view="flow"] {
    display: flex;
    gap: 22px;
    overflow-x: auto;
    padding: 12px 4px 28px;
    scroll-snap-type: x proximity;
}

.vinyl-box[data-view="flow"] .sleeve {
    flex: 0 0 auto;
    width: 170px;
    scroll-snap-align: center;
}

.vinyl-box[data-view="flow"] .sleeve-cover {
    width: 170px;
    height: 170px;
    transition: transform 0.2s ease;
}

.vinyl-box[data-view="flow"] .sleeve:hover .sleeve-cover {
    transform: scale(1.04) translateY(-4px);
}

.vinyl-box[data-view="grid"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
}

.vinyl-box[data-view="grid"] .sleeve-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.sleeve-cover {
    border-radius: 0;
    object-fit: cover;
    display: block;
    border: 2px solid var(--border);
}

.sleeve-caption {
    margin-top: 8px;
}

.sleeve-title {
    font-size: 0.85rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sleeve-artist {
    font-size: 0.78rem;
}

/* ── Vinyl box preview on the profile page ── */
.profile-box-section {
    margin-top: 28px;
}

.profile-box-grid.vinyl-box[data-view="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 14px;
    margin-top: 12px;
}

/* ── Places section on the profile page — a plain list, not a map (see
   entryModel.getLocationsByUser and the comment in profile.handlebars).
   Each group gets a keyline on the left rather than a full card border —
   this list can be short and is meant to read light, closer to the
   friends-list chips than another boxed section. ── */
.profile-locations-section {
    margin-top: 28px;
}
.location-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}
.location-group {
    border-left: 3px solid var(--accent2);
    padding-left: 12px;
}
.location-name {
    font-family: 'Archivo Black', sans-serif;
    font-size: 0.95rem;
}
.location-songs {
    font-size: 0.8rem;
    margin-top: 2px;
}

/* ── Mood chips (add-song form + edit dialog) and mood pills (home table
   display) — src/moods.ts owns the actual per-mood colors; these rules are
   just the chrome around them, and stay theme-neutral on purpose so a
   mood's color reads the same in light or dark mode. ── */
.mood-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.mood-chip {
    --mood-color: var(--accent);
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
    padding: 7px 12px;
    border-radius: 99px;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mood-chip:hover {
    border-color: var(--mood-color);
    color: var(--text);
}

.mood-chip.selected {
    background: var(--mood-color);
    border-color: var(--mood-color);
    color: #14120f;
    font-weight: 700;
}

.mood-pill {
    display: inline-block;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.02em;
    padding: 3px 10px;
    border-radius: 99px;
    color: #14120f;
    margin: 0 4px 4px 0;
}

/* "New"/"old" pill inside the mood cell — outlined rather than filled like
   a real mood-pill, so it reads as a different kind of tag. Blue for "new"
   echoes the "Open" month badge's use of blue for the current, active
   state; "old" stays neutral. */
.type-pill {
    display: inline-block;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 99px;
    border: 1.5px solid var(--border);
    color: var(--muted);
    background: transparent;
    margin: 0 4px 4px 0;
}

.type-pill-new {
    border-color: var(--accent2);
    color: var(--accent2);
}

.song-cover-thumb {
    width: 28px;
    height: 28px;
    border-radius: 0;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid var(--border);
}

.song-cover-thumb-lg {
    width: 100px;
    height: 100px;
    border-radius: 0;
    object-fit: cover;
    display: block;
    border: 2px solid var(--border);
}

/* ── Home table column widths (kept for any page still using the table
   layout — the home page itself now uses the card grid, see the "Card
   grid" section near the bottom) ── */
.music-table {
    table-layout: fixed;
    border: 2px solid var(--border);
}

.music-table .col-date   { width: 46px; }
.music-table .col-cover  { width: 130px; }
.music-table .col-mood   { width: 190px; }

.music-table td, .music-table th {
    overflow-wrap: break-word;
}

.music-table th {
    padding: 8px 6px;
    font-size: 10px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.music-table .cell-date {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--accent);
    padding-left: 6px;
    padding-right: 6px;
    white-space: nowrap;
}

.music-table .cell-cover {
    padding-left: 8px;
    padding-right: 8px;
}

.song-title {
    font-family: 'Archivo Black', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text);
}

.song-artist {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.song-album {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--muted);
    opacity: 0.8;
    margin-top: 2px;
}

.cell-mood {
    line-height: 1.6;
}

.music-table td[data-open-detail] {
    cursor: pointer;
}

/* ── Entry detail popup ── */
.detail-dialog {
    text-align: center;
    padding: 36px 28px 28px;
    cursor: default;
}

.detail-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
}

.detail-close:hover {
    color: var(--text);
}

.detail-cover {
    width: 220px;
    height: 220px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 0;
    border: 3px solid var(--border);
    display: block;
    margin: 0 auto 20px;
}

.detail-title {
    font-family: 'Archivo Black', sans-serif;
    font-size: 1.3rem;
    color: var(--text);
}

.detail-artist {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.detail-album {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted);
    opacity: 0.8;
    margin-top: 2px;
}

.detail-meta-list {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.detail-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.detail-tags {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}

.detail-status {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.detail-box-toggle {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
    padding: 6px 14px;
    border-radius: 99px;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.detail-box-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}

.detail-box-toggle.in-box {
    border-color: var(--accent);
    color: var(--accent);
}

.detail-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.detail-delete {
    border-color: var(--red);
    color: var(--red);
}

/* ── Date sidebar (home page "jump to a month" index) — kept in the
   card-grid layout too (see below), same fixed-position quiet archive-link
   list as before. ── */
.date-sidebar {
    display: none;
    position: fixed;
    top: 150px;
    left: calc(50% - 620px);
    width: 150px;
    max-height: calc(100vh - 190px);
    overflow-y: auto;
    border-left: 3px solid var(--border);
    padding-left: 16px;
}

@media (min-width: 1280px) {
    .date-sidebar {
        display: block;
    }
}

.date-sidebar-year {
    margin-bottom: 20px;
}

.date-sidebar-year-label {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 6px;
}

.date-sidebar-month {
    display: block;
    font-family: 'Archivo', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text);
    padding: 3px 0;
}

.date-sidebar-month:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Month groups (still used by any remaining table-based page; the home
   page's own month sections are the "Card grid" rules below) ── */
.month-group {
    margin-top: 40px;
    scroll-margin-top: 100px;
}

.month-group:first-of-type {
    margin-top: 24px;
}

.month-group-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.month-group-header h2 {
    margin-bottom: 0;
}

.month-group-empty-row td {
    padding: 22px 14px;
    font-style: italic;
}

/* ── Activity heatmap (profile page) ── */
.heatmap-section {
    margin: 24px 0 8px;
}

.heatmap {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    padding: 20px 2px 6px;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: relative;
    flex-shrink: 0;
}

.heatmap-month-label {
    position: absolute;
    top: -18px;
    left: 0;
    font-family: 'Archivo', sans-serif;
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.heatmap-day {
    width: 11px;
    height: 11px;
    border-radius: 1px;
    background: var(--surface2);
    border: 1px solid var(--border);
    display: inline-block;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 12px;
}

.heatmap-legend .text-muted {
    font-size: 11px;
    margin: 0;
}

.mood-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ── Button row ── */
.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 16px;
}

/* ── Grids ── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

div {
    display: block; /* reset old default flex */
}

/* The rule above is author CSS, which beats the browser's own built-in
   [hidden] { display: none } rule no matter the specificity (author
   origin always wins over user-agent origin) — so setting an element's
   `hidden` property (e.g. the box search filtering sleeves in/out as you
   type — see views/box.handlebars) had zero visible effect: the element
   still computed to display:block. Restating [hidden] here, as author
   CSS ourselves, fixes it for every hidden div in the app: an attribute
   selector's specificity (0,1,0) already beats a bare type selector's
   (0,0,1), so this only needs to exist, not to fight for priority. */
[hidden] {
    display: none;
}

/* ── Navigation ── */
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 26px 32px;
    border-bottom: 3px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

nav a {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    letter-spacing: 0.06em;
    transition: color 0.15s;
}

nav a:hover, nav a.active {
    color: var(--accent);
}

nav a.nav-logo {
    font-family: 'Archivo Black', sans-serif;
    font-size: 1.3rem;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

nav a.nav-logo:hover {
    color: var(--text);
}

nav a.nav-logo::after {
    content: '';
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

nav a.nav-logo em {
    font-style: normal;
}

/* ── Monospace-style code spans (kept legible, not a Bauhaus focal point) ── */
code {
    font-family: 'Archivo', monospace;
    font-size: 12px;
    background: rgba(29,78,155,0.1);
    color: var(--accent2);
    padding: 2px 7px;
    border-radius: 3px;
}

/* ── Explore ── */
.explore-mode-tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0 24px;
    border-bottom: 2px solid var(--border);
}

.explore-mode-tab {
    padding: 10px 4px;
    margin-right: 20px;
    color: var(--muted);
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom: 3px solid transparent;
}

.explore-mode-tab:hover {
    color: var(--text);
    text-decoration: none;
}

/* Sits apart from the Charts/Moods toggle it shares a row with — an
   action, not a third mode, so it's pushed to the far side and doesn't
   get the underline treatment on hover/active. */
.explore-surprise-link {
    margin-left: auto;
    margin-right: 0;
}

.explore-mode-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.explore-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.explore-sort-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.explore-genre-form select {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 0;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.85rem;
}

.explore-chart-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.explore-chart-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 0;
    color: inherit;
}

.explore-chart-row:hover {
    background: var(--surface2);
    text-decoration: none;
}

.explore-chart-cover {
    width: 52px;
    height: 52px;
    border-radius: 0;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.explore-chart-info {
    flex: 1;
    min-width: 0;
}

.explore-chart-count {
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.explore-mood-picker {
    margin: 4px 0 24px;
}

.explore-mood-picker .mood-chip {
    text-decoration: none;
    display: inline-block;
}

.explore-mood-feed {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.explore-mood-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px;
    border-radius: 0;
}

.explore-mood-row:hover {
    background: var(--surface2);
}

.explore-mood-info {
    flex: 1;
    min-width: 0;
}

.explore-mood-info .song-title {
    display: block;
}

.explore-mood-meta {
    font-size: 0.8rem;
    margin-top: 2px;
}

.explore-mood-tags {
    margin-top: 6px;
}

.detail-explore-link {
    display: block;
    margin-top: 14px;
    font-size: 0.8rem;
    text-align: center;
}

/* ── Song page ── */
.song-page {
    max-width: 480px;
    margin: 24px auto 0;
    text-align: center;
}

.song-page-cover {
    width: 220px;
    height: 220px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 0;
    border: 3px solid var(--border);
    display: block;
    margin: 0 auto 20px;
}

.song-page-title {
    font-family: 'Archivo Black', sans-serif;
    font-size: 1.5rem;
    color: var(--text);
}

.song-page-artist {
    font-size: 1rem;
    color: var(--muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.song-page-album {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--muted);
    opacity: 0.8;
    margin-top: 2px;
}

.song-page-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.song-page-section {
    margin-top: 28px;
    text-align: left;
}

.song-page-section h3 {
    margin-bottom: 12px;
}

.mood-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mood-breakdown-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mood-breakdown-label {
    width: 90px;
    flex-shrink: 0;
    font-size: 0.82rem;
    color: var(--text);
}

.mood-breakdown-bar-track {
    flex: 1;
    height: 8px;
    border-radius: 99px;
    background: var(--surface2);
    overflow: hidden;
}

.mood-breakdown-bar {
    height: 100%;
    border-radius: 99px;
}

.mood-breakdown-percent {
    width: 36px;
    flex-shrink: 0;
    text-align: right;
    font-size: 0.78rem;
}

.song-page-loggers {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

/* ── Utility ── */
.right-top {
    position: absolute;
    top: 16px;
    bottom: 16px;
    right: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ── Responsive ──────────────────────────────────────────────────────
   Below 768px: the desktop nav's full button row (Box/Explore/Surprise
   me/Profile/Search/Log out) would just wrap and overlap the logo at
   phone widths, so it's replaced by two things instead — a slim top bar
   (logo + the notifications bell, which is all that's left visible in
   .right-top) and a fixed bottom tab bar (see .mobile-tabbar below, and
   the markup in views/layouts/main.handlebars) covering the five
   destinations someone actually reaches for on a phone. Surprise me and
   Log out move to Explore and Profile respectively rather than taking a
   sixth/seventh tab slot — see the comments in those two templates.
   Nothing here touches the desktop nav itself; it's simply hidden. ── */
/* Base (desktop) state — always present in the DOM, just invisible until
   the media query below turns it on. This has to come *before* that media
   query in the file: two rules of equal specificity where one is
   unconditional and the other lives in an @media block are decided by
   plain source order once the query matches, not by which one "looks"
   more specific to the breakpoint — so a display:none stated after the
   media query would silently win at every width, query or no query. */
.mobile-tabbar {
    display: none;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--bg);
    padding: 0;
    border-top: 3px solid var(--border);
    border-bottom: none;
}

.mobile-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 4px 10px;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 10.5px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    border-top: 3px solid transparent;
    margin-top: -3px; /* sits over the bar's own top border */
    text-align: center;
}

.mobile-tab:hover {
    color: var(--text);
    text-decoration: none;
}

.mobile-tab.active {
    color: var(--accent);
    border-top-color: var(--accent);
}

@media (max-width: 768px) {
    nav {
        padding: 14px 20px;
    }

    .right-top > a,
    .right-top > form {
        display: none;
    }

    .page-wrap {
        padding: 32px 20px 96px;
    }

    .mobile-tabbar {
        display: grid;
    }
}

@media (max-width: 600px) {
    .two-col, .three-col {
        grid-template-columns: 1fr;
    }

    /* One card per row rather than a cramped two — a phone-width square
       cover plus title/artist/album/pills/date has more room to actually
       be legible this way than splitting the width in half. */
    .card-grid {
        grid-template-columns: 1fr !important;
    }

    /* A handful of header rows (month heading + status badge + progress
       text, the home page's greeting + Add button, the Places/sub-header
       strip) assume there's room for everything on one line — true on
       desktop, not guaranteed on the narrowest phones. Letting them wrap
       instead of overflow is a one-line fix for all of them. */
    h2 {
        font-size: 1.2rem;
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .grid-month-header {
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .grid-month-progress {
        margin-left: 0;
    }
    .home-top-row {
        flex-wrap: wrap;
    }
    .sub-header-strip {
        flex-wrap: wrap;
        gap: 8px 16px;
    }
    /* Purely decorative (the Bauhaus shape flourish) — the first thing
       worth dropping once space is tight. */
    .sub-header-strip .shape-row {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Card grid — the home page's layout (views/home.handlebars +
   views/partials/music-card.handlebars). Each month is a heading plus a
   grid of square cover cards instead of a table; the open (current) month
   fills any unused slots under the monthly cap with a dashed "Log a song"
   placeholder, so the cap is always visible at a glance. The date sidebar
   above is unrelated to table vs. grid and works the same either way —
   its #month-<key> anchor targets just need to exist on whatever wraps
   each month's section, which is .grid-month-block below.
   ══════════════════════════════════════════════════════════════════════ */
/* Greeting + "Add new Song" button, side by side (views/home.handlebars) —
   the page no longer has a "Home" heading above this, so this row is the
   first thing on the page; the button sits on the right rather than
   centered/left so it doesn't compete with the greeting for attention. */
.home-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.home-greeting {
    margin: 0;
    font-size: 1.1rem;
}

.sub-header-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 16px;
    margin-bottom: 8px;
    border-bottom: 3px solid var(--border);
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.shape-row { display: flex; gap: 8px; align-items: center; }
.shape-row .sh { display: inline-block; }
.shape-row .sh-circle { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.shape-row .sh-square { width: 10px; height: 10px; background: var(--accent2); }
.shape-row .sh-triangle { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 10px solid var(--yellow); }

.grid-month-block {
    margin-top: 48px;
    scroll-margin-top: 100px;
}
.grid-month-block:first-of-type { margin-top: 30px; }

.grid-month-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 4px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--border);
}
.grid-month-header h2 { margin-bottom: 0; }
.grid-month-progress {
    margin-left: auto;
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    margin-top: 22px;
}

.grid-card { border: 3px solid var(--border); background: var(--surface); cursor: pointer; }
.grid-card-cover {
    position: relative;
    aspect-ratio: 1/1;
    display: flex;
    align-items: flex-end;
    border-bottom: 3px solid var(--border);
    background: var(--surface2);
    overflow: hidden;
}
.grid-card-cover-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.grid-card-num {
    position: absolute; top: 10px; left: 10px; z-index: 1;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--border); color: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 11px;
}
.grid-card-cover-title {
    position: relative; z-index: 1;
    color: #fff;
    font-family: 'Archivo Black', sans-serif;
    font-size: 0.95rem;
    padding: 12px 14px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.grid-card-info { padding: 14px 16px 16px; }
.grid-card-title { font-family: 'Archivo Black', sans-serif; font-size: 1.05rem; margin-bottom: 4px; }
.grid-card-artist { font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.grid-card-album { font-size: 10px; font-style: italic; color: var(--muted); opacity: 0.85; margin-top: 2px; }
/* The free-text "location" tag (e.g. "France vacation") — a diary-side
   note, not tied to the song itself, so it gets its own accent color
   rather than reading as more song metadata like artist/album do. */
.grid-card-location { font-size: 10px; font-weight: 700; color: var(--accent2); margin-top: 4px; }
/* Whichever of title/artist/album/location is last, .grid-card-meta's own
   top margin is what guarantees the gap above the pills/date row —
   simpler than chasing :last-of-type across four optional lines. */
.grid-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.grid-card-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.grid-card-date { font-family: 'Archivo', sans-serif; font-size: 11px; color: var(--muted); white-space: nowrap; }

.grid-card-empty {
    border: 3px dashed var(--muted);
    background: transparent;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}
.grid-card-empty:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.grid-card-empty .plus { font-size: 1.8rem; font-weight: 300; line-height: 1; }
.grid-card-empty .label { font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }

.grid-month-empty {
    border: 3px dashed var(--muted);
    padding: 28px;
    text-align: center;
    font-style: italic;
    color: var(--muted);
    margin-top: 22px;
}

/* ══════════════════════════════════════════════════════════════════════
   Appearance / dark mode toggle (Settings page — controllers/settings.ts,
   views/settings.handlebars). A plain checkbox-style switch, not tied to
   the OS theme — the user picks light or dark explicitly and it's
   remembered (frontend/events.ts stores it in localStorage and stamps
   data-theme on <html>; a tiny inline script in the layout head applies
   the saved choice before first paint so there's no flash of the wrong
   theme). ══════════════════════════════════════════════════════════════ */
.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.theme-switch-track {
    position: absolute;
    inset: 0;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 99px;
    cursor: pointer;
    transition: background 0.15s;
}
.theme-switch-track::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--border);
    transition: transform 0.15s;
}
.theme-switch input:checked + .theme-switch-track {
    background: var(--border);
}
.theme-switch input:checked + .theme-switch-track::before {
    transform: translateX(24px);
    background: var(--bg);
}

/* ══════════════════════════════════════════════════════════════════════
   Dark mode — same variables, dark values. Everything above is built on
   these custom properties, so this block is the entire dark theme; no
   selector above needs its own dark-mode override. Warm near-black
   (not cold blue-black), cream ink, brightened accent colors for
   contrast, and the border color flips to cream too so the bold keyline
   borders stay legible against the dark background instead of vanishing.
   ══════════════════════════════════════════════════════════════════════ */
:root[data-theme="dark"] {
    --bg:       #16140f;
    --surface:  #1d1a14;
    --surface2: #26221a;
    --border:   #ece6d6;
    --accent:   #e9503d;
    --accent2:  #5b8fd6;
    --yellow:   #f4c23a;
    --text:     #f2ede0;
    --muted:    #a89f8c;
    --green:    #5b8fd6;
    --red:      #e9503d;
}

:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] button[type="submit"] {
    color: #16140f;
}
:root[data-theme="dark"] .btn-primary:hover,
:root[data-theme="dark"] button[type="submit"]:hover {
    background: #f0745f;
    border-color: #f0745f;
}
:root[data-theme="dark"] .badge-gold { color: #16140f; }
