/* ImageURL — base styles.
   Inherits look from the original demo at /index.html (sidebar + dark hero).
   Tailwind CDN handles spacing/layout; this file holds bespoke components. */

:root {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #818cf8;
  --ok: #16a34a;
  --danger: #dc2626;
  --gradient-hero: linear-gradient(135deg, #ffffff 0%, #eef2ff 60%, #f5f3ff 100%);
  --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ============ Topbar (landing only) ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand span {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topnav { display: flex; gap: 10px; align-items: center; }
.topnav .h-right { display: flex; gap: 8px; align-items: center; }
.link { color: var(--muted); font-size: 14px; transition: color .15s; }
.link:hover { color: var(--text); }

/* Authenticated header pills */
.h-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--line);
}
.h-chip b { font-weight: 800; }
.h-plan  { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.h-plan:hover { background: #e0e7ff; color: #3730a3; }
.h-credits { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.h-email {
  font-size: 13px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.h-btn { font-size: 13px; padding: 7px 12px; }
.btn-ghost {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
}
.btn-primary {
  padding: 8px 14px;
  font-size: 14px;
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #292e3a; }
.w-full { width: 100%; }

/* ============ Hero (landing & dashboard upload tab) ============ */
.hero {
  background: var(--gradient-hero);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 64px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 920px;
  margin: 40px auto 0;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-glow);
  pointer-events: none;
}
.hero h1, .hero h2 {
  font-size: 48px;
  margin: 0 0 16px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.hero p {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 18px;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Badge on hero */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 99px;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(168,85,247,0.1));
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #6366f1;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
  animation: badgePulse 3s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}
.tab {
  background: white;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}

.drop {
  border: 1.5px dashed #c7d2fe;
  border-radius: 14px;
  padding: 42px 20px;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: #f5f3ff; }
.drop strong { display: block; margin-bottom: 6px; color: var(--text); }
.drop span { color: var(--muted); }
.drop small { color: var(--muted); display: block; margin-top: 6px; }

.b64box { text-align: left; }
.b64box textarea {
  width: 100%;
  height: 170px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 12px;
  padding: 15px;
  resize: vertical;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.b64box textarea:focus { border-color: var(--accent); }
.b64box .primary {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 9px;
  padding: 11px 18px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: background .15s;
}
.b64box .primary:hover { background: #4f46e5; }

.result {
  display: none;
  margin-top: 18px;
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  text-align: left;
}
.result-row { display: flex; gap: 8px; margin-top: 10px; }
.result input {
  flex: 1;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  background: var(--soft);
  color: var(--text);
}
.copy {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.copy:hover { background: #4f46e5; }
.del {
  border: 1px solid var(--line);
  background: white;
  color: var(--danger);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}
.del:hover { background: #fef2f2; }
.preview {
  margin-top: 12px;
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}

.error-box {
  margin-top: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
}

/* ============ AI Generate form ============ */
.aigen-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
  text-align: left;
}
.aigen-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.aigen-field > span { font-weight: 600; color: var(--text); }
.aigen-field textarea,
.aigen-field select,
.aigen-field input {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.aigen-field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}
.aigen-field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #6b7280 50%),
                    linear-gradient(135deg, #6b7280 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.aigen-field textarea:focus,
.aigen-field select:focus,
.aigen-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.aigen-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.aigen-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.aigen-cost {
  font-size: 12px;
  color: var(--muted);
}
.aigen-result { margin-top: 24px; }
.aigen-result-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
  box-shadow: 0 4px 16px rgba(99, 102, 241, .06);
}
.aigen-result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.aigen-credit-row {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
@media (max-width: 640px) {
  .aigen-row { grid-template-columns: 1fr; }
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.features {
  max-width: 1080px;
  margin: 64px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.feature {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 28px 22px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.feature::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.03) 0%, transparent 60%);
  pointer-events: none;
}
.feature:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(99, 102, 241, 0.15);
}
.feature h3 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  position: relative;
}
.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}
.feature code {
  background: rgba(99, 102, 241, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.footer {
  max-width: 1080px;
  margin: 32px auto 48px;
  padding: 28px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.footer a {
  color: var(--muted);
  margin: 0 10px;
  transition: color .15s;
}
.footer a:hover { color: var(--primary); }

/* ============ Auth (login/register) ============ */
.auth-body {
  background: linear-gradient(135deg, #111827 0%, #1f2937 60%, #111827 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 18px;
  padding: 36px;
  box-shadow: 0 30px 60px #0008;
}
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-card p.muted { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #6366f122; }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--accent); font-weight: 600; }
.hint {
  margin-top: 14px;
  background: var(--soft);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.hint code { background: white; padding: 1px 6px; border-radius: 5px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ============ App shell (dashboard) ============ */
.app { display: flex; min-height: 100vh; }
.side {
  width: 240px;
  background: white;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.logo {
  font-weight: 800;
  font-size: 20px;
  padding: 0 12px 28px;
}
.logo span { color: var(--accent); }
.nav button {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 14px;
  color: #4b5563;
  cursor: pointer;
  margin-bottom: 3px;
}
.nav button.active,
.nav button:hover { background: #f3f4f6; color: var(--text); font-weight: 600; }

.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.logout-btn {
  width: 100%;
  background: var(--soft);
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.logout-btn:hover { background: #e5e7eb; }

.main {
  margin-left: 240px;
  flex: 1;
  padding: 34px 42px;
  max-width: 1250px;
}
.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.page-title-row h1 { font-size: 28px; margin: 0; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.top h1 { font-size: 28px; margin: 0; }
.user-info { font-size: 13px; color: var(--muted); }

.page { display: none; }
.page.active { display: block; }

/* ============ Cards / tables / grids ============ */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.mt-4 { margin-top: 18px; }
.muted { color: var(--muted); font-size: 13px; }
.metric { font-size: 25px; font-weight: 800; margin-top: 8px; }

.table {
  margin-top: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.tr {
  display: grid;
  grid-template-columns: 64px 1.8fr 100px 90px 130px 130px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.tr:last-child { border-bottom: 0; }
.tr.th { font-weight: 700; background: #fafafa; }
.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #eef2f7;
}
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 99px;
  background: #ecfdf3;
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
}
.badge.del { background: #fef2f2; color: var(--danger); }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 14px;
}
.pagination button {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.pagination button:disabled { opacity: .5; cursor: not-allowed; }

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.plan-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: white;
}
.plan-card h4 { margin: 0 0 8px; font-size: 16px; }
.plan-card .price { font-weight: 800; font-size: 22px; }
.plan-card ul { padding-left: 18px; margin: 8px 0; color: var(--muted); font-size: 13px; }
.plan-card .actions { margin-top: 12px; }

/* ============ API keys ============ */
.key-display {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.key-display input {
  flex: 1;
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.key-row:last-child { border-bottom: 0; }
.key-row .meta { font-size: 12px; color: var(--muted); }

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-body {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.modal-body h3 { margin: 0 0 8px; }
.modal-body p { margin: 0; }
.modal-body pre { background: var(--soft); padding: 12px; border-radius: 8px; }

/* ============ Documentation tab ============ */
.docs-hero {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: white;
  border-radius: 16px;
  padding: 26px 28px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px #11182722;
}
.docs-hero h2 { margin: 0 0 6px; font-size: 22px; }
.docs-hero p { margin: 0 0 14px; color: #cbd5e1; font-size: 14px; }
.docs-hero code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 5px; }
.docs-base {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.08);
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
}
.docs-base .muted { color: #cbd5e1; font-size: 12px; }
.docs-base code {
  background: transparent;
  padding: 0;
  color: #e5e7eb;
  font-size: 13px;
}
.docs-base .copy-inline {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: white;
}
.docs-base .copy-inline:hover { background: rgba(255,255,255,.2); }

.docs-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.api-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 22px;
  transition: border-color .15s, box-shadow .15s;
}
.api-card:hover { border-color: #d1d5db; box-shadow: 0 4px 14px #11182708; }
.api-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.api-card h3 { margin: 0 0 6px; font-size: 16px; }
.api-card h4 {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.api-card p { margin: 0 0 8px; font-size: 14px; color: #374151; }

.method-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  letter-spacing: .04em;
}
.m-get    { background: #dbeafe; color: #1d4ed8; }
.m-post   { background: #dcfce7; color: #15803d; }
.m-del    { background: #fee2e2; color: #b91c1c; }
.m-info   { background: #ede9fe; color: #6d28d9; }

.endpoint {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--soft);
  color: var(--text);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 13px;
}
.auth-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
}
.auth-badge.public { background: #fef9c3; color: #854d0e; border-color: #fde68a; }

.code-block {
  position: relative;
  background: #0f172a;
  color: #e5e7eb;
  padding: 14px 16px;
  border-radius: 10px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.55;
  margin: 0;
}
.code-block code {
  color: #e5e7eb;
  background: transparent;
  padding: 0;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}
.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  padding: 4px 9px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  color: #e5e7eb;
  border-radius: 6px;
}
.copy-code:hover { background: rgba(255,255,255,.16); }
.copy-code.copied { background: #065f46; border-color: #047857; color: white; }
.copy.copied { background: var(--ok); border-color: var(--ok); color: white; }

.error-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.error-codes code {
  background: #fef2f2;
  color: #b91c1c;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid #fecaca;
}

/* ============ SEO landing sections (long-form content) ============ */
.seo-content {
  max-width: 920px;
  margin: 64px auto;
  padding: 0 24px;
  color: var(--text);
}
.seo-content > h2 {
  font-size: 32px;
  margin: 0 0 20px;
  letter-spacing: -0.02em;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.seo-content > h3 {
  font-size: 19px;
  margin: 28px 0 10px;
  font-weight: 700;
  color: var(--text);
}
.seo-content p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 16px;
}
.seo-content code {
  background: rgba(99, 102, 241, 0.06);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 14px;
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.12);
}

/* Steps list (How it works) */
.steps {
  counter-reset: step;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 14px;
}
.steps li {
  position: relative;
  padding: 18px 20px 18px 64px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  transition: border-color .2s ease, transform .2s ease;
  box-shadow: var(--shadow-sm);
}
.steps li:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateX(4px);
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 18px; top: 18px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

/* Use cases grid */
.usecases {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.usecase {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  transition: border-color .2s ease, box-shadow .2s ease;
  box-shadow: var(--shadow-sm);
}
.usecase:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: var(--shadow-md);
}
.usecase h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--text);
  font-weight: 700;
}
.usecase p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Code snippet block (API examples) */
.code-snippet {
  position: relative;
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 20px 22px;
  margin: 16px 0 20px;
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}
.code-snippet code {
  background: transparent;
  color: #e5e7eb;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}

/* Pricing cards */
.pricing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.price-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  box-shadow: var(--shadow-sm);
}
.price-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(99, 102, 241, 0.3);
}
.price-card.highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), var(--shadow-md);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.04) 0%, var(--card) 40%);
}
.price-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.price-card .price-amt {
  font-size: 28px;
  font-weight: 800;
  margin: 6px 0 14px;
  color: var(--text);
}
.price-card.highlight .price-amt {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.price-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.9;
}
.price-card ul li::before {
  content: "✓ ";
  color: var(--ok);
  font-weight: 700;
  margin-right: 4px;
}
.cta-inline {
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px dashed rgba(99, 102, 241, 0.4);
  transition: color .15s, border-color .15s;
}
.cta-inline:hover {
  color: #a855f7;
  border-color: #a855f7;
}

/* FAQ details */
.seo-content details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: border-color .2s ease;
  box-shadow: var(--shadow-sm);
}
.seo-content details[open] {
  border-color: rgba(99, 102, 241, 0.3);
}
.seo-content details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.seo-content details summary:hover { color: var(--primary); }
.seo-content details[open] summary { margin-bottom: 10px; }
.seo-content details p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

/* Final CTA */
.cta {
  max-width: 920px;
  margin: 72px auto 48px;
  padding: 48px 32px;
  text-align: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 60%, #111827 100%);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.25) 0%, transparent 65%);
  pointer-events: none;
}
.cta h2 {
  margin: 0 0 12px;
  font-size: 30px;
  color: white;
  font-weight: 800;
  letter-spacing: -0.02em;
  position: relative;
}
.cta > p {
  color: #cbd5e1;
  margin: 0 0 24px;
  font-size: 16px;
  line-height: 1.6;
  position: relative;
}

/* Hero CTA stack — landing (khi chưa đăng nhập) */
.cta-stack {
  margin-top: 32px;
  position: relative;
}
.cta-note {
  color: #94a3b8;
  font-size: 14px;
  margin: 0 auto 22px;
  max-width: 540px;
  line-height: 1.6;
}
.cta-buttons {
  margin: 0;
}
.cta-buttons .cta-btn { margin: 0 6px; }

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  margin: 0 6px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.cta-btn.primary {
  background: white;
  color: var(--primary);
  border: 2px solid white;
}
.cta-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.25);
  background: #f8fafc;
}
.cta-btn.ghost {
  background: transparent;
  color: white;
  border: 2px solid rgba(255,255,255,0.35);
}
.cta-btn.ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.6);
  transform: translateY(-2px);
}

/* Visually hidden — for screen-reader-only labels */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Show dropzone/result always — initial render must not flash */
.hero .drop,
.hero .b64box {
  display: block;
}
.hero .b64box[hidden] { display: none; }
#result[hidden] { display: none; }

/* ============ Responsive ============ */
@media (max-width: 800px) {
  .side { width: 68px; padding: 24px 6px; }
  .logo { font-size: 0; padding-bottom: 28px; }
  .logo span { font-size: 20px; }
  .nav button { font-size: 0; text-align: center; padding: 11px 0; }
  .nav button::first-letter { font-size: 14px; }
  .side-foot { padding: 8px 0; }
  .logout-btn { font-size: 0; padding: 12px 0; }
  .main { margin-left: 68px; padding: 22px; }
  .grid-3, .plans-grid { grid-template-columns: 1fr; }
  .features { grid-template-columns: 1fr 1fr; }
  .tr { grid-template-columns: 52px 1fr 80px; }
  .tr > *:nth-child(n+4) { display: none; }
  .topbar { padding: 12px 18px; flex-wrap: wrap; gap: 8px; }
  .topnav .h-right { flex-wrap: wrap; }
  .h-email { display: none; }
  .hero { margin: 20px 12px 0; padding: 24px; }
  .hero h1, .hero h2 { font-size: 24px; }
  .api-card { padding: 14px 16px; }
  .code-block { font-size: 11.5px; }
  .seo-content { margin: 36px auto; padding: 0 16px; }
  .usecases, .pricing { grid-template-columns: 1fr; }
  .cta { margin: 40px 12px 28px; padding: 28px 20px; }
  .cta-btn { margin: 4px; }
}

@media (max-width: 480px) {
  .features { grid-template-columns: 1fr; }
  .footer { flex-direction: column; gap: 8px; text-align: center; }
}

/* ============ Payment page ============ */
.pay-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.pay-stage { display: none; }
.pay-stage.active { display: block; }

.pay-stage-head { margin-bottom: 22px; text-align: center; }
.pay-stage-head h1 { font-size: 26px; margin: 0 0 6px; }
.pay-stage-head p { margin: 0; }

.pay-back {
  display: inline-block;
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}
.pay-back:hover { color: var(--text); }

.pay-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.pay-plan {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  opacity: .5;
  cursor: not-allowed;
  transition: opacity .2s ease, transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.pay-plan.is-actionable {
  opacity: 1;
  cursor: pointer;
  border-color: var(--line);
}
.pay-plan.is-actionable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 24px #11182720;
}
.pay-plan.is-actionable button {
  animation: payPulse 2.4s ease-in-out infinite;
}
@keyframes payPulse {
  0%, 100% { box-shadow: 0 0 0 0 #6366f130; }
  50%      { box-shadow: 0 0 0 8px #6366f100; }
}
.pay-plan.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #6366f118;
  opacity: 1;          /* gói hiện tại luôn hiện rõ để user thấy */
  cursor: pointer;
}
.pay-plan.is-current.is-actionable:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px #11182720, 0 0 0 3px #6366f118;
}
.pay-plan h3 { margin: 0 0 8px; font-size: 18px; }
.pay-plan .pay-price { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.pay-plan ul {
  padding-left: 18px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  flex-grow: 1;
}
.pay-plan small { display: block; margin-top: 6px; font-size: 12px; }

.pay-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  margin-top: 20px;
  align-items: stretch;
}
.pay-qr {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.qr-frame {
  background: #f9fafb;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.qr-frame img {
  display: block;
  width: 240px;
  height: 300px;
  border-radius: 6px;
}
.qr-countdown {
  margin-top: 14px;
  font-family: ui-monospace, monospace;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.qr-countdown.expired { color: var(--danger); }

.pay-info {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.pay-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.pay-row:last-of-type { border-bottom: 0; }
.pay-row .muted { font-size: 12px; }
.pay-row b { font-weight: 600; }
.pay-row code { font-size: 13px; }
.pay-row em { color: var(--danger); font-style: normal; font-size: 11px; margin-left: 4px; }

.code-pill {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 4px 10px;
  font-family: ui-monospace, monospace;
  font-weight: 700;
}

.pay-state {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--soft);
  color: var(--text);
}
.pay-state .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.4s infinite;
}
.pay-state.pending .dot { background: #f59e0b; }
.pay-state.ok       { background: #ecfdf5; color: #047857; }
.pay-state.ok       .dot { background: #047857; animation: none; }
.pay-state.expired  { background: #fef2f2; color: #b91c1c; }
.pay-state.expired  .dot { background: #b91c1c; animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.pay-cancel { margin-top: 14px; }

.pay-tip {
  margin-top: 22px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 13px;
}
.pay-tip code {
  background: white;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid #fed7aa;
}

.pay-success {
  text-align: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 60px 30px;
  max-width: 520px;
  margin: 40px auto;
}
.pay-success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #d1fae5;
  color: #047857;
  font-size: 36px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.pay-success h1 { margin: 0 0 8px; font-size: 24px; }
.pay-success p  { margin: 0 0 22px; }
.pay-success-actions { display: flex; gap: 10px; justify-content: center; }

.pay-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.pay-error[hidden] { display: none; }

@media (max-width: 800px) {
  .pay-plans { grid-template-columns: 1fr; }
  .pay-grid  { grid-template-columns: 1fr; }
  .qr-frame img { width: 200px; height: 200px; }
}