/*
 * One stylesheet, no build step, no framework.
 *
 * Dark by default with a light-scheme override, because this is a tool someone
 * keeps open in a tab rather than a page they visit.
 */

:root {
    --bg: #12151a;
    --surface: #1a1f27;
    --surface-2: #222834;
    --line: #2e3542;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --accent: #5b9cf8;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --radius: 10px;
    --brand: var(--accent);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f7f9;
        --surface: #ffffff;
        --surface-2: #f0f2f5;
        --line: #d9dee7;
        --text: #1a1f27;
        --muted: #5b6472;
        --accent: #1a6fd4;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
h4 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }

a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

/* ---------- chrome ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { font-weight: 650; text-decoration: none; color: var(--text); }

.topbar nav { display: flex; gap: 4px; flex: 1; }

.topbar nav a {
    padding: 6px 12px;
    border-radius: 7px;
    text-decoration: none;
    color: var(--muted);
    font-size: 14px;
}

.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.tz { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 20px; }

footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    flex-wrap: wrap;
}

.banner {
    background: color-mix(in srgb, var(--warn) 18%, var(--bg));
    border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
    padding: 10px 20px;
    font-size: 13px;
}

/* ---------- cards and layout ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}

.card.narrow { max-width: 420px; margin: 40px auto; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.composer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
    gap: 18px;
    align-items: start;
}

@media (max-width: 900px) {
    .composer-grid { grid-template-columns: 1fr; }
}

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

.field { display: block; margin-bottom: 14px; }
.field.required .label { font-weight: 600; }

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}

.label small {
    display: block;
    font-weight: 400;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

textarea, input[type="text"], input[type="password"], input[type="datetime-local"], select {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

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

textarea:focus, input:focus, select:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 12px; }
.checkbox input { margin: 0; }

button, .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

button:hover, .button:hover { border-color: var(--accent); }

button.primary, .button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.danger:hover { background: color-mix(in srgb, var(--bad) 15%, transparent); border-color: var(--bad); }

button.link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    text-decoration: underline;
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
form.inline { display: inline; }

/* ---------- flashes ---------- */

.flashes { margin-bottom: 16px; display: grid; gap: 8px; }

.flash {
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-size: 14px;
}

