/* Shared controls. Marketing and the hosted app both load this file. */

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  z-index: 50;
  border-radius: var(--radius);
}
.skip:focus { top: 12px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--on-accent);
  font: 600 var(--text-md)/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover, .button:hover { background: var(--muted); color: var(--bg); }
button.secondary, .button.secondary, .button.ghost, button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
button.secondary:hover, .button.secondary:hover, .button.ghost:hover, button.ghost:hover {
  background: var(--hover);
  color: var(--ink);
  border-color: var(--line);
}
button.small, .button.small { min-height: 32px; padding: 0 12px; font-size: var(--text-sm); }
button:disabled, .button:disabled { opacity: .55; cursor: not-allowed; }
.icon-button {
  min-width: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.icon-button:hover { background: var(--hover); color: var(--ink); }

label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: var(--text-sm); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: inherit;
  font: 16px/1.4 var(--sans);
}
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  padding: 0;
  flex: none;
  accent-color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* The half-filled "waiting" mark is drawn, not a character: U+25D0 is not in
   IBM Plex, and the fallback fonts drew it as a sliver (#186). */
/* Status chips (#170) are square stamps: mono text and a
   glyph per state, so the meaning never rides on color alone. Proof red
   (--accent) marks the approval stamp and the brand mark, never a control, a chip or a focus ring. */
.chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  height: auto;
  gap: 4px;
  padding: 2px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--muted);
  font: 400 12px/18px var(--sans);
}
.chip.draft, .chip.proposed, .chip.unscheduled { color: var(--muted); background: var(--chip); }
.chip.submitted, .chip.pending, .chip.pending_approval, .chip.in_review,
.chip.awaiting_approval, .chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.approved { color: var(--ink); background: transparent; box-shadow: inset 0 0 0 1px var(--ink); }
.chip.scheduled, .chip.queued { color: var(--info); background: var(--info-soft); }
.chip.published, .chip.good, .chip.active { color: var(--good); background: var(--good-bg); }
.chip.failed, .chip.rejected, .chip.cancelled, .chip.bad { color: var(--bad); background: var(--bad-bg); }
:is(.chip.draft, .chip.proposed, .chip.unscheduled)::before { content: "\25CB"; content: "\25CB" / ""; }
:is(.chip.submitted, .chip.pending, .chip.pending_approval, .chip.in_review, .chip.awaiting_approval, .chip.warn)::before { content: ""; content: "" / ""; display: inline-block; box-sizing: border-box; width: 9px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
:is(.chip.approved, .chip.published, .chip.good, .chip.active)::before { content: "\2713"; content: "\2713" / ""; }
:is(.chip.scheduled, .chip.queued)::before { content: "\25CF"; content: "\25CF" / ""; }
:is(.chip.failed, .chip.rejected, .chip.cancelled, .chip.bad)::before { content: "\2715"; content: "\2715" / ""; }
.chip::before { font-family: var(--sans); font-size: 12px; }

kbd {
  font: 600 12px/1.4 var(--sans);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  padding: 0 4px;
  background: var(--card);
  color: var(--muted);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 16px;
  text-align: center;
}
.empty-title { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.empty-state p { margin: 0; color: var(--muted); }

.cite {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  background: var(--chip);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}
a.cite:hover { border-color: var(--ink); color: var(--ink); }
.citations { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 12px 4px 4px;
  background: var(--chip);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}
.source-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
}
a.source-chip:hover { border-color: var(--ink); color: var(--ink); }

.x-thread { display: grid; max-width: 520px; }
.x-post {
  max-width: 520px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
}
.x-thread .x-post { border-radius: 0; }
.x-thread .x-post:first-child { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.x-thread .x-post:last-child { border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.x-thread .x-post:only-child { border-radius: var(--radius-xl); }
.x-post + .x-post { border-top: 0; position: relative; }
.x-post + .x-post::before {
  content: "";
  position: absolute;
  left: 28px;
  top: -10px;
  width: 2px;
  height: 10px;
  background: var(--line);
}
.x-post-head { display: flex; align-items: center; gap: 8px; }
.x-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}
.x-name { font-weight: 600; }
.x-handle, .x-post-meta { color: var(--muted); font-size: var(--text-sm); }
.x-post-body { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.x-post-meta { margin: 0; }

.skeleton {
  display: block;
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--hover), var(--line), var(--hover));
  background-size: 200% 100%;
  animation: skeleton 1.1s ease-in-out infinite;
}
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  margin: 0;
  background: var(--inverse);
  color: var(--inverse-ink);
  border-radius: var(--radius-lg);
  padding: 12px 12px;
  box-shadow: var(--shadow-pop);
  font-size: var(--text-md);
}

