/* PDFbat design system — neutral surfaces, one solid accent, no gradients */
:root {
  /* Warm neutral palette (PostHog style): off white canvas, white cards, olive grey borders, near black ink, orange accent */
  --bg: #eeefe9;
  --surface: #ffffff;
  --surface-2: #f4f4f0;
  --surface-3: #e5e7e0;
  --border: #d9dad2;
  --border-strong: #c3c4bb;
  --text: #151515;
  --text-2: #3b3d38;
  --muted: #6b6d66;
  --accent: #f54e00;
  --accent-hover: #d84500;
  --accent-soft: #fdeee6;
  --accent-text: #d14400;
  --on-accent: #ffffff;
  --ring: rgba(245, 78, 0, .22);
  --btn-edge: #b9bab1;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --success: #079455;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 8px;
  --radius-lg: 12px;
  --canvas-bg: #e5e7e0;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bar-h: 60px;
  --header-h: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); /* includes the status bar area when installed */
  --tabbar-h: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1f27; --surface: #26282f; --surface-2: #2c2e36; --surface-3: #34363f; --border: #3a3c45; --border-strong: #4a4c56; --text: #eeefe9; --text-2: #cfd0c8; --muted: #9a9c94; --accent: #ff6a2b; --accent-hover: #ff8550; --accent-soft: #3a261d; --accent-text: #ff8a55; --on-accent: #ffffff; --ring: rgba(255, 106, 43, .3); --btn-edge: #15161b;
    --danger-soft: #3a1512; --success-soft: #0f2e20; --warning-soft: #33240b; --canvas-bg: #17181e; color-scheme: dark;
    --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #1d1f27; --surface: #26282f; --surface-2: #2c2e36; --surface-3: #34363f; --border: #3a3c45; --border-strong: #4a4c56; --text: #eeefe9; --text-2: #cfd0c8; --muted: #9a9c94; --accent: #ff6a2b; --accent-hover: #ff8550; --accent-soft: #3a261d; --accent-text: #ff8a55; --on-accent: #ffffff; --ring: rgba(255, 106, 43, .3); --btn-edge: #15161b;
  --danger-soft: #3a1512; --success-soft: #0f2e20; --warning-soft: #33240b; --canvas-bg: #17181e; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Icons are SVG masks so they inherit currentColor */
