/*
 * ChoirTools — light, compact, professional.
 *
 * One stylesheet, no build step (an asset pipeline arrives with the score and
 * audio players). Density is deliberate: choir admins work through long lists
 * of people, dates and pieces, so the layout is tuned for information per
 * screen rather than for whitespace.
 *
 * A choir can set its own accent colour; --accent is overridden inline on
 * tenant pages, and every accent use goes through the token.
 */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --fg: #1b1f24;
    --fg-soft: #414b57;
    --muted: #6b7683;
    --line: #dfe4ea;
    --line-strong: #c8d0da;

    --accent: #1f4e9c;
    --accent-fg: #ffffff;
    --accent-soft: #eaf1fb;

    --ok: #1a7f4b;
    --ok-soft: #e8f5ee;
    --warn: #9a6400;
    --warn-soft: #fdf3e2;
    --err: #b3261e;
    --err-soft: #fdecea;

    --radius: 4px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);

    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.15rem; }
h2 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: .875rem; margin: 1rem 0 .35rem; }
p { margin: .4rem 0; }
small, .small { font-size: .8125rem; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* ---------------------------------------------------------------- layout -- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 1rem;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
    color: var(--fg);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 18px; height: 18px;
    border-radius: 3px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: .6875rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}
.topbar nav { display: flex; align-items: center; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a, .topbar nav form button {
    color: var(--fg-soft);
    font-size: .8125rem;
    padding: .25rem .5rem;
    border-radius: var(--radius);
}
.topbar nav a:hover { background: var(--surface-alt); text-decoration: none; color: var(--fg); }
.topbar nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar .who { font-size: .8125rem; color: var(--muted); padding-right: .25rem; }
.lang { display: inline-flex; gap: .125rem; border-left: 1px solid var(--line); margin-left: .35rem; padding-left: .45rem; }
.lang a, .lang span { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; padding: .2rem .35rem; }
.lang span { color: var(--fg); font-weight: 700; }

.page { max-width: 72rem; margin: 0 auto; padding: 1rem; }
.page.narrow { max-width: 44rem; }
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}
.page-head p { margin: .15rem 0 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .75rem .875rem;
    margin-bottom: .75rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-title {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    margin: 0 0 .4rem;
}
.grid { display: grid; gap: .75rem; }
@media (min-width: 40rem) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 60rem) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.stat { display: flex; align-items: baseline; gap: .4rem; }
.stat-value { font-size: 1.35rem; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------------------------ list -- */

ul.plain, ol.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.tight { margin: .35rem 0; padding-left: 1.1rem; }
ul.tight li { margin: .1rem 0; }

table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    background: var(--surface-alt);
    white-space: nowrap;
}
tbody tr:hover { background: var(--surface-alt); }
td.actions, th.actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 0 -.875rem -.75rem; }
.table-wrap table { min-width: 32rem; }

.badge {
    display: inline-block;
    font-size: .6875rem;
    font-weight: 600;
    line-height: 1.4;
    padding: .05rem .35rem;
    border-radius: 3px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    color: var(--fg-soft);
    white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge.err { background: var(--err-soft); border-color: transparent; color: var(--err); }

/* ----------------------------------------------------------------- forms -- */

form { margin: 0; }
.form-narrow { max-width: 24rem; }
form > div, .form-row { margin-bottom: .55rem; }
label { display: block; font-size: .75rem; font-weight: 600; color: var(--fg-soft); margin-bottom: .15rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=date], input[type=time], input[type=number], input[type=url], select, textarea {
    width: 100%;
    font: inherit;
    font-size: .8125rem;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: .3rem .45rem;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
input[type=checkbox], input[type=radio] { margin: 0 .35rem 0 0; }
.checkbox label, label.checkbox { display: flex; align-items: flex-start; gap: .1rem; font-weight: 400; font-size: .8125rem; color: var(--fg); }
.help-block, .form-help, small.help { display: block; color: var(--muted); font-size: .75rem; margin-top: .1rem; }
ul.form-errors { list-style: none; margin: .15rem 0 0; padding: 0; color: var(--err); font-size: .75rem; }
.form-actions { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }

button, .button {
    font: inherit;
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.4;
    padding: .3rem .7rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--accent-fg);
    cursor: pointer;
    white-space: nowrap;
}
button:hover, .button:hover { filter: brightness(1.07); text-decoration: none; }
button.secondary, .button.secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--fg-soft);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-alt); filter: none; }
button.link { background: none; border: 0; color: var(--accent); padding: .2rem .25rem; }
button.danger { background: var(--err); }
button.small, .button.small { font-size: .75rem; padding: .15rem .45rem; }