.flash-success { background: color-mix(in srgb, var(--ok) 15%, var(--bg)); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.flash-error { background: color-mix(in srgb, var(--bad) 15%, var(--bg)); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.flash-warn { background: color-mix(in srgb, var(--warn) 15%, var(--bg)); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.hint.bad { color: var(--bad); }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }

.pill {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}

.tone-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.tone-bad, .bad { color: var(--bad); }
.tone-warn, .warn { color: var(--warn); }
.tone-busy { color: var(--accent); }
.tone-wait { color: var(--muted); }
.tone-muted, .muted { color: var(--muted); }

/* ---------- accounts sidebar ---------- */

.accounts-list { display: grid; gap: 2px; margin-bottom: 12px; }

.account-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.account-row:hover { background: var(--surface-2); }
.account-row.disabled { opacity: 0.55; cursor: not-allowed; }

.account-meta { display: flex; flex-direction: column; line-height: 1.35; }
.account-meta small { color: var(--muted); font-size: 12px; }

/* ---------- media ---------- */

.dropzone {
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dropzone p { margin: 4px 0; }
.dropzone input[type="file"] { display: none; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.thumb {
    position: relative;
    width: 92px;
    border: 2px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface-2);
}

.thumb.on { border-color: var(--accent); }
.thumbs.readonly .thumb { cursor: default; }

.thumb input { position: absolute; top: 5px; left: 5px; z-index: 2; }
.thumb img { display: block; width: 100%; height: 74px; object-fit: cover; }

.thumb-video {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 74px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
}

.thumb-video.small { width: 56px; height: 56px; border-radius: 6px; }

.thumb-meta {
    display: block;
    font-size: 10px;
    color: var(--muted);
    padding: 3px 5px;
    text-align: center;
}

.library summary { cursor: pointer; font-size: 13px; color: var(--muted); }

/* ---------- panels ---------- */

.panels-section { margin-top: 8px; }

.panels-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panels-head h2 { margin: 0; }
.panels-actions { display: flex; align-items: center; gap: 14px; }
.panels-actions .checkbox { margin: 0; white-space: nowrap; }

/*
 * A preview panel is not a destination, and must not be mistaken for one at a
 * glance: no brand stripe, dimmed, and dashed to read as provisional.
 */
.panel-preview {
    border-left-color: var(--line);
    border-style: dashed;
    opacity: 0.86;
}

.panel-preview .body-text { margin-bottom: 0; }

#panels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius);
    padding: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.panel-title { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.panel-title small { color: var(--muted); font-size: 12px; }

.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter small { display: block; font-size: 10px; opacity: 0.75; }
.counter.bad { color: var(--bad); font-weight: 600; }

.changes {
    margin: 0 0 12px;
    padding: 9px 12px 9px 26px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-radius: 8px;
    font-size: 12px;
    color: var(--muted);
}

.changes.edited { padding-left: 12px; list-style: none; }
.changes li { margin: 2px 0; }

.notes {
    margin: 12px 0 0;
    padding: 10px 12px 10px 28px;
    background: color-mix(in srgb, var(--warn) 12%, transparent);
    border-radius: 8px;
    font-size: 12px;
}

.notes.plain { background: none; padding-left: 20px; }
.notes li { margin: 4px 0; }

.options {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: 8px;
    margin-bottom: 12px;
}

.options .field { margin-bottom: 8px; }
.options .field:last-child { margin-bottom: 0; }

/* ---------- the framing control ---------- */

.frames { display: grid; gap: 16px; margin-top: 4px; }

.frame-stage {
    position: relative;
    width: 100%;
    max-height: 340px;
    background:
        repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.frame-image {
    display: block;
    width: 100%;
    height: 100%;
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
}

.video-placeholder span { text-transform: uppercase; letter-spacing: 0.08em; }
.video-placeholder small { font-size: 11px; opacity: 0.8; }

/* The draggable focal point. Only shown while cropping — a pad has no focus. */
.focal {
    position: absolute;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.22);
    cursor: grab;
    z-index: 3;
}

.focal:active { cursor: grabbing; }
.frame-stage.grabbing { cursor: grabbing; }

.frame-explain { font-size: 12px; color: var(--muted); margin: 8px 0 6px; }
.frame-meta { font-size: 11px; color: var(--muted); margin: 6px 0 0; font-variant-numeric: tabular-nums; }

.frame-controls { display: grid; gap: 10px; }

.fit-toggle { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.fit-toggle label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.fit-toggle input { margin: 0; }
.loss { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.anchor-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 84px;
}

.anchor {
    aspect-ratio: 1;
    padding: 0;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    cursor: pointer;
}

.anchor:hover { border-color: var(--accent); }
.anchor.on { background: var(--accent); border-color: var(--accent); }
.anchor-grid[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

.zoom { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.zoom span { flex: 0 0 auto; }
.zoom input { flex: 1; }
.zoom output { font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.zoom[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

/* ---------- posts ---------- */

.tallies { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

.tally {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 16px;
    min-width: 88px;
}

.tally strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.tally span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

.upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.upcoming li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.upcoming li:last-child { border-bottom: none; }
.upcoming .when { color: var(--muted); margin-left: auto; font-size: 12px; }

.post-row { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.post-row-main { display: flex; gap: 14px; min-width: 0; flex: 1; }
.post-row-media { position: relative; flex: 0 0 auto; }
.post-row-media img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }

.post-row-media .count {
    position: absolute;
    right: -4px;
    bottom: -4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 10px;
    padding: 1px 5px;
}

.post-row-body { min-width: 0; flex: 1; }
.post-row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.post-link { text-decoration: none; font-weight: 550; }
.post-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; }

.target-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.body-text {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 13px;
    margin: 0 0 12px;
    font: inherit;
    font-size: 14px;
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.error-box {
    background: color-mix(in srgb, var(--bad) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--line));
    border-radius: 8px;
    padding: 10px 13px;
    margin-bottom: 12px;
    font-size: 13px;
}

.error-box strong { color: var(--bad); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.error-box p, .error-box ul { margin: 5px 0 0; }
.error-box ul { padding-left: 18px; }

details { margin-bottom: 12px; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
details summary:hover { color: var(--text); }

.attempts { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.attempts th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.attempts td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.attempts em { display: block; color: var(--warn); font-size: 11px; margin-top: 2px; }

/* ---------- accounts page ---------- */

.platform { border-left: 3px solid var(--brand); }

.account-cards { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }

.account-cards li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 8px;
    flex-wrap: wrap;
}

.account-card-main { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.account-card-main div { display: flex; flex-direction: column; line-height: 1.35; }
.account-card-main small { color: var(--muted); font-size: 12px; }
.account-card-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--line); }

.preflight ul { font-size: 13px; padding-left: 20px; margin: 8px 0; }
.preflight li { margin: 5px 0; }

/* ---------- health ---------- */

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.check {
    display: flex;
    gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.check:last-child { border-bottom: none; }
.check div { min-width: 0; }
.check strong { display: block; }
.check p { margin: 3px 0 0; color: var(--muted); }
.check-mark { flex: 0 0 18px; text-align: center; font-weight: 700; }
.check.tone-ok .check-mark { color: var(--ok); }
.check.tone-warn .check-mark { color: var(--warn); }
.check.tone-bad .check-mark { color: var(--bad); }
.check.tone-muted .check-mark { color: var(--muted); }

.runbook { font-size: 13px; padding-left: 20px; margin: 8px 0 0; }
.runbook li { margin: 8px 0; }
