/* ═══════════════════════════════════════════════════════════
   Pixel — shared design layer (soft, airy, gradient-accent style)
   Loaded AFTER style.css (storefront) or cloud-admin.css (admin):
   redefines the tokens both stylesheets use, then restyles the
   shared primitives. Page-specific rules are scoped by body class:
     body.ui-front  → storefront     body.ui-admin → admin console
   ═══════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --font: 'Figtree', 'Noto Sans SC', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --surface-3: #e4e9f1;
  --border: #e3e8ef;
  --border-strong: #c9d1dc;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-3: #5e6368;

  --primary: #0b57d0;
  --primary-hover: #0842a0;
  --primary-text: #0b57d0;
  --primary-soft: #d3e3fd;
  --on-primary: #ffffff;

  --success: #146c2e;
  --success-soft: #c4eed0;
  --warning: #7a4f00;
  --warning-soft: #ffefc9;
  --danger: #b3261e;
  --danger-soft: #fce8e6;
  --info: #0b57d0;
  --info-soft: #e3edfd;
  --running: #0b57d0;
  --running-soft: #d3e3fd;
  --neutral-soft: #f0f4f9;
  --violet: #7c4dce;
  --violet-soft: #efe7fb;
  --teal: #00696b;
  --teal-soft: #d5f3f1;

  --grad: linear-gradient(90deg, #4f8ef7 0%, #9a6ff0 55%, #e8708f 100%);
  --grad-soft: linear-gradient(135deg, rgba(79, 142, 247, 0.14), rgba(154, 111, 240, 0.12) 55%, rgba(232, 112, 143, 0.10));
  --glow-1: rgba(79, 142, 247, 0.16);
  --glow-2: rgba(232, 112, 143, 0.10);

  --focus: 0 0 0 3px rgba(11, 87, 208, 0.28);
  --ring: var(--focus);
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.08);
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.06), 0 2px 8px rgba(60, 64, 67, 0.05);
  --shadow-lg: 0 12px 40px rgba(60, 64, 67, 0.22);
  --backdrop: rgba(32, 33, 36, 0.4);

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 28px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131314;
    --surface: #1e1f20;
    --surface-2: #282a2c;
    --surface-3: #333537;
    --border: #2f3133;
    --border-strong: #444746;
    --text: #e3e3e3;
    --text-2: #c4c7c5;
    --text-3: #9aa0a6;
    --primary: #a8c7fa;
    --primary-hover: #c2d7fb;
    --primary-text: #a8c7fa;
    --primary-soft: rgba(168, 199, 250, 0.16);
    --on-primary: #062e6f;
    --success: #6dd58c;
    --success-soft: rgba(109, 213, 140, 0.14);
    --warning: #fdd663;
    --warning-soft: rgba(253, 214, 99, 0.14);
    --danger: #f2b8b5;
    --danger-soft: rgba(242, 184, 181, 0.14);
    --info: #a8c7fa;
    --info-soft: rgba(168, 199, 250, 0.12);
    --running: #a8c7fa;
    --running-soft: rgba(168, 199, 250, 0.16);
    --neutral-soft: #282a2c;
    --violet: #d0bcff;
    --violet-soft: rgba(208, 188, 255, 0.14);
    --teal: #80d5d0;
    --teal-soft: rgba(128, 213, 208, 0.14);
    --glow-1: rgba(79, 142, 247, 0.14);
    --glow-2: rgba(154, 111, 240, 0.10);
    --focus: 0 0 0 3px rgba(168, 199, 250, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
    --backdrop: rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131314;
  --surface: #1e1f20;
  --surface-2: #282a2c;
  --surface-3: #333537;
  --border: #2f3133;
  --border-strong: #444746;
  --text: #e3e3e3;
  --text-2: #c4c7c5;
  --text-3: #9aa0a6;
  --primary: #a8c7fa;
  --primary-hover: #c2d7fb;
  --primary-text: #a8c7fa;
  --primary-soft: rgba(168, 199, 250, 0.16);
  --on-primary: #062e6f;
  --success: #6dd58c;
  --success-soft: rgba(109, 213, 140, 0.14);
  --warning: #fdd663;
  --warning-soft: rgba(253, 214, 99, 0.14);
  --danger: #f2b8b5;
  --danger-soft: rgba(242, 184, 181, 0.14);
  --info: #a8c7fa;
  --info-soft: rgba(168, 199, 250, 0.12);
  --running: #a8c7fa;
  --running-soft: rgba(168, 199, 250, 0.16);
  --neutral-soft: #282a2c;
  --violet: #d0bcff;
  --violet-soft: rgba(208, 188, 255, 0.14);
  --teal: #80d5d0;
  --teal-soft: rgba(128, 213, 208, 0.14);
  --glow-1: rgba(79, 142, 247, 0.14);
  --glow-2: rgba(154, 111, 240, 0.10);
  --focus: 0 0 0 3px rgba(168, 199, 250, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --backdrop: rgba(0, 0, 0, 0.6);
}

/* ─── Base ─────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background-color: var(--bg);
  letter-spacing: 0.005em;
}
h1, h2, h3, h4 { letter-spacing: -0.01em; }
::selection { background: var(--primary-soft); }

/* Brand mark (inline SVG sparkle) */
.brand-mark { display: inline-block; flex-shrink: 0; width: 28px; height: 28px; }
.brand-mark--lg { width: 48px; height: 48px; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ─── Primitives ───────────────────────────────────────── */
.btn {
  border-radius: 999px;
  font-weight: 600;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 1px 3px rgba(11, 87, 208, 0.3); }
.btn--secondary { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; }

.icon-btn { border-radius: 999px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.input, .select, .textarea {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.input:hover:not(:focus):not(:disabled), .select:hover:not(:focus), .textarea:hover:not(:focus) { background: var(--surface-3); }
.input:focus, .select:focus, .textarea:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: var(--focus);
}
.input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }

.badge { border-radius: 999px; font-weight: 600; }
.pill { border-color: transparent; background: var(--surface-2); }

.progress, .meter { background: var(--surface-3); }
.progress__bar, .meter__bar { background: var(--grad); }

.card {
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  box-shadow: none;
}
:root[data-theme="dark"] .card { border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card { border-color: var(--border); } }

/* ═══════ Storefront ═══════ */
body.ui-front {
  background:
    radial-gradient(900px 480px at 12% -8%, var(--glow-1), transparent 70%),
    radial-gradient(800px 420px at 92% -4%, var(--glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.ui-front .topbar {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom-color: transparent;
}
.ui-front .topbar__inner { max-width: 1200px; min-height: 64px; padding: 10px 24px; }
.ui-front .brand { gap: 10px; }
.ui-front .brand__name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.ui-front .seg { border-color: transparent; border-radius: 999px; padding: 3px; }
.ui-front .seg__btn { border-radius: 999px; height: 30px; padding: 0 14px; }

/* Key + submit merged card: two parts separated by a hairline */
.card__part--divided { border-top: 1px solid var(--border); }
.ui-front .card__part--divided .card__head { padding-top: 20px; }

/* Hero greeting */
.hero { max-width: 1200px; margin: 0 auto; padding: 40px 24px 8px; }
.hero__title {
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 600; line-height: 1.15; letter-spacing: -0.025em;
}
.hero__sub { margin-top: 10px; font-size: clamp(15px, 1.8vw, 18px); color: var(--text-3); max-width: 640px; }

.ui-front .banners { max-width: 1200px; }
.ui-front .banner { border-radius: var(--radius-lg); border-color: transparent; }
.ui-front .layout { max-width: 1200px; padding: 24px; gap: 24px; }
.ui-front .col { gap: 24px; }

.ui-front .card__head { border-bottom: 0; padding: 22px 24px 4px; }
.ui-front .card__body { padding: 16px 24px 24px; }
.ui-front .card__foot { border-top-color: transparent; padding: 0 24px 20px; }
.ui-front .card__title { font-size: 18px; font-weight: 600; }
.ui-front .card__sub { color: var(--text-3); }
.ui-front .step-num {
  width: 32px; height: 32px; font-size: 14px;
  background: var(--grad-soft); color: var(--text);
}

.ui-front .btn { --h: 44px; padding: 0 22px; }
.ui-front .btn--lg { --h: 52px; font-size: 16px; }
.ui-front .btn--sm { --h: 36px; padding: 0 14px; }
.ui-front .btn--xs { border-radius: 999px; }
.ui-front .input { height: 52px; padding: 0 18px; font-size: 15px; }
.ui-front .input-wrap .input { padding-right: 52px; }
.ui-front .input-wrap__btn { right: 8px; }
.ui-front .textarea { height: auto; padding: 14px 18px; border-radius: var(--radius-lg); }
.ui-front .label { font-size: 13px; font-weight: 600; color: var(--text-2); }

.ui-front .tabs.seg, .ui-front .seg--block { border-radius: 999px; }
.ui-front .seg--block .seg__btn { height: 38px; }
.ui-front .seg__btn[aria-pressed="true"], .ui-front .seg__btn[aria-selected="true"], .ui-front .seg__btn.is-active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}

.ui-front .key-info {
  border: 0; border-radius: var(--radius-lg);
  background: var(--grad-soft);
  padding: 18px 20px;
}
.ui-front .quota__big { font-size: 34px; font-weight: 600; }
.ui-front .notice { border-radius: var(--radius); border-color: transparent; }
.ui-front .twofa-box { border-radius: var(--radius-lg); border-color: transparent; background: var(--surface-2); }

.ui-front .task, .ui-front .batch-row { border-color: transparent; }
.ui-front .list > * + * { border-top-color: var(--border); }
.ui-front .result { border-radius: var(--radius); border-color: transparent; }
.ui-front .progress { height: 6px; }
.ui-front .progress--queued .progress__bar { background: var(--surface-3); }

.ui-front .drawer__panel, .ui-front .modal__panel { border-radius: var(--radius-xl); border-color: transparent; }
.ui-front .menu__list { border-radius: var(--radius); border-color: transparent; box-shadow: var(--shadow-lg); }
.ui-front .toast { border-radius: var(--radius); }
.ui-front .footer { max-width: 1200px; }

@media (max-width: 720px) {
  .hero { padding: 24px 16px 0; }
  .ui-front .topbar__inner { padding: 8px 16px; }
  .ui-front .layout { padding: 16px; gap: 16px; }
  .ui-front .col { gap: 16px; }
  .ui-front .card { border-radius: var(--radius-lg); }
  .ui-front .card__head { padding: 18px 18px 2px; }
  .ui-front .card__body { padding: 14px 18px 18px; }
  .ui-front .card__foot { padding: 0 18px 16px; }
}

/* ═══════ Admin console ═══════ */
body.ui-admin { background: var(--bg); }
.ui-admin .sidebar { background: var(--bg); border-right-color: transparent; }
.ui-admin .nav-item { border-radius: 999px; }
.ui-admin .nav-item--active { background: var(--primary-soft); color: var(--text); }
.ui-admin .topbar { background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom-color: transparent; }
.ui-admin .card { border-radius: var(--radius-lg); }
.ui-admin .card__head { border-bottom-color: var(--border); }
.ui-admin .stat { border-radius: var(--radius-lg); border-color: transparent; }
.ui-admin .btn { --h: 38px; padding: 0 18px; }
.ui-admin .btn--sm { --h: 32px; padding: 0 12px; }
.ui-admin .input, .ui-admin .select { min-height: 40px; }
.ui-admin .table th { background: transparent; }
.ui-admin .mode-opt, .ui-admin .balance__item, .ui-admin .node, .ui-admin .alert { border-radius: var(--radius); }
.ui-admin .px-modal { border-radius: var(--radius-xl); }
.ui-admin .login { background:
    radial-gradient(800px 420px at 20% 0%, var(--glow-1), transparent 70%),
    radial-gradient(700px 380px at 85% 10%, var(--glow-2), transparent 70%),
    var(--bg); }
.ui-admin .login__card { border-radius: var(--radius-xl); border-color: transparent; box-shadow: var(--shadow-lg); }
.ui-admin .page-head__title { font-weight: 600; letter-spacing: -0.02em; }

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
}

/* ═══════ Storefront · desktop "one screen" layout ═══════
   ≥1100px wide and ≥640px tall: the page is exactly one viewport.
   Three columns — [key + submit] [live queue] [history] — and each
   card scrolls inside itself instead of the page scrolling. */
@media (min-width: 1100px) and (min-height: 640px) {
  body.ui-front {
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .ui-front .topbar { flex: none; }
  .ui-front .topbar__inner { max-width: 1440px; padding: 10px 28px; }
  .ui-front .banners { flex: none; width: 100%; }
  .ui-front .footer { display: none; }

  .hero {
    flex: none; width: 100%; max-width: 1440px;
    padding: 14px 28px 0;
    display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  }
  .hero__title { font-size: clamp(24px, 2.2vw, 32px); }
  .hero__sub { margin-top: 0; font-size: 15px; }

  .ui-front .layout {
    flex: 1; min-height: 0; width: 100%; max-width: 1440px;
    padding: 16px 28px 24px; gap: 20px;
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }
  /* right-hand .col dissolves so queue + history become grid columns */
  .ui-front .layout > .col:last-child { display: contents; }
  .ui-front .layout > .col:first-child { min-height: 0; display: flex; flex-direction: column; gap: 20px; }

  .ui-front .card { display: flex; flex-direction: column; min-height: 0; }
  .ui-front .card__head { flex: none; }
  .ui-front #workCard { flex: 1; }
  .ui-front #workCard > .card__scroll,
  .ui-front #queueCard > .list,
  .ui-front #historyCard > .list {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
  }
  .ui-front #queueCard > .list, .ui-front #historyCard > .list { padding-bottom: 8px; }
  .ui-front .card__foot { flex: none; padding-top: 12px; }

  /* tighter key section so the submit form gets the room */
  .ui-front #keyCard .card__body { padding-top: 12px; padding-bottom: 18px; }
  .ui-front #submitCard .card__head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-bottom: 12px; }
  .ui-front .key-info { margin-top: 12px; padding: 14px 18px; }
  .ui-front .quota__big { font-size: 28px; }
}

/* Short desktop screens (e.g. 1366×768): drop the greeting, keep everything else on screen */
@media (min-width: 1100px) and (min-height: 640px) and (max-height: 820px) {
  .hero { display: none; }
  .ui-front .layout { padding-top: 8px; }
  .ui-front .card__head { padding-top: 16px; }
}

/* Phones: brand mark + actions on one row, status pills on the next */
@media (max-width: 480px) {
  .ui-front .brand__name { display: none; }
  .ui-front .topbar__actions { margin-left: auto; gap: 2px; }
  .ui-front .seg--lang .seg__btn { padding: 0 10px; }
}

/* ─── Compact access-key strip (key + verify in one row, one-line quota) ─── */
.ui-front .step-num { display: none; }
.ui-front #keyCard .card__body { padding: 20px 24px 16px; }
.ui-front #keyCard .label { margin-bottom: 6px !important; }
.ui-front .key-row { flex-direction: row; gap: 8px; }
.ui-front .key-row .btn { width: auto; --h: 44px; padding: 0 20px; }
.ui-front #keyInput { height: 44px; font-size: 14px; padding: 0 16px; }
.ui-front .key-opts { margin-top: 8px; font-size: 13px; }
.ui-front .key-info {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
}
.ui-front .key-info__top { flex: 1; min-width: 0; margin: 0; gap: 6px; }
.ui-front .key-info__label { font-size: 13px; }
.ui-front .quota { display: contents; }
.ui-front .quota__nums { flex-wrap: nowrap; gap: 4px; }
.ui-front .quota__big { font-size: 18px !important; font-weight: 600; }
.ui-front .quota__of { font-size: 12.5px; }
.ui-front .quota__used { display: none; }
.ui-front .key-info .meter { flex-basis: 100%; height: 4px; margin-top: 2px; }
.ui-front #keyCardNotices { margin-top: 10px; }
.ui-front #keyCardNotices .notice { padding: 8px 12px; font-size: 12.5px; }
.ui-front .card__part--divided .card__head { padding-top: 18px; }
@media (min-width: 1100px) and (min-height: 640px) {
  .ui-front #keyCard .card__body { padding: 18px 24px 14px; }
  .ui-front .key-info { padding: 10px 14px; margin-top: 10px; }
}

/* ═══════ Top notice bar ═══════
   All notices (announcement, paused/offline, quota/capacity, submit hints) stack
   here as slim full-width lines. A line that overflows scrolls back and forth. */
.ui-front .noticebar {
  max-width: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  position: relative; z-index: 31;
}
.ui-front .noticebar:empty, .ui-front #keyCardNotices:empty { display: none; }
.ui-front #keyCardNotices { display: contents; }
.ui-front .noticebar .banner {
  margin: 0; border: 0; border-radius: 0;
  min-height: 36px; padding: 6px max(16px, calc((100vw - 1440px) / 2 + 28px));
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; line-height: 1.4;
}
.ui-front .noticebar .banner + .banner,
.ui-front .noticebar #keyCardNotices > .banner { border-top: 1px solid color-mix(in srgb, var(--text) 6%, transparent); }
.ui-front .noticebar .banner > .icon { width: 16px; height: 16px; }
.ui-front .noticebar .icon-btn { width: 28px; height: 28px; margin: -4px -6px -4px 0; }
.banner--muted { background: var(--surface-2); color: var(--text-2); }
.banner--muted > .icon { color: var(--text-3); }

.nb-clip {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
}
.nb-clip > .banner__text { display: inline-block; white-space: nowrap; flex: none; }
.nb-clip .banner__title { display: inline; margin-right: 8px; }
.nb-clip.is-scrolling {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 24px), transparent);
}
.nb-clip.is-scrolling > .banner__text {
  padding-left: 12px;
  animation: nb-scroll var(--nb-dur, 10s) ease-in-out infinite alternate;
}
.nb-clip.is-scrolling:hover > .banner__text { animation-play-state: paused; }
@keyframes nb-scroll {
  0%, 12% { transform: translateX(0); }
  88%, 100% { transform: translateX(var(--nb-shift, 0)); }
}
@media (prefers-reduced-motion: reduce) {
  .nb-clip, .nb-clip > .banner__text { white-space: normal; }
  .nb-clip.is-scrolling > .banner__text { animation: none; }
  .nb-clip.is-scrolling { -webkit-mask-image: none; mask-image: none; }
}