/* --------------------------------------------------------------- notices -- */

.flash {
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: var(--surface);
    border-radius: var(--radius);
    padding: .4rem .6rem;
    margin-bottom: .6rem;
    font-size: .8125rem;
}
.flash-success { border-left-color: var(--ok); background: var(--ok-soft); }
.flash-error { border-left-color: var(--err); background: var(--err-soft); }
.flash-warning { border-left-color: var(--warn); background: var(--warn-soft); }

.empty {
    text-align: center;
    color: var(--muted);
    font-size: .8125rem;
    padding: 1.25rem .75rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

/* ---------------------------------------------------------- public pages -- */

.hero {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 1.75rem 1rem;
}
.hero-inner { max-width: 48rem; margin: 0 auto; }
.hero h1 { font-size: 1.6rem; line-height: 1.2; }
.hero p.lead { font-size: .9375rem; color: var(--fg-soft); margin-top: .4rem; }
.hero .form-actions { margin-top: .9rem; }

.prose { font-size: .875rem; color: var(--fg-soft); }
.prose h2 { margin: 1.1rem 0 .35rem; color: var(--fg); }
.prose h3 { margin: .85rem 0 .25rem; color: var(--fg); }
.prose p { margin: .35rem 0; }
.prose ul, .prose ol { margin: .35rem 0; padding-left: 1.15rem; }
.prose li { margin: .1rem 0; }
.prose blockquote {
    margin: .5rem 0;
    padding: .2rem .7rem;
    border-left: 2px solid var(--line-strong);
    color: var(--muted);
}
.prose a { text-decoration: underline; }

.feature-list { display: grid; gap: .5rem; }
@media (min-width: 44rem) { .feature-list { grid-template-columns: 1fr 1fr; } }
.feature { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .6rem .7rem; }
.feature h3 { margin: 0 0 .15rem; font-size: .8125rem; }
.feature p { margin: 0; font-size: .8125rem; color: var(--muted); }

.social-links { display: flex; flex-wrap: wrap; gap: .35rem; }
.social-links a {
    font-size: .75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .1rem .55rem;
    background: var(--surface);
    color: var(--fg-soft);
}
.social-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.footer {
    border-top: 1px solid var(--line);
    margin-top: 1.5rem;
    padding: .75rem 1rem;
    background: var(--surface);
}
.footer-inner {
    max-width: 72rem;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    justify-content: space-between;
    font-size: .75rem;
    color: var(--muted);
}
.footer a { color: var(--muted); }

.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;
}

