:root {
  --c-bg: #f1f5f9;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-primary: #0b2545;
  --c-primary-600: #13315c;
  --c-primary-700: #0a1f3d;
  --c-accent: #ffd166;
  --c-text: #0f172a;
  --c-muted: #64748b;
  --c-border: #e2e8f0;
  --c-success: #16a34a;
  --c-danger: #dc2626;
  --c-info: #2563eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--c-info); text-decoration: none; }

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-600) 100%);
  padding: 24px;
}
.auth-card {
  background: var(--c-surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  padding: 32px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; color: var(--c-primary); font-weight: 800; font-size: 22px; }
.auth-sub { color: var(--c-muted); margin-bottom: 22px; }
.brand-mark { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: var(--c-primary); color: var(--c-accent); border-radius: 9px; }

/* ---- Layout ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--c-primary);
  color: #cbd5e1;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 18px; padding: 6px 8px 18px; }
.sidebar .brand .brand-mark { background: rgba(255,255,255,.12); color: var(--c-accent); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #cbd5e1; cursor: pointer; user-select: none; font-weight: 500;
  background: none; border: none; width: 100%; text-align: left;
  font-family: var(--font); font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--c-accent); color: var(--c-primary); font-weight: 700; }
.nav-item svg { flex: 0 0 auto; }
/* F-19: #64748b on #0b2545 was ~2.4:1 (fails WCAG AA). #94a3b8 is ~4.6:1. */
.sidebar .foot { margin-top: auto; font-size: 12px; color: #94a3b8; padding: 10px 8px 0; }
.sidebar .foot .powered { margin-top: 6px; opacity: 0.8; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar .title { font-weight: 700; font-size: 16px; color: var(--c-primary); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.lang-btn { border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--c-primary); }

.content { padding: 24px; overflow: auto; }

/* ---- Cards / generic ---- */
.grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--c-muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 800; color: var(--c-primary); margin-top: 4px; }
.stat .ico { color: var(--c-accent); }

.panel {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; color: var(--c-primary); }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--c-primary); }