/* ═══════ Compact submit form + pinned submit button ═══════ */
.ui-front #submitCard .card__head { padding-bottom: 6px; }
.ui-front #submitCard .card__sub { font-size: 12.5px; }
.ui-front #submitCard .card__body { padding-top: 10px; }
.ui-front #submitCard .field { margin-bottom: 12px; }
.ui-front #submitCard .label { margin-bottom: 5px; font-size: 12.5px; }
.ui-front #submitCard .input:not(.textarea) { height: 44px; font-size: 14px; padding: 0 16px; }
.ui-front #submitCard .input-wrap .input { padding-right: 48px; }
/* "必填" pill → a quiet asterisk */
.ui-front #submitCard .label__tag--req { font-size: 0; padding: 0; background: none; border: 0; margin-left: 2px; }
.ui-front #submitCard .label__tag--req::after { content: '*'; font-size: 13px; font-weight: 700; color: var(--danger); }
.ui-front #submitCard .twofa-box { padding: 12px 14px; margin-bottom: 10px; }
.ui-front #submitCard .twofa-box__head { margin-bottom: 8px; }
.ui-front #submitCard .twofa-box .field { margin-bottom: 0; }
.ui-front #submitCard .twofa-box .input { background: var(--surface); }
.ui-front #submitCard .twofa-box .seg__btn { height: 28px; padding: 0 12px; font-size: 12.5px; }
.ui-front #submitCard .help { font-size: 12px; margin-top: 4px; }
.ui-front #submitCard .details { border: 0; padding: 0; margin-bottom: 4px; }
.ui-front #submitCard .details > summary { padding: 4px 0; font-size: 12.5px; color: var(--text-3); }
.ui-front #submitCard .textarea { min-height: 120px; }

