:root {
  color-scheme: light;
  --bg: #f8fbff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e4e9f2;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --side: rgba(255, 255, 255, 0.86);
  --side-soft: #f3f6ff;
  --accent: #5b5cf6;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --brand-warm: #f97316;
  --brand-warm-dark: #c2410c;
  --green: #059669;
  --orange: #f97316;
  --danger: #dc2626;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
  --soft-shadow: 0 16px 48px rgba(67, 56, 202, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 12%, rgba(91, 92, 246, 0.14), transparent 32%),
    radial-gradient(circle at 90% 8%, rgba(249, 115, 22, 0.12), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 42%, #f7f4ff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  align-content: center;
  gap: 22px;
  width: min(520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}

.auth-brand .brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid #eadfd6;
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
}

.auth-brand h1 {
  font-size: 28px;
  line-height: 1.1;
}

.auth-brand .eyebrow {
  color: var(--accent);
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.auth-grid.single-auth {
  grid-template-columns: minmax(0, 500px);
  justify-content: center;
}

.auth-panel {
  gap: 16px;
  padding: 26px;
  border-color: #eadfd6;
  background: linear-gradient(180deg, #fff 0%, #fffaf5 100%);
}

.auth-card-head {
  display: grid;
  gap: 6px;
  padding-bottom: 4px;
}

.auth-card-head h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.auth-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 64px;
  gap: 8px;
  align-items: center;
}

.captcha-row strong {
  padding: 0 10px;
  border: 1px solid #e7d8cd;
  border-radius: 8px;
  background: #fffaf5;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 41px;
  text-align: center;
  white-space: nowrap;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: center;
}

.aliyun-captcha-panel {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
}

.aliyun-captcha-panel strong {
  font-size: 13px;
}

.aliyun-captcha-panel span {
  color: #7c6f68;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.aliyun-captcha-element {
  position: fixed;
  z-index: 1000000;
}

.auth-switch {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 900;
}

.auth-foot {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.task-center {
  position: relative;
  z-index: 92;
  display: grid;
  justify-items: end;
  flex: 0 0 auto;
  width: auto;
  pointer-events: none;
}

.task-center-toggle,
.task-center-panel {
  pointer-events: auto;
}

.task-center-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.14);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  backdrop-filter: blur(14px);
}

.task-center-toggle strong {
  min-width: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 24px;
  text-align: center;
}

.task-center-toggle strong.idle {
  background: #94a3b8;
}

.task-center-panel {
  position: absolute;
  z-index: 94;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  max-height: 430px;
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(16px);
}

.task-center.collapsed .task-center-panel {
  display: none;
}

.task-center-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--ink);
}

.task-center-head strong {
  font-size: 14px;
}

.task-center-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.task-empty {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.task-filter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.task-filter button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.task-filter button.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.task-item {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.task-item:hover {
  border-color: #fed7aa;
  background: #fff7ed;
}

.task-item > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.task-item strong,
.task-item span,
.task-item em,
.task-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item strong {
  font-size: 13px;
}

.task-item span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.task-model-meta,
.thumb-model-meta {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  max-width: 100%;
  min-width: 0;
  width: max-content;
  padding: 3px 7px;
  border: 1px solid rgba(91, 92, 246, 0.18);
  border-radius: 999px;
  background: rgba(238, 242, 255, 0.78);
  color: #4f46e5;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-model-meta {
  align-self: flex-start;
}

.task-item.done span {
  color: var(--green);
}

.task-item.failed span {
  color: var(--danger);
}

.task-item small {
  color: var(--muted);
  font-size: 11px;
}

.task-progress {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.task-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ea580c, #f59e0b);
  transition: width 180ms ease;
}

.task-item.running .task-progress i {
  position: relative;
  min-width: 22px;
  overflow: hidden;
}

.task-item.running .task-progress i::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 32%,
    rgba(255, 255, 255, 0.62) 50%,
    rgba(255, 255, 255, 0.18) 68%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: task-progress-shine 1.15s linear infinite;
}

.task-item.running .task-progress::after {
  position: absolute;
  inset: 0;
  content: "";
  background-image: linear-gradient(
    45deg,
    rgba(234, 88, 12, 0.12) 25%,
    transparent 25%,
    transparent 50%,
    rgba(234, 88, 12, 0.12) 50%,
    rgba(234, 88, 12, 0.12) 75%,
    transparent 75%,
    transparent
  );
  background-size: 18px 18px;
  animation: task-progress-stripes 0.85s linear infinite;
  pointer-events: none;
}

.task-item.failed .task-progress i {
  background: var(--danger);
}

@keyframes task-progress-shine {
  to {
    transform: translateX(100%);
  }
}

@keyframes task-progress-stripes {
  to {
    background-position: 18px 0;
  }
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  width: 100%;
  min-height: 72px;
  padding: 14px clamp(22px, 4vw, 52px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.78);
  background: var(--side);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, #5b5cf6 0%, #7c3aed 58%, #f97316 100%);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(91, 92, 246, 0.22);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  color: var(--ink);
  font-size: 26px;
  line-height: 1.15;
}

h3 {
  font-size: 17px;
}

.side-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.side-nav a,
.side-nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  text-align: center;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.side-nav a:hover,
.side-nav a.active,
.side-nav button:hover,
.side-nav button.active {
  border-color: rgba(91, 92, 246, 0.14);
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 10px 28px rgba(91, 92, 246, 0.1);
}

.side-nav span {
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.side-nav small {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}

.side-status {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.side-status span {
  color: #9ca3af;
  font-size: 11px;
  font-weight: 800;
}

.side-status strong {
  color: #f9fafb;
  font-size: 12px;
}

.side-logout {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.side-logout:hover {
  background: rgba(255, 255, 255, 0.14);
}

.credit-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.credit-summary button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.credit-summary button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.credit-warning {
  color: #fecaca;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.credit-banner {
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.45;
}

.path-status {
  padding: 10px 11px;
  border: 1px solid #e4e9f2;
  border-radius: 14px;
  background: #f8fbff;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.path-status.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.path-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.submit-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 251, 247, 0.92);
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.submit-feedback.ok {
  border-color: rgba(5, 150, 105, 0.24);
  background: rgba(236, 253, 245, 0.88);
  color: #047857;
}

.submit-feedback.error {
  border-color: rgba(185, 28, 28, 0.24);
  background: rgba(254, 242, 242, 0.9);
  color: #991b1b;
}

.save-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e4e9f2;
  border-radius: 16px;
  background: #f8fbff;
}

.save-picker div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.save-picker strong {
  font-size: 13px;
}

.save-picker span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-button {
  min-height: 31px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.side-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.content {
  display: grid;
  gap: 22px;
  align-content: start;
  width: min(1360px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 34px 0 46px;
}

.admin-login-page {
  background:
    radial-gradient(circle at 50% 0%, rgba(234, 88, 12, 0.12), transparent 34%),
    linear-gradient(180deg, #fffaf5 0%, #f6f3ef 48%, #efe9e2 100%);
}

.admin-login-page .app-shell {
  grid-template-columns: 1fr;
}

.admin-login-page .content {
  min-height: 100vh;
  align-content: center;
  justify-items: center;
  padding: 28px 18px;
}

.admin-login-page .page-head {
  justify-content: center;
  min-height: auto;
  padding: 0;
  text-align: center;
}

.admin-login-page .page-head > div:first-child {
  margin-right: 0;
}

.admin-login-page .page-head h2 {
  font-size: 26px;
}

.page-head {
  position: relative;
  z-index: 86;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-height: 78px;
  padding: 4px 0 10px;
  background: transparent;
}

.page-head > div:first-child {
  margin-right: auto;
}

.top-account {
  position: relative;
  z-index: 91;
  display: flex;
  justify-content: flex-end;
  flex: 0 1 auto;
  min-width: 0;
}

.account-guest,
.account-user,
.account-loading {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.account-user,
.account-loading {
  padding: 8px 10px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(14px);
}

.account-loading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.account-loading span::after {
  content: '';
  display: inline-block;
  width: 1.5em;
  animation: loading-dots 1.2s steps(4, end) infinite;
}

@keyframes loading-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75%,
  100% { content: '...'; }
}

.account-user span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.account-user strong {
  color: var(--accent-dark);
  font-size: 13px;
}

.account-guest.hidden,
.account-user.hidden {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-tab-panel {
  display: grid;
  gap: 15px;
}

.admin-tab-panel.hidden {
  display: none;
}

.login-panel {
  width: min(460px, 100%);
}

.contact-change-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.contact-change-note strong {
  color: var(--ink);
}

[data-login-captcha-field] {
  display: none !important;
}

.admin-login-page .login-panel {
  position: relative;
  width: min(380px, 100%);
  padding: 22px;
  border-color: rgba(154, 52, 18, 0.16);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 54px rgba(17, 24, 39, 0.12);
  backdrop-filter: blur(12px);
}

.admin-security-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(234, 88, 12, 0.18);
  border-radius: 8px;
  background: var(--accent-soft);
}

.panel,
.results {
  border: 1px solid rgba(226, 232, 240, 0.86);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.panel-title,
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input,
select {
  height: 43px;
  padding: 0 12px;
}

textarea {
  min-height: 118px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.14);
}

.grid {
  display: grid;
  gap: 12px;
}

.two {
  grid-template-columns: 1fr 1fr;
}

.three {
  grid-template-columns: repeat(3, 1fr);
}

.hidden {
  display: none !important;
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  border-radius: 999px;
  cursor: pointer;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  color: white;
  font-weight: 900;
}

.primary {
  background: linear-gradient(135deg, #5b5cf6, #7c3aed 62%, #f97316);
  box-shadow: 0 16px 36px rgba(91, 92, 246, 0.22);
}

.primary:hover {
  background: linear-gradient(135deg, #4f46e5, #6d28d9 62%, #ea580c);
  transform: translateY(-1px);
}

.secondary {
  background: linear-gradient(135deg, #5b5cf6, #7c3aed);
  box-shadow: 0 14px 32px rgba(91, 92, 246, 0.2);
}

.secondary:hover {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  transform: translateY(-1px);
}

.primary:disabled,
.secondary:disabled {
  cursor: wait;
  opacity: 0.68;
}

.ghost {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-weight: 800;
}

.ghost:hover {
  border-color: #fed7aa;
  color: var(--accent-dark);
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.upload-box,
.batch-box,
.batch-note,
.save-folder {
  display: grid;
  gap: 10px;
  border-radius: 8px;
}

.upload-box {
  padding: 12px;
  border: 1px dashed #fed7aa;
  background: var(--accent-soft);
}

.prompt-composer {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid #e4e9f2;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(248, 251, 255, 0.94)),
    #f8fbff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.prompt-composer.drag-over {
  border-color: var(--accent);
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.composer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.composer-head strong {
  color: #1f2937;
  font-size: 15px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer-actions span {
  min-width: 44px;
  color: #64748b;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.reference-strip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.prompt-composer .reference-grid {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.prompt-composer .reference-grid:empty {
  display: none;
}

.prompt-composer .reference-grid figure {
  position: relative;
  overflow: hidden;
  flex: 0 0 88px;
  width: 88px;
  margin: 0;
  border-radius: 8px;
}

.prompt-composer .reference-grid img {
  width: 88px;
  height: 88px;
  border: 1px solid #e4e9f2;
  border-radius: 14px;
  background: #ffffff;
  object-fit: cover;
}

.prompt-composer .reference-grid figcaption {
  display: none;
}

.reference-index {
  position: absolute;
  top: 5px;
  left: 5px;
  min-width: 22px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
}

.reference-controls {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.reference-controls button {
  min-width: 0;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.74);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.reference-controls button:hover {
  background: rgba(234, 88, 12, 0.9);
}

.reference-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.upload-tile {
  display: grid;
  flex: 0 0 88px;
  order: -1;
  width: 88px;
  height: 88px;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px dashed #c7d2fe;
  border-radius: 14px;
  color: #4f46e5;
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
}

.upload-tile:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #eef2ff;
}

.upload-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-tile span {
  font-size: 32px;
  font-weight: 400;
  line-height: 24px;
}

.upload-tile small {
  font-size: 13px;
  font-weight: 800;
}

.prompt-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.prompt-presets button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: #4f46e5;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.prompt-presets button:hover {
  border-color: var(--accent);
  background: #eef2ff;
  color: var(--accent-dark);
}

.option-panel {
  display: grid;
  gap: 20px;
  padding: 18px;
  border: 1px solid #e4e9f2;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.88)),
    #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.option-section {
  display: grid;
  gap: 12px;
}

.option-section > span {
  color: #1f2937;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
}


.toggle-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e7d8cd;
  border-radius: 8px;
  background: #fffaf5;
  cursor: pointer;
}

.toggle-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #171717;
}

.toggle-option span {
  display: grid;
  gap: 4px;
}

.toggle-option strong {
  color: #171717;
  font-size: 15px;
}

.toggle-option small {
  color: #7c6f68;
  font-size: 12px;
  line-height: 1.5;
}

.option-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.option-buttons button {
  min-width: 0;
  min-height: 58px;
  padding: 0 14px;
  border: 1px solid #e4e9f2;
  border-radius: 14px;
  background: #f8faff;
  color: #1f2937;
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.option-buttons button:hover {
  color: var(--accent-dark);
  background: #ffffff;
  border-color: #c7d2fe;
}

.option-buttons button.active {
  background: #ffffff;
  color: var(--accent-dark);
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(91, 92, 246, 0.12), 0 0 0 1px rgba(91, 92, 246, 0.12);
  transform: translateY(-1px);
}

.option-buttons:not(.compact-options) button::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  vertical-align: -5px;
  border: 2px solid #b7bfd3;
  border-radius: 6px;
  background: rgba(255, 253, 251, 0.88);
}

.option-buttons:not(.compact-options) button.active::before {
  border-color: var(--accent);
  background: #eef2ff;
}

.option-buttons:not(.compact-options) button[data-option-value="smart"]::before {
  border-radius: 7px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.86);
}

.option-buttons:not(.compact-options) button[data-option-value="16:9"]::before,
.option-buttons:not(.compact-options) button[data-option-value="4:3"]::before,
.option-buttons:not(.compact-options) button[data-option-value="3:2"]::before,
.option-buttons:not(.compact-options) button[data-option-value="4:1"]::before,
.option-buttons:not(.compact-options) button[data-option-value="8:1"]::before {
  width: 34px;
  height: 20px;
}

.option-buttons:not(.compact-options) button[data-option-value="9:16"]::before,
.option-buttons:not(.compact-options) button[data-option-value="3:4"]::before,
.option-buttons:not(.compact-options) button[data-option-value="2:3"]::before,
.option-buttons:not(.compact-options) button[data-option-value="1:4"]::before,
.option-buttons:not(.compact-options) button[data-option-value="1:8"]::before {
  width: 20px;
  height: 34px;
  vertical-align: -11px;
}

.compact-options button {
  min-height: 54px;
}

.compact-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.format-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.format-choice-grid button {
  min-height: 58px;
  border: 1px solid #e4e9f2;
  border-radius: 14px;
  background: #f8faff;
  color: #1f2937;
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
}

.format-choice-grid button:hover,
.format-choice-grid button.active {
  border-color: var(--accent);
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 14px 30px rgba(91, 92, 246, 0.12), 0 0 0 1px rgba(91, 92, 246, 0.12);
}

.prompt-composer textarea {
  min-height: 190px;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid #e4e9f2;
  border-radius: 0;
  background: transparent;
  color: #111827;
  font-size: 15px;
}

.prompt-composer textarea:focus {
  box-shadow: none;
}

.batch-box {
  padding: 14px;
  border: 1px solid #e4e9f2;
  background: #f8fbff;
}

.folder-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  border: 1px dashed #c7d2fe;
  border-radius: 16px;
  background: #ffffff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.folder-picker:hover {
  border-color: var(--accent);
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.1);
}

.folder-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.folder-file-picker {
  position: relative;
}

.folder-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.folder-drop-zone {
  display: grid;
  gap: 5px;
  min-height: 86px;
  place-items: center;
  padding: 16px;
  border: 1px dashed #c7d2fe;
  border-radius: 16px;
  background: #eef2ff;
  color: var(--accent-dark);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.folder-drop-zone strong {
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 900;
}

.folder-drop-zone span {
  max-width: 420px;
  color: #7c6f68;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.folder-drop-zone.drag-over {
  border-color: var(--accent);
  background: #e0e7ff;
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.12);
}

.folder-preview {
  max-height: 250px;
  overflow-y: auto;
  padding-right: 3px;
}

.folder-preview:empty {
  display: none;
}

.folder-preview .folder-preview-item {
  position: relative;
}

.folder-preview-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
}

.folder-preview-actions button {
  display: grid;
  width: 26px;
  height: 26px;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.74);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.22);
}

.folder-preview-actions button:hover {
  background: rgba(234, 88, 12, 0.92);
}

.batch-note {
  padding: 11px 12px;
  border: 1px solid #e7d8cd;
  background: #fffaf5;
  color: #7c6f68;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.section-title {
  padding-top: 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.settings-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.settings-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.settings-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.settings-list strong {
  color: var(--ink);
  font-size: 13px;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.setting-toggle input {
  width: 18px;
  height: 18px;
}

.sidebar-nav-settings {
  display: grid;
  gap: 12px;
}

.sidebar-nav-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}

.disabled-page {
  display: grid;
  min-height: 52vh;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}

.disabled-page h2 {
  font-size: 32px;
}

.disabled-page p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.disabled-page-link {
  display: inline-flex;
  width: auto;
  min-height: 42px;
  align-items: center;
  margin-top: 8px;
  text-decoration: none;
}

.api-mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  width: min(360px, 100%);
  padding: 5px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf3;
}

.api-mode-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.api-mode-tabs button.active {
  color: var(--accent-deep);
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.api-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.api-toolbar strong,
.api-toolbar span {
  display: block;
}

.api-toolbar strong {
  color: var(--ink);
  font-size: 15px;
}

.api-toolbar span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-routes-toolbar {
  grid-template-columns: 1fr auto;
}

.provider-list {
  display: grid;
  gap: 12px;
}

.provider-route-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: #f8fafc;
}

.provider-route-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.provider-route-group-head div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.provider-route-group-head strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
}

.provider-route-group-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.provider-route-group-head em {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: #ffffff;
  color: #64748b;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.provider-route-group-list {
  display: grid;
  gap: 10px;
}

.provider-route-summary-list {
  display: grid;
  gap: 8px;
}

.provider-route-summary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: #ffffff;
}

.provider-route-summary-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.provider-route-summary-item strong,
.provider-route-summary-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-route-summary-item strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.provider-route-summary-item span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.provider-route-group-empty {
  display: none;
  margin: 0;
  padding: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.36);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.provider-route-group.is-empty .provider-route-group-empty {
  display: block;
}

.provider-card {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}

.provider-card-highlight {
  border-color: rgba(91, 92, 246, 0.72);
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.14);
}

.provider-card details {
  display: grid;
}

.provider-card summary {
  cursor: pointer;
  list-style: none;
}

.provider-card summary::-webkit-details-marker {
  display: none;
}

.provider-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
  border-bottom: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.96), rgba(255, 255, 255, 0.88));
}

