/* Music Pages editor. Phone first; follows the device's light/dark mode.
   Every form control sets both its text and background colour from the
   theme, so no control falls back to the browser's (dark-on-dark) default. */

:root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --text: #18181b;
    --muted: #5f6068;
    --line: #d8d8dc;
    --field-bg: #ffffff;
    --field-text: #18181b;
    --accent: #2f2f35;
    --accent-text: #ffffff;
    --error: #b42318;
    --ok: #146c43;
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111113;
        --surface: #1b1b1f;
        --text: #ececef;
        --muted: #a1a1aa;
        --line: #34343a;
        --field-bg: #26262b;
        --field-text: #f4f4f5;
        --accent: #e7e7ea;
        --accent-text: #111113;
        --error: #ff8a80;
        --ok: #6fd3a0;
        color-scheme: dark;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .75rem; }

.card {
    max-width: 30rem;
    margin: 2rem auto;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.form { display: grid; gap: .5rem; margin: 0 0 1rem; }
.form label { font-weight: 600; font-size: .9rem; margin-top: .5rem; }

input, select, textarea {
    width: 100%;
    font: inherit;
    padding: .6rem .7rem;
    color: var(--field-text);
    background-color: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    padding: .6rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--text);
    background-color: var(--surface);
    text-decoration: none;
    cursor: pointer;
}
.btn.primary { background-color: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--error); }

.or { text-align: center; color: var(--muted); margin: .75rem 0; }
.hint { color: var(--muted); font-size: .9rem; }
.error { color: var(--error); margin: 0; }
.notice { color: var(--ok); }

/* ---- Editor shell: form and live preview ---------------------------- */

body.editor { min-height: 100vh; }
.shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    display: flex; gap: 1rem; align-items: center;
    padding: .6rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; text-decoration: none; }
