/* ==========================================================================
   StudioFlow — application stylesheet
   Table of contents:
   1. Reset & base       5. Cards & badges        9.  Sidebar & topbar
   2. Layout helpers     6. Tables                10. Marketing / landing
   3. Typography         7. Alerts & flash         11. Utilities
   4. Buttons & forms    8. Modals & dropdowns     12. Motion & focus
   ========================================================================== */

/* ---------- 1. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-ink);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
/* Inline SVGs default to baseline alignment, which leaves a few pixels of
   phantom whitespace below the shape — the #1 cause of icons looking
   slightly off-center inside a button. Blocking it out fixes every icon
   at once instead of nudging each one by hand. */
.btn svg, .btn-icon svg, .sidebar-link svg, .notif-item svg { flex-shrink: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }

/* ---------- 2. Layout helpers ---------- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content {
  flex: 1;
  padding: var(--space-8) var(--space-8) var(--space-16);
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- 3. Typography ---------- */
.h-display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; line-height: var(--leading-tight); color: var(--color-ink); }
h1.h-display, .text-4xl { font-size: var(--text-4xl); }
h2.h-display, .text-3xl { font-size: var(--text-3xl); }
h3.h-display, .text-2xl { font-size: var(--text-2xl); }
h4.h-display, .text-xl { font-size: var(--text-xl); }
.text-lg { font-size: var(--text-lg); }
.text-md { font-size: var(--text-md); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-mono { font-family: var(--font-mono); }
.text-soft { color: var(--color-ink-soft); }
.text-faint { color: var(--color-ink-faint); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.lede { font-size: var(--text-lg); color: var(--color-ink-soft); line-height: var(--leading-relaxed); }

/* ---------- 4. Buttons & forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0 var(--space-4);
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
  box-sizing: border-box;
  vertical-align: middle;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--color-accent);
  color: var(--color-ink-on-accent);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  color: var(--color-ink-on-accent);
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-ink);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-border-strong);
  color: var(--color-ink);
}
.btn-ghost {
  background: transparent;
  color: var(--color-ink-soft);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-bg-subtle);
  color: var(--color-ink);
}
.btn-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}
.btn-lg {
  height: 44px;
  padding: 0 var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}
.btn-block { width: 100%; }
.btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0 !important;
  margin: 0;
  border-radius: var(--radius-md);
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
  text-align: center;
  line-height: 1;
}
.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--radius-sm);
}
.btn-icon svg,
.btn svg {
  display: block;
  margin: 0 auto;
  flex-shrink: 0;
  pointer-events: none;
}
.btn:disabled, .btn-icon:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-ink-soft); }
.field .hint { font-size: var(--text-xs); color: var(--color-ink-faint); margin-top: 2px; }
.field .error { font-size: var(--text-xs); color: var(--color-danger); margin-top: 2px; }

.input, select.input, textarea.input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 40px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  box-sizing: border-box;
}
select.input {
  cursor: pointer;
  padding-right: var(--space-6);
}
textarea.input {
  height: auto;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
  min-height: 80px;
}
.input:hover, select.input:hover, textarea.input:hover {
  border-color: var(--color-border-strong);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.input.has-error { border-color: var(--color-danger); }
.input-group { display: flex; gap: var(--space-2); }
.checkbox-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-ink-soft); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; }

/* ---------- 5. Cards & badges ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}
.card-flush { padding: 0; overflow: hidden; }

.page-header {
  margin-bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-header-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}
.page-header-desc {
  font-size: var(--text-sm);
  color: var(--color-ink-soft);
  margin-top: var(--space-1);
}

.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.table-card .table-wrap {
  border: none;
  border-radius: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--color-bg-subtle);
  color: var(--color-ink-soft);
  white-space: nowrap;
}
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); border: 1px solid var(--color-accent-border); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); border: 1px solid var(--color-danger-border); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-accent-soft); color: var(--color-accent);
  border: 1px solid var(--color-accent-border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 600; flex-shrink: 0;
  overflow: hidden; text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 52px; height: 52px; font-size: var(--text-md); }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

.progress-track { height: 6px; border-radius: var(--radius-full); background: var(--color-bg-subtle); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-accent); border-radius: var(--radius-full); transition: width var(--transition-base); }

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-ink-soft);
}
.empty-state .icon-ring {
  width: 44px; height: 44px; margin: 0 auto var(--space-3);
  border-radius: 50%; background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-ink-faint);
}

/* Signature texture: faint blueprint grid */
.blueprint-grid {
  position: relative;
  background-image:
    linear-gradient(var(--color-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-border) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center;
}

/* ---------- 6. Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--color-surface); }
table.table th {
  text-align: left; font-weight: 600; color: var(--color-ink-faint);
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle); white-space: nowrap;
}
table.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: var(--color-bg-subtle); }

/* ---------- 7. Alerts & flash ---------- */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: var(--color-success-border); }
.alert-error { background: var(--color-danger-soft); color: var(--color-danger); border-color: var(--color-danger-border); }
.alert-info { background: var(--color-accent-soft); color: var(--color-accent); border-color: var(--color-accent-border); }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: var(--color-warning-border); }

/* ---------- 8. Modals & dropdowns ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6); z-index: 100;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
}
.modal-backdrop.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.modal {
  background: var(--color-surface); border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-strong); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  padding: var(--space-6);
  transform: translateY(12px) scale(0.98);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }
.modal-wide { max-width: 620px; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  min-width: 200px; padding: var(--space-1); z-index: 50;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}
.dropdown-menu.is-open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); cursor: pointer; width: 100%; text-align: left;
  background: none; border: none; color: var(--color-ink); text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  box-sizing: border-box;
}
.dropdown-item:hover { background: var(--color-bg-subtle); color: var(--color-ink); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }

/* Notification bell + dropdown */
.notif-bell-trigger { position: relative; }
.notif-badge {
  position: absolute; top: 1px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: var(--radius-full);
  background: var(--color-danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  border: 2px solid var(--color-surface);
  box-sizing: content-box;
}
.notif-dropdown {
  width: 380px; max-width: calc(100vw - 32px); padding: 0; right: 0;
  border-radius: var(--radius-lg); overflow: hidden;
}
.notif-dropdown-head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.notif-dropdown-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  align-items: flex-start; text-decoration: none;
  transition: background var(--transition-fast);
}
.notif-item:first-child { border-top: none; }
.notif-item:hover { background: var(--color-bg-subtle); }
.notif-item.is-unread { background: var(--color-accent-soft); }
.notif-item.is-unread:hover { background: var(--color-accent-soft); filter: brightness(0.97); }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); flex-shrink: 0; margin-top: 6px; }
.notif-item-body { min-width: 0; flex: 1; }
.notif-item-title { font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); }
.notif-item-excerpt { font-size: var(--text-xs); color: var(--color-ink-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-item-time { font-size: 11px; color: var(--color-ink-faint); margin-top: 4px; }
.notif-empty { text-align: center; padding: var(--space-8) var(--space-4); color: var(--color-ink-faint); }
.notif-view-all {
  display: block; text-align: center;
  padding: var(--space-3); font-size: var(--text-xs); font-weight: 600; color: var(--color-accent);
  border-top: 1px solid var(--color-border); background: var(--color-bg-subtle);
  text-decoration: none;
}
.notif-view-all:hover { background: var(--color-accent-soft); }
@media (max-width: 480px) {
  .notif-dropdown { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; }
}

/* Tabs */
.tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-6); }
.tab {
  padding: var(--space-2) var(--space-3); font-size: var(--text-sm); font-weight: 500;
  color: var(--color-ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none; transition: all var(--transition-fast);
}
.tab.is-active { color: var(--color-accent); border-color: var(--color-accent); font-weight: 600; }
.tab:hover:not(.is-active) { color: var(--color-ink); }

/* ---------- 9. Sidebar & topbar (app shell) ---------- */
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--color-bg-subtle); border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; padding: var(--space-4) var(--space-3);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-5); text-decoration: none; }
.sidebar-brand .mark { width: 26px; height: 26px; }
.sidebar-brand .name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); color: var(--color-ink); }
.sidebar-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-ink-faint); padding: var(--space-4) var(--space-3) var(--space-1); }
.sidebar-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-soft);
  transition: all var(--transition-fast); text-decoration: none;
  border: 1px solid transparent;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.8; }