.provider-card details[open] .provider-card-head {
  border-bottom-color: var(--line);
}

.provider-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.provider-card-head strong,
.provider-card-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-card-head strong {
  color: var(--ink);
  font-size: 15px;
}

.provider-card-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.provider-state {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid rgba(5, 150, 105, 0.18);
  border-radius: 999px;
  background: rgba(236, 253, 245, 0.9);
}

.provider-state.danger {
  color: var(--danger);
  border-color: rgba(190, 61, 32, 0.24);
  background: #fef2f2;
}

.provider-fields {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.provider-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(226, 214, 205, 0.82);
  border-radius: 8px;
  background: rgba(255, 250, 245, 0.72);
}

.provider-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.provider-section-head strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.provider-section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.provider-grid {
  display: grid;
  gap: 8px;
}

.provider-grid-main {
  grid-template-columns: minmax(140px, 0.8fr) minmax(220px, 1.25fr) minmax(180px, 0.9fr) minmax(90px, 0.42fr) minmax(120px, 0.54fr) minmax(140px, 0.62fr);
}

.provider-grid-models {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.provider-grid-endpoints {
  grid-template-columns:
    minmax(150px, 0.68fr)
    minmax(220px, 1.1fr)
    minmax(220px, 1.1fr)
    minmax(120px, 0.56fr)
    minmax(180px, 0.72fr)
    auto;
  align-items: end;
}

.provider-card label {
  gap: 5px;
  font-size: 12px;
  min-width: 0;
}

.provider-card input,
.provider-card select {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}

.provider-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.provider-checkbox input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  flex: 0 0 auto;
}

.provider-checkbox span {
  color: #374151;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.provider-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
  min-width: 112px;
}


.provider-engine-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.provider-test-actions {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.provider-test-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.provider-test-select select {
  min-width: 92px;
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 760px) {
  .provider-test-select {
    width: 100%;
    margin-right: 0;
  }
}
.provider-health-line {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.danger-soft {
  color: var(--danger);
  border-color: rgba(190, 61, 32, 0.24);
}

.danger-soft:disabled {
  color: var(--muted);
  opacity: 0.75;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.error-log-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.storage-health-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.storage-health-card,
.storage-health-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.storage-health-card strong,
.storage-health-card span {
  display: block;
}

.storage-health-card strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.storage-health-card span,
.storage-health-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.storage-health-note {
  grid-column: 1 / -1;
  margin-top: 0;
}

.health-banner {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  align-items: center;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.health-banner.ok {
  border-color: rgba(4, 120, 87, 0.22);
  background: #ecfdf5;
}

.health-banner.warning {
  border-color: rgba(234, 88, 12, 0.22);
  background: #fff7ed;
}

.health-banner.danger {
  border-color: rgba(190, 61, 32, 0.24);
  background: #fef2f2;
}

.health-main {
  display: flex;
  gap: 12px;
  align-items: center;
}

.health-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #f97316;
  box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.12);
}

.health-banner.ok .health-dot {
  background: #10b981;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.14);
}

.health-banner.danger .health-dot {
  background: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.13);
}

.health-main strong,
.health-main small {
  display: block;
}

.health-main strong {
  color: var(--ink);
  font-size: 17px;
}

.health-main small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.health-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.health-pill {
  max-width: 100%;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  color: #9a3412;
  font-size: 12px;
  font-weight: 900;
}

.health-pill.ok {
  background: rgba(16, 185, 129, 0.13);
  color: #047857;
}

.health-pill.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.overview-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.overview-card span,
.overview-card strong,
.overview-card small {
  display: block;
}

.overview-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.overview-card strong {
  margin-top: 7px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.overview-card small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.overview-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.overview-columns h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
}

.compact-table {
  display: grid;
  gap: 8px;
}

.compact-table-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) repeat(3, minmax(80px, 1fr));
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.compact-table-row strong,
.compact-table-row span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-table-row span {
  color: var(--muted);
  font-weight: 800;
}

.overview-alerts {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.overview-alert {
  padding: 10px 12px;
  border-radius: 9px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 900;
}

.overview-alert.ok {
  background: #ecfdf5;
  color: #047857;
}

.overview-alert.danger {
  background: #fef2f2;
  color: var(--danger);
}

.user-search {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.generation-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}


.generation-record-card {
  display: grid;
  grid-template-columns: auto 88px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  min-height: 116px;
}

.generation-record-thumb {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  flex: 0 0 auto;
}

.generation-record-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.generation-record-main {
  min-width: 0;
}

.generation-record-main strong,
.generation-record-main span,
.generation-record-main small {
  display: block;
  overflow-wrap: anywhere;
}

.generation-record-main span,
.generation-record-main small {
  color: var(--muted);
  margin-top: 4px;
}

.generation-record-card.is-failed {
  border-color: rgba(190, 61, 32, 0.22);
  background: rgba(255, 247, 242, 0.82);
}

.generation-record-card.is-failed .generation-record-main small {
  color: var(--danger);
  font-weight: 800;
}

.generation-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.generation-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.generation-record-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 860px) {
  .generation-record-card {
    grid-template-columns: auto 72px minmax(0, 1fr);
  }

  .generation-record-thumb {
    width: 72px;
    height: 72px;
  }

  .generation-record-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.generation-check {
  display: grid;
  place-items: center;
  align-self: stretch;
}

.generation-check input {
  width: 18px;
  height: 18px;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.credit-form {
  display: grid;
  grid-template-columns: 110px auto auto auto auto auto;
  gap: 8px;
  align-items: center;
}

.credit-form input {
  height: 34px;
}

.danger-button {
  color: var(--danger);
}

.generation-detail-dialog {
  width: min(920px, 96vw);
}

.generation-detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.generation-detail-summary.warning {
  border-color: #fed7aa;
  background: #fff7ed;
}

.generation-detail-summary strong,
.generation-detail-summary span {
  font-size: 13px;
}

.generation-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.generation-detail-row,
.generation-detail-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.generation-detail-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.generation-detail-row strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-size: 13px;
}

.generation-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.generation-detail-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.generation-detail-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.generation-detail-dialog h4 {
  margin: 4px 0 0;
}

.error-log-row {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.error-log-main {
  display: grid;
  gap: 7px;
}

.error-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.error-log-head strong {
  color: var(--danger);
  font-size: 15px;
}

.error-log-head span,
.error-log-main small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.error-log-main p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
  word-break: break-word;
}

.error-log-row details {
  border-top: 1px solid #fee2e2;
  padding-top: 8px;
}

.error-log-row summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.error-log-row pre {
  overflow: auto;
  max-height: 280px;
  margin: 9px 0 0;
  padding: 11px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
}

.compact-empty {
  min-height: 120px;
}

.batch-head h3 {
  font-size: 15px;
}

.batch-head p,
.result-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.upload-hint {
  margin: -2px 0 0;
  color: #7c6f68;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.upload-actions,
.batch-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 8px;
}

.reference-grid figure {
  min-width: 0;
  margin: 0;
}

.reference-grid img {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
  background: #e5e7eb;
}

.reference-grid figcaption {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results {
  min-height: 640px;
  padding: 22px;
}

.save-folder {
  margin: 14px 0;
  padding: 13px 14px;
  border: 1px solid #e4e9f2;
  background: #f8fbff;
}

.save-folder span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.save-folder strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  display: grid;
  min-height: 440px;
  place-items: center;
  border: 1px dashed #c7d2fe;
  border-radius: 18px;
  color: var(--muted);
  background:
    radial-gradient(circle at 50% 35%, rgba(91, 92, 246, 0.08), transparent 34%),
    var(--panel-soft);
  text-align: center;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  gap: 14px;
  align-items: start;
}

.main-preview {
  overflow: hidden;
  min-height: 520px;
  border: 1px solid #e4e9f2;
  border-radius: 20px;
  background: var(--panel-soft);
}

.main-preview .empty {
  min-height: 520px;
  border: 0;
  background: transparent;
}

.main-preview .preview {
  min-height: 520px;
  align-content: start;
}

.preview-loading {
  display: grid;
  min-height: 492px;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--ink);
  text-align: center;
}

.preview-loading i {
  display: block;
  width: 54px;
  height: 54px;
  border: 4px solid #e0e7ff;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

.preview-loading strong {
  font-size: 18px;
  font-weight: 900;
}

.preview-loading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.main-preview .preview img,
.main-preview .preview video {
  max-height: 620px;
}

.batch-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  padding: 12px;
}

.batch-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 0;
}

.batch-preview-toolbar strong {
  color: var(--ink);
  font-size: 14px;
}

.batch-preview-toolbar button,
.history-download {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.batch-preview-toolbar button:hover,
.history-download:hover {
  background: #e0e7ff;
}

.history-download.history-delete,
.batch-download.batch-delete,
.output-actions .danger-soft {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.history-download.history-delete:hover,
.batch-download.batch-delete:hover,
.output-actions .danger-soft:hover {
  background: #ffe4e6;
}

.history-download.history-delete:disabled,
.batch-download.batch-delete:disabled,
.output-actions .danger-soft:disabled {
  cursor: wait;
  opacity: 0.72;
}

.batch-preview-toolbar button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.batch-result-thumb {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.batch-result-thumb:hover,
.batch-result-thumb.active {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.12);
}

.batch-result-media {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #111827;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 900;
}

.batch-result-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-result-thumb span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-download {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  border: 0;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.batch-download:hover {
  background: #e0e7ff;
}

.history-panel {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: hidden;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 2px;
  color: var(--ink);
  font-size: 13px;
}

.history-head span {
  min-width: 28px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 24px;
  text-align: center;
}

.history {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-height: 570px;
  overflow-y: auto;
  padding-right: 6px;
}

.history-thumb {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 142px;
  padding: 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.history-thumb:hover,
.history-thumb.active {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.12);
}

.thumb-media {
  display: grid;
  width: 86px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: #eef2ff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.thumb-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-batch-thumb {
  border-color: rgba(91, 92, 246, 0.24);
  background: linear-gradient(135deg, rgba(238, 242, 255, 0.95), var(--panel));
}

.batch-thumb-media {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  background: #111827;
}

.batch-thumb-media img {
  border-radius: 3px;
}

.batch-thumb-media span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.86);
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
}

.thumb-meta {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 5px;
}

.thumb-meta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-meta .thumb-model-meta {
  max-width: 100%;
  margin: 1px 0 2px;
}

.thumb-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 6px;
}

.thumb-model-row .thumb-model-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.thumb-model-row .history-delete {
  flex: 0 0 auto;
  min-width: 42px;
  min-height: 24px;
  padding: 0 8px;
  font-size: 10px;
}

