:root {
    --bg: #F5F5F3;
    --panel: #FFFFFF;
    --panel-2: #DEDEDA;
    --text: #111111;
    --muted: #6F6F6F;
    --accent: #111111;
    --accent-2: #3D3D3D;
    --danger: #B3261E;
    --ok: #1E7B45;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }

.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: var(--panel);
    padding: 24px 16px;
    border-right: 1px solid var(--panel-2);
}
.sidebar h1 { font-size: 18px; margin: 0 0 24px; color: var(--accent); }
.sidebar nav a {
    display: block;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--accent); color: var(--bg); }
.sidebar .user {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--panel-2);
    font-size: 13px;
    color: var(--muted);
}

.content { flex: 1; padding: 32px 40px; max-width: 1100px; }
h1, h2 { color: var(--text); margin-top: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-top: 24px; }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--panel-2);
}
.flash.success { border-color: var(--ok);     color: var(--ok); }
.flash.error   { border-color: var(--danger); color: var(--danger); }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--panel-2); }
th { font-weight: 600; color: var(--muted); font-size: 13px; text-transform: uppercase; }


label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }

/* Style every text-like input, including those without an explicit type=.
   Exclude controls that should keep their native look (checkbox/radio/file/etc.)
   and the wrapped file input inside .file-input. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="range"]):not([type="color"]),
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--panel-2);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    box-sizing: border-box;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }

textarea { min-height: 100px; resize: vertical; }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="range"]):not([type="color"]):focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

/* Checkboxes/radios — keep native look but tint to the accent so they don't
   look like a stray bright-blue against the warm palette. */
input[type="checkbox"], input[type="radio"] {
    accent-color: var(--accent);
    margin-right: 6px;
}

/* Inline labels for checkboxes shouldn't be block-level. */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    font-size: 15px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--accent-2); color: var(--bg); }
.btn.secondary { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.btn.secondary:hover { background: var(--panel-2); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); color: var(--bg); }

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 360px;
    padding: 32px;
    background: var(--panel);
    border-radius: 12px;
}
.login-box h1 { text-align: center; color: var(--accent); margin-bottom: 24px; }

.row { display: flex; gap: 16px; align-items: center; }
.muted { color: var(--muted); }
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--panel-2);
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
}

.thumb {
    display: inline-block;
    width: 64px;
    height: 44px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--panel-2);
    vertical-align: middle;
}

/* File input: hide the native control, style a label as the button.
   Markup convention: <label class="file-input"><span>Pick a file…</span><input type="file" ...></label> */
.file-input {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--panel);
    border: 1px dashed var(--panel-2);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.15s, background 0.15s;
}
.file-input:hover { border-color: var(--accent); background: var(--panel-2); }
.file-input input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.file-input .file-button {
    display: inline-block;
    padding: 4px 10px;
    background: var(--accent);
    color: var(--bg);
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}
.file-input .file-name {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 280px;
}
.file-input.has-file .file-name { color: var(--text); }

.thumb.empty, .preview.empty { border: 1px dashed var(--panel-2); background: transparent; }
.preview {
    display: block;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 3 / 2;
    border-radius: 6px;
    object-fit: cover;
    background: var(--panel-2);
}

.breadcrumbs { margin: 0 0 12px; font-size: 14px; }

/* Page sections. */
.card {
    background: var(--panel);
    border: 1px solid var(--panel-2);
    border-radius: 8px;
    padding: 20px 24px;
    margin-top: 20px;
}
.card > h2:first-child { margin-top: 0; }
.card table { margin-top: 4px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.fields .wide { grid-column: 1 / -1; }
.media { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell form { display: inline; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
audio { width: 100%; max-width: 360px; }

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--panel-2);
    color: var(--muted);
    white-space: nowrap;
}
.pill.ok { border-color: var(--ok); color: var(--ok); }
.pill.warn { border-color: var(--danger); color: var(--danger); }

/* Drag-to-reorder rows (see assets/js/cms.js). user-select:none stops the
   browser starting a text selection instead of the row drag. */
tbody.reorder tr { cursor: grab; user-select: none; -webkit-user-select: none; }
tbody.reorder tr:active { cursor: grabbing; }
tbody.reorder tr.dragging { opacity: 0.4; }
tbody.reorder tr.drop-target td { box-shadow: inset 0 2px 0 0 var(--accent); }
tbody.reorder.saving { opacity: 0.6; pointer-events: none; }
td.grip { width: 28px; color: var(--muted); }

@media (max-width: 760px) {
    .layout { flex-direction: column; }
    .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--panel-2); }
    .content { padding: 20px 16px; }
    .fields, .media { grid-template-columns: 1fr; }
    table { display: block; overflow-x: auto; }
}
