/* Social Scheduler */
:root {
    --ink: #1e2a3a;
    --ink-soft: #4a5566;
    --muted: #6b7482;
    --paper: #eef1ee;
    --surface: #ffffff;
    --line: #d7dcd8;
    --accent: #0f6e74;
    --accent-dark: #0a5559;
    --accent-tint: #e1f0ef;

    --draft: #6b7280;
    --scheduled: #3559a8;
    --published: #2f7a3e;
    --partial: #b26a00;
    --failed: #b42318;

    --fb: #1d5fd6;
    --ig: #b52d79;

    --radius-sm: 4px;
    --radius: 8px;
    --font: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 15px/1.5 var(--font);
    color: var(--ink);
    background: var(--paper);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
code { background: var(--accent-tint); padding: .1em .35em; border-radius: var(--radius-sm); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
img { max-width: 100%; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--partial); font-style: normal; }
.inline { display: inline; }

/* Layout */
body.has-nav { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--ink);
    color: #dfe5ec;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .55rem; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background:
        linear-gradient(var(--ink), var(--ink)) 5px 9px / 12px 2px no-repeat,
        linear-gradient(var(--ink), var(--ink)) 5px 13px / 8px 2px no-repeat,
        #7fd1c7;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    color: #c7d0da; text-decoration: none; padding: .5rem .7rem; border-radius: var(--radius-sm);
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: rgba(127,209,199,.16); color: #fff; box-shadow: inset 3px 0 0 #7fd1c7; }
.signout { margin-top: auto; font-size: .85rem; display: flex; justify-content: space-between; gap: .5rem; }
.signout .link-button { color: #9fb0c0; }

main.content { padding: 2rem 2.25rem 4rem; min-width: 0; max-width: 1400px; }
main.narrow { padding: 3rem 1rem; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Buttons and forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .5rem .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    border-radius: var(--radius-sm); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
    line-height: 1.2;
}
.btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { color: var(--failed); }
.btn-danger:hover { border-color: var(--failed); color: var(--failed); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-facebook { background: var(--fb); border-color: var(--fb); }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=datetime-local], select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem;
}
textarea { resize: vertical; line-height: 1.55; }
.toolbar select { width: auto; }
label { display: block; font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack label > input, .stack label > select, .stack label > textarea { margin-top: .3rem; }
.narrow-form { max-width: 460px; }

.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border-left: 4px solid; background: var(--surface); }
.flash-success { border-color: var(--published); }
.flash-error { border-color: var(--failed); }

/* Panels and tables */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.danger-zone { border-color: color-mix(in srgb, var(--failed) 35%, var(--line)); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.table th, .table td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #f7f8f7; }
.table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: .4rem; align-items: flex-start; flex-wrap: wrap; }
.row-actions details form { display: flex; gap: .35rem; margin-top: .35rem; }

.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Status badges and platform tags */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; color: #fff; background: var(--draft); white-space: nowrap; }
.badge-scheduled { background: var(--scheduled); }
.badge-published { background: var(--published); }
.badge-partial { background: var(--partial); }
.badge-failed { background: var(--failed); }
.badge-publishing { background: var(--accent); }
.ptag { flex-shrink: 0; display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 4px; font-size: .68rem; font-weight: 700; color: #fff; background: var(--fb); vertical-align: middle; }
.ptag-instagram { background: var(--ig); }

/* Calendar */
.attention { background: #fff7e8; border: 1px solid #f0d6a8; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }
.attention p { margin: .2rem 0; }
.calendar {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.cal-dow { background: #f7f8f7; padding: .45rem .6rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cal-day { background: var(--surface); min-height: 128px; padding: .4rem .45rem .55rem; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.other-month { background: #f7f8f7; }
.cal-day.other-month .cal-date span { color: #a9b0b8; }
.cal-day.past { background-image: linear-gradient(rgba(238,241,238,.45), rgba(238,241,238,.45)); }
.cal-date { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; font-weight: 600; padding: 0 .15rem; }
.cal-day.today .cal-date span { background: var(--accent); color: #fff; border-radius: 999px; min-width: 1.7em; text-align: center; padding: 0 .35em; }
.cal-add { opacity: 0; text-decoration: none; font-size: 1.1rem; line-height: 1; padding: 0 .3rem; border-radius: var(--radius-sm); }
.cal-day:hover .cal-add, .cal-add:focus { opacity: 1; }
.cal-add:hover { background: var(--accent-tint); }
.chip {
    display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 7px; border-radius: var(--radius-sm);
    background: #f2f4f6; color: var(--ink); text-decoration: none; font-size: .78rem; line-height: 1.25;
    border-left: 3px solid var(--draft); min-width: 0;
}
.chip:hover { background: #e7ebef; color: var(--ink); }
.chip-scheduled { border-color: var(--scheduled); background: #edf1fa; }
.chip-published { border-color: var(--published); background: #eaf4ec; }
.chip-partial { border-color: var(--partial); background: #fbf1e1; }
.chip-failed { border-color: var(--failed); background: #fbeceb; }
.chip-publishing { border-color: var(--accent); }
.chip-draft { border-left-style: dashed; }
.chip .ptag { font-size: .62rem; width: 1.6em; height: 1.6em; }
.chip-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.legend { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .85rem; }

/* Posts list */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: .5rem .85rem; text-decoration: none; color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.post-list { display: flex; flex-direction: column; gap: .75rem; }
.post-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.post-thumb img, .post-thumb .text-only { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: 1.4rem; }
.post-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.post-body { margin: 0 0 .5rem; white-space: normal; max-width: 72ch; }
.targets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.target { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.target-error { flex-basis: 100%; color: var(--failed); font-size: .82rem; padding-left: 1.9em; }
.target-published .muted { color: var(--published); }
.target-failed .muted { color: var(--failed); }
.post-actions { display: flex; flex-direction: column; gap: .4rem; min-width: 140px; }
.post-actions .btn { width: 100%; }

/* Composer */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.5rem; align-items: start; }
.composer-main, .composer-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.composer-side { position: sticky; top: 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.field-group { border: 0; padding: 0; margin: 0 0 1.4rem; min-width: 0; }
.composer-side .field-group { margin-bottom: .5rem; }
.group-label { display: block; font-weight: 600; margin-bottom: .45rem; padding: 0; }
.account-picks { display: flex; flex-wrap: wrap; gap: .5rem; }
.account-pick { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; cursor: pointer; }
.account-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.account-pick:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.counter { text-align: right; margin-top: .25rem; }
.counter.over { color: var(--failed); font-weight: 600; }
.upload { display: flex; flex-direction: column; gap: .3rem; font-weight: 400; margin-bottom: .75rem; }
.upload span { font-size: .85rem; color: var(--muted); }
.upload-preview { max-height: 240px; border-radius: var(--radius-sm); margin-bottom: .75rem; display: block; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.media-pick { position: relative; aspect-ratio: 1; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: #f2f4f6; }
.media-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-pick input { position: absolute; opacity: 0; pointer-events: none; }
.media-pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.media-pick:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.media-none { display: grid; place-items: center; font-size: .82rem; color: var(--muted); border: 1px dashed var(--line); }
.ig-no { position: absolute; left: 4px; bottom: 4px; font-size: .65rem; background: rgba(30,42,58,.82); color: #fff; padding: 1px 5px; border-radius: 3px; }
.radio { display: flex; align-items: center; gap: .5rem; font-weight: 400; padding: .2rem 0; }
#when-field { margin-top: .6rem; }
#when-field input { margin: .3rem 0 .2rem; }

/* Clients and accounts */
.account-list { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.account-list li { display: grid; grid-template-columns: 40px 1fr auto; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-tint); object-fit: cover; display: block; }
.connect-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: .5rem; }
.connect-options > div { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.invite-new { margin-top: 1rem; padding: 1rem; background: var(--accent-tint); border-radius: var(--radius); display: flex; gap: .5rem; align-items: flex-end; }
.invite-new label { flex: 1; }
.check-list { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.check-list label { font-weight: 400; }
.page-picks { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.page-picks li { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.page-picks label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.indent { margin: .4rem 0 0 1.6rem; }

/* Signed-out pages */
.auth-card { max-width: 420px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.auth-card.wide { max-width: 680px; }
.checklist { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.checklist li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.checklist .ok strong { color: var(--published); }
.checklist .bad strong { color: var(--failed); }
.checklist .fix { display: block; font-size: .85rem; color: var(--ink-soft); word-break: break-all; }
.prose { line-height: 1.65; }
.prose h2 { margin-top: 1.5em; }

/* Small screens */
@media (max-width: 900px) {
    body.has-nav { display: block; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .75rem 1rem; gap: .75rem; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar .btn-block { width: auto; }
    .signout { margin-top: 0; margin-left: auto; }
    main.content { padding: 1.25rem 1rem 3rem; }
    .composer { grid-template-columns: 1fr; }
    .composer-side { position: static; }
    .connect-options { grid-template-columns: 1fr; }
    .post-row { grid-template-columns: 64px 1fr; }
    .post-thumb img, .post-thumb .text-only { width: 64px; height: 64px; }
    .post-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
    .post-actions .btn, .post-actions form { width: auto; }
    .calendar { grid-template-columns: 1fr; }
    .cal-dow, .cal-day.other-month { display: none; }
    .cal-day { min-height: 0; }
    .cal-day:not(:has(.chip)):not(.today) { display: none; }
    .cal-add { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