.thumb-meta span {
  overflow: visible;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.28;
  text-overflow: clip;
  white-space: pre-line;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.history-actions .history-download {
  flex: 0 0 auto;
  min-width: 56px;
  width: auto;
  min-height: 28px;
  padding: 0 10px;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.history-actions .history-download:nth-child(2) {
  grid-column: auto;
  order: 2;
}

.history-actions .history-download:nth-child(3) {
  order: 3;
}

.detail-login-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.detail-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "tools"
    "board"
    "results";
  gap: 18px;
  align-items: start;
}

.detail-tools {
  grid-area: tools;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(300px, 1fr) minmax(260px, 340px);
  gap: 14px;
  align-items: stretch;
}

.detail-tools .panel-title,
.detail-tools .credit-banner {
  grid-column: 1 / -1;
}

.detail-board {
  grid-area: board;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.detail-results {
  grid-area: results;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  gap: 10px;
  max-height: min(78vh, 980px);
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

.detail-upload {
  display: grid;
  place-items: center;
  min-height: 142px;
  border: 1px dashed #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
}

.detail-upload input {
  display: none;
}

.detail-prompt-field textarea {
  min-height: 142px;
}

.detail-control-stack {
  display: grid;
  gap: 10px;
  align-content: start;
}

.detail-upload:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.62;
}

.detail-status {
  margin: 0;
  padding: 10px 11px;
  border: 1px solid #e7d8cd;
  border-radius: 8px;
  background: #fffaf5;
  color: #7c6f68;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.detail-status.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.detail-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.detail-canvas-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.detail-canvas-head p,
.detail-results .result-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-stage {
  position: relative;
  display: grid;
  min-height: 560px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(234, 88, 12, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(234, 88, 12, 0.04) 25%, transparent 25%),
    #fffaf5;
  touch-action: none;
}

.detail-stage.empty-stage {
  min-height: 420px;
  border-style: dashed;
  background: #fff;
  touch-action: auto;
}

.detail-stage img {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 760px);
  object-fit: contain;
  user-select: none;
}

.detail-stage img.hidden {
  display: none;
}

.detail-empty {
  padding: 20px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.detail-stage.empty-stage .detail-empty {
  color: #8a817b;
}

.detail-stage.empty-stage .mark-layer {
  display: none;
}

.mark-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.mark-box {
  position: absolute;
  display: block;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(234, 88, 12, 0.12);
  cursor: pointer;
}

.mark-box span {
  position: absolute;
  top: -28px;
  left: -2px;
  max-width: 170px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.mark-box.draft {
  border-style: dashed;
  pointer-events: none;
}

.mark-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.mark-list article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mark-list strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mark-list button,
.detail-result-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #fed7aa;
  border-radius: 7px;
  background: #fff7ed;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.detail-result-grid {
  display: grid;
  align-items: start;
  align-self: start;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  padding-bottom: 72px;
  scrollbar-width: thin;
}

.detail-result-grid article {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-result-grid article > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.detail-result-grid strong {
  color: var(--ink);
  font-size: 12px;
}

.detail-result-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.detail-result-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  background: var(--panel-soft);
  cursor: zoom-in;
  object-fit: cover;
}

.detail-result-grid p {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.detail-result-actions {
  display: flex;
  justify-content: flex-end;
}

.gallery-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 18px;
}

.gallery-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e7d8cd;
  border-radius: 8px;
  background: #fffaf5;
}

.gallery-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.gallery-toolbar .gallery-delete-selected {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.gallery-toolbar .gallery-delete-selected:not(:disabled):hover {
  background: #ffe4e6;
}

.gallery-select-all,
.gallery-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #7c4a2f;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  user-select: none;
}

.gallery-select input,
.gallery-select-all input {
  width: 16px;
  height: 16px;
  accent-color: #ea580c;
}

.gallery-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}

.gallery-card.selected {
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

.gallery-card.highlight {
  border-color: #fb923c;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.2);
}

.gallery-card .gallery-select {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 245, 0.92);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  background: var(--panel-soft);
  object-fit: cover;
}

.gallery-card strong,
.gallery-card span {
  display: block;
}

.gallery-card strong {
  color: var(--ink);
  font-size: 13px;
}

.gallery-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.3;
  white-space: pre-line;
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: stretch;
}

.gallery-actions button {
  flex: 1 1 78px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid #fed7aa;
  border-radius: 7px;
  background: #fff7ed;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.gallery-actions .gallery-delete {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.gallery-actions .gallery-delete:hover {
  background: #ffe4e6;
}

.gallery-actions .gallery-delete:disabled {
  cursor: wait;
  opacity: 0.72;
}

.gallery-empty {
  padding: 28px;
  border: 1px dashed #fed7aa;
  border-radius: 8px;
  background: #fffaf5;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.gallery-load-sentinel {
  grid-column: 1 / -1;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 250, 245, 0.9);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.preview {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.preview img,
.preview video {
  width: 100%;
  max-height: 560px;
  border-radius: 7px;
  object-fit: contain;
  background: #111827;
}

.clickable-preview {
  cursor: zoom-in;
}

.preview a {
  color: var(--accent-dark);
  font-weight: 800;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.output-actions button,
.output-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.output-actions button:hover,
.output-actions a:hover {
  background: #ffedd5;
}

.saved-path {
  overflow-wrap: anywhere;
  padding: 9px 10px;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.error {
  color: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.confirm-overlay {
  background: rgba(17, 24, 39, 0.38);
  backdrop-filter: blur(3px);
}

.confirm-dialog {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  width: min(480px, 100%);
  padding: 20px;
  border: 1px solid #eadbd1;
  border-radius: 12px;
  background: #fffaf5;
  box-shadow: 0 24px 70px rgba(43, 29, 19, 0.22);
}

.confirm-dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #fff0dd;
  color: var(--accent-dark);
  font-size: 24px;
  font-weight: 950;
}

.confirm-dialog-danger .confirm-dialog-icon {
  background: #fee2e2;
  color: #b91c1c;
}

.confirm-dialog-content {
  min-width: 0;
}

.confirm-dialog h3 {
  margin: 1px 0 8px;
  color: var(--text);
  font-size: 20px;
  font-weight: 950;
  letter-spacing: 0;
}

.confirm-dialog-body {
  display: grid;
  gap: 4px;
}

.confirm-dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.65;
}

.confirm-dialog-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.confirm-dialog-actions button {
  min-width: 112px;
  min-height: 42px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 900;
}

.confirm-dialog-actions .danger-action {
  border: 1px solid #ef4444;
  background: #dc2626;
  color: #ffffff;
  cursor: pointer;
}

.confirm-dialog-actions .danger-action:hover {
  background: #b91c1c;
}

.reminder-dialog {
  display: grid;
  gap: 14px;
  width: min(460px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.reminder-dialog h3 {
  margin: 0;
  font-size: 18px;
}

.reminder-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.reminder-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reminder-actions .primary {
  grid-column: 1 / -1;
}

.credit-dialog {
  display: grid;
  gap: 13px;
  width: min(620px, 96vw);
  max-height: 82vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.credit-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.credit-dialog-head h3,
.credit-dialog p {
  margin: 0;
}

.credit-dialog-head button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.credit-dialog p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-modal.credit-dialog {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  gap: 18px;
  padding: 26px;
  border-color: rgba(226, 232, 240, 0.95);
}

.auth-modal .credit-dialog-head {
  justify-content: center;
  padding: 0 44px;
  text-align: center;
}

.auth-modal .credit-dialog-head h3 {
  font-size: 24px;
  font-weight: 950;
  line-height: 1.2;
}

.auth-modal .credit-dialog-head button {
  position: absolute;
  top: 18px;
  right: 18px;
  min-width: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  font-size: 0;
}

.auth-modal .credit-dialog-head button::before {
  content: "×";
  font-size: 20px;
  line-height: 1;
}

.auth-modal-form {
  display: grid;
  gap: 14px;
}

.auth-modal-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.auth-modal-form input {
  width: 100%;
  min-height: 44px;
}

.auth-modal-form > button[type="submit"] {
  width: 100%;
  min-height: 46px;
  margin-top: 2px;
  justify-content: center;
  text-align: center;
}

.auth-modal .code-row {
  grid-template-columns: minmax(0, 1fr) 108px;
}

.auth-modal .form-message {
  text-align: center;
}

.auth-modal .auth-foot {
  justify-content: center;
  gap: 16px;
  padding-top: 0;
}

.credit-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.credit-filters button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.credit-filters button.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.credit-ledger {
  display: grid;
  gap: 8px;
  overflow: auto;
  max-height: 58vh;
}

.credit-ledger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.credit-ledger-row strong,
.credit-ledger-row span {
  display: block;
}

.credit-ledger-row strong {
  color: var(--ink);
  font-size: 13px;
}

.credit-ledger-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.credit-ledger-row em {
  color: var(--green);
  font-style: normal;
  font-weight: 900;
}

.credit-ledger-row.debit em {
  color: var(--danger);
}

.recharge-open-button {
  width: max-content;
}

.wechat-recharge {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf5;
  text-align: center;
}

.wechat-recharge strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}

.wechat-recharge img {
  width: min(260px, 72vw);
  border-radius: 8px;
  background: #ffffff;
}

.wechat-recharge span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.recharge-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.recharge-plan {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf5;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.recharge-plan:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.12);
}

.recharge-plan strong {
  font-size: 16px;
  font-weight: 950;
}

.recharge-plan span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.recharge-plan em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 950;
}

.lightbox-overlay {
  z-index: 320;
  background: rgba(15, 23, 42, 0.74);
}

.image-lightbox {
  position: relative;
  z-index: 321;
  display: grid;
  gap: 12px;
  width: min(1120px, 96vw);
  max-height: 94vh;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #0f172a;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.lightbox-head {
  position: relative;
  z-index: 324;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.lightbox-head strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-head button {
  position: relative;
  z-index: 325;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.lightbox-stage {
  position: relative;
  z-index: 322;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.lightbox-stage.is-grid-mode {
  grid-template-columns: minmax(0, 1fr);
}

.lightbox-nav {
  display: grid;
  width: 44px;
  height: 72px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  font-size: 34px;
  font-weight: 500;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-nav:disabled {
  cursor: default;
  opacity: 0.25;
}

.lightbox-viewport {
  overflow: auto;
  max-height: calc(94vh - 132px);
  border-radius: 7px;
  background: #020617;
  overscroll-behavior: contain;
  text-align: center;
  touch-action: none;
}

.lightbox-thumb-grid {
  display: grid;
  overflow: auto;
  max-height: calc(94vh - 132px);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 4px;
}

.lightbox-thumb-item {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  cursor: pointer;
  text-align: left;
}

.lightbox-thumb-item:hover {
  border-color: rgba(251, 146, 60, 0.8);
  background: rgba(251, 146, 60, 0.14);
}

.lightbox-thumb-item img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: #020617;
}

.lightbox-thumb-item span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 900;
}

.image-lightbox img {
  width: 100%;
  max-height: calc(94vh - 120px);
  border-radius: 7px;
  object-fit: contain;
  background: #020617;
  transform-origin: center center;
  transition: transform 120ms ease;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

.image-lightbox img.is-panning {
  transition: none;
}

.lightbox-zoom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lightbox-zoom span {
  min-width: 48px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  .side-nav {
    grid-template-columns: 1fr 1fr;
  }

  .side-status {
    margin-top: 0;
  }

  .workspace,
  .detail-workspace,
  .admin-workspace,
  .auth-grid,
  .two,
  .api-toolbar,
  .provider-grid-main,
  .provider-grid-models,
  .provider-grid-endpoints {
    grid-template-columns: 1fr;
  }

  .storage-health-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-columns {
    grid-template-columns: 1fr;
  }

  .health-banner {
    grid-template-columns: 1fr;
  }

  .health-checks {
    justify-content: flex-start;
  }

  .detail-workspace {
    grid-template-areas:
      "tools"
      "board"
      "results";
  }

  .detail-tools {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .detail-control-stack {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px) minmax(240px, 320px);
    align-items: start;
  }

  .auth-shell {
    width: min(100vw - 24px, 520px);
    padding: 24px 0;
  }

  .auth-panel {
    padding: 20px;
  }

  .captcha-row {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .captcha-row .captcha-refresh {
    grid-column: 1 / -1;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

  .result-layout {
    grid-template-columns: 1fr;
  }

  .history-panel,
  .history {
    max-height: none;
  }

  .history {
    grid-template-columns: 1fr;
  }

  .user-row,
  .credit-form {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

  .lightbox-stage {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .lightbox-nav {
    width: 36px;
    height: 58px;
    font-size: 28px;
  }
}

@media (max-width: 720px) {
  body {
    background: #f7f4ef;
  }

  .storage-health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-table-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 88;
    display: grid;
    min-height: 0;
    height: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: hidden;
    padding: 9px 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  }

  .brand {
    justify-content: flex-start;
    gap: 8px;
    min-height: 30px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 11px;
  }

  .brand .eyebrow {
    margin-bottom: 1px;
    font-size: 9px;
    line-height: 1;
  }

  .brand h1 {
    font-size: 14px;
    line-height: 1.05;
  }

  .side-nav {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 0 0 2px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .side-nav a,
  .side-nav button {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 104px;
    min-height: 34px;
    padding: 0 12px;
    border-color: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    text-align: center;
    scroll-snap-align: start;
  }

  .side-nav span {
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }

  .side-nav small,
  .page-head .eyebrow {
    display: none;
  }

  .side-status {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    padding: 8px;
    min-height: 36px;
  }

  .side-status > span:nth-of-type(2),
  .side-status > strong#apiStatus {
    display: none;
  }

  .side-status span,
  .side-status strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .side-status strong {
    font-size: 11px;
  }

  .side-logout {
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    white-space: nowrap;
  }

  .credit-summary {
    justify-content: flex-start;
  }

  .side-button,
  .credit-summary button {
    min-height: 30px;
    font-size: 11px;
  }

  .content {
    gap: 14px;
    padding: 12px 12px 20px;
  }

  .page-head {
    z-index: 86;
    min-height: auto;
    align-items: stretch;
    flex-direction: column;
    margin: 0 -12px;
    padding: 10px 12px;
    border-bottom: 0;
  }

  .top-account {
    width: 100%;
    min-width: 0;
    justify-content: stretch;
  }

  .account-guest,
  .account-user {
    width: 100%;
    justify-content: stretch;
  }

  .account-guest button,
  .account-guest a,
  .account-user button {
    flex: 1 1 auto;
  }

  .account-user span,
  .account-user strong {
    flex: 1 0 100%;
  }

  h2 {
    font-size: 22px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .detail-workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .detail-tools,
  .detail-control-stack {
    grid-template-columns: 1fr;
  }

  .detail-tools .panel-title,
  .detail-tools .credit-banner,
  .detail-control-stack {
    grid-column: auto;
  }

  .detail-stage {
    min-height: 320px;
  }

  .detail-stage img {
    max-height: 62vh;
  }

  .detail-canvas-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel,
  .results {
    padding: 14px;
    border-radius: 8px;
  }

  .prompt-composer {
    padding: 14px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .reference-strip {
    gap: 10px;
  }

  .prompt-composer .reference-grid figure,
  .prompt-composer .reference-grid img,
  .upload-tile {
    width: 74px;
    height: 74px;
  }

  .prompt-composer .reference-grid figure {
    flex-basis: 74px;
  }

  .upload-tile {
    flex-basis: 74px;
  }

  .prompt-composer textarea {
    min-height: 150px;
    font-size: 16px;
  }

  .option-panel {
    gap: 14px;
    padding: 12px;
  }

  .option-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .option-buttons button {
    min-height: 48px;
    font-size: 14px;
  }

  .compact-options,
  .format-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .save-picker {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .folder-picker-grid {
    grid-template-columns: 1fr;
  }

  .save-picker button,
  .folder-picker,
  .primary,
  .secondary {
    width: 100%;
  }

  .auth-modal.credit-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 22px 16px;
  }

  .auth-modal .credit-dialog-head {
    padding: 0 38px;
  }

  .auth-modal .code-row {
    grid-template-columns: 1fr;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }

  .result-layout {
    grid-template-columns: 1fr;
  }

  .main-preview,
  .main-preview .empty,
  .main-preview .preview,
  .preview-loading {
    min-height: 280px;
  }

  .batch-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history {
    grid-template-columns: 1fr;
  }

  .history-thumb {
    grid-template-columns: 86px minmax(0, 1fr);
    min-height: 124px;
  }

  .thumb-media {
    width: 86px;
  }

  .thumb-meta strong,
  .thumb-meta span {
    font-size: 12px;
  }

  .thumb-meta span {
    font-size: 10px;
    white-space: pre-line;
  }

  .task-center {
    justify-items: stretch;
    width: 100%;
  }

  .task-center-panel {
    right: auto;
    left: 0;
    width: 100%;
    max-height: 56vh;
    overflow: hidden;
  }

  .auth-shell {
    align-content: start;
    min-height: 100vh;
    padding: 22px 0;
  }

  .auth-brand h1 {
    font-size: 24px;
  }

  .auth-card-head h3 {
    font-size: 22px;
  }

  .auth-foot {
    flex-wrap: wrap;
  }

  .admin-workspace {
    gap: 14px;
  }

  .user-row {
    gap: 10px;
  }

  .credit-form {
    grid-template-columns: 1fr 1fr;
  }

  .credit-form input {
    grid-column: 1 / -1;
  }

  .error-log-row {
    padding: 11px;
  }

  .api-toolbar {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .provider-card {
    padding: 0;
  }

  .provider-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .provider-actions {
    justify-content: stretch;
  }

  .modal-overlay {
    align-items: start;
    padding: 12px;
    overflow-y: auto;
  }

  .credit-dialog,
  .reminder-dialog,
  .confirm-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
  }

  .confirm-dialog {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .confirm-dialog-icon {
    width: 40px;
    height: 40px;
    font-size: 21px;
  }

  .confirm-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .confirm-dialog-actions button {
    min-width: 0;
  }

  .recharge-plans {
    grid-template-columns: 1fr;
  }

  .lightbox-stage {
    grid-template-columns: 1fr;
  }

  .lightbox-nav {
    display: none;
  }
}

.model-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.model-option-section.is-loading {
  display: none;
}

.model-choice-grid button {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 16px;
  border: 1px solid #e4e9f2;
  border-radius: 18px;
  background: rgba(248, 250, 255, 0.86);
  color: #475569;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.model-choice-grid button:hover {
  border-color: #c7d2fe;
  color: var(--accent-dark);
  background: #ffffff;
  transform: translateY(-1px);
}

.model-choice-grid button.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  color: var(--accent-dark);
  box-shadow: 0 16px 34px rgba(91, 92, 246, 0.14), 0 0 0 2px rgba(91, 92, 246, 0.1);
}

.model-choice-grid strong {
  color: #111827;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.model-choice-grid small {
  color: #7c6f68;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.model-choice-grid button.active strong {
  color: var(--accent-dark);
}

.option-buttons button:disabled,
.model-choice-grid button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

@media (max-width: 860px) {
  .model-choice-grid {
    grid-template-columns: 1fr;
  }
}

.api-models-workspace {
  display: grid;
  gap: 16px;
}

.models-panel {
  gap: 18px;
}

.models-page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, #fff 0%, #fff7ed 100%);
}

.models-page-head h3 {
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
}

.models-page-head span {
  display: block;
  max-width: 760px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
}

.model-config-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff 0%, #fffaf5 100%);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.04);
}

.model-config-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.model-config-head strong,
.frontend-model-head strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}

.model-config-head span,
.frontend-model-head span,
.model-route-card strong {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.model-route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.model-route-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.model-route-card.highlight {
  border-color: #fed7aa;
  background: #fff7ed;
}

.model-route-card > span {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 950;
}

.model-route-card select,
.frontend-model-card input,
.frontend-model-card textarea,
.frontend-model-card select {
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}

.frontend-model-card input,
.frontend-model-card select {
  height: 40px;
}

.frontend-model-card textarea {
  min-height: 72px;
  padding: 10px;
  resize: vertical;
}

.model-route-card select:focus,
.frontend-model-card input:focus,
.frontend-model-card textarea:focus,
.frontend-model-card select:focus {
  border-color: #fb923c;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.14);
}

.frontend-model-panel {
  display: grid;
  gap: 14px;
}

.frontend-model-list {
  display: grid;
  gap: 14px;
}

.frontend-model-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.05);
}

.frontend-model-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fffaf5;
}

.frontend-model-head > div:first-child {
  min-width: 0;
}

.frontend-model-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.model-status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 950;
}

.model-status-pill.muted {
  background: #f3f4f6;
  color: #6b7280;
}

.model-status-pill.locked {
  background: #eff6ff;
  color: #1d4ed8;
}

.frontend-model-body {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 1fr);
  gap: 16px;
  padding: 18px;
}

.frontend-model-section {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #f0e4dc;
  border-radius: 12px;
  background: #fffdfb;
}

.frontend-model-section:nth-child(3) {
  grid-column: 1 / -1;
}

.frontend-model-section h4 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 950;
}

.frontend-model-grid {
  display: grid;
  gap: 10px;
}

.frontend-model-grid.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.frontend-model-wide {
  grid-column: 1 / -1;
}

.frontend-model-card label,
.frontend-model-capabilities > div > span {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.frontend-model-card label.is-disabled {
  opacity: 0.58;
}

.frontend-model-capabilities {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.frontend-model-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 40px;
  align-items: center;
}

.frontend-model-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.model-switch-row {
  display: flex !important;
  align-items: flex-start;
  gap: 10px !important;
  min-height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.model-switch-row input,
.frontend-model-checks input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.model-switch-row span,
.model-switch-row strong,
.model-switch-row small {
  display: block;
}

.model-switch-row strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.model-switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 1180px) {
  .model-route-grid,
  .frontend-model-body,
  .frontend-model-capabilities {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .models-page-head,
  .model-config-head,
  .frontend-model-head {
    display: grid;
  }

  .model-route-grid,
  .frontend-model-body,
  .frontend-model-capabilities,
  .frontend-model-grid.two-cols {
    grid-template-columns: 1fr;
  }

  .frontend-model-section:nth-child(3) {
    grid-column: auto;
  }
}

.prompt-presets .user-preset-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
}

.prompt-presets .user-preset {
  border-color: #bae6fd;
  border-radius: 999px 0 0 999px;
  background: #f0f9ff;
  color: #0369a1;
}

.prompt-presets .user-preset-remove {
  min-width: 28px;
  padding: 0 8px;
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: #fff;
  color: #64748b;
}

.prompt-presets .save-prompt-preset {
  border-style: dashed;
  color: #0f766e;
}

.prompt-preset-dialog {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
}

.prompt-preset-dialog label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.prompt-preset-dialog input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  color: #0f172a;
  font: inherit;
  font-weight: 750;
  outline: none;
}

.prompt-preset-dialog input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.option-section.option-required-missing {
  padding: 10px;
  border: 1px solid #ef4444;
  border-radius: 10px;
  background: #fff7f7;
}

.option-section.option-required-missing > span {
  color: #b91c1c;
}

.failed-task-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff7f7;
}

.failed-task-panel h3 {
  margin: 0;
  color: #991b1b;
  font-size: 14px;
}

.failed-task-list {
  display: grid;
  gap: 8px;
}

.failed-task-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #fee2e2;
  border-radius: 10px;
  background: #fff;
}

