:root {
    --bg: #14110F;
    --panel: #1F1B17;
    --panel-2: #2A241E;
    --text: #ECE6DA;
    --muted: #8A8278;
    --accent: #C9A95C;
    --accent-2: #8C7A47;
    --danger: #D17A6A;
    --ok: #7AB28A;
}

* { 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: none; }
a:hover { text-decoration: underline; }

.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);
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: var(--panel-2);
    text-decoration: none;
}
.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; }
tr:hover td { background: var(--panel); }

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;
}
.btn:hover { background: var(--accent-2); color: var(--text); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--text); }
.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;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 1px solid var(--panel-2);
    margin: 16px 0 0;
}
.tab {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 8px 14px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--text);
    background: var(--panel);
    border-color: var(--panel-2);
    margin-bottom: -1px;
}
.tab-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}
.tab-indicator.ok      { background: var(--ok); }
.tab-indicator.partial { background: var(--accent-2); }
.tab-panel {
    border: 1px solid var(--panel-2);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px;
    background: var(--panel);
}

textarea.vtt-source {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
    min-height: 220px;
    tab-size: 4;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0;
}
.image-card {
    margin: 0;
    background: var(--panel-2);
    border: 1px solid var(--panel-2);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: element;
    transition: transform 0.15s, opacity 0.15s, border-color 0.15s;
}
.image-card img { -webkit-user-drag: none; user-drag: none; }
.image-card:active { cursor: grabbing; }
.image-grid.saving { opacity: 0.6; pointer-events: none; }
.image-card.dragging { opacity: 0.4; transform: scale(0.97); }
.image-card.drop-target { border-color: var(--accent); }

/* Tour stop list — drag-to-reorder table rows. user-select:none is what stops
   the browser starting a text/page selection drag instead of the row drag. */
#tour-stop-list .tour-stop {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.15s, background-color 0.15s, box-shadow 0.15s;
}
#tour-stop-list .tour-stop:active { cursor: grabbing; }
#tour-stop-list.saving { opacity: 0.6; pointer-events: none; }
#tour-stop-list .tour-stop.dragging { opacity: 0.4; }
#tour-stop-list .tour-stop.drop-target {
    box-shadow: inset 0 2px 0 0 var(--accent);
}
/* Only the handle cell shows the grab cursor strongly; the Remove button stays
   clickable (its own pointer cursor wins). */
#tour-stop-list .drag-handle { cursor: grab; color: var(--muted); }
#tour-stop-list .tour-stop form,
#tour-stop-list .tour-stop .btn { cursor: pointer; user-select: none; }

.drag-handle {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 2;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
    font-weight: 700;
    pointer-events: none; /* don't block the drag from the card itself */
}
.image-card a {
    display: block;
    background: #000;
}
.image-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}
.image-card figcaption {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.image-card .image-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
}
.image-card .image-caption {
    font-size: 13px;
    color: var(--text);
}
.image-card form { margin: 0; }
.image-card .btn { padding: 4px 10px; font-size: 13px; }

.thumb {
    width: 48px;
    height: 36px;
    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); }