@media print {
    .topbar, .footer, .form-actions { display: none; }
    body { background: #fff; }
}

/* Practice player embedded on a score page (static app under /player/). */
.score-player { display: block; width: 100%; height: calc(100vh - 9rem); min-height: 32rem; border: 1px solid var(--line, #ddd); border-radius: 8px; background: #fff; }

/* Drag-and-drop score upload. */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2rem 1rem; text-align: center;
    border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--accent-soft); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-icon { font-size: 2.2rem; line-height: 1; color: var(--accent); }
.dropzone-title { font-size: 1.1rem; font-weight: 600; }
.dropzone-sub { color: var(--muted); }
.dropzone .help-block { max-width: 40rem; }
body.is-dragging .dropzone { border-color: var(--accent); background: #fff; transform: scale(1.01); box-shadow: 0 0 0 6px var(--accent-soft); }
body.is-dragging::after { content: ''; position: fixed; inset: 0; background: rgba(31, 78, 156, .08); pointer-events: none; z-index: 50; }
.upload-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .4rem; }
.upload-list:empty { display: none; }
.upload-list li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.upload-list .upload-name { font-weight: 600; overflow-wrap: anywhere; }
.upload-list .upload-state { color: var(--muted); font-size: .9em; }
.upload-list progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--accent); }
.upload-list li.is-done { border-color: var(--ok); }
.upload-list li.is-done .upload-state { color: var(--ok); }
.upload-list li.is-error { border-color: var(--err); }
.upload-list li.is-error .upload-state { color: var(--err); }
.upload-details { margin-top: .75rem; }
#upload-reload { margin-top: .5rem; }

/* Event programme */
ol.programme { margin: 0; padding-left: 1.4rem; }
ol.programme li { padding: .3rem 0; }
.programme-actions { display: inline-flex; gap: .25rem; margin-left: .5rem; vertical-align: middle; }
.programme-actions form { display: inline; margin: 0; }
.programme-actions button { padding: .1rem .45rem; min-width: 0; }
.programme-add { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.programme-add select { flex: 1 1 14rem; width: auto; margin: 0; }

/* List tabs and search */
.list-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.tab { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg-soft); text-decoration: none; font-size: .875rem; background: var(--surface); }
.tab:hover { border-color: var(--line-strong); }
.tab.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tab .count { color: var(--muted); font-weight: 400; margin-left: .15rem; }
.search { margin: 0; flex: 0 1 16rem; }
.search input { margin: 0; width: 100%; }

/* Phones: the menu folds under one button — a checkbox, so no script is needed. */
.nav-toggle-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nav-toggle { display: none; }
@media (max-width: 47.99rem) {
    .topbar-inner { flex-wrap: wrap; height: auto; min-height: 44px; padding-block: .35rem; gap: .5rem; }
    .nav-toggle {
        display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; cursor: pointer;
        background: var(--surface); color: var(--fg-soft); border: 1px solid var(--line);
        padding: .35rem .7rem; font-size: .9rem; border-radius: var(--radius); user-select: none;
    }
    .nav-toggle-input:focus-visible + .nav-toggle { outline: 2px solid var(--accent); outline-offset: 2px; }
    .nav-toggle-input:checked + .nav-toggle { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
    .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; padding-bottom: .4rem; }
    .nav-toggle-input:checked ~ nav { display: flex; }
    .topbar nav a, .topbar .who { padding: .6rem .5rem; font-size: .95rem; border-bottom: 1px solid var(--line); }
    .topbar .lang { border-left: 0; margin: .4rem 0 0; padding-left: .25rem; }
    .page { padding: .75rem; }
    .page-head { flex-wrap: wrap; gap: .5rem; }
}
.quick-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 0; }

/* Recordings */
.recordings li { padding: .55rem 0; }
.recordings li.is-mine { background: var(--accent-soft); margin: 0 -.75rem; padding: .55rem .75rem; }
.recording-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .3rem; }
.recording-delete { margin: 0 0 0 auto; }
.recordings audio { width: 100%; height: 36px; }
.recording-upload { margin-top: .6rem; }
.feed-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Announcements */
.announcement.is-pinned { border-left: 3px solid var(--accent); }
.announcement-head { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.announcement-head h2 { margin: 0; font-size: 1rem; }
.announcement-actions { display: inline-flex; gap: .3rem; }
.announcement-actions form { margin: 0; }
.announcement-teaser { margin-top: .15rem; }
.field-error { color: var(--err); font-size: .8125rem; margin: .2rem 0 0; }

/* RSVP per section */
table.coverage .num { text-align: right; width: 4.5rem; }
table.coverage tr.is-short td:first-child { color: var(--err); font-weight: 600; }