.failed-task-body {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.failed-task-body strong,
.failed-task-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.failed-task-body small {
  color: #b91c1c;
}

/* lg365-inspired commercial SaaS polish: front-end only, no behavior changes */
body:not(.admin-page):not(.admin-login-page) .app-shell {
  position: relative;
}

body:not(.admin-page):not(.admin-login-page) .app-shell::before {
  position: fixed;
  inset: 74px auto auto 50%;
  z-index: -1;
  width: min(980px, 84vw);
  height: 360px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(91, 92, 246, 0.12), rgba(14, 165, 233, 0.08), rgba(249, 115, 22, 0.08));
  filter: blur(28px);
  transform: translateX(-50%);
  content: "";
  pointer-events: none;
}

body:not(.admin-page):not(.admin-login-page) .sidebar {
  grid-template-columns: auto minmax(0, 1fr);
  border-bottom-color: rgba(226, 232, 240, 0.72);
  background: rgba(255, 255, 255, 0.82);
}

body:not(.admin-page):not(.admin-login-page) .brand {
  min-width: 168px;
}

body:not(.admin-page):not(.admin-login-page) .brand-mark {
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 58%, #f97316 100%);
  box-shadow: 0 16px 34px rgba(91, 92, 246, 0.24);
}

body:not(.admin-page):not(.admin-login-page) .brand h1 {
  font-size: 19px;
  font-weight: 950;
  letter-spacing: -0.03em;
}

body:not(.admin-page):not(.admin-login-page) .brand .eyebrow {
  color: #64748b;
  letter-spacing: 0.12em;
}

body:not(.admin-page):not(.admin-login-page) .side-nav {
  justify-content: flex-end;
}

body:not(.admin-page):not(.admin-login-page) .side-nav a,
body:not(.admin-page):not(.admin-login-page) .side-nav button {
  min-height: 40px;
  padding: 0 17px;
  color: #475569;
  font-size: 13px;
}

body:not(.admin-page):not(.admin-login-page) .side-nav a.active,
body:not(.admin-page):not(.admin-login-page) .side-nav button.active {
  border-color: rgba(91, 92, 246, 0.18);
  background: linear-gradient(180deg, #ffffff, #f4f7ff);
  color: var(--accent-dark);
}

body:not(.admin-page):not(.admin-login-page) .content {
  width: min(1440px, calc(100vw - 56px));
  gap: 24px;
  padding-top: 30px;
}

body:not(.admin-page):not(.admin-login-page) .page-head {
  min-height: 96px;
  padding: 14px 6px 18px;
}

body:not(.admin-page):not(.admin-login-page) .page-head::before {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(91, 92, 246, 0.12);
  border-radius: 999px;
  background: rgba(238, 242, 255, 0.82);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 950;
  content: "AI 创作工作台";
}

body:not(.admin-page):not(.admin-login-page) .page-head > div:first-child {
  display: grid;
  gap: 6px;
}

body:not(.admin-page):not(.admin-login-page) .page-head h2 {
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 950;
  letter-spacing: -0.055em;
}

body:not(.admin-page):not(.admin-login-page) .page-head .eyebrow {
  color: var(--accent);
  font-size: 11px;
}

body:not(.admin-page):not(.admin-login-page) .top-account {
  align-self: flex-start;
}

body:not(.admin-page):not(.admin-login-page) .account-user,
body:not(.admin-page):not(.admin-login-page) .account-loading {
  border-color: rgba(226, 232, 240, 0.82);
  background: rgba(255, 255, 255, 0.9);
}

body:not(.admin-page):not(.admin-login-page) .workspace {
  grid-template-columns: minmax(380px, 520px) minmax(0, 1fr);
  gap: 24px;
}

body:not(.admin-page):not(.admin-login-page) .panel,
body:not(.admin-page):not(.admin-login-page) .results {
  border-color: rgba(226, 232, 240, 0.82);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.09);
}

body:not(.admin-page):not(.admin-login-page) .panel {
  gap: 20px;
  padding: 24px;
}

body:not(.admin-page):not(.admin-login-page) .panel-title h3,
body:not(.admin-page):not(.admin-login-page) .result-head h3 {
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -0.035em;
}

body:not(.admin-page):not(.admin-login-page) .save-picker,
body:not(.admin-page):not(.admin-login-page) .path-status,
body:not(.admin-page):not(.admin-login-page) .save-folder,
body:not(.admin-page):not(.admin-login-page) .batch-box,
body:not(.admin-page):not(.admin-login-page) .batch-note,
body:not(.admin-page):not(.admin-login-page) .detail-status,
body:not(.admin-page):not(.admin-login-page) .generation-detail-summary,
body:not(.admin-page):not(.admin-login-page) .gallery-toolbar {
  border-color: #e4e9f2;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(255, 255, 255, 0.9));
  color: #64748b;
}

body:not(.admin-page):not(.admin-login-page) .prompt-composer,
body:not(.admin-page):not(.admin-login-page) .option-panel {
  border-color: rgba(199, 210, 254, 0.72);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 18px 44px rgba(91, 92, 246, 0.06);
}

body:not(.admin-page):not(.admin-login-page) input,
body:not(.admin-page):not(.admin-login-page) select,
body:not(.admin-page):not(.admin-login-page) textarea {
  border-radius: 14px;
}

body:not(.admin-page):not(.admin-login-page) input:focus,
body:not(.admin-page):not(.admin-login-page) select:focus,
body:not(.admin-page):not(.admin-login-page) textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 92, 246, 0.12);
}

body:not(.admin-page):not(.admin-login-page) .prompt-composer textarea {
  border-radius: 0;
  font-size: 15px;
}

body:not(.admin-page):not(.admin-login-page) .upload-tile,
body:not(.admin-page):not(.admin-login-page) .folder-picker,
body:not(.admin-page):not(.admin-login-page) .folder-drop-zone,
body:not(.admin-page):not(.admin-login-page) .detail-upload {
  border-color: #c7d2fe;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  color: var(--accent-dark);
}

body:not(.admin-page):not(.admin-login-page) .upload-tile:hover,
body:not(.admin-page):not(.admin-login-page) .folder-picker:hover,
body:not(.admin-page):not(.admin-login-page) .detail-upload:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 92, 246, 0.1);
}

