/* GaMa Social. Same brand as the GaMa website: Archivo for headings, Hanken Grotesk for text,
   GaMa blue for actions and orange as the single accent. */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/hanken-grotesk-latin.woff2") format("woff2");
}

:root {
  --ink: #0c0d0f;
  --text: #14161b;
  --muted: #4a505c;
  --surface: #ffffff;
  --paper: #f3f5f9;
  --sunk: #e9ecf2;
  --line: #dde1e8;
  --line-strong: #b9c0cc;
  --blue: #1d4fe0;
  --blue-ink: #ffffff;
  --blue-soft: #e8eeff;
  --orange: #ff6b1a;
  --orange-soft: #ffe6d6;
  --orange-ink: #a63a00;
  --orange-text: #e2560b; /* the wordmark orange, dark enough to read on white at this size */
  --ok: #0b6b38;
  --ok-soft: #ddf3e6;
  --warn: #8a5300;
  --warn-soft: #fff1d6;
  --bad: #b42318;
  --bad-soft: #fde4e1;
  --focus: #ff6b1a;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(12 13 15 / 0.06), 0 4px 16px rgb(12 13 15 / 0.05);
  --display: "Archivo", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4f6fa;
    --text: #e6e9ef;
    --muted: #a3abb9;
    --surface: #161a22;
    --paper: #0e1117;
    --sunk: #1d222c;
    --line: #2a303c;
    --line-strong: #444c5b;
    --blue: #7c9bff;
    --blue-ink: #0b0e14;
    --blue-soft: #1c2647;
    --orange: #ff8a4c;
    --orange-soft: #3a2214;
    --orange-ink: #ffb48a;
    --orange-text: #ff8a4c;
    --ok: #6fd49a;
    --ok-soft: #12301f;
    --warn: #f3bd6a;
    --warn-soft: #33260f;
    --bad: #ff8f85;
    --bad-soft: #3a1714;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.15; margin: 0; overflow-wrap: break-word; min-width: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.005em; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.bad-text { color: var(--bad); font-weight: 600; }
.small { font-size: 0.9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner, .wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand span { color: var(--orange-text); }
.who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wrap { padding-top: 24px; padding-bottom: 64px; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.layout > .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stack > * + * { margin-top: 16px; }

/* ---------- App layout: compose on the left, calendar and posts on the right ---------- */
.layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); margin-top: 20px; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
  .layout > .compose { position: sticky; top: 16px; }
}

/* ---------- Usage strip ---------- */
.usage { display: flex; gap: 12px 28px; flex-wrap: wrap; align-items: center; }
.meter { display: grid; gap: 6px; min-width: 180px; flex: 1; }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; }
.meter-track { height: 8px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.meter-fill { height: 100%; width: 100%; transform-origin: left; background: var(--blue); }
.meter-fill.full { background: var(--warn); }

/* ---------- Controls ---------- */
label, .label { display: block; font-weight: 600; margin: 14px 0 6px; color: var(--ink); }
input[type="text"], input[type="search"], input[type="email"], input[type="url"], input[type="datetime-local"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 140px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:disabled, select:disabled, textarea:disabled { background: var(--sunk); color: var(--muted); cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
.hint { font-size: 0.88rem; color: var(--muted); margin-top: 6px; max-width: 72ch; }
.counter { font-size: 0.85rem; color: var(--muted); text-align: right; margin-top: 4px; }
.counter.over { color: var(--bad); font-weight: 600; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--blue); background: var(--blue); color: var(--blue-ink);
  font: 600 0.98rem/1.2 var(--body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.btn:hover, button:hover { opacity: 0.9; }
.btn:active, button:active { transform: translateY(1px); }
.btn.secondary, button.secondary { background: transparent; color: var(--blue); }
.btn.secondary:hover, button.secondary:hover { background: var(--blue-soft); opacity: 1; }
.btn.quiet, button.quiet { background: transparent; border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn.quiet:hover, button.quiet:hover { color: var(--ink); background: var(--sunk); opacity: 1; }
.btn.danger, button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover, button.danger:hover { background: var(--bad-soft); opacity: 1; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
button[aria-busy="true"] { cursor: progress; opacity: 0.7; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--blue); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.check:hover { border-color: var(--line-strong); }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.check:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }

/* ---------- Status pills (text plus colour, never colour alone) ---------- */
.pill { display: inline-flex; align-items: center; font-size: 0.85rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.s-posted, .s-connected { background: var(--ok-soft); color: var(--ok); }
.s-failed, .s-needs_reconnect { background: var(--bad-soft); color: var(--bad); }
.s-pending { background: var(--blue-soft); color: var(--blue); }
.s-queued, .s-publishing { background: var(--warn-soft); color: var(--warn); }
.s-skipped, .s-cancelled { background: var(--sunk); color: var(--muted); }
.net { font-size: 0.85rem; color: var(--muted); }

/* ---------- Notices ---------- */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.notice.test { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-ink); }
#banner:empty { display: none; }
#banner { margin-top: 16px; }

/* ---------- Accounts ---------- */
.accounts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.account { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); flex-wrap: wrap; }
.account img, .avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; background: var(--sunk); }
.avatar { display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--muted); }
.account-name { flex: 1; min-width: 140px; }
.account-name strong { display: block; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--sunk); border-radius: var(--radius-sm); }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); min-height: 36px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); opacity: 1; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 0.85rem; color: var(--muted); padding: 4px 6px; }
.cal-day { min-height: 96px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.other { background: var(--paper); }
.cal-day.other .cal-num { color: var(--muted); }
.cal-day.today .cal-n { background: var(--ink); color: var(--surface); }
.cal-num { font-size: 0.85rem; font-weight: 700; color: var(--ink); }
.cal-item {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; width: 100%; min-height: 0; padding: 3px 6px; border-radius: 6px; border: 0;
  font: 500 0.8rem/1.3 var(--body); text-align: left; white-space: normal; overflow: hidden; overflow-wrap: anywhere;
  background: var(--blue-soft); color: var(--blue);
}
.cal-item.done { background: var(--ok-soft); color: var(--ok); }
.cal-item.bad { background: var(--bad-soft); color: var(--bad); }
.cal-item.off { background: var(--sunk); color: var(--muted); }
.cal-day { position: relative; }
.cal-day.selected { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
button.cal-num { align-self: flex-start; min-height: 28px; padding: 2px 6px; margin: -2px 0 0 -2px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); font: 700 0.85rem/1 var(--body); }
button.cal-num:hover { background: var(--sunk); opacity: 1; }
.cal-day.other button.cal-num { color: var(--muted); }
.cal-count { display: none; }
@media (max-width: 640px) {
  .cal-day { min-height: 56px; padding: 4px; }
  .cal-item { display: none; }
  /* The whole day is the button on a phone. */
  button.cal-num { position: absolute; inset: 0; margin: 0; padding: 6px; align-items: flex-start; justify-content: flex-start; border-radius: var(--radius-sm); }
  .cal-count { display: inline-flex; position: absolute; right: 4px; bottom: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
    align-items: center; justify-content: center; background: var(--blue); color: var(--blue-ink); font: 700 0.75rem/1 var(--body); pointer-events: none; }
  .cal-dow { font-size: 0.75rem; padding: 2px; }
}
.cal-dayview { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.day-posts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.day-post { width: 100%; justify-content: flex-start; gap: 10px; background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 400; white-space: normal; text-align: left; }
.day-post:hover { border-color: var(--line-strong); opacity: 1; }
.day-post-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Fold-away cards (plan, accounts, settings) ---------- */
.fold > summary { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; list-style: none; cursor: pointer; padding-right: 28px; position: relative; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: ""; position: absolute; right: 4px; top: 50%; width: 9px; height: 9px; margin-top: -7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s ease; }
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.fold[open] > summary { margin-bottom: 14px; }
.fold[open] .fold-short { display: none; }
.fold > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }

/* ---------- Posts ---------- */
.posts { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.post { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.post.highlight { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.post.draft { border-style: dashed; }
.post:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.post-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; max-width: 70ch; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.thumbs img, .thumbs video { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--sunk); }
.targets { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.target { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.95rem; }
.target .err { flex-basis: 100%; color: var(--bad); font-size: 0.88rem; }
.empty { text-align: center; padding: 32px 12px; color: var(--muted); }

/* ---------- Problems while composing ---------- */
.problems { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.problems:empty { display: none; }
.problems li { color: var(--bad); font-size: 0.92rem; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bad-soft); }

/* ---------- Failure alert ---------- */
.alert-fail { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px;
  padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--bad); background: var(--bad-soft); color: var(--bad); }
.alert-fail strong { font-family: var(--display); font-size: 1.05rem; }
.alert-fail button { border-color: var(--bad); background: var(--bad); color: var(--surface); }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 8px 40px rgb(12 13 15 / 0.25); }
dialog::backdrop { background: rgb(12 13 15 / 0.45); }
.dlg { padding: 22px; }
.dlg h2 { margin-bottom: 12px; }
.dlg-actions { justify-content: flex-end; margin-top: 20px; }
.preview { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--paper); }
.preview .post-body { margin: 0; max-height: 220px; overflow: auto; }
.preview-to { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Admin table ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.88rem; color: var(--muted); font-weight: 600; border-top: 0; }
td select { width: auto; min-width: 130px; padding: 6px 8px; }

/* ---------- Sign-in and document pages ---------- */
.narrow { max-width: 480px; }
.doc { max-width: 760px; }
.doc h2 { margin-top: 28px; }
.doc p, .doc ul { margin-top: 10px; max-width: 70ch; text-wrap: pretty; }
.doc li + li { margin-top: 4px; }
.placeholder { background: var(--orange-soft); color: var(--orange-ink); padding: 0 4px; border-radius: 4px; }
.footer { max-width: var(--max); margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 0.9rem; display: flex; gap: 8px 20px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:active, button:active { transform: none; }
}

/* First-time guide */
.start { margin-top: 16px; border-color: var(--blue); }
.start h2 { font-size: 1.25rem; }
.steps { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.step { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.step.current { border-color: var(--blue); background: var(--blue-soft); }
.step.done { color: var(--muted); }
.step-text p { margin-top: 2px; max-width: 60ch; }
.step-mark { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; border: 1.5px solid var(--line-strong); color: var(--muted); }
.step.current .step-mark { border-color: var(--blue); background: var(--blue); color: var(--blue-ink); }
.step.done .step-mark { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.step-done { margin-left: 8px; font-size: 0.85rem; color: var(--ok); font-weight: 600; }
@media (max-width: 560px) {
  .step { grid-template-columns: 32px minmax(0, 1fr); }
  .step > .btn, .step > button { grid-column: 2; justify-self: start; }
}

/* Greeting */
.hello { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); margin: 4px 0 16px; }

/* Calendar day number (today wears a dark badge) */
.cal-n { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 999px; }

/* Drag and drop for images */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.drop { display: grid; gap: 2px; justify-items: center; text-align: center; margin: 0; padding: 18px 12px; font-weight: 400;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease; }
.drop strong { color: var(--ink); }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.file-input:focus-visible + .drop { outline: 3px solid var(--focus); outline-offset: 2px; }
.thumb { position: relative; }
.thumb-x { position: absolute; top: -6px; right: -6px; min-height: 0; width: 24px; height: 24px; padding: 0; border-radius: 999px;
  background: var(--ink); border-color: var(--surface); color: var(--surface); font-size: 1rem; line-height: 1; }

/* List filters */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter { min-height: 36px; padding: 6px 12px; background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 500; }
.filter:hover { background: var(--sunk); opacity: 1; }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.filter.has-bad:not([aria-pressed="true"]) { border-color: var(--bad); color: var(--bad); }
.posts .more { text-align: center; padding: 8px 0; }

/* Help */
.help-list { margin: 0; display: grid; gap: 4px; }
.help-list dt { font-weight: 700; color: var(--ink); margin-top: 10px; }
.help-list dt:first-child { margin-top: 0; }
.help-list dd { margin: 0; color: var(--muted); max-width: 60ch; }
.help-contact { padding: 12px; border-radius: var(--radius-sm); background: var(--paper); }

/* Write with your own AI */
.code-box { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; word-break: break-all; }
.help-steps { margin: 8px 0 12px 20px; display: grid; gap: 8px; }
.help-steps button { margin-right: 6px; }

/* Find a photo (Pexels) */
.photo-row { margin-top: 8px; }
.photos-dlg { width: min(860px, calc(100vw - 32px)); }
.photo-search input { flex: 1 1 240px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: min(60vh, 560px); overflow: auto; margin: 8px 0; }
.photo-grid figure { margin: 0; display: grid; gap: 4px; align-content: start; }
.photo-pick { padding: 0; min-height: 0; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--sunk); overflow: hidden; }
.photo-pick:hover, .photo-pick:focus-visible { border-color: var(--blue); opacity: 1; }
.photo-pick img { display: block; width: 100%; height: 130px; object-fit: cover; }
.photo-grid figcaption, .thumb-credit { font-size: 0.78rem; color: var(--muted); line-height: 1.3; }
.photo-grid figcaption a, .thumb-credit a { color: inherit; }
.photo-shape { color: var(--warn); font-weight: 600; }
.photo-source { margin-top: 8px; }
.thumb-credit { max-width: 120px; margin-top: 2px; }
