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