body:not(.admin-page):not(.admin-login-page) .option-buttons button,
body:not(.admin-page):not(.admin-login-page) .format-choice-grid button,
body:not(.admin-page):not(.admin-login-page) .model-choice-grid button {
  border-color: #e4e9f2;
  border-radius: 18px;
  background: #f8fbff;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons button:hover,
body:not(.admin-page):not(.admin-login-page) .format-choice-grid button:hover,
body:not(.admin-page):not(.admin-login-page) .model-choice-grid button:hover {
  border-color: #c7d2fe;
  background: #ffffff;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons button.active,
body:not(.admin-page):not(.admin-login-page) .format-choice-grid button.active,
body:not(.admin-page):not(.admin-login-page) .model-choice-grid button.active {
  border-color: rgba(91, 92, 246, 0.78);
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  box-shadow: 0 18px 38px rgba(91, 92, 246, 0.14), 0 0 0 2px rgba(91, 92, 246, 0.09);
}

body:not(.admin-page):not(.admin-login-page) .model-choice-grid small,
body:not(.admin-page):not(.admin-login-page) .folder-drop-zone span,
body:not(.admin-page):not(.admin-login-page) .batch-note,
body:not(.admin-page):not(.admin-login-page) .detail-status {
  color: #64748b;
}

body:not(.admin-page):not(.admin-login-page) .primary,
body:not(.admin-page):not(.admin-login-page) .secondary {
  min-height: 50px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #5b5cf6 48%, #7c3aed 100%);
  box-shadow: 0 18px 44px rgba(91, 92, 246, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

body:not(.admin-page):not(.admin-login-page) .primary:hover,
body:not(.admin-page):not(.admin-login-page) .secondary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 48%, #6d28d9 100%);
  box-shadow: 0 22px 52px rgba(91, 92, 246, 0.28);
  filter: saturate(1.03);
  transform: translateY(-1px);
}

body:not(.admin-page):not(.admin-login-page) .ghost {
  border-color: #dbe4f0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #475569;
}

body:not(.admin-page):not(.admin-login-page) .ghost:hover {
  border-color: #c7d2fe;
  color: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(91, 92, 246, 0.1);
}

body:not(.admin-page):not(.admin-login-page) .main-preview,
body:not(.admin-page):not(.admin-login-page) .history-panel,
body:not(.admin-page):not(.admin-login-page) .detail-stage {
  border-radius: 22px;
  border-color: #e4e9f2;
  background:
    linear-gradient(45deg, rgba(91, 92, 246, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(91, 92, 246, 0.035) 25%, transparent 25%),
    #f8fbff;
}

body:not(.admin-page):not(.admin-login-page) .history-thumb,
body:not(.admin-page):not(.admin-login-page) .gallery-card,
body:not(.admin-page):not(.admin-login-page) .collection-thumb,
body:not(.admin-page):not(.admin-login-page) .mark-list article {
  border-color: #e4e9f2;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.055);
}

body:not(.admin-page):not(.admin-login-page) .history-thumb:hover,
body:not(.admin-page):not(.admin-login-page) .gallery-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 18px 42px rgba(91, 92, 246, 0.11);
  transform: translateY(-1px);
}

body:not(.admin-page):not(.admin-login-page) .gallery-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 92, 246, 0.12), 0 18px 42px rgba(91, 92, 246, 0.11);
}

body:not(.admin-page):not(.admin-login-page) .gallery-select input,
body:not(.admin-page):not(.admin-login-page) .gallery-select-all input,
body:not(.admin-page):not(.admin-login-page) .toggle-option input,
body:not(.admin-page):not(.admin-login-page) .check-row input {
  accent-color: var(--accent);
}

body:not(.admin-page):not(.admin-login-page) .reference-controls button:hover,
body:not(.admin-page):not(.admin-login-page) .folder-preview-actions button:hover {
  background: rgba(79, 70, 229, 0.92);
}

body:not(.admin-page):not(.admin-login-page) .task-item:hover {
  border-color: #c7d2fe;
  background: #eef2ff;
}

body:not(.admin-page):not(.admin-login-page) .task-progress i {
  background: linear-gradient(90deg, #2563eb, #7c3aed);
}

body:not(.admin-page):not(.admin-login-page) .task-item.running .task-progress::after {
  background-image: linear-gradient(
    45deg,
    rgba(91, 92, 246, 0.14) 25%,
    transparent 25%,
    transparent 50%,
    rgba(91, 92, 246, 0.14) 50%,
    rgba(91, 92, 246, 0.14) 75%,
    transparent 75%,
    transparent
  );
}

@media (max-width: 1180px) {
  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    padding: 0 13px;
  }
}

@media (max-width: 980px) {
  body:not(.admin-page):not(.admin-login-page) .app-shell {
    display: flex;
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: auto;
    padding: 12px 18px 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .brand {
    min-width: 0;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav::-webkit-scrollbar {
    display: none;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 28px, 860px);
    padding: 22px 0 34px;
  }

  body:not(.admin-page):not(.admin-login-page) .workspace,
  body:not(.admin-page):not(.admin-login-page) .detail-workspace {
    grid-template-columns: 1fr;
  }

  body:not(.admin-page):not(.admin-login-page) .panel,
  body:not(.admin-page):not(.admin-login-page) .results {
    border-radius: 24px;
  }
}

@media (max-width: 720px) {
  body:not(.admin-page):not(.admin-login-page) {
    background:
      radial-gradient(circle at 18% 8%, rgba(91, 92, 246, 0.14), transparent 34%),
      linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    gap: 9px;
    padding: 10px 12px 9px;
    border-bottom-color: rgba(226, 232, 240, 0.86);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  }

  body:not(.admin-page):not(.admin-login-page) .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .brand h1 {
    font-size: 15px;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    min-width: 104px;
    min-height: 34px;
    padding: 0 12px;
    border-color: rgba(226, 232, 240, 0.82);
    background: rgba(255, 255, 255, 0.72);
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 22px, 720px);
    gap: 14px;
    padding: 14px 0 24px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    gap: 12px;
    margin: 0;
    padding: 10px 2px 6px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head::before {
    min-height: 26px;
    font-size: 11px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head h2 {
    font-size: 30px;
  }

  body:not(.admin-page):not(.admin-login-page) .panel,
  body:not(.admin-page):not(.admin-login-page) .results {
    border-radius: 20px;
  }

  body:not(.admin-page):not(.admin-login-page) .panel {
    padding: 17px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:not(.admin-page):not(.admin-login-page) .compact-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons button,
  body:not(.admin-page):not(.admin-login-page) .format-choice-grid button {
    min-height: 50px;
    padding: 0 10px;
    font-size: 13px;
  }

  body:not(.admin-page):not(.admin-login-page) .main-preview,
  body:not(.admin-page):not(.admin-login-page) .detail-stage {
    border-radius: 18px;
  }
}

/* user-markup pass: left feature rail + cleaner header alignment */
body:not(.admin-page):not(.admin-login-page) .app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

body:not(.admin-page):not(.admin-login-page) .app-shell::before {
  display: none;
}

body:not(.admin-page):not(.admin-login-page) .sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 24px;
  width: 244px;
  height: 100vh;
  min-height: 0;
  padding: 22px 18px;
  border-right: 1px solid rgba(226, 232, 240, 0.86);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 16px 0 44px rgba(15, 23, 42, 0.045);
  backdrop-filter: blur(18px);
}

body:not(.admin-page):not(.admin-login-page) .brand {
  min-width: 0;
  gap: 12px;
  padding: 0 8px 18px;
  border-bottom: 1px solid #e8edf6;
}

body:not(.admin-page):not(.admin-login-page) .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
}

body:not(.admin-page):not(.admin-login-page) .brand .eyebrow {
  margin-bottom: 2px;
  color: #64748b;
  font-size: 11px;
}

body:not(.admin-page):not(.admin-login-page) .brand h1 {
  font-size: 21px;
  line-height: 1.05;
}

body:not(.admin-page):not(.admin-login-page) .side-nav {
  display: grid;
  justify-content: stretch;
  gap: 10px;
  min-width: 0;
}

body:not(.admin-page):not(.admin-login-page) .side-nav::before {
  display: block;
  padding: 0 12px 2px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  content: "功能导航";
}

body:not(.admin-page):not(.admin-login-page) .side-nav a,
body:not(.admin-page):not(.admin-login-page) .side-nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: #475569;
  text-align: left;
  box-shadow: none;
}

body:not(.admin-page):not(.admin-login-page) .side-nav a:hover,
body:not(.admin-page):not(.admin-login-page) .side-nav button:hover {
  border-color: #dbe4ff;
  background: #f8fbff;
  box-shadow: 0 10px 28px rgba(91, 92, 246, 0.08);
}

body:not(.admin-page):not(.admin-login-page) .side-nav a.active,
body:not(.admin-page):not(.admin-login-page) .side-nav button.active {
  border-color: rgba(91, 92, 246, 0.2);
  background: linear-gradient(135deg, #eef2ff, #ffffff);
  color: var(--accent-dark);
  box-shadow: 0 14px 34px rgba(91, 92, 246, 0.12);
}

body:not(.admin-page):not(.admin-login-page) .side-nav span {
  font-size: 14px;
}

body:not(.admin-page):not(.admin-login-page) .content {
  width: min(1440px, calc(100vw - 244px - 56px));
  margin: 0 auto;
  padding-top: 36px;
}

body:not(.admin-page):not(.admin-login-page) .page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 24px;
  min-height: 118px;
  padding: 0 0 20px;
}

body:not(.admin-page):not(.admin-login-page) .page-head::before {
  display: none;
}

body:not(.admin-page):not(.admin-login-page) .page-head > div:first-child {
  margin-right: 0;
  padding-top: 2px;
}

body:not(.admin-page):not(.admin-login-page) .page-head .eyebrow {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(91, 92, 246, 0.16);
  border-radius: 999px;
  background: rgba(238, 242, 255, 0.82);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
}

body:not(.admin-page):not(.admin-login-page) .page-head h2 {
  margin-top: 8px;
}

body:not(.admin-page):not(.admin-login-page) .page-utility-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  align-self: start;
  min-width: 0;
  padding-top: 12px;
}

body:not(.admin-page):not(.admin-login-page) .top-account {
  align-self: auto;
  flex: 0 1 auto;
}

body:not(.admin-page):not(.admin-login-page) .task-center {
  display: flex;
  align-items: center;
  justify-items: stretch;
  flex: 0 0 auto;
}

body:not(.admin-page):not(.admin-login-page) .task-center-toggle,
body:not(.admin-page):not(.admin-login-page) .account-user,
body:not(.admin-page):not(.admin-login-page) .account-loading,
body:not(.admin-page):not(.admin-login-page) .account-guest {
  min-height: 48px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(14px);
}

body:not(.admin-page):not(.admin-login-page) .task-center-toggle {
  padding: 0 12px 0 16px;
}

body:not(.admin-page):not(.admin-login-page) .task-center-toggle span,
body:not(.admin-page):not(.admin-login-page) .account-user span,
body:not(.admin-page):not(.admin-login-page) .account-user strong {
  font-size: 13px;
  line-height: 1;
}

body:not(.admin-page):not(.admin-login-page) .task-center-toggle strong {
  min-width: 28px;
  line-height: 28px;
}

body:not(.admin-page):not(.admin-login-page) .account-user,
body:not(.admin-page):not(.admin-login-page) .account-loading,
body:not(.admin-page):not(.admin-login-page) .account-guest {
  padding: 7px 10px;
}

body:not(.admin-page):not(.admin-login-page) .account-user .ghost,
body:not(.admin-page):not(.admin-login-page) .account-guest .ghost,
body:not(.admin-page):not(.admin-login-page) .account-guest .primary {
  min-height: 32px;
  padding: 0 12px;
  box-shadow: none;
}

body:not(.admin-page):not(.admin-login-page) .task-center-panel {
  border-radius: 18px;
}

@media (max-width: 1280px) {
  body:not(.admin-page):not(.admin-login-page) .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    width: 220px;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 220px - 34px, 1180px);
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  body:not(.admin-page):not(.admin-login-page) .page-utility-bar {
    justify-content: flex-start;
    padding-top: 0;
  }
}

@media (max-width: 980px) {
  body:not(.admin-page):not(.admin-login-page) .app-shell {
    display: flex;
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.86);
  }

  body:not(.admin-page):not(.admin-login-page) .brand {
    padding-bottom: 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav::before {
    display: none;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    flex: 0 0 auto;
    width: auto;
    min-width: 116px;
    min-height: 40px;
    justify-content: center;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 28px, 860px);
  }

  body:not(.admin-page):not(.admin-login-page) .page-utility-bar {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  body:not(.admin-page):not(.admin-login-page) .sidebar {
    padding: 10px 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    gap: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-utility-bar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  body:not(.admin-page):not(.admin-login-page) .task-center,
  body:not(.admin-page):not(.admin-login-page) .top-account,
  body:not(.admin-page):not(.admin-login-page) .task-center-toggle,
  body:not(.admin-page):not(.admin-login-page) .account-user,
  body:not(.admin-page):not(.admin-login-page) .account-loading,
  body:not(.admin-page):not(.admin-login-page) .account-guest {
    width: 100%;
  }

  body:not(.admin-page):not(.admin-login-page) .task-center-toggle,
  body:not(.admin-page):not(.admin-login-page) .account-user,
  body:not(.admin-page):not(.admin-login-page) .account-loading,
  body:not(.admin-page):not(.admin-login-page) .account-guest {
    justify-content: center;
  }
}

/* screenshot feedback pass: floating logo/nav, no left background slab, hidden hero copy */
body:not(.admin-page):not(.admin-login-page) .app-shell {
  display: block;
  min-height: 100vh;
}

body:not(.admin-page):not(.admin-login-page) .sidebar {
  position: fixed;
  top: 22px;
  left: 20px;
  z-index: 120;
  display: grid;
  gap: 18px;
  width: 214px;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: none;
}

body:not(.admin-page):not(.admin-login-page) .brand,
body:not(.admin-page):not(.admin-login-page) .side-nav {
  pointer-events: auto;
}

body:not(.admin-page):not(.admin-login-page) .brand {
  width: fit-content;
  min-width: 0;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body:not(.admin-page):not(.admin-login-page) .brand-mark {
  width: 43px;
  height: 43px;
  border-radius: 15px;
  box-shadow: 0 16px 34px rgba(91, 92, 246, 0.22);
}

body:not(.admin-page):not(.admin-login-page) .brand .eyebrow {
  margin: 0 0 2px;
  color: #64748b;
  font-size: 11px;
  letter-spacing: 0.12em;
}

body:not(.admin-page):not(.admin-login-page) .brand h1 {
  color: #111827;
  font-size: 21px;
  font-weight: 950;
  line-height: 1.04;
}

body:not(.admin-page):not(.admin-login-page) .side-nav {
  display: grid;
  gap: 10px;
  width: 214px;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

body:not(.admin-page):not(.admin-login-page) .side-nav::before {
  display: block;
  padding: 0 8px 2px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.12em;
  content: "功能导航";
}

body:not(.admin-page):not(.admin-login-page) .side-nav a,
body:not(.admin-page):not(.admin-login-page) .side-nav button {
  min-height: 47px;
  padding: 0 13px;
  border-radius: 15px;
  background: transparent;
  color: #475569;
}

body:not(.admin-page):not(.admin-login-page) .side-nav a.active,
body:not(.admin-page):not(.admin-login-page) .side-nav button.active {
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-dark);
  box-shadow: 0 12px 26px rgba(91, 92, 246, 0.1);
}

body:not(.admin-page):not(.admin-login-page) .content {
  width: min(1440px, calc(100vw - 370px));
  margin: 0 62px 0 auto;
  padding-top: 48px;
}

body:not(.admin-page):not(.admin-login-page) .page-head {
  display: flex;
  justify-content: flex-end;
  min-height: 68px;
  padding: 0 0 18px;
}

body:not(.admin-page):not(.admin-login-page) .page-head > div:first-child {
  display: none;
}

body:not(.admin-page):not(.admin-login-page) .page-head::before,
body:not(.admin-page):not(.admin-login-page) .page-head .eyebrow,
body:not(.admin-page):not(.admin-login-page) .page-head h2 {
  display: none;
}

body:not(.admin-page):not(.admin-login-page) .page-utility-bar {
  justify-content: flex-end;
  padding-top: 0;
}

@media (max-width: 1280px) {
  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 292px, 1080px);
    margin-right: 28px;
  }
}

@media (max-width: 980px) {
  body:not(.admin-page):not(.admin-login-page) .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.86);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px);
    pointer-events: auto;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding: 4px 0 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav::before {
    display: none;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    flex: 0 0 auto;
    min-width: 116px;
    justify-content: center;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: min(100vw - 28px, 860px);
    margin: 0 auto;
    padding-top: 18px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    min-height: auto;
  }
}

/* compact centered workspace pass: nav belongs to the canvas, not the viewport edge */
@media (min-width: 981px) {
  body:not(.admin-page):not(.admin-login-page) {
    --float-nav-width: 214px;
    --float-nav-gap: 26px;
    --work-main-width: min(1320px, calc(100vw - 330px));
    --work-total-width: calc(var(--float-nav-width) + var(--float-nav-gap) + var(--work-main-width));
    --work-left: max(22px, calc((100vw - var(--work-total-width)) / 2));
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    left: var(--work-left);
    top: 26px;
    width: var(--float-nav-width);
  }

  body:not(.admin-page):not(.admin-login-page) .brand {
    margin-left: 4px;
    margin-bottom: 2px;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav {
    width: var(--float-nav-width);
    padding: 8px;
    border-radius: 20px;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    width: var(--work-main-width);
    margin-right: auto;
    margin-left: calc(var(--work-left) + var(--float-nav-width) + var(--float-nav-gap));
    padding-top: 50px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    min-height: 58px;
    padding-bottom: 14px;
  }

  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(370px, 500px) minmax(0, 1fr);
    gap: 20px;
  }

  body:not(.admin-page):not(.admin-login-page) .panel,
  body:not(.admin-page):not(.admin-login-page) .results {
    border-radius: 26px;
  }
}