.ui-front #submitCard .form-actions,
.ui-front #submitCard .batch-toolbar {
  position: sticky; bottom: 0; z-index: 3;
  margin: 8px -24px -24px; padding: 12px 24px 20px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 0%, transparent), var(--surface) 14px);
}
.ui-front #submitCard .form-actions .btn { --h: 48px; }

@media (min-width: 1100px) and (min-height: 640px) {
  /* stretch the submit part so its button sits on the card's bottom edge */
  .ui-front #workCard > .card__scroll { display: flex; flex-direction: column; }
  .ui-front #submitCard { flex: 1; display: flex; flex-direction: column; }
  .ui-front #submitCard > .card__body,
  .ui-front #submitCard .tab-panel:not([hidden]),
  .ui-front #singleForm { flex: 1; display: flex; flex-direction: column; }
  .ui-front #submitCard .form-actions,
  .ui-front #submitCard .batch-toolbar { margin-top: auto; }
  .ui-front #submitCard .card__head { position: static; }
}
@media (max-width: 720px) {
  .ui-front #submitCard .form-actions,
  .ui-front #submitCard .batch-toolbar { margin: 8px -18px -18px; padding: 12px 18px 16px; }
}

/* Desktop: email + password side by side so the whole form fits without scrolling */
@media (min-width: 1100px) and (min-height: 640px) {
  .ui-front .layout { grid-template-columns: minmax(400px, 460px) minmax(0, 1fr) minmax(0, 1.15fr); }
  .ui-front #submitCard .card__sub { display: none; }
  .ui-front #submitCard .card__head { padding-top: 14px; padding-bottom: 2px; }
  .ui-front #singleForm {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr; column-gap: 10px; align-content: stretch;
  }
  .ui-front #singleForm > * { grid-column: 1 / -1; }
  .ui-front #singleForm > .field:nth-child(1) { grid-column: 1; }
  .ui-front #singleForm > .field:nth-child(2) { grid-column: 2; }
  .ui-front #singleForm > .form-actions { align-self: end; }
  .ui-front #keyCard .card__body { padding-top: 14px; padding-bottom: 12px; }
  .ui-front .key-opts { margin-top: 6px; }
}

