/* Family Guy Explainer — AF-layout design system (structural, not a theme).
 * Layout primitives mirrored from AvatarForge: sticky top bar with section
 * tabs, tabbed library, job-detail tab bar + inspector sidebar, settings
 * sidebar nav, card gallery density, empty states, bottom nav on mobile.
 * Product identity (logo, explainer domain language) is unchanged. */

:root {
  --fge-bg: #f4f5f7;
  --fge-surface: #ffffff;
  --fge-border: #e3e6eb;
  --fge-border-strong: #cfd4dc;
  --fge-ink: #101828;
  --fge-ink-2: #344054;
  --fge-muted: #667085;
  --fge-faint: #98a2b3;
  --fge-accent: #175cd3;
  --fge-accent-soft: #eff4ff;
  --fge-good: #067647;
  --fge-good-soft: #ecfdf3;
  --fge-warn: #b54708;
  --fge-warn-soft: #fffaeb;
  --fge-bad: #b42318;
  --fge-bad-soft: #fef3f2;
  --fge-radius: 10px;
  --fge-radius-sm: 7px;
  --fge-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --fge-topbar-h: 60px;
}

/* ---- app frame ---- */
.fge-body { background: var(--fge-bg); }
.fge-topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--fge-topbar-h);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--fge-border);
}
.fge-topbar__inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: var(--fge-topbar-h);
  display: flex; align-items: center; gap: 14px;
}
.fge-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.fge-brand img { width: 34px; height: 34px; object-fit: contain; }
.fge-brand__name { font-weight: 700; font-size: 15px; color: var(--fge-ink); white-space: nowrap; }
.fge-version {
  font-size: 11px; font-weight: 600; color: var(--fge-muted);
  background: #eef1f5; border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.fge-tabs { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.fge-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--fge-muted);
  text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
.fge-tab:hover { color: var(--fge-ink); background: #f2f4f7; }
.fge-tab--active { color: var(--fge-accent); background: var(--fge-accent-soft); border-color: #d1e0ff; }
.fge-tab__count {
  font-size: 11px; font-weight: 700; background: #e4e9f0; color: var(--fge-ink-2);
  border-radius: 999px; padding: 1px 7px;
}
.fge-tab--active .fge-tab__count { background: #d1e0ff; color: var(--fge-accent); }
.fge-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--fge-muted); text-decoration: none;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-size: 16px;
}
.fge-iconbtn:hover { color: var(--fge-ink); background: #f2f4f7; }
.fge-iconbtn--active { color: var(--fge-accent); background: var(--fge-accent-soft); border-color: #d1e0ff; }

.fge-main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 96px; }
.fge-flash {
  border-radius: var(--fge-radius); padding: 12px 16px; font-size: 14px; margin-bottom: 16px;
}
.fge-flash--ok { background: var(--fge-good-soft); color: var(--fge-good); border: 1px solid #a6f4c5; }
.fge-flash--err { background: var(--fge-bad-soft); color: var(--fge-bad); border: 1px solid #fecdca; }

/* ---- page header (sticky section header pattern) ---- */
.fge-pagehead {
  position: sticky; top: var(--fge-topbar-h); z-index: 30;
  background: rgba(244, 245, 247, 0.96); backdrop-filter: blur(6px);
  padding: 14px 0 12px; margin-bottom: 16px;
  border-bottom: 1px solid transparent;
}
.fge-pagehead__row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.fge-pagehead h1 { font-size: 22px; font-weight: 700; color: var(--fge-ink); margin: 0; }
.fge-pagehead p.fge-sub { color: var(--fge-muted); font-size: 13.5px; margin: 4px 0 0; max-width: 70ch; }
.fge-spacer { flex: 1 1 auto; }

/* ---- segmented tabs (library / detail) ---- */
.fge-segtabs {
  display: inline-flex; gap: 2px; background: #e9edf2; border-radius: 10px; padding: 3px;
  max-width: 100%; overflow-x: auto;
}
.fge-segtab {
  padding: 7px 14px; border-radius: 7px; font-size: 13.5px; font-weight: 600;
  color: var(--fge-muted); text-decoration: none; white-space: nowrap; border: 0; background: transparent;
}
.fge-segtab:hover { color: var(--fge-ink); }
.fge-segtab--active { background: var(--fge-surface); color: var(--fge-ink); box-shadow: var(--fge-shadow); }

/* ---- filter bar ---- */
.fge-filterbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--fge-surface); border: 1px solid var(--fge-border);
  border-radius: var(--fge-radius); padding: 10px 12px; box-shadow: var(--fge-shadow);
  margin-bottom: 16px;
}
.fge-search { position: relative; flex: 1 1 220px; min-width: 180px; }
.fge-search input {
  width: 100%; border: 1px solid var(--fge-border-strong); border-radius: 8px;
  padding: 8px 12px 8px 32px; font-size: 14px; background: #fcfcfd; color: var(--fge-ink);
}
.fge-search::before { content: "\2315"; position: absolute; left: 10px; top: 7px; color: var(--fge-faint); }
.fge-select {
  border: 1px solid var(--fge-border-strong); border-radius: 8px; background: #fcfcfd;
  padding: 8px 10px; font-size: 13.5px; color: var(--fge-ink-2); font-weight: 500;
}
.fge-chiprow { display: flex; gap: 6px; flex-wrap: wrap; }
.fge-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--fge-border); background: var(--fge-surface); color: var(--fge-ink-2);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.fge-chip:hover { border-color: var(--fge-border-strong); }
.fge-chip--active { background: var(--fge-ink); border-color: var(--fge-ink); color: #fff; }

/* ---- cards / gallery ---- */
.fge-grid { display: grid; gap: 14px; }
.fge-grid--gallery { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.fge-card {
  background: var(--fge-surface); border: 1px solid var(--fge-border);
  border-radius: var(--fge-radius); box-shadow: var(--fge-shadow); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
}
.fge-card__thumb {
  aspect-ratio: 16 / 9; background: linear-gradient(135deg, #1d2939 0%, #344054 55%, #175cd3 130%);
  display: grid; place-items: center; color: #fff; position: relative; overflow: hidden;
}
.fge-card__thumb img, .fge-card__thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fge-card__thumb--empty span { font-size: 13px; font-weight: 600; opacity: 0.85; padding: 0 16px; text-align: center; }
.fge-card__status { position: absolute; left: 10px; top: 10px; }
.fge-card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fge-card__title { font-weight: 700; font-size: 14.5px; color: var(--fge-ink); margin: 0;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fge-card__meta { font-size: 12.5px; color: var(--fge-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.fge-card__topic { font-size: 12.5px; color: var(--fge-muted);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fge-card__actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ---- queue rows (dense list) ---- */
.fge-queue { display: flex; flex-direction: column; gap: 10px; }
.fge-row {
  background: var(--fge-surface); border: 1px solid var(--fge-border); border-radius: var(--fge-radius);
  box-shadow: var(--fge-shadow); padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
.fge-row--draft { background: #f8fafc; }
.fge-dot { width: 10px; height: 10px; border-radius: 999px; margin-top: 5px; flex-shrink: 0; }
.fge-dot--idle { background: #98a2b3; } .fge-dot--queued { background: #eaaa08; }
.fge-dot--processing { background: #175cd3; animation: fge-pulse 1.6s ease-in-out infinite; }
.fge-dot--done { background: #12b76a; } .fge-dot--needs_attention { background: #f04438; }
.fge-dot--stopped, .fge-dot--cancelled { background: #98a2b3; }
@keyframes fge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- buttons ---- */
.fge-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--fge-border-strong); background: var(--fge-surface); color: var(--fge-ink-2);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.fge-btn:hover { background: #f8fafc; }
.fge-btn--primary { background: var(--fge-accent); border-color: var(--fge-accent); color: #fff; }
.fge-btn--primary:hover { background: #1849a9; }
.fge-btn--good { background: #067647; border-color: #067647; color: #fff; }
.fge-btn--good:hover { background: #05603a; }
.fge-btn--danger { background: #b42318; border-color: #b42318; color: #fff; }
.fge-btn--dark { background: #101828; border-color: #101828; color: #fff; }
.fge-btn--sm { padding: 5px 10px; font-size: 12.5px; }
.fge-link { color: var(--fge-accent); font-weight: 600; font-size: 13.5px; text-decoration: none; }
.fge-link:hover { text-decoration: underline; }

/* ---- badges (keep existing status vocabulary) ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge-idle { background: #eef1f5; color: #344054; }
.badge-queued, .badge-pending { background: #fef0c7; color: #93370d; }
.badge-processing, .badge-running { background: #e0eaff; color: #1849a9; }
.badge-done, .badge-completed { background: #d3f8df; color: #05603a; }
.badge-needs_attention, .badge-failed { background: #fee4e2; color: #912018; }
.badge-cancelled, .badge-stopped { background: #eef1f5; color: #475467; }
.progress-fill {
  background: linear-gradient(90deg, #175cd3, #0e9384, #12b76a);
  background-size: 180% 100%;
  animation: progressMotion 2.4s ease-in-out infinite;
}
@keyframes progressMotion { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ---- layout columns ---- */
.fge-cols { display: grid; gap: 20px; align-items: start; }
.fge-cols--create { grid-template-columns: 400px minmax(0, 1fr); }
.fge-cols--detail { grid-template-columns: minmax(0, 1fr) 320px; }
.fge-cols--settings { grid-template-columns: 230px minmax(0, 1fr); }
@media (max-width: 1024px) {
  .fge-cols--create, .fge-cols--detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .fge-cols--settings { grid-template-columns: 1fr; }
  .fge-settingsnav { position: static !important; flex-direction: row !important; overflow-x: auto; }
}

/* ---- panels ---- */
.fge-panel {
  background: var(--fge-surface); border: 1px solid var(--fge-border);
  border-radius: var(--fge-radius); box-shadow: var(--fge-shadow); padding: 18px;
}
.fge-panel + .fge-panel { margin-top: 14px; }
.fge-panel h2 { font-size: 15px; font-weight: 700; color: var(--fge-ink); margin: 0 0 4px; }
.fge-panel__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.fge-sticky { position: sticky; top: calc(var(--fge-topbar-h) + 76px); }
@media (max-width: 1024px) { .fge-sticky { position: static; } }

/* ---- settings sidebar ---- */
.fge-settingsnav {
  position: sticky; top: calc(var(--fge-topbar-h) + 76px);
  display: flex; flex-direction: column; gap: 2px;
  background: var(--fge-surface); border: 1px solid var(--fge-border);
  border-radius: var(--fge-radius); box-shadow: var(--fge-shadow); padding: 8px;
}
.fge-settingsnav a {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 7px;
  font-size: 13.5px; font-weight: 600; color: var(--fge-muted); text-decoration: none;
}
.fge-settingsnav a:hover { background: #f2f4f7; color: var(--fge-ink); }
.fge-settingsnav a.fge-settingsnav--active { background: var(--fge-accent-soft); color: var(--fge-accent); }
.fge-settingsnav__count { margin-left: auto; font-size: 11px; background: #eef1f5; border-radius: 999px; padding: 1px 7px; }
.fge-savebar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.97); border: 1px solid var(--fge-border);
  border-radius: var(--fge-radius); box-shadow: var(--fge-shadow);
  padding: 10px 14px; margin-top: 14px;
}

/* ---- detail header ---- */
.fge-detailhead {
  position: sticky; top: var(--fge-topbar-h); z-index: 30;
  background: rgba(244, 245, 247, 0.97); backdrop-filter: blur(6px);
  padding: 12px 0; margin-bottom: 14px; border-bottom: 1px solid var(--fge-border);
}
.fge-back { font-size: 13px; font-weight: 600; color: var(--fge-muted); text-decoration: none; }
.fge-back:hover { color: var(--fge-ink); }
.fge-progressline { height: 8px; border-radius: 999px; background: #e9edf2; overflow: hidden; margin-top: 10px; }
.fge-progressline > div { height: 100%; border-radius: 999px; }

/* ---- stats ---- */
.fge-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.fge-stat { background: var(--fge-surface); border: 1px solid var(--fge-border); border-radius: var(--fge-radius); padding: 12px 14px; box-shadow: var(--fge-shadow); }
.fge-stat__label { font-size: 11.5px; color: var(--fge-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.fge-stat__value { font-size: 24px; font-weight: 800; color: var(--fge-ink); }

/* ---- empty states ---- */
.fge-empty {
  background: var(--fge-surface); border: 1.5px dashed var(--fge-border-strong);
  border-radius: var(--fge-radius); padding: 40px 24px; text-align: center; color: var(--fge-muted);
}
.fge-empty__title { font-size: 15px; font-weight: 700; color: var(--fge-ink); margin-bottom: 6px; }
.fge-empty p { font-size: 13.5px; margin: 0 0 12px; }

/* ---- tables (activity) ---- */
.fge-tablewrap { background: var(--fge-surface); border: 1px solid var(--fge-border); border-radius: var(--fge-radius); box-shadow: var(--fge-shadow); overflow-x: auto; }
.fge-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fge-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fge-muted); padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--fge-border); white-space: nowrap; }
.fge-table td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
.fge-table tr:last-child td { border-bottom: 0; }

/* ---- inspector definition list ---- */
.fge-inspect { display: flex; flex-direction: column; gap: 12px; font-size: 13.5px; }
.fge-inspect dt { color: var(--fge-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.fge-inspect dd { margin: 2px 0 0; color: var(--fge-ink); font-weight: 500; word-break: break-word; }

/* ---- modal / lightbox ---- */
.fge-modal { position: fixed; inset: 0; z-index: 60; background: rgba(16, 24, 40, 0.72); padding: 20px; }
.fge-modal[hidden] { display: none; }
.fge-modal__box { max-width: 1024px; height: 100%; margin: 0 auto; background: #fff; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.fge-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--fge-border); }
.fge-modal__body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.fge-modal__media { background: #101828; display: grid; place-items: center; padding: 16px; min-height: 0; }
.fge-modal__media img, .fge-modal__media video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.fge-modal__side { padding: 16px; border-left: 1px solid var(--fge-border); overflow-y: auto; }
@media (max-width: 860px) { .fge-modal__body { grid-template-columns: 1fr; } .fge-modal__side { border-left: 0; border-top: 1px solid var(--fge-border); } }

/* ---- forms ---- */
.fge-field { margin-bottom: 14px; }
.fge-label { display: block; font-size: 13px; font-weight: 600; color: var(--fge-ink); margin-bottom: 5px; }
.fge-hint { font-size: 12px; color: var(--fge-muted); margin-top: 4px; }
.fge-input, .fge-textarea {
  width: 100%; border: 1px solid var(--fge-border-strong); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; color: var(--fge-ink); background: #fcfcfd;
}
.fge-input:focus, .fge-textarea:focus { outline: 2px solid #b2ccff; border-color: var(--fge-accent); }
.fge-disclosure { border: 1px solid var(--fge-border); border-radius: 8px; margin-bottom: 14px; background: #fcfcfd; }
.fge-disclosure summary { cursor: pointer; padding: 10px 12px; font-size: 13.5px; font-weight: 600; color: var(--fge-ink-2); list-style: none; }
.fge-disclosure summary::-webkit-details-marker { display: none; }
.fge-disclosure summary::before { content: "+ "; color: var(--fge-accent); font-weight: 800; }
.fge-disclosure[open] summary::before { content: "\2212  "; }
.fge-disclosure__body { padding: 0 12px 12px; }

/* ---- switch (queue enable toggle, kept behavior) ---- */
.switch { position: relative; display: inline-flex; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 9999px; background: #d1d5db; transition: 0.18s ease; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 9999px; background: white; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: 0.18s ease; }
.switch input:checked + .switch-track { background: #12b76a; }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }

/* ---- drag reorder ---- */
.queue-item[draggable="true"] { cursor: grab; }
.queue-item.dragging { opacity: 0.45; }
.queue-item.is-draft { background: #f8fafc; }
.queue-item.is-draft .topic-text { color: var(--fge-faint); }

/* ---- bottom nav (mobile, AF pattern) ---- */
.fge-bottomnav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.98); border-top: 1px solid var(--fge-border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.fge-bottomnav__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.fge-bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--fge-muted); text-decoration: none;
  padding: 6px 2px; border-radius: 8px;
}
.fge-bottomnav a.fge-bottomnav--active { color: var(--fge-accent); }
.fge-bottomnav .fge-bnicon { font-size: 18px; line-height: 1; }
@media (max-width: 720px) {
  .fge-tabs { display: none; }
  .fge-brand__name { display: none; }
  .fge-bottomnav { display: block; }
  .fge-main { padding: 16px 12px 120px; }
  .fge-pagehead { top: var(--fge-topbar-h); }
}