.sidebar-link:hover { background: var(--color-surface); color: var(--color-ink); }
.sidebar-link.is-active {
  background: var(--color-surface); color: var(--color-accent);
  box-shadow: var(--shadow-xs); border-color: var(--color-border);
  font-weight: 600;
}
[data-theme="dark"] .sidebar-link.is-active {
  background: var(--color-surface-raised);
  border-color: var(--color-border-strong);
  color: var(--color-accent);
}
.sidebar-link.is-active svg { opacity: 1; }
.sidebar-footer { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
.sidebar-back { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-ink-faint); padding: var(--space-2) var(--space-3) var(--space-3); text-decoration: none; }
.sidebar-back:hover { color: var(--color-ink); }

.topbar {
  height: var(--topbar-height); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-8); border-bottom: 1px solid var(--color-border);
  background: var(--color-bg); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); color: var(--color-ink); }
.mobile-nav-toggle { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; top: 0; height: 100vh; z-index: 90; transition: left var(--transition-base); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { left: 0; }
  .mobile-nav-toggle { display: inline-flex; }
  .app-content { padding: var(--space-5); }
  .topbar { padding: 0 var(--space-4); }
}
@media (max-width: 480px) {
  .topbar { gap: var(--space-2); }
  .topbar-title { font-size: var(--text-md); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-backdrop { padding: var(--space-3); }
  .modal { padding: var(--space-5); }
}

/* ---------- 10. Marketing / landing page ---------- */
.nav-marketing {
  height: var(--topbar-height); border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; position: sticky; top: 0; background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px); z-index: 30;
}
[data-theme="dark"] .nav-marketing { background: rgba(20,22,27,0.85); }
.nav-marketing .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); }
.brand-mark { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); flex-shrink: 0; }
.nav-links { display: flex; align-items: center; gap: var(--space-6); flex-shrink: 0; }
.nav-links a { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-soft); }
.nav-links a:hover { color: var(--color-ink); }
@media (max-width: 680px) {
  .nav-links { gap: var(--space-3); }
  .nav-links .nav-link-secondary { display: none; }
}