@media (min-width: 981px) and (max-width: 1500px) {
  body:not(.admin-page):not(.admin-login-page) {
    --float-nav-width: 200px;
    --float-nav-gap: 22px;
    --work-main-width: min(1160px, calc(100vw - 272px));
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav a,
  body:not(.admin-page):not(.admin-login-page) .side-nav button {
    min-height: 44px;
  }

  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(350px, 470px) minmax(0, 1fr);
    gap: 18px;
  }
}

/* senior polish: shorter parameter panel + consistent option button baseline */
body:not(.admin-page):not(.admin-login-page) .panel {
  gap: 14px;
  padding: 19px;
}

body:not(.admin-page):not(.admin-login-page) .panel-title h3,
body:not(.admin-page):not(.admin-login-page) .result-head h3 {
  font-size: 19px;
}

body:not(.admin-page):not(.admin-login-page) .save-picker {
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 16px;
}

body:not(.admin-page):not(.admin-login-page) .path-status {
  padding: 9px 12px;
  border-radius: 15px;
}

body:not(.admin-page):not(.admin-login-page) .prompt-composer {
  gap: 11px;
  padding: 15px;
  border-radius: 21px;
}

body:not(.admin-page):not(.admin-login-page) .composer-head strong,
body:not(.admin-page):not(.admin-login-page) .option-section > span {
  font-size: 14px;
}

body:not(.admin-page):not(.admin-login-page) .reference-strip,
body:not(.admin-page):not(.admin-login-page) .prompt-composer .reference-grid {
  gap: 10px;
}

body:not(.admin-page):not(.admin-login-page) .upload-tile,
body:not(.admin-page):not(.admin-login-page) .prompt-composer .reference-grid figure,
body:not(.admin-page):not(.admin-login-page) .prompt-composer .reference-grid img {
  width: 72px;
  height: 72px;
}

body:not(.admin-page):not(.admin-login-page) .upload-tile {
  flex-basis: 72px;
  gap: 2px;
  border-radius: 16px;
}

body:not(.admin-page):not(.admin-login-page) .upload-tile span {
  font-size: 28px;
  line-height: 20px;
}

body:not(.admin-page):not(.admin-login-page) .upload-tile small {
  font-size: 12px;
}

body:not(.admin-page):not(.admin-login-page) .prompt-presets button {
  min-height: 27px;
  padding: 0 10px;
  font-size: 11px;
}

body:not(.admin-page):not(.admin-login-page) .prompt-composer textarea {
  min-height: 138px;
  padding-top: 13px;
  font-size: 14px;
  line-height: 1.46;
}

body:not(.admin-page):not(.admin-login-page) .option-panel {
  gap: 14px;
  padding: 15px;
  border-radius: 21px;
}

body:not(.admin-page):not(.admin-login-page) .option-section {
  gap: 9px;
}

body:not(.admin-page):not(.admin-login-page) .model-choice-grid {
  gap: 10px;
}

body:not(.admin-page):not(.admin-login-page) .model-choice-grid button {
  min-height: 94px;
  padding: 14px;
  border-radius: 16px;
}

body:not(.admin-page):not(.admin-login-page) .model-choice-grid strong {
  font-size: 17px;
}

body:not(.admin-page):not(.admin-login-page) .model-choice-grid small {
  font-size: 11px;
  line-height: 1.42;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons {
  gap: 9px;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons button {
  display: grid;
  grid-template-rows: 28px auto;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 7px 8px 8px;
  border-radius: 15px;
  font-size: 13px;
  line-height: 1;
  text-align: center;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button::before {
  display: block;
  grid-row: 1;
  margin: 0;
  vertical-align: 0;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="16:9"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="4:3"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="3:2"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="4:1"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="8:1"]::before {
  align-self: end;
  width: 32px;
  height: 18px;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="9:16"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="3:4"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="2:3"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="1:4"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="1:8"]::before {
  align-self: end;
  width: 18px;
  height: 28px;
}

body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="smart"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="1:1"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="4:5"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="5:4"]::before,
body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="21:9"]::before {
  align-self: end;
}

body:not(.admin-page):not(.admin-login-page) .compact-options button,
body:not(.admin-page):not(.admin-login-page) .format-choice-grid button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 10px;
  text-align: center;
}

body:not(.admin-page):not(.admin-login-page) .primary,
body:not(.admin-page):not(.admin-login-page) .secondary {
  min-height: 46px;
}

@media (min-width: 981px) {
  body:not(.admin-page):not(.admin-login-page) .workspace {
    align-items: start;
  }

  body:not(.admin-page):not(.admin-login-page) .panel {
    max-height: calc(100vh - 108px);
    overflow: auto;
    scrollbar-width: thin;
  }
}