.topbar .site-name { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.publish-bar {
    display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.publish-bar p { margin: 0; }
.publish-bar .status { font-weight: 600; }
.publish-bar.status-changed .status::before,
.publish-bar.status-neverpublished .status::before { content: "● "; color: #d97706; }
.publish-bar.status-uptodate .status::before { content: "● "; color: var(--ok); }
.publish-bar .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.publish-bar .actions form { margin: 0; }
.publish-bar .hint, .publish-bar .live { flex-basis: 100%; }

.workspace { display: flex; flex-direction: column; flex: 1; }
.pane { padding: 1rem; min-width: 0; }

/* Phone: the preview is a strip above the form. */
.preview { order: -1; border-bottom: 1px solid var(--line); background: var(--bg); }
.preview iframe { display: block; width: 100%; height: 38vh; border: 0; background: #000; }
.preview .open-preview { display: block; padding: .35rem 1rem; font-size: .85rem; color: var(--muted); }

/* Laptop: form on the left, the real site on the right. */
@media (min-width: 900px) {
    .workspace { flex-direction: row; }
    .pane { flex: 0 0 min(34rem, 45%); overflow-y: auto; max-height: calc(100vh - 7rem); }
    .preview { order: 0; flex: 1; border-bottom: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
    .preview iframe { flex: 1; height: auto; min-height: calc(100vh - 9rem); }
}

.sections ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.sections a {
    display: block; padding: .8rem 1rem; text-decoration: none; font-weight: 600;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}

/* Lists of items with drag handles. */
.items { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.items > li {
    display: flex; gap: .75rem; align-items: center;
    padding: .6rem .75rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.items .grow { flex: 1; min-width: 0; }
.items .muted, .muted { color: var(--muted); font-size: .9rem; }
.handle { cursor: grab; touch-action: none; user-select: none; color: var(--muted); padding: .25rem; font-size: 1.2rem; }
.sortable-ghost { opacity: .4; }
.tag { font-size: .7rem; border-radius: 4px; padding: .05rem .4rem; background: var(--line); color: var(--fg, inherit); white-space: nowrap; vertical-align: middle; }
.notice.warn, .notice.getting-started { color: inherit; padding: .6rem .8rem; border-radius: 6px; }
.notice.warn { background: color-mix(in srgb, #e0a800 18%, transparent); }
.notice.getting-started { background: color-mix(in srgb, #2a78d6 14%, transparent); }
.legal-footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 1rem; }
.legal-footer a { color: var(--muted); }
.badge { font-size: .75rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; color: var(--muted); }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--line); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 8rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: .5rem 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .25rem; }
.lang-tag { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.icon svg { width: 1.4rem; height: 1.4rem; fill: currentColor; display: block; }
.date-block { display: grid; text-align: center; min-width: 3rem; line-height: 1.1; }
.date-block strong { font-size: 1.3rem; }
.date-block small { color: var(--muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .05em; }
.items a.grow { text-decoration: none; }
label.choice { display: flex; gap: .5rem; align-items: baseline; font-weight: 400; }

/* Admin */
main.wide { max-width: 60rem; margin: 1.5rem auto; padding: 0 1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1.5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.admin-actions { display: grid; gap: 1rem; max-width: 30rem; }
table.dns { border-collapse: collapse; width: 100%; font-family: ui-monospace, monospace; font-size: .9rem; }
table.dns td { border: 1px solid var(--line); padding: .35rem .5rem; overflow-wrap: anywhere; }

/* Dashboard: the page as cards */
.card-link { display: flex; gap: .75rem; align-items: center; padding: .8rem 1rem; margin: 0 0 .5rem;
    text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.module-cards .card-title { display: block; text-decoration: none; }
.module-cards .switches { display: flex; gap: 1rem; flex-wrap: wrap; margin: .35rem 0 0; font-size: .9rem; }
.module-cards .switches label { display: flex; gap: .35rem; align-items: center; font-weight: 400; }
.module-cards details.more { margin-top: .35rem; font-size: .9rem; }
.module-cards details.more summary { color: var(--muted); cursor: pointer; }
#add-module { margin-top: 1.5rem; }
.topbar .gear { font-size: 1.3rem; text-decoration: none; line-height: 1; }
.settings-nav { margin: 0 0 1rem; }
.settings-nav ul { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.settings-nav li a { display: inline-block; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: .9rem; }
.settings-nav li a[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.site-switcher { flex: 1; position: relative; min-width: 0; }
.site-switcher summary { cursor: pointer; list-style: none; }
.site-switcher ul { position: absolute; z-index: 5; list-style: none; margin: .4rem 0 0; padding: .4rem; min-width: 14rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.site-switcher form { margin: 0; }
button.link { font: inherit; background: none; border: 0; color: var(--text); padding: .45rem .5rem; width: 100%; text-align: left; cursor: pointer; }
button.link[aria-current="true"] { font-weight: 700; }

/* Support mode */
.support-banner { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
    padding: .6rem 1rem; background: #b45309; color: #fff; font-weight: 600; }
.support-banner form { margin: 0; }
.support-notice { margin: 0 0 1rem; padding: .75rem 1rem; border: 1px solid #d97706; border-radius: var(--radius); }
.support-notice ul { margin: .4rem 0; padding-left: 1.2rem; font-size: .9rem; }

/* Admin dashboard. Series colours validated (dataviz validator) against
   the editor surfaces: light #ffffff, dark #1b1b1f. */
.viz-root { --series-1: #2a78d6; --series-2: #eb6834; }
@media (prefers-color-scheme: dark) { .viz-root { --series-1: #3987e5; --series-2: #d95926; } }
.stat-tiles { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .5rem; }
.stat-tiles li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem; display: grid; }
.stat-tiles strong { font-size: 1.6rem; line-height: 1.1; }
.stat-tiles span { color: var(--muted); font-size: .85rem; }
.week-chart { margin: 0 0 1.5rem; padding: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.week-chart figcaption { font-weight: 600; }
.week-chart .legend { display: flex; gap: .4rem 1rem; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .85rem; margin: .4rem 0 .6rem; }
.week-chart .key { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: -.6rem; }
.week-chart .key.s1, .week-chart .bar.s1 { background: var(--series-1); }
.week-chart .key.s2, .week-chart .bar.s2 { background: var(--series-2); }
.week-chart .bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; height: 9rem; align-items: end;
    border-bottom: 1px solid var(--line); }
.week-chart .week { display: grid; grid-template-rows: 1fr auto; height: 100%; outline-offset: 2px; }
.week-chart .pair { display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.week-chart .bar { flex: 1; min-height: 0; border-radius: 4px 4px 0 0; }
.week-chart .tick { font-size: .7rem; color: var(--muted); text-align: center; height: 1rem; white-space: nowrap; overflow: visible; }
.week-chart details { margin-top: .75rem; font-size: .9rem; }
.week-chart table { border-collapse: collapse; margin-top: .4rem; }
.week-chart th, .week-chart td { padding: .2rem .6rem; border-bottom: 1px solid var(--line); text-align: right; }
.week-chart th:first-child, .week-chart td:first-child { text-align: left; }