.hero { padding: var(--space-24) 0 var(--space-16); }
.hero-inner { max-width: 720px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500;
  color: var(--color-accent); background: var(--color-accent-soft);
  padding: 5px 12px; border-radius: var(--radius-full); margin-bottom: var(--space-5);
}
.hero h1 { font-size: var(--text-5xl); margin-bottom: var(--space-5); }
@media (max-width: 640px) { .hero h1 { font-size: var(--text-3xl); } .hero { padding: var(--space-12) 0 var(--space-10); } }
.hero-actions { display: flex; gap: var(--space-3); margin-top: var(--space-8); flex-wrap: wrap; }

.section { padding: var(--space-20) 0; border-top: 1px solid var(--color-border); }
.section-head { max-width: 620px; margin-bottom: var(--space-10); }
.feature-card { padding: var(--space-6); }
.feature-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--color-accent-soft); color: var(--color-accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-4);
}
.marketing-footer { border-top: 1px solid var(--color-border); padding: var(--space-10) 0; }
.marketing-footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); }

/* Legal documents (/terms, /privacy, /refunds) */
.legal-layout { display: grid; grid-template-columns: 200px 1fr; gap: var(--space-12); align-items: start; max-width: 980px; margin: 0 auto; }
.legal-toc { position: sticky; top: calc(var(--topbar-height) + var(--space-6)); }
.legal-toc-link { display: block; padding: 5px 0; font-size: var(--text-sm); color: var(--color-ink-soft); border-left: 2px solid transparent; padding-left: var(--space-3); }
.legal-toc-link:hover { color: var(--color-ink); border-left-color: var(--color-border-strong); }
.legal-content { max-width: 680px; }
.legal-content h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); margin-top: var(--space-10); margin-bottom: var(--space-3); scroll-margin-top: calc(var(--topbar-height) + var(--space-4)); }
.legal-content h3 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); margin-top: var(--space-6); margin-bottom: var(--space-2); }
.legal-content p { margin-bottom: var(--space-4); color: var(--color-ink-soft); line-height: var(--leading-relaxed); }
.legal-content ul, .legal-content ol { margin: 0 0 var(--space-4); padding-left: var(--space-5); color: var(--color-ink-soft); line-height: var(--leading-relaxed); }
.legal-content ul { list-style: disc; }
.legal-content ol { list-style: decimal; }
.legal-content li { margin-bottom: var(--space-2); }
.legal-content strong { color: var(--color-ink); }
.legal-callout { background: var(--color-accent-soft); border: 1px solid var(--color-accent-border); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); font-size: var(--text-sm); }
@media (max-width: 900px) {
  .legal-layout { grid-template-columns: 1fr; }
  .legal-toc { position: static; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-6); }
}