@media (max-width: 720px) {
  body:not(.admin-page):not(.admin-login-page) .prompt-composer textarea {
    min-height: 120px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons button {
    min-height: 52px;
  }
}

/* fixed one-screen workstation: nav is a real column beside parameter panel */
@media (min-width: 981px) {
  html,
  body:not(.admin-page):not(.admin-login-page) {
    height: 100%;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .app-shell {
    --nav-column-width: 214px;
    --nav-column-gap: 22px;
    --main-column-width: min(1320px, calc(100vw - 318px));
    display: grid;
    grid-template-columns: var(--nav-column-width) var(--main-column-width);
    justify-content: center;
    column-gap: var(--nav-column-gap);
    height: 100vh;
    min-height: 0;
    padding: 24px 28px;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .sidebar {
    position: static;
    z-index: 1;
    align-self: start;
    display: grid;
    gap: 16px;
    width: var(--nav-column-width);
    height: auto;
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: auto;
  }

  body:not(.admin-page):not(.admin-login-page) .brand,
  body:not(.admin-page):not(.admin-login-page) .side-nav {
    pointer-events: auto;
  }

  body:not(.admin-page):not(.admin-login-page) .brand {
    margin: 0 0 0 4px;
  }

  body:not(.admin-page):not(.admin-login-page) .side-nav {
    width: var(--nav-column-width);
    padding: 8px;
    border: 1px solid rgba(226, 232, 240, 0.82);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(10px);
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    height: calc(100vh - 48px);
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    min-height: 48px;
    padding: 0;
  }

  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .panel,
  body:not(.admin-page):not(.admin-login-page) .results {
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .panel {
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
    align-content: start;
    height: 100%;
    overflow-y: auto;
    padding: 18px;
    scrollbar-width: thin;
  }

  body:not(.admin-page):not(.admin-login-page) .results.saved-panel,
  body:not(.admin-page):not(.admin-login-page) .gallery-panel,
  body:not(.admin-page):not(.admin-login-page) .detail-board,
  body:not(.admin-page):not(.admin-login-page) .detail-results {
    height: 100%;
  }

  body:not(.admin-page):not(.admin-login-page) .results.saved-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .result-layout {
    min-height: 0;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .main-preview,
  body:not(.admin-page):not(.admin-login-page) .history-panel,
  body:not(.admin-page):not(.admin-login-page) .history {
    min-height: 0;
  }

  body:not(.admin-page):not(.admin-login-page) .history-panel,
  body:not(.admin-page):not(.admin-login-page) .history {
    max-height: none;
  }

  body:not(.admin-page):not(.admin-login-page) .main-preview,
  body:not(.admin-page):not(.admin-login-page) .history {
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

@media (min-width: 981px) and (max-width: 1500px) {
  body:not(.admin-page):not(.admin-login-page) .app-shell {
    --nav-column-width: 200px;
    --nav-column-gap: 18px;
    --main-column-width: min(1160px, calc(100vw - 260px));
    padding: 20px 22px;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    height: calc(100vh - 40px);
  }

  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
    gap: 16px;
  }
}

/* one-screen fit pass: parameter panel shows all controls without inner scroll */
@media (min-width: 981px) {
  body:not(.admin-page):not(.admin-login-page) .app-shell {
    --main-column-width: min(1390px, calc(100vw - 300px));
    padding-top: 18px;
    padding-bottom: 18px;
  }

  body:not(.admin-page):not(.admin-login-page) .content {
    height: calc(100vh - 36px);
    gap: 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .page-head {
    min-height: 42px;
    padding: 0;
  }

  body:not(.admin-page):not(.admin-login-page) .workspace {
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    gap: 16px;
  }

  body:not(.admin-page):not(.admin-login-page) .panel {
    height: 100%;
    gap: 10px;
    padding: 16px;
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .panel-title h3 {
    font-size: 18px;
  }

  body:not(.admin-page):not(.admin-login-page) .save-picker {
    min-height: 48px;
    padding: 8px 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .save-picker strong,
  body:not(.admin-page):not(.admin-login-page) .save-picker span,
  body:not(.admin-page):not(.admin-login-page) .path-status {
    font-size: 11px;
    line-height: 1.3;
  }

  body:not(.admin-page):not(.admin-login-page) .path-status {
    padding: 7px 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .prompt-composer {
    gap: 8px;
    padding: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .composer-head strong,
  body:not(.admin-page):not(.admin-login-page) .option-section > span {
    font-size: 13px;
  }

  body:not(.admin-page):not(.admin-login-page) .composer-actions span {
    font-size: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .upload-tile,
  body:not(.admin-page):not(.admin-login-page) .prompt-composer .reference-grid figure,
  body:not(.admin-page):not(.admin-login-page) .prompt-composer .reference-grid img {
    width: 60px;
    height: 60px;
  }

  body:not(.admin-page):not(.admin-login-page) .upload-tile {
    flex-basis: 60px;
    border-radius: 14px;
  }

  body:not(.admin-page):not(.admin-login-page) .upload-tile span {
    font-size: 24px;
    line-height: 18px;
  }

  body:not(.admin-page):not(.admin-login-page) .upload-tile small {
    font-size: 11px;
  }

  body:not(.admin-page):not(.admin-login-page) .prompt-presets button {
    min-height: 24px;
    padding: 0 9px;
    font-size: 10px;
  }

  body:not(.admin-page):not(.admin-login-page) .prompt-composer textarea {
    min-height: clamp(82px, 12vh, 118px);
    padding-top: 10px;
    font-size: 13px;
    line-height: 1.38;
  }

  body:not(.admin-page):not(.admin-login-page) .option-panel {
    gap: 10px;
    padding: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-section {
    gap: 7px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid button {
    min-height: 78px;
    padding: 11px;
    border-radius: 15px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid strong {
    font-size: 15px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid small {
    font-size: 10px;
    line-height: 1.32;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons button {
    grid-template-rows: 23px auto;
    gap: 2px;
    min-height: 43px;
    padding: 5px 6px 6px;
    border-radius: 13px;
    font-size: 11px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button::before {
    width: 18px;
    height: 18px;
    border-width: 2px;
    border-radius: 5px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="16:9"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="4:3"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="3:2"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="4:1"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="8:1"]::before {
    width: 25px;
    height: 14px;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="9:16"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="3:4"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="2:3"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="1:4"]::before,
  body:not(.admin-page):not(.admin-login-page) .option-buttons:not(.compact-options) button[data-option-value="1:8"]::before {
    width: 14px;
    height: 23px;
  }

  body:not(.admin-page):not(.admin-login-page) .compact-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body:not(.admin-page):not(.admin-login-page) .compact-options button,
  body:not(.admin-page):not(.admin-login-page) .format-choice-grid button {
    min-height: 38px;
    font-size: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .primary,
  body:not(.admin-page):not(.admin-login-page) .secondary {
    min-height: 42px;
  }

  body:not(.admin-page):not(.admin-login-page) .submit-feedback {
    margin-top: 0;
    padding: 8px 10px;
    font-size: 12px;
  }

  body:not(.admin-page):not(.admin-login-page) .history-panel {
    overflow: hidden;
  }

  body:not(.admin-page):not(.admin-login-page) .history {
    overflow-y: auto;
    padding-right: 4px;
  }
}

@media (min-width: 981px) and (max-height: 840px) {
  body:not(.admin-page):not(.admin-login-page) .prompt-composer textarea {
    min-height: 72px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid button {
    min-height: 68px;
  }

  body:not(.admin-page):not(.admin-login-page) .model-choice-grid small {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  body:not(.admin-page):not(.admin-login-page) .option-buttons button {
    min-height: 40px;
  }
}

/* page scoped layout repair: prevent single-page rules from breaking batch/detail/gallery */
@media (min-width: 981px) {
  body.page-single:not(.admin-page):not(.admin-login-page),
  body.page-batch:not(.admin-page):not(.admin-login-page),
  body.page-detail:not(.admin-page):not(.admin-login-page),
  body.page-gallery:not(.admin-page):not(.admin-login-page) {
    height: 100%;
    overflow: hidden;
  }

  body.page-single .app-shell,
  body.page-batch .app-shell,
  body.page-detail .app-shell,
  body.page-gallery .app-shell {
    --nav-column-width: 214px;
    --nav-column-gap: 22px;
    --main-column-width: min(1390px, calc(100vw - 300px));
    display: grid;
    grid-template-columns: var(--nav-column-width) var(--main-column-width);
    justify-content: center;
    column-gap: var(--nav-column-gap);
    height: 100vh;
    min-height: 0;
    padding: 18px 28px;
    overflow: hidden;
  }

  body.page-single .sidebar,
  body.page-batch .sidebar,
  body.page-detail .sidebar,
  body.page-gallery .sidebar {
    position: static;
    align-self: start;
    width: var(--nav-column-width);
    max-height: calc(100vh - 36px);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  body.page-single .content,
  body.page-batch .content,
  body.page-detail .content,
  body.page-gallery .content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    height: calc(100vh - 36px);
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  body.page-single .page-head,
  body.page-batch .page-head,
  body.page-detail .page-head,
  body.page-gallery .page-head {
    min-height: 42px;
    padding: 0;
  }

  body.page-single .page-head > div:first-child,
  body.page-batch .page-head > div:first-child,
  body.page-detail .page-head > div:first-child,
  body.page-gallery .page-head > div:first-child {
    display: none;
  }

  body.page-single .workspace,
  body.page-batch .workspace {
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }

  body.page-single .panel,
  body.page-batch .panel {
    height: 100%;
    max-height: none;
    overflow: hidden;
  }

  body.page-single .panel {
    gap: 9px;
    padding: 15px;
  }

  body.page-batch .panel {
    gap: 10px;
    padding: 15px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  body.page-single .results.saved-panel,
  body.page-batch .results.saved-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
  }

  body.page-single .result-layout,
  body.page-batch .result-layout {
    min-height: 0;
    overflow: hidden;
  }

  body.page-single .history,
  body.page-batch .history,
  body.page-single .main-preview,
  body.page-batch .main-preview {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  body.page-detail .detail-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr) minmax(260px, 330px);
    grid-template-areas: "tools board results";
    gap: 16px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }

  body.page-detail .detail-tools,
  body.page-detail .detail-board,
  body.page-detail .detail-results {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-detail .detail-tools {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 10px;
    padding: 15px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  body.page-detail .detail-tools .panel-title,
  body.page-detail .detail-tools .credit-banner {
    grid-column: auto;
  }

  body.page-detail .detail-upload {
    min-height: 110px;
  }

  body.page-detail .detail-prompt-field textarea {
    min-height: 104px;
  }

  body.page-detail .detail-board {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 15px;
  }

  body.page-detail .detail-stage {
    min-height: 0;
    height: 100%;
  }

  body.page-detail .detail-stage.empty-stage {
    min-height: 0;
  }

  body.page-detail .detail-results {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 15px;
  }

  body.page-detail .detail-result-grid {
    overflow-y: auto;
    scrollbar-width: thin;
  }

  body.page-gallery .gallery-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
  }

  body.page-gallery .gallery-grid {
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
  }
}

@media (min-width: 981px) and (max-width: 1500px) {
  body.page-single .app-shell,
  body.page-batch .app-shell,
  body.page-detail .app-shell,
  body.page-gallery .app-shell {
    --nav-column-width: 200px;
    --nav-column-gap: 18px;
    --main-column-width: min(1180px, calc(100vw - 260px));
    padding: 16px 22px;
  }

  body.page-single .content,
  body.page-batch .content,
  body.page-detail .content,
  body.page-gallery .content {
    height: calc(100vh - 32px);
  }

  body.page-single .workspace,
  body.page-batch .workspace {
    grid-template-columns: minmax(335px, 420px) minmax(0, 1fr);
  }

  body.page-detail .detail-workspace {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(240px, 300px);
  }
}

/* single page final fit: safe bottom spacing and no clipped result card */
@media (min-width: 981px) {
  body.page-single .app-shell {
    padding-top: 18px;
    padding-bottom: 24px;
  }

  body.page-single .content {
    height: calc(100vh - 42px);
  }

  body.page-single .workspace {
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 16px;
  }

  body.page-single .panel {
    display: flex;
    flex-direction: column;
    gap: 9px;
    height: 100%;
    padding: 15px 15px 18px;
    overflow: hidden;
  }

  body.page-single .option-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  body.page-single .prompt-composer {
    flex: 0 0 auto;
  }

  body.page-single .option-section {
    min-height: 0;
  }

  body.page-single .option-section.model-option-section {
    flex: 0 0 auto;
  }

  body.page-single .model-choice-grid button {
    min-height: 72px;
  }

  body.page-single .option-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  body.page-single .option-buttons button {
    min-height: 38px;
    padding: 4px 5px 5px;
  }

  body.page-single .compact-options button {
    min-height: 36px;
  }

  body.page-single .primary[type="submit"] {
    flex: 0 0 auto;
    min-height: 42px;
    margin-top: 2px;
    margin-bottom: 6px;
  }

  body.page-single .results.saved-panel {
    height: 100%;
    min-height: 0;
    padding-bottom: 18px;
  }

  body.page-single .result-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
    gap: 16px;
    min-height: 0;
    overflow: hidden;
  }

  body.page-single .main-preview,
  body.page-single .history-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-single .main-preview {
    display: grid;
    align-content: start;
    overflow-y: auto;
    padding-bottom: 12px;
  }

  body.page-single .history-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.page-single .history {
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
  }
}

@media (min-width: 981px) and (max-height: 840px) {
  body.page-single .panel {
    gap: 7px;
    padding: 13px 13px 16px;
  }

  body.page-single .save-picker {
    min-height: 42px;
  }

  body.page-single .prompt-composer textarea {
    min-height: 58px;
  }

  body.page-single .model-choice-grid button {
    min-height: 60px;
  }

  body.page-single .option-buttons button {
    min-height: 34px;
  }

  body.page-single .primary[type="submit"] {
    min-height: 40px;
    margin-bottom: 4px;
  }
}

/* airy canvas pass: remove heavy card backgrounds and show ratios as text only */
body.page-single .workspace,
body.page-batch .workspace {
  gap: 20px;
}

body.page-single .panel,
body.page-batch .panel,
body.page-single .results.saved-panel,
body.page-batch .results.saved-panel {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body.page-single .panel,
body.page-batch .panel {
  padding: 4px 0 12px;
}

body.page-single .results.saved-panel,
body.page-batch .results.saved-panel {
  padding: 4px 0 14px;
}

body.page-single .prompt-composer,
body.page-batch .prompt-composer,
body.page-single .option-panel,
body.page-batch .option-panel,
body.page-single .save-picker,
body.page-batch .save-picker,
body.page-single .path-status,
body.page-batch .path-status,
body.page-single .save-folder,
body.page-batch .save-folder,
body.page-single .main-preview,
body.page-batch .main-preview,
body.page-single .history-panel,
body.page-batch .history-panel {
  background: rgba(255, 255, 255, 0.54);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

body.page-single .result-head,
body.page-batch .result-head,
body.page-single .panel-title,
body.page-batch .panel-title {
  padding: 0 2px;
}

body.page-single .option-buttons:not(.compact-options) button,
body.page-batch .option-buttons:not(.compact-options) button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1;
  text-align: center;
}

body.page-single .option-buttons:not(.compact-options) button::before,
body.page-batch .option-buttons:not(.compact-options) button::before {
  display: none !important;
  content: none !important;
}

body.page-single .option-buttons,
body.page-batch .option-buttons {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

body.page-single .compact-options button,
body.page-batch .compact-options button {
  min-height: 36px;
}

@media (min-width: 981px) {
  body.page-single .workspace,
  body.page-batch .workspace {
    grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  }

  body.page-single .panel,
  body.page-batch .panel {
    padding-bottom: 8px;
  }

  body.page-single .option-panel,
  body.page-batch .option-panel {
    gap: 9px;
  }
}

/* batch page repair: batch has many controls, let the parameter column breathe and scroll */
@media (min-width: 981px) {
  body.page-batch .workspace {
    grid-template-columns: minmax(360px, 450px) minmax(0, 1fr);
    gap: 18px;
  }

  body.page-batch .panel {
    display: grid;
    align-content: start;
    gap: 13px;
    height: 100%;
    padding: 15px 12px 16px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
  }

  body.page-batch .prompt-composer,
  body.page-batch .option-panel,
  body.page-batch .batch-box,
  body.page-batch .save-picker,
  body.page-batch .path-status {
    flex: none;
  }

  body.page-batch .prompt-composer textarea {
    min-height: 120px;
  }

  body.page-batch .model-choice-grid button {
    min-height: 86px;
  }

  body.page-batch .batch-box {
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.54);
    backdrop-filter: blur(10px);
  }

  body.page-batch .folder-drop-zone {
    min-height: 74px;
  }

  body.page-batch .folder-preview {
    max-height: 210px;
  }

  body.page-batch .secondary#batchGenerate {
    position: sticky;
    bottom: 0;
    z-index: 5;
    min-height: 44px;
    margin-top: 2px;
    box-shadow: 0 16px 34px rgba(91, 92, 246, 0.22);
  }

  body.page-batch .results.saved-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-batch .result-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
    gap: 16px;
    min-height: 0;
    overflow: hidden;
  }

  body.page-batch .main-preview,
  body.page-batch .history-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-batch .main-preview {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    overflow: hidden;
    padding-bottom: 12px;
  }

  body.page-batch .batch-preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(248, 251, 255, 0.92);
    backdrop-filter: blur(10px);
  }

  body.page-batch .batch-preview-grid {
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 12px;
    scrollbar-width: thin;
  }

  body.page-batch .history-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  body.page-batch .history {
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 12px;
    scrollbar-width: thin;
  }
}

/* batch page final repair: clean scrollable form, no sticky overlay, history title inside panel */
@media (min-width: 981px) {
  body.page-batch .panel {
    display: block;
    height: 100%;
    padding: 18px 14px 22px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
  }

  body.page-batch .panel > * + * {
    margin-top: 14px;
  }

  body.page-batch .secondary#batchGenerate {
    position: static;
    width: 100%;
    min-height: 46px;
    margin: 16px 0 4px;
    box-shadow: 0 16px 34px rgba(91, 92, 246, 0.2);
  }

  body.page-batch .batch-box {
    display: grid;
    gap: 11px;
    padding: 14px;
    border: 1px solid rgba(199, 210, 254, 0.72);
  }

  body.page-batch .folder-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.page-batch .folder-drop-zone {
    min-height: 88px;
  }

  body.page-batch .folder-preview {
    max-height: 260px;
  }

  body.page-batch .results.saved-panel {
    padding: 14px 0 16px;
  }

  body.page-batch .result-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    align-items: stretch;
  }

  body.page-batch .main-preview {
    padding: 12px;
    border-radius: 22px;
  }

  body.page-batch .batch-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
  }

  body.page-batch .history-panel {
    padding: 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.54);
    overflow: hidden;
  }

  body.page-batch .history-head {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 0 10px;
    padding: 0 0 8px;
    background: rgba(248, 251, 255, 0.9);
    backdrop-filter: blur(10px);
  }

  body.page-batch .history {
    display: grid;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
    padding: 0 4px 12px 0;
  }
}

/* batch hard override: stable scroll columns and softer canvas transitions */
@media (min-width: 981px) {
  body.page-batch {
    background:
      radial-gradient(circle at 16% 18%, rgba(91, 92, 246, 0.10), transparent 34%),
      radial-gradient(circle at 88% 10%, rgba(249, 115, 22, 0.08), transparent 32%),
      linear-gradient(90deg, #f1f3ff 0%, #f8fbff 26%, #ffffff 54%, #fff7ed 100%);
  }

  body.page-batch .app-shell {
    --nav-column-width: 205px;
    --nav-column-gap: 20px;
    --main-column-width: min(1440px, calc(100vw - 280px));
    align-items: stretch;
    padding: 18px 24px 22px;
  }

  body.page-batch .sidebar {
    padding-top: 0;
  }

  body.page-batch .side-nav {
    background: rgba(255, 255, 255, 0.48);
    border-color: rgba(226, 232, 240, 0.62);
  }

  body.page-batch .content {
    height: calc(100vh - 40px);
    overflow: hidden;
  }

  body.page-batch .workspace {
    grid-template-columns: minmax(390px, 470px) minmax(0, 1fr);
    gap: 18px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-batch form.panel#generateForm {
    display: block !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 16px 12px 24px 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.page-batch form.panel#generateForm > * {
    margin-top: 0;
    margin-bottom: 14px;
  }

  body.page-batch form.panel#generateForm > *:last-child {
    margin-bottom: 0;
  }

  body.page-batch .prompt-composer,
  body.page-batch .option-panel,
  body.page-batch .batch-box,
  body.page-batch .save-picker,
  body.page-batch .path-status {
    position: static !important;
    width: 100%;
  }

  body.page-batch .prompt-composer textarea {
    min-height: 150px;
  }

  body.page-batch .model-choice-grid button {
    min-height: 92px;
  }

  body.page-batch .batch-box {
    margin-bottom: 14px;
  }

  body.page-batch .folder-drop-zone {
    min-height: 96px;
  }

  body.page-batch .folder-preview {
    max-height: 280px;
  }

  body.page-batch button#batchGenerate.secondary {
    position: static !important;
    inset: auto !important;
    display: flex;
    width: 100%;
    min-height: 48px;
    margin: 12px 0 8px !important;
    transform: none !important;
  }

  body.page-batch .results.saved-panel {
    height: 100%;
    min-height: 0;
    padding: 16px 0 16px;
    overflow: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  body.page-batch .result-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 18px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.page-batch .main-preview,
  body.page-batch .history-panel {
    height: 100%;
    min-height: 0;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(226, 232, 240, 0.72);
    border-radius: 24px;
    backdrop-filter: blur(12px);
  }

  body.page-batch .main-preview {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 16px;
    overflow: hidden !important;
  }

  body.page-batch .batch-preview-grid {
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding-right: 6px;
    padding-bottom: 12px;
    scrollbar-width: thin;
  }

  body.page-batch .history-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 16px;
    overflow: hidden !important;
  }

  body.page-batch .history-head {
    position: static;
    margin: 0 0 12px;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

  body.page-batch .history {
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding-right: 6px;
    padding-bottom: 12px;
    scrollbar-width: thin;
  }
}

/* toast feedback + refined scroll/transition polish */
.app-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 500;
  max-width: min(560px, calc(100vw - 36px));
  padding: 12px 18px;
  border: 1px solid rgba(199, 210, 254, 0.78);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  box-shadow: 0 18px 52px rgba(15, 23, 42, 0.14);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -18px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(16px);
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.app-toast.ok {
  border-color: rgba(34, 197, 94, 0.26);
  color: #047857;
}

.app-toast.error {
  border-color: rgba(239, 68, 68, 0.28);
  color: #b91c1c;
}

@media (min-width: 981px) {
  body.page-batch form.panel#generateForm,
  body.page-batch .batch-preview-grid,
  body.page-batch .history {
    scrollbar-color: rgba(100, 116, 139, 0.32) transparent;
  }

  body.page-batch form.panel#generateForm::-webkit-scrollbar,
  body.page-batch .batch-preview-grid::-webkit-scrollbar,
  body.page-batch .history::-webkit-scrollbar {
    width: 6px;
  }

  body.page-batch form.panel#generateForm::-webkit-scrollbar-track,
  body.page-batch .batch-preview-grid::-webkit-scrollbar-track,
  body.page-batch .history::-webkit-scrollbar-track {
    background: transparent;
  }

  body.page-batch form.panel#generateForm::-webkit-scrollbar-thumb,
  body.page-batch .batch-preview-grid::-webkit-scrollbar-thumb,
  body.page-batch .history::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.28);
  }

  body.page-batch .content {
    position: relative;
  }

  body.page-batch .content::before {
    position: absolute;
    inset: 48px auto 18px -16px;
    z-index: -1;
    width: 44px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(241, 243, 255, 0), rgba(255, 255, 255, 0.58));
    content: "";
    pointer-events: none;
  }

  body.page-batch .side-nav {
    box-shadow: 0 14px 40px rgba(91, 92, 246, 0.05);
  }

  body.page-batch .main-preview,
  body.page-batch .history-panel,
  body.page-batch .prompt-composer,
  body.page-batch .option-panel,
  body.page-batch .batch-box,
  body.page-batch .save-picker,
  body.page-batch .path-status {
    background: rgba(255, 255, 255, 0.62);
  }
}

/* batch parameter frame: subtle boundary without heavy card feel */
@media (min-width: 981px) {
  body.page-batch form.panel#generateForm {
    padding: 16px 14px 22px !important;
    border: 1px solid rgba(199, 210, 254, 0.68) !important;
    border-radius: 24px !important;
    background: rgba(255, 255, 255, 0.42) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66) !important;
    backdrop-filter: blur(10px);
  }
}

/* global quiet scrollbars: hidden at rest, visible on interaction */
:root {
  --scrollbar-idle: transparent;
  --scrollbar-active: rgba(100, 116, 139, 0.34);
  --scrollbar-active-strong: rgba(79, 70, 229, 0.42);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-idle) transparent;
}

*:hover,
*:focus,
*:focus-within {
  scrollbar-color: var(--scrollbar-active) transparent;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  background-clip: padding-box;
}

*:hover::-webkit-scrollbar-thumb,
*:focus::-webkit-scrollbar-thumb,
*:focus-within::-webkit-scrollbar-thumb {
  background: var(--scrollbar-active);
  background-clip: padding-box;
}

*:hover::-webkit-scrollbar-thumb:hover,
*:focus::-webkit-scrollbar-thumb:hover,
*:focus-within::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-active-strong);
  background-clip: padding-box;
}

body.page-batch form.panel#generateForm,
body.page-batch .batch-preview-grid,
body.page-batch .history,
body.page-single .main-preview,
body.page-single .history,
body.page-gallery .gallery-grid,
body.page-detail .detail-tools,
body.page-detail .detail-result-grid {
  scrollbar-color: var(--scrollbar-idle) transparent;
}

body.page-batch form.panel#generateForm:hover,
body.page-batch form.panel#generateForm:focus-within,
body.page-batch .batch-preview-grid:hover,
body.page-batch .history:hover,
body.page-single .main-preview:hover,
body.page-single .history:hover,
body.page-gallery .gallery-grid:hover,
body.page-detail .detail-tools:hover,
body.page-detail .detail-tools:focus-within,
body.page-detail .detail-result-grid:hover {
  scrollbar-color: var(--scrollbar-active) transparent;
}

/* single page responsive repair: let parameters scroll on shorter screens */
@media (min-width: 981px) {
  body.page-single .panel {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin;
    padding-right: 12px;
  }

  body.page-single .panel::-webkit-scrollbar {
    width: 7px;
  }

  body.page-single .panel::-webkit-scrollbar-track {
    background: transparent;
  }

  body.page-single .panel::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: transparent;
    background-clip: padding-box;
  }

  body.page-single .panel:hover::-webkit-scrollbar-thumb,
  body.page-single .panel:focus-within::-webkit-scrollbar-thumb {
    background: var(--scrollbar-active);
    background-clip: padding-box;
  }
}

@media (min-width: 981px) and (max-height: 900px) {
  body.page-single .panel {
    display: block;
    padding-bottom: 18px;
  }

  body.page-single .panel > * + * {
    margin-top: 10px;
  }

  body.page-single .prompt-composer textarea {
    min-height: 88px;
  }

  body.page-single .model-choice-grid button {
    min-height: 68px;
  }

  body.page-single .primary[type="submit"] {
    position: sticky;
    bottom: 0;
    z-index: 5;
    width: 100%;
    margin-top: 12px;
    margin-bottom: 0;
    box-shadow: 0 16px 34px rgba(91, 92, 246, 0.22);
  }
}

/* final single/admin repair: short screens scroll inside panels, admin is isolated */
@media (min-width: 981px) {
  body.page-single .workspace {
    grid-template-columns: minmax(350px, 410px) minmax(0, 1fr) !important;
    height: 100%;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }

  body.page-single form.panel#generateForm {
    display: block !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    padding: 16px 14px 24px 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    scrollbar-width: thin;
  }

  body.page-single form.panel#generateForm > * {
    margin-top: 0 !important;
    margin-bottom: 12px !important;
  }

  body.page-single form.panel#generateForm > *:last-child {
    margin-bottom: 0 !important;
  }

  body.page-single .prompt-composer,
  body.page-single .option-panel,
  body.page-single .save-picker,
  body.page-single .path-status {
    position: static !important;
    width: 100%;
  }

  body.page-single .prompt-composer {
    padding: 14px;
  }

  body.page-single .prompt-composer textarea {
    min-height: 112px;
  }

  body.page-single .option-panel {
    display: grid;
    gap: 12px;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.page-single .model-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.page-single .model-choice-grid button {
    min-height: 70px;
    padding: 10px;
  }

  body.page-single .option-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  body.page-single .option-buttons button {
    min-height: 36px;
  }

  body.page-single .primary[type="submit"] {
    position: static !important;
    inset: auto !important;
    display: flex;
    width: 100%;
    min-height: 46px;
    margin: 14px 0 4px !important;
    transform: none !important;
  }

  body.page-single form.panel#generateForm:hover,
  body.page-single form.panel#generateForm:focus-within {
    scrollbar-color: var(--scrollbar-active) transparent;
  }
}

@media (min-width: 981px) and (max-height: 860px) {
  body.page-single .content {
    gap: 8px;
  }

  body.page-single form.panel#generateForm {
    padding-top: 10px !important;
    padding-bottom: 18px !important;
  }

  body.page-single form.panel#generateForm > * {
    margin-bottom: 9px !important;
  }

  body.page-single .save-picker {
    min-height: 40px;
    padding: 10px 12px;
  }

  body.page-single .path-status {
    padding: 8px 12px;
  }

  body.page-single .prompt-composer {
    padding: 12px;
  }

  body.page-single .prompt-composer textarea {
    min-height: 82px;
  }

  body.page-single .model-choice-grid button {
    min-height: 58px;
  }

  body.page-single .model-choice-grid small {
    -webkit-line-clamp: 1;
  }

  body.page-single .option-buttons {
    gap: 6px;
  }

  body.page-single .option-buttons button,
  body.page-single .compact-options button,
  body.page-single .format-choice-grid button {
    min-height: 32px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
}

body.admin-page.admin-authenticated-page {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(91, 92, 246, 0.08), transparent 34%),
    linear-gradient(135deg, #f8fafc 0%, #fff7ed 100%);
}

body.admin-page.admin-authenticated-page .app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

body.admin-page.admin-authenticated-page .sidebar {
  position: static;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 16px;
  width: 270px;
  height: 100vh;
  min-height: 0;
  padding: 20px 14px;
  border-right: 1px solid rgba(226, 232, 240, 0.88);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 18px 0 54px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

body.admin-page.admin-authenticated-page .brand {
  min-width: 0;
  padding: 4px 8px 10px;
}

body.admin-page.admin-authenticated-page .side-nav.admin-side-nav {
  display: grid;
  justify-content: stretch;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 8px;
}

body.admin-page.admin-authenticated-page .side-nav.admin-side-nav button {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 3px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 16px;
  text-align: left;
}

body.admin-page.admin-authenticated-page .side-nav.admin-side-nav span {
  font-size: 14px;
}

body.admin-page.admin-authenticated-page .side-nav.admin-side-nav small {
  font-size: 11px;
  line-height: 1.25;
}

body.admin-page.admin-authenticated-page .side-status {
  margin-top: 0;
  padding: 12px;
  border-color: rgba(226, 232, 240, 0.78);
  background: rgba(248, 250, 252, 0.74);
}

body.admin-page.admin-authenticated-page .side-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  border-color: rgba(226, 232, 240, 0.95);
  background: #ffffff;
  color: #475569;
  font-size: 13px;
  line-height: 1.2;
  opacity: 1;
  visibility: visible;
  box-shadow: none;
}

body.admin-page.admin-authenticated-page .side-logout:hover {
  background: #f8fafc;
  color: #0f172a;
}

body.admin-page.admin-authenticated-page .content {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 16px;
  width: auto;
  height: 100vh;
  min-height: 0;
  margin: 0;
  padding: 22px 24px 28px;
  overflow: hidden;
}

body.admin-page.admin-authenticated-page .page-head {
  min-height: 48px;
  padding: 0;
  justify-content: flex-start;
}

body.admin-page.admin-authenticated-page .page-head > div:first-child {
  display: block;
  margin-right: auto;
}

body.admin-page.admin-authenticated-page .admin-workspace:not(.hidden) {
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 8px 28px 0;
}

body.admin-page.admin-authenticated-page .admin-panel,
body.admin-page.admin-authenticated-page .admin-card {
  width: 100%;
  max-width: none;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.07);
}

body.admin-page.admin-authenticated-page .admin-tab-panel {
  min-width: 0;
}

body.admin-page.admin-authenticated-page .grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.admin-page.admin-authenticated-page .grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  body.admin-page.admin-authenticated-page .app-shell {
    grid-template-columns: 238px minmax(0, 1fr);
  }

  body.admin-page.admin-authenticated-page .sidebar {
    width: 238px;
  }

  body.admin-page.admin-authenticated-page .content {
    padding-right: 18px;
    padding-left: 18px;
  }

  body.admin-page.admin-authenticated-page .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body.admin-page.admin-authenticated-page {
    overflow: auto;
  }

  body.admin-page.admin-authenticated-page .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  body.admin-page.admin-authenticated-page .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    max-height: 52vh;
    border-right: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.88);
  }

  body.admin-page.admin-authenticated-page .content {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

body.admin-page.admin-authenticated-page .grid.two,
body.admin-page.admin-authenticated-page .grid.three {
  grid-template-columns: 1fr;
}
}