.preview-card {
  height: 130px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff;
  box-shadow: var(--shadow); text-align: center; padding: 8px; position: relative;
  overflow: hidden;
}
.preview-card .t { font-weight: 800; font-size: 18px; position: relative; z-index: 1; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.preview-card .pico { margin-bottom: 8px; opacity: .95; display: flex; justify-content: center; position: relative; z-index: 1; }
/* F-19: white at .85 opacity over an arbitrary background can drop below AA. The
   text-shadow already carries legibility, so the text itself goes to full opacity. */
.preview-card .z { font-size: 13px; margin-top: 4px; position: relative; z-index: 1; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
/* F-20: the tile LOOKED selectable (cursor:pointer) but had no click handler. The
   explicit "Use this card" button below is the real affordance, so the tile no
   longer advertises one. */
.preview-card.clickable { cursor: pointer; }
.preview-card.clickable:hover { transform: translateY(-2px); }
/* Stock-card images fill the tile; the title/occasion stay legible on a scrim. */
.preview-card.has-img .preview-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-card.has-img::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 62%; background: linear-gradient(to bottom, rgba(8,15,30,0) 0%, rgba(8,15,30,.72) 100%); }
.preview-card.has-img .pico { display: none; }

/* Compose live "baked" preview (message over the chosen stock photo). */
.compose-preview { margin-top: 4px; }
.baked { position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.baked img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.baked .scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 58%; background: linear-gradient(to bottom, rgba(8,15,30,0) 0%, rgba(8,15,30,.78) 100%); }
.baked .msg { position: absolute; left: 0; right: 0; bottom: 8%; padding: 0 8%; text-align: center; color: #fff; font-weight: 800; font-size: 18px; line-height: 1.3; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.baked-fallback { display: flex; align-items: center; justify-content: center; }
.baked-fallback .msg { position: static; }
#word-count { font-weight: 600; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; color: var(--c-primary); margin-bottom: 6px; font-size: 13px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--c-text); background: var(--c-surface);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--c-primary-600); border-color: var(--c-primary-600); }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }

/* Real-time email verification hint (edge /api/verify, as the user types). Advisory
   only — the hard gate still lives at capture (POST /api/contacts) + pre-send. */
.verify-status { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.4; min-height: 16px; }
.verify-status.good { color: var(--c-success); }
.verify-status.warn { color: #b45309; }
.verify-status.bad  { color: var(--c-danger); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; cursor: pointer; font-family: var(--font); font-size: 14px;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-700); }
.btn-accent { background: var(--c-accent); color: var(--c-primary); }
.btn-accent:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--c-surface); border-color: var(--c-border); color: var(--c-primary); }
.btn-ghost:hover { background: var(--c-surface-2); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
/* Alpha stagewall: the send button is disabled for unauthorized accounts. */
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:disabled:hover { filter: none; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--c-border); font-size: 13px; }
.table th { color: var(--c-muted); font-weight: 700; }
.table tr:hover td { background: var(--c-surface-2); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag-year { background: #ecfdf5; color: var(--c-success); }
.tag-once { background: #eff6ff; color: var(--c-info); }
.tag-dev { background: #fef3c7; color: #b45309; }

.notice { background: var(--c-surface-2); border: 1px solid var(--c-border); border-left: 4px solid var(--c-accent); border-radius: 8px; padding: 12px 14px; color: var(--c-text); font-size: 13px; }
.notice.info { border-left-color: var(--c-info); }
.notice.success { border-left-color: var(--c-success); }
.notice.warn { border-left-color: var(--c-danger); }

.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.import-box { border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 14px; background: var(--c-surface-2); }
.import-box .field { margin-bottom: 10px; }
.import-box textarea { min-height: 110px; width: 100%; }
@media (max-width: 720px) { .import-grid { grid-template-columns: 1fr; } }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; padding: 24px; z-index: 50; }
.modal { background: var(--c-surface); border-radius: 14px; width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal-body { padding: 18px; }
.modal iframe { width: 100%; height: 70vh; border: 0; border-radius: 8px; background: #fff; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--c-border); }
.modal-head h2 { margin: 0; font-size: 16px; color: var(--c-primary); }
.modal-x { border: none; background: transparent; cursor: pointer; color: var(--c-muted); display: inline-flex; padding: 4px; border-radius: 8px; }
.modal-x:hover { background: var(--c-surface-2); color: var(--c-text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--c-border); }
.modal .contact-form h3 { margin: 18px 0 10px; font-size: 12px; color: var(--c-muted); text-transform: uppercase; letter-spacing: .4px; }
.modal .contact-form h3:first-child { margin-top: 0; }
.table-scroll { overflow-x: auto; }
.row-actions { white-space: nowrap; }
.table td .btn-sm { margin-right: 4px; }
.table td .btn-sm:last-child { margin-right: 0; }

.muted { color: var(--c-muted); }
.center-empty { text-align: center; color: var(--c-muted); padding: 40px 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--c-primary); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-weight: 600; }
/* F-07: errors must be announced and must not vanish after 2.2s. */
.toast.toast-error { background: var(--c-danger); cursor: pointer; max-width: min(560px, calc(100vw - 32px)); }
.toast.toast-warn { background: #b45309; }

/* F-08: visible focus for every interactive element (the stylesheet previously had
   focus styling for form fields ONLY — a keyboard user could not see where they were). */
.btn:focus-visible,
.nav-item:focus-visible,
.chip:focus-visible,
.modal-x:focus-visible,
.table td .btn-sm:focus-visible,
.home-card .use-btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* F-22: a real loading surface instead of three literal dots. */
.skeleton { display: grid; gap: 12px; }
.skeleton .sk-row { height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--c-surface-2) 25%, #eef2f7 37%, var(--c-surface-2) 63%); background-size: 400% 100%; animation: sk-shimmer 1.3s ease-in-out infinite; }
.skeleton .sk-row.w60 { width: 60%; }
.skeleton .sk-row.w40 { width: 40%; }
.skeleton .sk-block { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--c-surface-2) 25%, #eef2f7 37%, var(--c-surface-2) 63%); background-size: 400% 100%; animation: sk-shimmer 1.3s ease-in-out infinite; }
@keyframes sk-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* F-11: every data table must scroll horizontally instead of stretching the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table { min-width: 560px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  /* F-10: the sidebar became an unlabelled horizontal scroller. Hide the brand
     (the topbar already shows the location), keep the scroller but add a fade
     affordance, and never hide the Plus indicator (it lives in the topbar). */
  .sidebar { flex-direction: row; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; align-items: center; padding: 8px 10px; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { display: none; }
  .sidebar .foot { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .import-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* F-28: iOS Safari zooms the viewport on focus for any input under 16px. */
  input, textarea, select { font-size: 16px; }
  .modal-mask { padding: 8px; }
  .plan-card { padding: 16px; }
  .home-hero h1 { font-size: 30px; }
}

/* ---- SEO / no-JS landing (crawlable; hidden once the SPA mounts) ---- */
.seo-landing { background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-600) 100%); color: #fff; min-height: 100vh; display: flex; align-items: center; }
.seo-wrap { max-width: 760px; margin: 0 auto; padding: 48px 24px; }
.seo-top { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.seo-brand { font-weight: 800; font-size: 22px; color: #fff; }
.seo-tag { font-size: 13px; color: var(--c-primary); background: var(--c-accent); padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.seo-landing h1 { font-size: 40px; line-height: 1.1; margin: 0 0 16px; font-weight: 800; }
.seo-lead { font-size: 18px; line-height: 1.6; color: #e2e8f0; margin: 0 0 24px; }
.seo-feats { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 12px; }
.seo-feats li { background: rgba(255,255,255,.08); border-left: 4px solid var(--c-accent); padding: 12px 16px; border-radius: 8px; font-size: 15px; line-height: 1.5; }
.seo-feats strong { color: var(--c-accent); }
.seo-cta { font-size: 15px; color: #cbd5e1; margin: 0; }
.js .seo-landing { display: none !important; }
@media (max-width: 600px) { .seo-landing h1 { font-size: 30px; } }

/* ---- Public homepage (browse cards by occasion, no account needed) ---- */
.home { min-height: 100vh; display: flex; flex-direction: column; background: var(--c-bg); }
.home-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; background: var(--c-primary); color: #fff;
}
.home-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.home-brand .brand-mark { background: rgba(255,255,255,.14); color: var(--c-accent); }
.home-top-right { display: flex; align-items: center; gap: 12px; }
.home-alpha {
  font-size: 12px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  background: var(--c-accent); color: var(--c-primary); padding: 4px 10px; border-radius: 999px;
}
.home-hero {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-600) 100%);
  color: #fff; padding: 52px 28px 44px; text-align: center;
}
.home-hero h1 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; font-weight: 800; }
.home-hero p { font-size: 16px; line-height: 1.6; color: #e2e8f0; max-width: 640px; margin: 0 auto 20px; }
.home-hero .alpha-banner { max-width: 640px; margin: 0 auto; text-align: left; }
.home-gallery { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px; }
.home-gallery h2 { font-size: 18px; color: var(--c-primary); margin: 0 0 14px; }
.home-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.home-card { display: flex; flex-direction: column; gap: 8px; }
.home-card .preview-card { height: 150px; }
.home-card .use-btn { width: 100%; }
.home-foot { padding: 18px 28px; text-align: center; color: var(--c-muted); font-size: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-primary);
  border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer;
  font-family: var(--font);
}
.chip:hover { background: var(--c-surface-2); }
.chip-on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ---- Private-alpha banner (homepage + login screen) ---- */
.alpha-banner {
  display: flex; align-items: center; gap: 10px;
  background: #fffbeb; border: 1px solid #fde68a; border-left: 4px solid var(--c-accent);
  color: #92400e; border-radius: 8px; padding: 12px 14px; font-size: 13px; font-weight: 600;
}
.alpha-banner svg { flex: 0 0 auto; color: #b45309; }
.auth-alt { margin-top: 14px; text-align: center; font-size: 13px; }
.auth-alt a { color: var(--c-muted); }

/* ---- Upgrade / Plan (B-9) ---- */
.plus-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-accent); color: var(--c-primary);
  font-weight: 800; font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 8px; }
.plan-card {
  position: relative; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.plan-card.plan-best { border-color: var(--c-accent); box-shadow: 0 6px 22px rgba(255,209,102,.35); }
.plan-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--c-accent); color: var(--c-primary); font-weight: 800; font-size: 11px;
  letter-spacing: .3px; padding: 4px 12px; border-radius: 999px; text-transform: uppercase;
}
.plan-name { font-weight: 800; color: var(--c-primary); font-size: 18px; }
.plan-price { font-size: 34px; font-weight: 800; color: var(--c-primary); margin: 6px 0 2px; }
.plan-unit { font-size: 15px; font-weight: 600; color: var(--c-muted); margin-left: 4px; }
.plan-sub { color: var(--c-muted); font-size: 13px; }
/* F-19: 12px muted text was the smallest type on the pricing page. */
.plan-note { color: var(--c-muted); font-size: 13px; margin-top: 2px; }
.plan-choose { margin-top: 16px; width: 100%; }
.plan-compare th:first-child, .plan-compare td:first-child { text-align: left; }
.plan-compare .cmp-center { text-align: center; font-weight: 700; }
.plan-compare td:nth-child(2) { color: var(--c-muted); }
/* F-19/contrast: #16a34a on white is ~3.3:1 — fails AA for 13px table text. */
.plan-compare td:nth-child(3) { color: #15803d; }

/* Pending / cancelling subscription states (B-9 UX round). */
.plan-state {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; border: 1px solid var(--c-border); border-left: 4px solid var(--c-info);
  background: var(--c-surface-2); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px;
}
.plan-state .ps-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.plan-state .ps-title { font-weight: 700; color: var(--c-primary); }
.plan-state .ps-sub { font-size: 13px; color: var(--c-muted); }

/* Beta P1 — photo attach -----------------------------------------------------
   The file input is visually hidden but NOT display:none / visibility:hidden:
   a hidden input cannot receive keyboard focus, which would make the upload
   unreachable without a mouse. It stays in the layout and focusable. */
.visually-hidden-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.visually-hidden-input:focus-visible {
  position: static;
  width: auto; height: auto;
  clip: auto;
  margin: 0;
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}