/* Auth pages (accounts.sunstave.com) */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); background: var(--color-bg-subtle); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card { padding: var(--space-8); }
.auth-brand { display: flex; align-items: center; gap: var(--space-2); justify-content: center; margin-bottom: var(--space-8); }
.auth-foot { text-align: center; margin-top: var(--space-6); font-size: var(--text-sm); color: var(--color-ink-soft); }

/* ---------- 11. Utilities ---------- */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); } .mb-8 { margin-bottom: var(--space-8); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--color-border); border: none; margin: var(--space-6) 0; }
.pill-select { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.skeleton { background: linear-gradient(90deg, var(--color-bg-subtle) 25%, var(--color-border) 37%, var(--color-bg-subtle) 63%); background-size: 400% 100%; animation: sf-skeleton 1.4s ease infinite; border-radius: var(--radius-sm); }

/* ---------- 12. Motion & focus ---------- */
@keyframes sf-skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes sf-spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: sf-spin 0.6s linear infinite; display: inline-block;
}
.spinner-dark { border-color: var(--color-border-strong); border-top-color: var(--color-accent); }

.theme-icon-light { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.theme-icon-dark { display: none; align-items: center; justify-content: center; width: 100%; height: 100%; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline-flex; }

/* Logo: swap to the light-on-dark variant automatically with the theme */
.logo-light { display: block; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

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

/* Page-load progress bar (see app.js) */
#sfPageLoadBar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: var(--color-accent); z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: width 320ms ease, opacity 200ms ease;
}
#sfPageLoadBar.is-active { opacity: 1; }

/* Chat Markdown & Tables Styling */
.chat-bubble { max-width: 100%; overflow-wrap: break-word; }
.chat-rendered h2, .chat-rendered h3, .chat-rendered h4 { color: var(--color-ink); }
.chat-rendered table { border-collapse: collapse; width: 100%; font-size: 12px; }
.chat-rendered th { background: var(--color-bg-subtle); color: var(--color-ink); font-weight: 600; text-align: left; }
.chat-rendered td { border-bottom: 1px solid var(--color-border); color: var(--color-ink); }
.chat-rendered tr:last-child td { border-bottom: none; }
.chat-rendered tr:hover td { background: var(--color-bg-subtle); }
.chat-code-card { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; background: var(--color-bg); }
.chat-code-header { background: var(--color-bg-subtle); padding: 4px 10px; border-bottom: 1px solid var(--color-border); }
.chat-pre code { font-family: var(--font-mono); font-size: 12px; color: var(--color-ink); }