/* final layout guard: keep common ratios compact and history title inside the panel */
body.page-single .option-buttons[data-option-group="aspectRatio"],
body.page-batch .option-buttons[data-option-group="aspectRatio"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

body.page-single .option-buttons[data-option-group="aspectRatio"] button,
body.page-batch .option-buttons[data-option-group="aspectRatio"] button {
  min-width: 0;
  min-height: 34px;
  padding: 4px 6px;
  line-height: 1;
}

body.page-single .history-panel,
body.page-batch .history-panel {
  padding: 18px 18px 16px;
}

body.page-single .history-head,
body.page-batch .history-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin: 0 0 12px;
  padding: 0 2px;
  overflow: visible;
}

body.page-single .history-head strong,
body.page-batch .history-head strong {
  min-width: 0;
  line-height: 1.2;
}

body.page-single .history-head span,
body.page-batch .history-head span {
  flex: 0 0 auto;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  line-height: 24px;
}

body.page-single .history-thumb,
body.page-batch .history-thumb {
  align-items: start !important;
  grid-template-columns: 104px minmax(0, 1fr) !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 16px !important;
  overflow: hidden !important;
}

body.page-single .thumb-media,
body.page-batch .thumb-media {
  align-self: start;
  width: 104px !important;
}

body.page-single .thumb-meta,
body.page-batch .thumb-meta {
  align-content: start !important;
  grid-auto-rows: max-content;
  gap: 7px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

body.page-single .history-actions,
body.page-batch .history-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  justify-content: start;
  align-items: center;
  width: min(100%, 226px);
  gap: 8px !important;
  margin-top: 4px !important;
  overflow: hidden;
}

body.page-single .history-actions .history-download,
body.page-batch .history-actions .history-download {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none;
  min-height: 32px !important;
  padding: 0 10px !important;
  text-align: center;
}

@media (max-width: 520px) {
  body.page-single .history-thumb,
  body.page-batch .history-thumb {
    grid-template-columns: 86px minmax(0, 1fr) !important;
    gap: 12px;
    padding: 14px !important;
  }

  body.page-single .thumb-media,
  body.page-batch .thumb-media {
    width: 86px !important;
  }

  body.page-single .history-actions,
  body.page-batch .history-actions {
    width: 100%;
    max-width: 198px;
    gap: 7px !important;
  }

  body.page-single .history-actions .history-download,
  body.page-batch .history-actions .history-download {
    min-height: 30px !important;
    padding: 0 8px !important;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  body.page-single .history-actions,
  body.page-batch .history-actions {
    grid-template-columns: 1fr !important;
    max-width: 128px;
  }
}

@media (min-width: 981px) and (max-height: 860px) {
  body.page-single .option-buttons[data-option-group="aspectRatio"],
  body.page-batch .option-buttons[data-option-group="aspectRatio"] {
    gap: 6px;
  }

  body.page-single .option-buttons[data-option-group="aspectRatio"] button,
  body.page-batch .option-buttons[data-option-group="aspectRatio"] button {
    min-height: 32px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
}

/* history card repair: keep single/batch side history readable in narrow panels */
body.page-single .history,
body.page-batch .history {
  gap: 12px !important;
}

body.page-single .history-thumb,
body.page-batch .history-thumb {
  display: grid !important;
  grid-template-columns: 82px minmax(0, 1fr) !important;
  gap: 12px !important;
  align-items: start !important;
  min-height: 118px !important;
  padding: 12px !important;
  border-radius: 14px !important;
  overflow: visible !important;
}

body.page-single .thumb-media,
body.page-batch .thumb-media {
  width: 82px !important;
  height: 82px !important;
  min-width: 82px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 12px !important;
}

body.page-single .thumb-media img,
body.page-batch .thumb-media img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

body.page-single .thumb-meta,
body.page-batch .thumb-meta {
  display: grid !important;
  align-content: start !important;
  gap: 5px !important;
  min-width: 0 !important;
  overflow: visible !important;
}

body.page-single .thumb-meta strong,
body.page-batch .thumb-meta strong {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

body.page-single .thumb-meta span,
body.page-batch .thumb-meta span {
  max-height: 32px !important;
  overflow: hidden !important;
  line-height: 1.35 !important;
}

body.page-single .history-actions,
body.page-batch .history-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px !important;
  width: 100% !important;
  margin-top: 2px !important;
  overflow: visible !important;
}

body.page-single .history-actions .history-download,
body.page-batch .history-actions .history-download {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 28px !important;
  padding: 0 6px !important;
  font-size: 10px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

/* history action repair: buttons stay inside each side-history card */
body.page-single .history-thumb,
body.page-batch .history-thumb {
  grid-template-columns: 82px minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  min-height: 154px !important;
  align-items: start !important;
  overflow: hidden !important;
}

body.page-single .thumb-media,
body.page-batch .thumb-media {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

body.page-single .thumb-meta,
body.page-batch .thumb-meta {
  grid-column: 2 !important;
  grid-row: 1 / span 2 !important;
  display: grid !important;
  grid-template-rows: auto auto auto auto !important;
  align-content: start !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body.page-single .history-actions,
body.page-batch .history-actions {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 6px !important;
  margin-top: 6px !important;
  padding-top: 0 !important;
  overflow: visible !important;
}

body.page-single .history-actions .history-download,
body.page-batch .history-actions .history-download {
  min-height: 30px !important;
  height: 30px !important;
  padding: 0 6px !important;
  border-radius: 999px !important;
}

/* history action repair v2: compact one-row actions in side history */
body.page-single .history-thumb,
body.page-batch .history-thumb {
  grid-template-columns: 78px minmax(0, 1fr) !important;
  grid-template-rows: auto !important;
  min-height: 122px !important;
  padding: 11px !important;
  gap: 11px !important;
  overflow: hidden !important;
}

body.page-single .thumb-media,
body.page-batch .thumb-media {
  width: 78px !important;
  height: 78px !important;
  min-width: 78px !important;
}

body.page-single .thumb-meta,
body.page-batch .thumb-meta {
  grid-column: 2 !important;
  grid-row: 1 !important;
  display: grid !important;
  gap: 4px !important;
  overflow: hidden !important;
}

body.page-single .thumb-meta span,
body.page-batch .thumb-meta span {
  max-height: 30px !important;
  line-height: 1.28 !important;
}

body.page-single .history-actions,
body.page-batch .history-actions {
  display: flex !important;
  flex-wrap: nowrap !important;
  grid-template-columns: none !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 3px !important;
  margin-top: 2px !important;
  overflow: visible !important;
}

body.page-single .history-actions .history-download,
body.page-batch .history-actions .history-download {
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 3px !important;
  border-radius: 999px !important;
  font-size: 9px !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
}

/* history action repair v3: full-width one-row actions below thumbnail/meta */
body.page-single .history-thumb,
body.page-batch .history-thumb {
  grid-template-columns: 78px minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  min-height: 142px !important;
  padding: 11px !important;
  gap: 9px 11px !important;
  overflow: hidden !important;
}

body.page-single .thumb-media,
body.page-batch .thumb-media {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: 78px !important;
  height: 78px !important;
  min-width: 78px !important;
}

body.page-single .thumb-meta,
body.page-batch .thumb-meta {
  grid-column: 2 !important;
  grid-row: 1 !important;
  overflow: hidden !important;
}

body.page-single .history-actions,
body.page-batch .history-actions {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 5px !important;
  margin-top: 0 !important;
  overflow: visible !important;
}

body.page-single .history-actions .history-download,
body.page-batch .history-actions .history-download {
  width: 100% !important;
  min-width: 0 !important;
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 5px !important;
  border-radius: 999px !important;
  font-size: 10px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

/* Transparent background checkbox for GPT image model */
.transparent-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.transparent-toggle input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
  accent-color: #111827;
}

.transparent-toggle:hover {
  border-color: rgba(17, 24, 39, 0.3);
  background: rgba(255, 255, 255, 0.92);
}

.transparent-toggle strong {
  display: block;
  font-size: 13px;
  color: #111827;
}

.transparent-toggle small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
}

.site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 24;
  display: flex;
  justify-content: center;
  padding: 0 16px 1px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  pointer-events: none;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}

.site-footer a:hover {
  color: #94a3b8;
  text-decoration: underline;
}

@media (max-width: 720px) {
  .site-footer {
    font-size: 10px;
  }
}