dialog.palette, dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow-pop);
}
dialog.palette { width: min(520px, calc(100% - 32px)); }
dialog.modal { width: min(440px, calc(100% - 32px)); padding: 24px; }
dialog.palette::backdrop, dialog.modal::backdrop { background: rgba(12, 13, 16, .45); }
.palette-form { display: flex; flex-direction: column; margin: 0; }
.palette-form input[type="search"] {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  min-height: 48px;
  padding: 12px 16px;
  background: transparent;
}
.palette-form input:focus-visible { outline: none; }
#command-list { list-style: none; margin: 0; padding: 8px; max-height: 280px; overflow: auto; }
#command-list li { margin: 0; }
#command-list button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: var(--radius);
  min-height: 40px;
  font-weight: 600;
}
#command-list button[aria-selected="true"], #command-list button:hover {
  background: var(--hover);
  color: var(--ink);
}
.palette-hint { margin: 0; padding: 8px 16px 12px; color: var(--muted); font-size: var(--text-xs); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; }
.tabs a, .tabs button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  border: 0;
  text-decoration: none;
  font-size: var(--text-sm);
}
.tabs a:hover, .tabs button:hover { background: var(--hover); color: var(--ink); }
.tabs [aria-current="page"], .tabs strong {
  background: var(--chip);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 4px 12px;
}

@media (max-width: 390px) {
  button, .button { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Peter's review, 2026-10-24: progress, risky actions, undo. */
.spinner {
  display: inline-block; width: 0.9em; height: 0.9em; vertical-align: -0.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: bm-spin 0.8s linear infinite;
}
@keyframes bm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
button[aria-busy="true"] { cursor: progress; opacity: 0.85; }
.toast-error { background: var(--bad); color: var(--bg); }
.actions-risky {
  margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line, rgba(127,127,127,.35));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.actions-risky p { margin: 0; font-size: 0.85em; }
.banner form.undo { display: inline-block; margin-left: 8px; }
.banner p { display: inline; margin: 0; }
.char-count { display: block; font-size: 0.85em; }
.count-over { color: var(--bad); }
.x-post-body .count-over { background: var(--bad-bg); }

/* The wordmark beside the mark (#180). */
.logo-name { font: 400 20px/1 var(--display); letter-spacing: 0; }

/* Danger (#186): actions that post right now or delete. Oxblood, never proof
   red: red means a person approved. The outline form is for Delete. */
button.danger, .button.danger { background: var(--bad); color: var(--on-accent); border-color: var(--bad); }
button.danger:hover, .button.danger:hover { background: var(--bad-ink); color: var(--on-accent); filter: brightness(.92); }
button.secondary.danger, .button.secondary.danger { background: transparent; color: var(--bad-ink); border-color: var(--line); }
button.secondary.danger:hover, .button.secondary.danger:hover { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-ink); filter: none; }

/* Carbon-style base (#200): two weights, three control heights, lists and
   fieldsets on the 4px grid instead of em-based browser defaults. */
b, strong { font-weight: 600; }
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), select {
  height: var(--control-md);
  min-height: var(--control-md);
  padding-top: 0;
  padding-bottom: 0;
}
input[type="file"] { box-sizing: border-box; height: var(--control-md); min-height: var(--control-md); padding: 4px; }
ul, ol { margin-block: 0 12px; }
fieldset { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