/* Short desktop screens (≈768px tall): slightly smaller controls so the form still fits */
@media (min-width: 1100px) and (min-height: 640px) and (max-height: 820px) {
  .ui-front .layout { padding-bottom: 16px; gap: 16px; }
  .ui-front #keyInput, .ui-front #submitCard .input:not(.textarea) { height: 40px; }
  .ui-front .key-row .btn { --h: 40px; }
  .ui-front #keyCard .card__body { padding-top: 12px; padding-bottom: 10px; }
  .ui-front .key-info { margin-top: 8px; padding: 8px 12px; }
  .ui-front #submitCard .card__head { padding-top: 10px; }
  .ui-front #submitCard .field { margin-bottom: 10px; }
  .ui-front #submitCard .twofa-box { padding: 10px 12px; margin-bottom: 6px; }
  .ui-front #submitCard .twofa-box__head { margin-bottom: 6px; }
  .ui-front #submitCard .form-actions { padding: 8px 24px 16px; margin-top: 4px; }
  .ui-front #submitCard .form-actions .btn { --h: 44px; }
}

/* Notice bar: text only — no leading icons */
.ui-front .noticebar .banner > svg.icon { display: none; }

/* ─── Replace keys modal ───────────────────────────────── */
.ui-front .modal__panel--wide { width: min(560px, calc(100% - 32px)); text-align: left; padding: 24px 24px 20px; }
.ui-front .modal__panel--wide .modal__title { padding-right: 32px; }
.ui-front .modal__panel--wide .modal__desc { font-size: 13px; line-height: 1.6; }
.replace__form { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.replace__form .label { display: flex; align-items: baseline; font-size: 13px; font-weight: 600; }
.replace__form .label__aside { color: var(--text-3); font-size: 12px; }
.ui-front .replace__form .textarea { min-height: 120px; max-height: 240px; font-size: 13px; line-height: 1.7; resize: vertical; }
.replace__form .modal__actions, .replace__result .modal__actions { margin-top: 12px; }
.replace__result { margin-top: 16px; }
.replace__summary { font-size: 14px; font-weight: 600; padding: 10px 14px; border-radius: var(--radius-sm, 10px); }
.replace__summary--ok { background: var(--success-soft); color: var(--success); }
.replace__summary--warn { background: var(--warning-soft); color: var(--text); }
.replace__summary--danger { background: var(--danger-soft); color: var(--danger); }
.replace__warn { margin-top: 8px; font-size: 12.5px; color: var(--warning); }
.replace__list {
  list-style: none; margin: 10px 0 0; padding: 0; max-height: min(300px, 40vh); overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 10px);
}
.replace__row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.replace__row:last-child { border-bottom: 0; }
.replace__keys { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.replace__old, .replace__new { display: flex; align-items: center; gap: 6px; min-width: 0; }
.replace__old .mono { color: var(--text-3); text-decoration: line-through; font-size: 12px; overflow-wrap: anywhere; }
.replace__new .mono { color: var(--text); font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.replace__row--fail .replace__old .mono { text-decoration: none; }
.replace__tag { flex-shrink: 0; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); }
.replace__tag--new { background: var(--success-soft); color: var(--success); }
.replace__meta { flex-shrink: 0; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.replace__fail { font-size: 12.5px; color: var(--danger); }
.replace__more { margin-top: 10px; text-align: center; font-size: 13px; }
@media (max-width: 480px) {
  .replace__row { flex-wrap: wrap; }
  .replace__meta { order: 3; width: 100%; padding-left: 0; }
}
