.account-wrap {
  min-height: 70vh;
  display: grid;
  place-items: center;
  padding: var(--space-5, 24px) 16px;
}
.account-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1, #fff);
  border: 1px solid var(--border, #e4e7ee);
  border-radius: var(--radius-md, 14px);
  padding: 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.account-title { margin: 0 0 6px; font-size: 22px; color: var(--text-0, #0F172A); }
.account-email, .account-sub-line { margin: 0 0 18px; font-size: 14px; }

.auth-tabs { display: flex; gap: 4px; background: var(--bg-0, #f7f8fb); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: var(--text-1, #475569);
}
.auth-tab.is-active { background: var(--bg-1, #fff); color: var(--text-0, #0F172A); box-shadow: 0 1px 3px rgba(15,23,42,0.08); }

.auth-form { display: flex; flex-direction: column; }
.auth-label { font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: var(--text-0, #0F172A); }
.auth-input {
  width: 100%; box-sizing: border-box; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--border-strong, #c9cfdb); border-radius: 9px;
  background: var(--bg-0, #f7f8fb); color: var(--text-0, #0F172A);
}
.auth-input:focus { outline: 2px solid var(--accent, #FF5A36); outline-offset: 1px; border-color: transparent; }

/* ----- password field affordances -----
   A reveal toggle inside the field, and a strength meter that answers "is this long enough?"
   while typing rather than after a failed round-trip. */
.auth-field { position: relative; display: flex; align-items: center; }
.auth-field .auth-input { padding-right: 68px; width: 100%; }
.auth-reveal {
  position: absolute; right: 6px;
  padding: 4px 8px;
  border: 0; border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text-2, #5b6a80);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.auth-reveal:hover { color: var(--text-0, #0F172A); background: var(--bg-1, #eef1f6); }
.auth-reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.pw-meter { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; }
.pw-meter-bar {
  flex: 1; height: 4px; border-radius: 999px;
  background: var(--bg-2, #e6e9f0);
  overflow: hidden;
}
.pw-meter-bar i {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: var(--text-2);
  transition: width 220ms cubic-bezier(0.32, 0.72, 0, 1), background 220ms ease;
}
.pw-meter-label { font-size: 12px; font-weight: 600; color: var(--text-2); min-width: 72px; }
.pw-meter.is-weak   .pw-meter-bar i { background: var(--danger, #EF4444); }
.pw-meter.is-weak   .pw-meter-label { color: var(--danger-text, #a73030); }
.pw-meter.is-okay   .pw-meter-bar i { background: var(--warning, #8a5a02); }
.pw-meter.is-okay   .pw-meter-label { color: var(--warning, #8a5a02); }
.pw-meter.is-good   .pw-meter-bar i { background: var(--success-fill, #0a7450); }
.pw-meter.is-good   .pw-meter-label { color: var(--success-text, #0a7450); }
.pw-meter.is-strong .pw-meter-bar i { background: var(--success-fill, #0a7450); }
.pw-meter.is-strong .pw-meter-label { color: var(--success-text, #0a7450); }

.auth-hint { font-size: 12px; color: var(--text-2); margin: 6px 0 0; }
.portal-form .callout { margin-top: 12px; }
.portal-form .btn-primary { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  .pw-meter-bar i { transition-duration: 0.01ms; }
}
.auth-submit { margin-top: 18px; width: 100%; justify-content: center; }

.account-actions { display: flex; gap: 10px; margin-top: 20px; }
.account-actions .btn-secondary, .account-actions .btn-ghost { flex: 1; justify-content: center; }

.account-sub { margin: 4px 0 6px; }
.account-plan {
  border: 1px solid var(--border, #e4e7ee); border-radius: 12px; padding: 16px;
  background: var(--bg-0, #f7f8fb);
}
.account-plan-tier { font-weight: 700; text-transform: capitalize; color: var(--text-0, #0F172A); }
.account-plan-quota { margin-top: 4px; font-size: 14px; color: var(--text-0, #0F172A); }
.account-plan-renew { margin-top: 2px; font-size: 12px; }
.account-plan-none { font-weight: 600; margin: 0 0 4px; color: var(--text-0, #0F172A); }

#authError, #accountSub .callout { margin-top: 14px; }
#authNotice, #forgotNotice, #resetNotice, #forgotError, #resetError { margin-top: 14px; }
.auth-forgot {
  display: block; width: 100%; margin-top: 14px;
  background: none; border: 0; cursor: pointer;
  font-size: 13px; color: var(--text-1, #475569); text-align: center; text-decoration: underline;
}
.auth-forgot:hover { color: var(--text-0, #0F172A); }

.account-plan-note { margin: 0 0 14px; font-size: 13px; }
.account-manage { margin-top: 12px; }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .plan-grid { grid-template-columns: 1fr; } }
.plan-card {
  border: 1px solid var(--border, #e4e7ee); border-radius: 12px; padding: 16px;
  background: var(--bg-0, #f7f8fb); display: flex; flex-direction: column;
}
.plan-name { font-weight: 700; color: var(--text-0, #0F172A); }
.plan-price { font-size: 24px; font-weight: 800; margin: 4px 0 10px; color: var(--text-0, #0F172A); }
.plan-price span { font-size: 13px; font-weight: 600; color: var(--text-1, #475569); }
.plan-feats { list-style: none; padding: 0; margin: 0 0 14px; font-size: 13px; color: var(--text-1, #475569); }
.plan-feats li { padding: 3px 0 3px 18px; position: relative; }
.plan-feats li::before { content: "✓"; position: absolute; left: 0; color: var(--accent, #FF5A36); font-weight: 700; }
.plan-sub { margin-top: auto; width: 100%; justify-content: center; }
.account-live-link { display: inline-flex; margin-top: 10px; margin-right: 8px; }

/* Brand kit: saved export defaults. */
.brandkit { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border, #d7dbe5); }
.brandkit-title { margin: 0; font-size: 16px; font-weight: 650; }
.brandkit-sub { margin: 4px 0 14px; font-size: 13px; }
.brandkit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.brandkit-field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.brandkit-field select, .brandkit-field input { font: inherit; font-weight: 400; padding: 8px 10px;
  border: 1px solid var(--border, #d7dbe5); border-radius: 8px; background: var(--bg-1, #fff); }
.brandkit-toggles { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; font-size: 13px; }
.brandkit-toggles label { display: inline-flex; align-items: center; gap: 7px; }
.brandkit-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* Cover colours. These OVERRIDE the colours taken from each clip's own frame rather than
   supplying a default, so they are set apart from the fields above by a rule and a sub-heading
   that says what they actually do. */
.brandkit-covers { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border, #d7dbe5); }
.brandkit-subtitle { margin: 0 0 4px; font-size: 14px; font-weight: 650; }
.brandkit-covers .portal-panel-sub { margin: 0 0 14px; }
.brandkit-colour { display: flex; align-items: center; gap: 8px; }
.brandkit-colour input[type="color"] {
  width: 44px; height: 34px; padding: 2px; flex: none; cursor: pointer;
  border: 1px solid var(--border, #d7dbe5); border-radius: 8px; background: var(--bg-1, #fff);
}
/* A colour input always holds a value, so "not set" has to be shown rather than implied by an
   empty field — otherwise the swatch looks like a brand colour the user never chose. */
.brandkit-colour input[type="color"].is-unset { opacity: 0.4; }
.brandkit-clear {
  font: inherit; font-size: 12px; font-weight: 600; padding: 0; cursor: pointer;
  border: 0; background: none; color: var(--text-2, #6b7280); text-decoration: underline;
}
.brandkit-clear:hover { color: var(--text-0, #111); }

/* ============================================================================
   Portal — Projects + Account as two tabs of one place
   ----------------------------------------------------------------------------
   Projects used to live at the bottom of the marketing home page, so a
   returning user scrolled past the pitch to reach their own work, and Account
   was a separate island. These now share a header, a tab row, and one panel
   language so moving between them feels like staying put.
   ========================================================================== */
/* Scales with the viewport instead of sitting in a fixed 1120px column: on a 2560px screen a
   centred narrow strip left most of the page empty while the project list scrolled. The clamp
   keeps line lengths sane on a laptop and lets a wide monitor actually be used. */
.portal-wrap {
  width: min(100% - 2 * var(--space-5), 1680px);
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.portal-head { display: flex; flex-direction: column; gap: var(--space-5); }
.portal-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.portal-id { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.portal-avatar {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 19px; font-weight: 650;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #7c3aed));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 32%, transparent);
}
.portal-id-text { min-width: 0; }
.portal-title { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -0.01em; }
.portal-email {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-2);
  /* Long addresses must not push the New-project button off a phone screen. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw;
}
.portal-new { flex: none; }

/* Tabs: a sliding underline makes the two views feel like one surface rather than two pages. */
.portal-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.portal-tabs::-webkit-scrollbar { display: none; }
.portal-tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: 14px; font-weight: 560;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.portal-tab svg { width: 17px; height: 17px; }
.portal-tab:hover { color: var(--text-1); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.portal-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.portal-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* One panel language for every section on both tabs. */
.portal-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.portal-panel-quiet { background: transparent; border-style: dashed; box-shadow: none; }
.portal-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
}
.portal-panel-title { margin: 0; font-size: 17px; font-weight: 650; }
.portal-panel-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-2); }

/* Toolbar: search + status chips, shown only once the list is long enough to need them. */
.portal-toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap;
}
.portal-search {
  display: flex; align-items: center; gap: var(--space-2);
  flex: 1 1 240px; min-width: 0;
  padding: 0 var(--space-3);
  height: 40px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.portal-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.portal-search svg { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.portal-search input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font-family: var(--font-sans); font-size: 14px; color: var(--text-1);
}
.portal-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.portal-filter {
  height: 34px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-family: var(--font-sans); font-size: 13px; font-weight: 550;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}
.portal-filter:hover { color: var(--text-1); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.portal-filter.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}
.portal-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.portal-empty-filtered { margin: 0; font-size: 14px; color: var(--text-2); }
.link-button {
  border: 0; background: none; padding: 0;
  color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline;
}

/* The grid decides its own column count from the space available, so the same markup is one
   column on a phone and five on a wide monitor. Slightly smaller min track than the home page's
   280px: the portal is the place people scan a long list, so more columns beats bigger cards. */
.portal-wrap .projects-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: var(--space-4);
}

/* Cards fade up in sequence on arrival — the list reads as loading in, not snapping in.
   Capped so a long list doesn't stagger for seconds. */
@media (prefers-reduced-motion: no-preference) {
  .portal-wrap .project-card {
    animation: portalCardIn 300ms ease-out both;
    animation-delay: calc(min(var(--card-i, 0), 11) * 28ms);
  }
  .portal-panel { animation: portalCardIn 320ms ease-out both; }
}
@keyframes portalCardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.portal-wrap .project-card { transition: transform var(--transition-fast), box-shadow var(--transition), border-color var(--transition); }
@media (hover: hover) {
  .portal-wrap .project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
}

/* Phones: the header stacks, the button goes full width, and tabs stay thumb-sized. */
@media (max-width: 640px) {
  .portal-wrap { padding: var(--space-4) var(--space-3) var(--space-7); gap: var(--space-4); }
  .portal-head-top { align-items: stretch; }
  .portal-new { width: 100%; }
  .portal-email { max-width: 100%; }
  .portal-title { font-size: 20px; }
  .portal-panel { padding: var(--space-4); border-radius: var(--radius-md); }
  .portal-tab { padding: var(--space-3); font-size: 13px; }
  .portal-search { flex-basis: 100%; }
  .portal-filters { width: 100%; }
  .portal-filter { flex: 1; }
}

/* ----------------------------------------------------------------------------
   Account tab: panels side by side once there is room
   ----------------------------------------------------------------------------
   Stacked, the three panels (plan, default look, session) ran well past the
   fold on a desktop screen even though each is short — the page scrolled for
   content that would fit twice over. The plan card is narrow and fixed-height;
   the default-look form is the tall one, so it takes the wider track and the
   short panels sit beside it.
   -------------------------------------------------------------------------- */
.portal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  align-items: start;
}
/* [hidden] children (the email carrier) must not claim a grid cell. */
.portal-grid > [hidden] { display: none; }

@media (min-width: 1040px) {
  .portal-grid {
    /* Sidebar of short panels + the form that actually needs the room. */
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.6fr);
  }
  /* Plan first in the sidebar, session beneath it; the brand kit spans the tall right column.
     Selected by identity rather than nth-child: a hidden <span> is also a grid child here, and
     position-based rules would have shifted every panel by one cell. */
  .portal-grid > .portal-panel:not(.brandkit):not(.portal-panel-quiet) { grid-column: 1; grid-row: 1; }
  .portal-grid > .portal-panel-quiet { grid-column: 1; grid-row: 2; }
  .portal-grid > .brandkit           { grid-column: 2; grid-row: 1 / span 2; }
  /* The session panel shouldn't stretch to fill leftover column height. */
  .portal-grid > .portal-panel-quiet { align-self: start; }
}

/* The brand-kit form gets more columns as the panel widens, so a wide screen shows the whole
   "default look" at once instead of a tall single file. */
@media (min-width: 1360px) {
  .brandkit-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
}

/* Account tab on phones: full-width controls and comfortable tap targets. */
@media (max-width: 640px) {
  .portal-grid { gap: var(--space-4); }
  .brandkit-grid { grid-template-columns: 1fr; }
  .brandkit-actions { flex-direction: column; align-items: stretch; }
  .brandkit-actions .btn-primary { width: 100%; }
  .account-actions { flex-direction: column; }
  .account-actions .btn-secondary, .account-actions .btn-ghost { width: 100%; }
}

/* ----------------------------------------------------------------------------
   Project cards: real thumbnails + inline rename
   -------------------------------------------------------------------------- */
.project-card-wrap { position: relative; display: flex; }
.project-card-wrap > .project-card { flex: 1; min-width: 0; }

/* The frame already exists in storage from probe time — show it instead of an icon. */
.project-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Fade in so a slow thumbnail doesn't pop the card. */
  animation: thumbIn 260ms ease-out both;
}
@keyframes thumbIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .project-thumb-img { animation: none; } }

/* Rename sits over the card's corner: visible on hover/focus, always visible on touch where
   there is no hover to reveal it. */
.project-rename {
  position: absolute;
  top: 10px; right: 10px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-1) 88%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text-2);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition), border-color var(--transition);
}
.project-rename svg { width: 14px; height: 14px; }
.project-card-wrap:hover .project-rename,
.project-rename:focus-visible { opacity: 1; }
.project-rename:hover { color: var(--accent); border-color: var(--accent); }
.project-rename:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .project-rename { opacity: 1; } }

/* The input replaces the title in place, matching its size so the card doesn't reflow. */
.project-title-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  color: var(--text-0);
  padding: 2px 6px;
  margin: -2px -6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg-1);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}


/* Portal header actions: the primary CTA and the account menu sit together, and the menu is
   anchored to the right edge so it never hangs off the viewport. */
.portal-head-actions { display: flex; align-items: center; gap: var(--space-3, 12px); }
@media (max-width: 640px) {
  .portal-head-actions { width: 100%; justify-content: space-between; }
}

/* ===== Portal: project management =====
   Sorting and paging are server-side against a per-session listing index; the old portal read
   every manifest and signed every thumbnail on each load (~290 storage calls for 146 projects)
   before a single card appeared. */

.projects-toolbar {
  display: flex; align-items: center; gap: var(--space-3, 12px);
  margin: 0 0 var(--space-4, 16px); flex-wrap: wrap;
}
.projects-search { position: relative; flex: 1 1 220px; display: flex; align-items: center; }
.projects-search svg {
  position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-2); pointer-events: none;
}
.projects-search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  border: 1px solid var(--border-input, var(--border)); border-radius: var(--radius-sm, 8px);
  background: var(--surface-1); color: var(--text-0); font: inherit; font-size: 14px;
}
.projects-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.projects-sort { display: flex; align-items: center; gap: 8px; }
.projects-sort-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.projects-sort select {
  height: 38px; padding: 0 10px;
  border: 1px solid var(--border-input, var(--border)); border-radius: var(--radius-sm, 8px);
  background: var(--surface-1); color: var(--text-0); font: inherit; font-size: 14px;
}
.projects-sort select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Actions appear on hover/focus on a pointer device, and are always visible on touch — where
   there is no hover and a hidden control is simply unreachable. */
.project-actions {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 6px;
  opacity: 0; transition: opacity 140ms ease;
}
.project-card-wrap { position: relative; }
.project-card-wrap:hover .project-actions,
.project-card-wrap:focus-within .project-actions { opacity: 1; }
@media (hover: none) { .project-actions { opacity: 1; } }

.project-action {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--surface-1); color: var(--text-1);
  cursor: pointer; transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.project-action svg { width: 15px; height: 15px; }
.project-action:hover { background: var(--bg-1); color: var(--text-0); border-color: var(--border-strong); }
.project-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.project-action.is-danger:hover { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-text); }

.projects-pager {
  display: flex; align-items: center; justify-content: center; gap: var(--space-4, 16px);
  margin-top: var(--space-5, 20px);
}
.projects-pager-info { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.projects-pager button:disabled { opacity: 0.45; cursor: default; }
.projects-no-match { grid-column: 1 / -1; margin: 0; padding: var(--space-5) 0; text-align: center; color: var(--text-2); font-size: 14px; }

/* Skeletons: the grid keeps its shape while the first page loads instead of snapping from empty.
   A plain opacity pulse on pale grey is almost invisible — it read as three dead boxes — so these
   use a sweeping highlight, which is legible at a glance and says "working" rather than "empty".
   The cards also stagger in, so the group reads as loading rather than as a frozen layout. */
.project-card-wrap.is-skeleton .project-card { pointer-events: none; }
.project-card-wrap.is-skeleton .project-thumb,
.project-card-wrap.is-skeleton .sk-line {
  position: relative;
  overflow: hidden;
  background: var(--bg-2, #e6e9f0);
  border-radius: var(--radius-sm, 8px);
}
/* The sweep itself. A gradient moving across the block, not the block fading. */
.project-card-wrap.is-skeleton .project-thumb::after,
.project-card-wrap.is-skeleton .sk-line::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--surface-1, #fff) 70%, transparent) 50%,
    transparent 100%);
  animation: portal-sk-sweep 1500ms ease-in-out infinite;
}
.project-card-wrap.is-skeleton .sk-line { height: 12px; margin-top: 10px; }
.project-card-wrap.is-skeleton .sk-short { width: 60%; }

/* Stagger: each card starts its sweep slightly later, so the row has a direction. */
.project-card-wrap.is-skeleton:nth-child(2) .project-thumb::after,
.project-card-wrap.is-skeleton:nth-child(2) .sk-line::after { animation-delay: 140ms; }
.project-card-wrap.is-skeleton:nth-child(3) .project-thumb::after,
.project-card-wrap.is-skeleton:nth-child(3) .sk-line::after { animation-delay: 280ms; }

@keyframes portal-sk-sweep {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* Real cards fade up as they replace the skeletons, so the swap is a transition, not a flash. */
.project-card-wrap:not(.is-skeleton) { animation: portal-card-in 260ms ease-out both; }
@keyframes portal-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Download sheet — the files already exist; this just hands them over. */
.dl-sheet { max-width: 440px; text-align: left; }
.dl-title { margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.dl-sub { margin: 0 0 var(--space-4, 16px); font-size: 13px; color: var(--text-2); }
.dl-list { list-style: none; margin: 0 0 var(--space-4, 16px); padding: 0; display: flex; flex-direction: column; gap: 8px; }
.dl-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3, 12px);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--bg-1);
}
.dl-name { font-size: 14px; color: var(--text-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-get { flex: 0 0 auto; }
.dl-close { width: 100%; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .project-actions { transition-duration: 0.01ms; }
  .project-card-wrap.is-skeleton .project-thumb::after,
  .project-card-wrap.is-skeleton .sk-line::after { animation: none; }
  .project-card-wrap:not(.is-skeleton) { animation: none; }
}

/* ===== Portal dialogs =====
   Rename and delete used native prompt()/confirm(): unstyled OS chrome that ignored the theme
   and read as a browser warning rather than part of the product. These sit on the shared
   .scrim/.modal shell so every portal dialog matches the download sheet. */

.portal-dialog {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
}
.portal-dialog-title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-0);
  text-wrap: balance;
}
.portal-dialog-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
}
.portal-dialog-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-input, var(--border));
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-1);
  color: var(--text-0);
  font: inherit;
  /* 16px floor stops iOS Safari zooming the viewport on focus. */
  font-size: max(16px, 15px);
}
.portal-dialog-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.portal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2, 8px);
  margin-top: var(--space-1, 4px);
}
.portal-dialog-actions button { min-width: 92px; }
@media (max-width: 420px) {
  .portal-dialog-actions { flex-direction: column-reverse; }
  .portal-dialog-actions button { width: 100%; }
}

/* Loading status line. Motion alone does not say what is happening, and the first load after
   sign-in rebuilds the listing index, which takes a visible moment. */
.projects-loading {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  margin: 0 0 var(--space-3, 12px);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
}
.projects-loading[hidden] { display: none; }
.projects-loading-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: projects-spin 700ms linear infinite;
}
@keyframes projects-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .projects-loading-spinner { animation-duration: 2.4s; }
}

/* Inline action inside an error callout (e.g. "Email me the setup link" after a login that
   found a paid-but-passwordless account). */
.auth-inline-action { margin-top: 10px; }


/* ===== Streamer tier: the portal says so =====
   Gold is deliberate — distinct from the accent, so it reads as a status, not a button. */
.portal-avatar.is-premium {
  background: linear-gradient(135deg, #f5b02e, #e8742c 55%, #c2410c);
  box-shadow:
    0 0 0 3px var(--bg-0, #f7f8fb),
    0 0 0 5px #f5b02e,
    0 4px 14px rgba(245, 176, 46, 0.45);
}
.portal-tier-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: 10px; padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em; vertical-align: middle;
  color: #5a2d05;
  background: linear-gradient(135deg, #ffe08a, #f5b02e);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.5);
  animation: tier-badge-in 480ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.portal-tier-badge svg { width: 13px; height: 13px; }
@keyframes tier-badge-in { from { opacity: 0; transform: scale(0.7) translateY(2px); } to { opacity: 1; transform: none; } }
.portal-head.is-streamer .portal-title { display: flex; align-items: center; flex-wrap: wrap; }

/* The Live tab carries a pip that breathes — the one tab that is about something happening now. */
.portal-tab-pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: #e11d48;
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45);
  animation: portal-pip 2000ms ease-out infinite;
}
@keyframes portal-pip {
  0%   { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .portal-tier-badge { animation: none; }
  .portal-tab-pip { animation: none; }
}

/* ---- affiliate programme -------------------------------------------------------------------
   Reuses the portal panel shell; only the pieces unique to this page are defined here, so the
   affiliate view reads as another tab of the same portal rather than a bolted-on feature. */

.affiliate-form { display: flex; flex-direction: column; gap: var(--space-3); }
.affiliate-form .field { display: flex; flex-direction: column; gap: 6px; }
.affiliate-form .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.affiliate-form textarea,
.affiliate-form input[type="text"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  color: inherit;
  resize: vertical;
}
.affiliate-form textarea:focus-visible,
.affiliate-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.affiliate-form .btn-primary { align-self: flex-start; }

.affiliate-error {
  margin: 0;
  font-size: 13px;
  color: var(--danger-text);
  background: var(--danger-soft);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}

.affiliate-status h3 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.affiliate-status p { margin: 0 0 8px; }
.affiliate-status.is-approved h3 { color: var(--accent); }
.affiliate-reason {
  background: var(--bg-2);
  border-left: 3px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* The link is the whole point of the approved state, so it gets room and a one-press copy. */
.affiliate-link-row { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: 10px 0; }
.affiliate-link-row input {
  flex: 1 1 280px;
  font: inherit;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  color: inherit;
}

.affiliate-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
}
.affiliate-stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--space-3);
  background: var(--bg-2);
  border-radius: var(--radius-md);
}
.affiliate-stat-value {
  font-size: 22px; font-weight: 650;
  font-variant-numeric: tabular-nums;   /* so figures line up down the row */
}
.affiliate-stat-label { font-size: 12px; color: var(--text-2); }

/* The table can outgrow a phone, so it scrolls in its own box rather than the page going sideways. */
.affiliate-referrals { overflow-x: auto; }
.affiliate-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.affiliate-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.affiliate-table td {
  padding: 10px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.affiliate-table tr:last-child td { border-bottom: 0; }