.i { display: inline-block; width: 18px; height: 18px; background: currentColor; flex: none;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; vertical-align: middle; }
.i.lg { width: 24px; height: 24px; }
.i.sm { width: 15px; height: 15px; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--header-h); padding-top: env(safe-area-inset-top, 0px); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { height: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
.topbar.wide .topbar-inner { max-width: none; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 32px; height: 32px; display: block; flex: none; }
.brand .logo svg { width: 100%; height: 100%; display: block; }
.brand .name { font-weight: 500; }
.brand .name b { color: var(--accent-text); font-weight: 900; letter-spacing: -.03em; }
.nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.nav a { color: var(--text-2); padding: 7px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--accent-text); background: var(--accent-soft); }
/* "More" products menu */
.nav-more { position: relative; }
.nav-more-btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 10px 7px 12px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.nav-more-btn:hover, .nav-more.open .nav-more-btn { color: var(--text); background: var(--surface-2); }
.nav-more-btn.active { color: var(--accent-text); }
.nav-more-btn .i { transition: transform .15s; }
.nav-more.open .nav-more-btn .i { transform: rotate(180deg); }
.nav-more-menu { display: none; position: absolute; left: -8px; top: calc(100% + 10px); width: 300px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 70; }
.nav-more.open .nav-more-menu { display: grid; gap: 2px; animation: pop .14s ease; }
.nav .nav-more-menu a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; white-space: normal; }
.nav-more-menu .nm-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.nav-more-menu .nm-text { display: flex; flex-direction: column; min-width: 0; }
.nav-more-menu .nm-text b { font-weight: 600; color: var(--text); font-size: 13.5px; }
.nav-more-menu .nm-text small { color: var(--muted); font-size: 12px; font-weight: 400; }
.nav .nav-more-menu a.active .nm-text b { color: var(--accent-text); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 1001; background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }
.skip-link:focus { top: 10px; text-decoration: none; }
main[tabindex="-1"]:focus { outline: none; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu a.menu-upgrade { color: var(--accent-text); font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 600; font-size: 12px; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); border-radius: var(--radius); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.big { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.icon { width: 36px; padding: 0; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font: inherit; box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input[type=color] { width: 40px; height: 32px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px; background: var(--surface); cursor: pointer; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- Layout primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.container { max-width: 1240px; margin: 0 auto; padding: 36px 24px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { margin-bottom: 6px; }
.page-head p { color: var(--muted); margin: 0; font-size: 15px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); text-transform: capitalize; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.sent, .badge.viewed { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.completed, .badge.signed { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.declined, .badge.voided, .badge.expired { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.draft { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }

/* ---------- Home ---------- */
.hero { border-bottom: 1px solid var(--border); background: var(--surface); }
.hero-inner { max-width: 1240px; margin: 0 auto; padding: 64px 24px 56px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center; }
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; gap: 32px; padding: 40px 20px; } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent-text); margin-bottom: 16px; }
.hero h1 { font-size: clamp(32px, 4.4vw, 48px); line-height: 1.1; letter-spacing: -.03em; margin-bottom: 18px; }
.hero .lead { font-size: 17px; color: var(--muted); max-width: 540px; margin-bottom: 28px; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; }
.trust { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 28px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.trust span { display: inline-flex; align-items: center; gap: 7px; }
.trust .i { color: var(--accent-text); }
.hero-panel { padding: 20px; }
.hero-panel .dropzone { padding: 40px 20px; }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.quick-links a { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); font-weight: 500; font-size: 13px; background: var(--surface); }
.quick-links a:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.quick-links .i { color: var(--accent-text); }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; font: inherit; font-weight: 500; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; width: 300px; max-width: 100%; }
.search input { padding-left: 36px; }
.search .i { position: absolute; left: 12px; top: 10px; color: var(--muted); }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 30px 0 12px; }
.section-title:first-child { margin-top: 0; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 14px; padding: 16px; color: var(--text); transition: border-color .12s, box-shadow .12s; }
.tool-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.tool-card .ic { width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.tool-card.feature .ic { background: var(--accent); color: var(--on-accent); }
.tool-card h3 { font-size: 14.5px; margin: 1px 0 3px; }
.tool-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

.band { border-top: 1px solid var(--border); background: var(--surface); }
.band-inner { max-width: 1240px; margin: 0 auto; padding: 56px 24px; display: grid; grid-template-columns: .9fr 1.1fr; gap: 48px; align-items: center; }
@media (max-width: 900px) { .band-inner { grid-template-columns: 1fr; } }
.feature-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
@media (max-width: 560px) { .feature-list { grid-template-columns: 1fr; } }
.feature-list > div { display: flex; gap: 12px; }
.feature-list .ic { width: 34px; height: 34px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.feature-list b { display: block; font-size: 14px; margin-bottom: 2px; }
.feature-list p { margin: 0; font-size: 13px; color: var(--muted); }

.footer { border-top: 1px solid var(--border); background: var(--bg); }
.footer-inner { max-width: 1240px; margin: 0 auto; padding: 44px 24px 36px; display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 28px; color: var(--muted); font-size: 13px; }
.footer-brand p { margin: 12px 0 0; max-width: 300px; line-height: 1.5; }
.footer-brand .footer-copy { font-size: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 9px; }
.footer-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); margin: 4px 0 4px; }
.footer-inner a { color: var(--muted); }
.footer-inner .brand { color: var(--text); }
.footer-col a:hover { color: var(--text); }
@media (max-width: 900px) { .footer-inner { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }

/* ---------- Dropzone ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 48px 20px; text-align: center; background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; margin: 0 auto 14px; }
.dropzone h3 { margin: 0 0 4px; font-size: 16px; }
.dropzone .muted { font-size: 13px; }
.dropzone .btn { margin-top: 16px; pointer-events: none; }

/* ---------- Tool page ---------- */
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .tool-layout { grid-template-columns: 1fr; } }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.file-list .list-actions { display: flex; gap: 8px; margin-top: 4px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); }
.file-item .grip { color: var(--muted); cursor: grab; }
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-item .thumb { width: 36px; height: 46px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.file-item.dragging { opacity: .4; }
.options { position: sticky; top: calc(var(--header-h) + 20px); overflow: hidden; }
.options .opt-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.options .opt-head h3 { margin: 0; font-size: 15px; }
.options .opt-body { padding: 18px; }
.options .opt-foot { padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.result { padding: 28px; text-align: center; margin-top: 16px; }
.ok-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 0 auto 14px; }
.result .next { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.result .next .btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 14px; margin-top: 16px; }
.thumb-card { position: relative; padding: 8px; text-align: center; cursor: grab; user-select: none; border-radius: var(--radius); }
.thumb-card canvas, .thumb-card .blank { width: 100%; height: auto; background: #fff; border: 1px solid var(--border); border-radius: 4px; display: block; transition: transform .2s; }
.thumb-card .blank { aspect-ratio: 1 / 1.414; display: grid; place-items: center; color: #98a2b3; font-size: 12px; }
.thumb-card .num { font-size: 12px; color: var(--muted); margin-top: 6px; }
.thumb-card .actions { position: absolute; top: 12px; right: 12px; display: none; gap: 4px; }
.thumb-card:hover .actions { display: flex; }
.thumb-card .actions button { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.thumb-card.drop-before { box-shadow: -3px 0 0 var(--accent); }

/* ---------- Toast & modal ---------- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; pointer-events: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #101828; color: #fff; padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-weight: 500; font-size: 13.5px; animation: pop .18s ease; max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 900; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 92vh; overflow: auto; border: 1px solid var(--border); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent-text); border-color: var(--accent); }

/* ---------- Signature pad ---------- */
.sig-canvas { width: 100%; height: 180px; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); touch-action: none; cursor: crosshair; display: block; }
.sig-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sig-types button { background: #fff; color: #111; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; font-size: 26px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sig-types button.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.swatches { display: flex; gap: 8px; align-items: center; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.swatches button.active { box-shadow: 0 0 0 2px var(--accent); }
.saved-sigs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.saved-sigs .sig { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; cursor: pointer; position: relative; }
.saved-sigs .sig:hover { border-color: var(--accent); }
.saved-sigs .sig img { height: 44px; display: block; }
.saved-sigs .sig button { position: absolute; top: -7px; right: -7px; border-radius: 50%; border: 0; width: 18px; height: 18px; font-size: 11px; background: var(--danger); color: #fff; cursor: pointer; line-height: 1; }

/* ---------- Misc ---------- */
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); }
table.list th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--surface-2); }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: var(--surface-2); }

/* ---------- Account menu ---------- */
.account { position: relative; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 99px; background: none; color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; }
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; color: var(--text-2); font: inherit; font-weight: 500; text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 40px 16px; }
.auth-box { width: min(420px, 100%); }
.auth-box .card { padding: 28px; }
.auth-box h1 { font-size: 24px; text-align: center; margin-bottom: 6px; }
.auth-box .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.auth-box .segmented { display: flex; margin-bottom: 22px; }
.auth-box .segmented button { flex: 1; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-wrap button { position: absolute; right: 4px; top: 3px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.pw-wrap button:hover { color: var(--text); background: var(--surface-2); }
.optional { color: var(--muted); font-weight: 400; }
.auth-perks { display: grid; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.auth-perks span { display: flex; gap: 8px; align-items: center; }
.auth-perks .i { color: var(--accent-text); }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.settings { max-width: 640px; }
.settings .card { padding: 24px; margin-bottom: 18px; }
.settings .card h2 { font-size: 17px; margin-bottom: 4px; }
.settings .card > p { color: var(--muted); margin-bottom: 18px; }
.form-notice { background: var(--accent-soft); color: var(--accent-text); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.auth-links { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-links a { display: inline-flex; align-items: center; gap: 4px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }

/* =====================================================================
   Responsive
   ===================================================================== */
.nav-toggle { display: none; }
.signup .short { display: none; }
html { -webkit-text-size-adjust: 100%; }
img, canvas { max-width: 100%; }

/* Tablet and below: collapsible navigation */
@media (max-width: 900px) {
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .nav-toggle { display: inline-flex; margin-left: -6px; }
  .nav { position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; gap: 2px; padding: 10px 12px 14px;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); display: none; overflow: visible; }
  .topbar.nav-open .nav { display: flex; }
  .nav a { padding: 11px 12px; font-size: 15px; }
  .nav { align-items: stretch; }
  .nav-more-btn { display: none; }
  .nav-more-menu { display: grid !important; position: static; width: auto; border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 8px 0 0; margin-top: 6px; animation: none !important; }
  .nav .nav-more-menu a { padding: 8px 12px; }
  .topbar .right { margin-left: auto; }
  .container { padding: 28px 18px; }
  .hero-inner, .band-inner { padding-left: 18px; padding-right: 18px; }
  .options { position: static; }
}

/* Phones */
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  h1 { font-size: 24px; }
  .container { padding: 22px 14px; }
  .page-head { margin-bottom: 18px; }
  .page-head p { font-size: 14px; }
  .hero-inner { padding: 28px 14px 32px; gap: 24px; }
  .hero .lead { font-size: 15.5px; margin-bottom: 20px; }
  .hero .cta { flex-direction: column; }
  .hero .cta .btn { width: 100%; }
  .trust { gap: 10px 16px; margin-top: 18px; }
  .hero-panel { padding: 12px; }
  .hero-panel .dropzone, .dropzone { padding: 28px 14px; }
  .quick-links { grid-template-columns: 1fr 1fr; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .segmented { width: 100%; }
  .tool-grid { grid-template-columns: 1fr; gap: 8px; }
  .tool-card { padding: 13px; }
  .band-inner { padding: 36px 14px; gap: 24px; }
  .footer-inner { padding: 28px 16px calc(28px + var(--safe-b)); gap: 22px 16px; }
  .footer-col { gap: 0; }
  .footer-col a { min-height: 36px; display: flex; align-items: center; }
  .signup .long { display: none; }
  .signup .short { display: inline; }
  .topbar .right .btn { height: 34px; padding: 0 12px; }
  .brand .name { font-size: 16px; }
  .user-chip .uname { display: none; }
  /* Tool page: keep the action button reachable */
  .options .opt-foot { position: sticky; bottom: 0; box-shadow: 0 -4px 12px rgba(16,24,40,.08); z-index: 5; }
  .options { overflow: visible; }
  .file-item { padding: 8px 10px; gap: 10px; }
  .file-item .thumb { width: 30px; height: 38px; }
  .result { padding: 20px 14px; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .thumb-card .actions { display: flex; top: 10px; right: 10px; } /* no hover on touch */
  /* Dialogs become bottom sheets */
  .modal-back { place-items: end center; padding: 0; }
  .modal { width: 100% !important; max-height: 90vh; border-radius: 16px 16px 0 0; }
  .modal footer { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .modal footer .btn { flex: 1; }
  .sig-canvas { height: 160px; }
  .sig-types button { font-size: 22px; }
  .toasts { left: 12px; right: 12px; transform: none; bottom: max(16px, env(safe-area-inset-bottom)); }
  .toast { text-align: center; }
  /* Tables collapse to the essentials */
  table.list th.opt, table.list td.opt { display: none; }
  table.list th, table.list td { padding: 12px 10px; }
  .auth-box .card { padding: 22px 18px; }
  .settings .card { padding: 18px; }
  .menu { position: fixed; top: calc(var(--header-h) + 6px); right: 10px; left: auto; }
}


/* ---------- Drive picker ---------- */
.picker-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.linkish { border: 0; background: none; padding: 2px 4px; border-radius: 4px; color: var(--accent-text); font: inherit; cursor: pointer; }
.linkish:hover { background: var(--accent-soft); }
.picker-list { border: 1px solid var(--border); border-radius: var(--radius); max-height: 50vh; overflow: auto; }
.picker-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--surface-2); }
.picker-row.on { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.picker-row:disabled { opacity: .45; cursor: not-allowed; }
.picker-row .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ficon { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.ficon.folder { background: #fef3c7; color: #b45309; }
.ficon.pdf { background: #fee4e2; color: #d92d20; }
/* ---------- Storage banner ---------- */
.storage-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 9px 16px; font-size: 13.5px; font-weight: 500; text-align: center; }
.storage-banner.warning { background: var(--warning-soft); color: var(--warning); }
.storage-banner.full { background: var(--danger-soft); color: var(--danger); }
.storage-banner .btn { height: 30px; }
.storage-banner .x { border: 0; background: none; color: inherit; cursor: pointer; padding: 4px; display: grid; }

@media (hover: none) { .thumb-card .actions { display: flex; } }

/* =====================================================================
   Native app shell: safe areas, tab bar, sheets, touch sizing
   ===================================================================== */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
@media (orientation: landscape) { body { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); } }
.modal, .menu, .ctx, .picker-list, .preview-pages, .nav { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Bottom tab bar (signed in, phones only) */
.tabbar { display: none; }
@media (max-width: 760px), (pointer: coarse) and (max-height: 520px) {
  body.has-tabbar:not(.editing) { --tabbar-h: 58px; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
  body.has-tabbar:not(.editing) .tabbar { display: flex; }
  .tabbar { position: fixed; z-index: 85; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px);
    background: color-mix(in srgb, var(--surface) 94%, transparent); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--border); }
  .tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; color: var(--muted); font-size: 10.5px; white-space: nowrap; font-weight: 600; letter-spacing: .01em; }
  .tabbar .tab .i { width: 23px; height: 23px; }
  .tabbar .tab:hover { text-decoration: none; }
  .tabbar .tab.on { color: var(--accent-text); font-weight: 700; }
  .tabbar .tab:active { opacity: .6; }
  /* Fixed things that sit at the bottom move above the bar */
  body.has-tabbar:not(.editing) .toasts { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
  /* Editor start screen is a flex column at full height */
  body.has-tabbar:not(.editing) #app { padding-bottom: 0; }
}

/* Phones (portrait) */
@media (max-width: 600px) {
  :root { --bar-h: 54px; }
  .topbar-inner { gap: 6px; padding: 0 8px 0 10px; }
  .brand { gap: 8px; }
  .brand .logo { width: 30px; height: 30px; }
  h1 { letter-spacing: -.02em; }
  /* Sheets: grab handle, slide up, safe area */
  .modal { animation: sheet-up .22s cubic-bezier(.2,.8,.2,1); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; }
  .modal::before { content: ''; display: block; width: 38px; height: 5px; border-radius: 5px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .modal header { padding: 10px 16px 12px; border-bottom: 0; flex: none; }
  .modal .body { padding: 4px 16px 18px; overflow: auto; flex: 1 1 auto; min-height: 0; }
  .modal footer { flex: none; flex-wrap: wrap; padding: 12px 16px max(12px, var(--safe-b)); }
  .modal footer .btn { min-width: 0; }
  .modal:not(:has(footer)) .body { padding-bottom: max(18px, var(--safe-b)); }
  /* Account menu becomes an action sheet */
  .menu { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; border-radius: 16px 16px 0 0; padding: 8px 10px max(12px, var(--safe-b)); z-index: 950;
    box-shadow: 0 0 0 100vmax rgba(16, 24, 40, .45); animation: sheet-up .22s cubic-bezier(.2,.8,.2,1); max-height: 85dvh; overflow: auto; }
  .menu::before { content: ''; display: block; width: 38px; height: 5px; border-radius: 5px; background: var(--border-strong); margin: 0 auto 8px; }
  .menu a, .menu button { min-height: 48px; font-size: 15px; padding: 10px 12px; }
  /* Mobile nav drawer */
  .nav { max-height: calc(100dvh - var(--header-h)); overflow-y: auto; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }

/* Landscape phones: short screens get a compact header and full-height sheets */
@media (pointer: coarse) and (max-height: 520px) {
  :root { --bar-h: 50px; }
  .modal { max-height: calc(100dvh - 16px); }
  .modal-back { padding: 8px; }
  .auth-wrap { padding: 20px 16px; }
}

/* Touch screens: 44px targets, 16px inputs (stops iOS zoom), no hover-only affordances */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.icon { min-width: 44px; }
  .btn.ghost.icon { min-height: 44px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], select { min-height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  label.check { min-height: 44px; margin-bottom: 4px; }
  .nav a { min-height: 44px; display: flex; align-items: center; }
  .menu a, .menu button { min-height: 44px; }
  .linkish { min-height: 36px; padding: 6px 8px; }
  .segmented button { min-height: 40px; }
  .tabs button { min-height: 44px; }
  .picker-row { min-height: 52px; }
  .pw-wrap button { width: 40px; height: 40px; top: 2px; }
  .storage-banner .btn { min-height: 36px; }
  .user-chip { min-height: 44px; }
  .swatches button { width: 30px; height: 30px; }
  .saved-sigs .sig button { width: 24px; height: 24px; top: -10px; right: -10px; }
  .thumb-card .actions button { width: 34px; height: 34px; }
  .btn:active, .tool-card:active, .picker-row:active { transform: scale(.98); }
  a:hover { text-decoration: none; }
}
@media (hover: none) {
  .btn:hover { background: var(--surface); color: var(--text-2); }
  .btn.primary:hover { background: var(--accent); color: var(--on-accent); }
  .btn.ghost:hover { background: transparent; }
  .btn.active:hover { background: var(--accent-soft); color: var(--accent-text); }
  .btn.danger:hover { color: var(--danger); }
  .dropzone:hover { border-color: var(--border-strong); background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) { .modal, .menu, .ctx { animation: none !important; } }

/* ---------- Account ---------- */
.acct-usage { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.acct-usage > div { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.acct-usage b { font-size: 15px; }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings .segmented button { display: inline-flex; align-items: center; gap: 6px; flex: 1; justify-content: center; }
.settings > .btn.ghost { margin-top: 4px; }
@media (max-width: 600px) { .acct-actions .btn { flex: 1 1 100%; } .settings form.card .btn[type=submit] { width: 100%; } }
/* Reorder controls (work without drag and drop) */
.thumb-card .num { display: flex; align-items: center; justify-content: center; gap: 2px; }
.thumb-card .num .mv { width: 26px; height: 26px; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; display: grid; place-items: center; flex: none; }
.thumb-card .num .mv:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.thumb-card .num .mv:disabled { opacity: .3; cursor: default; }
.file-item .reorder { display: flex; gap: 0; }
.file-item .reorder .btn { width: 32px; height: 32px; }
@media (pointer: coarse) {
  .thumb-card .num .mv { width: 36px; height: 36px; }
  .file-item .reorder .btn { width: 40px; min-width: 40px; min-height: 40px; }
  .file-item .grip { display: none; }
}
@media (max-width: 600px) { .file-item .fsize { display: none; } }

/* =====================================================================
   Tool directory and tool page
   ===================================================================== */
.cat-organize { --c: #475467; } .cat-edit { --c: #1d4ed8; } .cat-convert { --c: #c11574; }
.cat-optimize { --c: #b54708; } .cat-security { --c: #d92d20; } .cat-sign { --c: #4e5ba6; } .cat-other { --c: var(--accent); }
[class*="cat-"] { --cbg: color-mix(in srgb, var(--c) 11%, var(--surface)); --ctext: color-mix(in srgb, var(--c) 85%, var(--text)); }
.tile { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--cbg, var(--accent-soft)); color: var(--ctext, var(--accent-text)); }
.td-hero { background: var(--surface); border-bottom: 1px solid var(--border); }
.td-hero-inner { max-width: 1240px; margin: 0 auto; padding: 44px 24px 34px; text-align: center; }
.td-hero h1 { font-size: clamp(26px, 3.6vw, 40px); letter-spacing: -.03em; margin-bottom: 8px; }
.td-hero p { color: var(--muted); font-size: 16px; margin: 0 auto 22px; max-width: 560px; }
.td-search { position: relative; display: flex; align-items: center; max-width: 620px; margin: 0 auto; }
.td-search > .i { position: absolute; left: 18px; color: var(--muted); }
.td-search input[type=search] { height: 54px; border-radius: 14px; padding: 0 52px; font-size: 16px; box-shadow: var(--shadow); -webkit-appearance: none; appearance: none; }
.td-search .td-kbd { position: absolute; right: 16px; min-width: 0; }
.td-wrap { max-width: 1240px; margin: 0 auto; padding: 26px 24px 56px; }
.td-apps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.td-app { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); min-width: 0; transition: border-color .12s, box-shadow .12s, transform .12s; }
.td-app:hover { text-decoration: none; border-color: color-mix(in srgb, var(--c) 40%, var(--border)); box-shadow: var(--shadow); }
.td-app .tile { background: var(--c); color: #fff; }
.td-app-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.td-app-text b { font-size: 14.5px; }
.td-app-text span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.td-app > .i { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; margin: 0 -2px 8px; position: sticky; top: var(--header-h); z-index: 5; background: var(--bg); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.chip small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.chip:hover { border-color: var(--text-2); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip.on small { color: inherit; opacity: .7; }
.td-title { display: flex; align-items: baseline; gap: 10px; font-size: 17px; margin: 22px 0 12px; }
.td-title small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.td-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.td-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); transition: border-color .12s, box-shadow .12s, transform .12s; }
.td-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--c) 45%, var(--border)); box-shadow: var(--shadow); transform: translateY(-1px); }
.td-card-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.td-card-text b { font-size: 14.5px; }
.td-card-text span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.td-grid.popular .td-card { align-items: center; }
.td-grid.popular .td-card-text span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1100px) { .td-apps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .td-hero-inner { padding: 22px 14px 18px; }
  .td-hero p { font-size: 14.5px; margin-bottom: 14px; }
  .td-search input[type=search] { height: 50px; }
  .td-search .td-kbd { display: none; }
  .td-wrap { padding: 16px 14px 32px; }
  .td-apps { display: flex; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 18px; padding: 0 14px; scroll-snap-type: x mandatory; scroll-padding-inline: 14px; }
  .td-apps::-webkit-scrollbar { display: none; }
  .td-app { flex: 0 0 72%; scroll-snap-align: start; }
  .td-grid { grid-template-columns: 1fr; gap: 8px; }
  .td-card { padding: 13px; }
  .td-card .tile { width: 40px; height: 40px; }
  .chips { margin: 0 -14px 4px; padding: 6px 14px; }
}
@media (pointer: coarse) { .chip { height: 40px; } .td-card:hover { transform: none; } }

/* Tool page header */
.tool-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.tool-hero .tile { width: 56px; height: 56px; border-radius: 16px; background: var(--c); color: #fff; }
.tool-hero .tile .i { width: 26px; height: 26px; }
.tool-hero h1 { margin: 0 0 4px; }
.tool-hero p { margin: 0; color: var(--muted); font-size: 15px; }
.related { margin-top: 40px; }
@media (max-width: 600px) {
  .tool-hero { gap: 12px; align-items: flex-start; margin-bottom: 16px; }
  .tool-hero .tile { width: 46px; height: 46px; border-radius: 13px; }
  .tool-hero p { font-size: 14px; }
}
.api-payg { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.api-payg p { margin: 2px 0 0; font-size: 13px; }
.api-keys-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.api-fresh { background: var(--surface-2); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; display: grid; gap: 10px; }
.newkey { background: var(--accent-soft); color: var(--accent-text); border-radius: var(--radius); padding: 12px; word-break: break-all; font: 13px ui-monospace, monospace; }
.api-key { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.api-key:last-child { border-bottom: 0; }
.api-key .tile { width: 34px; height: 34px; border-radius: 9px; }
.api-key-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.api-key-text .muted { font-size: 12.5px; overflow-wrap: anywhere; }
.api-key-text code { font-family: ui-monospace, monospace; }
.settings { max-width: 720px; }

/* Landscape phones: slimmer tab bar with icon and label side by side */
@media (pointer: coarse) and (max-height: 520px) {
  body.has-tabbar:not(.editing) { --tabbar-h: 46px; }
  .tabbar .tab { flex-direction: row; gap: 7px; font-size: 12.5px; }
  .tabbar .tab .i { width: 20px; height: 20px; }
}

/* Raised buttons with a pressed state, like PostHog */
.btn:not(.ghost) { border-bottom-width: 2px; border-bottom-color: var(--btn-edge); }
.btn.primary { border-bottom-color: #b83a00; }
.btn:not(.ghost):not(:disabled):active { transform: translateY(1px); border-bottom-width: 1px; margin-bottom: 1px; }
.chip { border-bottom-width: 2px; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }
.spinner.on-accent { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }

/* ---------- 404 and invalid link pages ---------- */
.nf { max-width: 560px; margin: 0 auto; padding: 72px 20px 80px; text-align: center; }
.nf-code { font-size: 88px; font-weight: 800; line-height: 1; letter-spacing: -.05em; color: var(--accent); margin-bottom: 16px; }
.nf h1 { font-size: 28px; }
.nf > p { font-size: 15px; margin-bottom: 22px; }
.nf-search { width: 100%; margin: 0 auto 18px; }
.nf-search .i { top: 50%; transform: translateY(-50%); }
.nf-links { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 600px) { .nf { padding: 44px 16px 56px; } .nf-code { font-size: 64px; } .nf-links .btn { flex: 1 1 calc(50% - 8px); } }
.state-card { max-width: 460px; margin: 56px auto; padding: 32px 28px; text-align: center; }
.state-card .ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--surface-2); color: var(--muted); }
.state-card.error .ic { background: var(--danger-soft); color: var(--danger); }
.state-card.ok .ic { background: var(--success-soft); color: var(--success); }
.state-card h1 { font-size: 22px; margin-bottom: 6px; }
.state-card p { color: var(--muted); margin-bottom: 20px; }
.state-card .acts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.badge.plain { text-transform: none; }
.page-loading { display: grid; place-items: center; min-height: 50vh; animation: fade .2s .25s both; }
.page-loading .spinner { width: 28px; height: 28px; border-width: 3px; }
/* Open account sheet or nav drawer sits above the tab bar and floating buttons */
.topbar:has(.menu:not(.hidden)), .topbar.nav-open { z-index: 960; }
/* Landing content under live tools and apps */
.fx-embed { margin-top: 40px; border-top: 1px solid var(--border); scroll-margin-top: var(--header-h); }
.fx-embed > .fx-section:first-child { padding-top: 56px; }
.fx-embed-drop { max-width: 560px; margin: 28px auto 0; text-align: center; }
.fx-embed > .fx-hero { border-bottom: 1px solid var(--border); }
.fx-embed:first-child { margin-top: 0; border-top: 0; }

/* Upload progress pills (lib/api.js) */
#upload-pills { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.upload-pill { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px; }
.upload-pill .up-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.upload-pill .up-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-pill .up-pct { font-variant-numeric: tabular-nums; color: var(--text-2); display: inline-flex; }
.upload-pill .up-x { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.upload-pill.busy .up-x { display: none; }
.upload-pill .up-bar { height: 6px; border-radius: 99px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.upload-pill .up-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upload-pill.busy .up-bar span { animation: up-pulse 1.2s ease-in-out infinite; }
@keyframes up-pulse { 50% { opacity: .45; } }
@media (max-width: 760px) { #upload-pills { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.upload-pill .spinner.sm { width: 16px; height: 16px; border-width: 2px; }
