:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --topbar: #374151;
  --topbar-button: #273240;
  --panel: #ffffff;
  --panel-border: #e7eaf0;
  --line: #d9dee8;
  --text: #334155;
  --muted: #7b8698;
  --strong: #1f2937;
  --primary: #3b4453;
  --primary-hover: #2f3744;
  --secondary: #eef1f6;
  --secondary-hover: #e5e9f1;
  --success-bg: #ecfdf5;
  --success: #047857;
  --danger-bg: #fef2f2;
  --danger: #b91c1c;
  --shadow: 0 10px 32px rgba(15, 23, 42, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
}

.app-body {
  padding: 0 0 56px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.shell,
.login-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.page-shell {
  display: grid;
  gap: 20px;
  padding: 36px 20px 0;
}

.topbar {
  background: var(--topbar);
  color: white;
}

.topbar-inner {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
}

.topbar-actions,
.hero-actions,
.toolbar-actions,
.dropzone-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-actions {
  flex-wrap: wrap;
}

.brand {
  color: #f8fafc;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel {
  padding: 26px 28px;
}

.upload-panel {
  padding-bottom: 22px;
}

.content-panel {
  padding-top: 22px;
}

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

.panel-header {
  margin-bottom: 20px;
}

.panel-header h1,
.simple-head h2,
.login-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.35rem);
  line-height: 1.1;
  font-weight: 400;
  color: var(--strong);
  letter-spacing: 0.01em;
}

.simple-head h2 {
  font-size: 1.5rem;
}

.panel-description,
.hero-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.badge,
.eyebrow,
.dropzone-mark {
  display: none;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button.secondary,
.button.subtle,
.button.ghost {
  background: var(--secondary);
  color: var(--strong);
  border-color: #dce2ec;
}

.button.secondary:hover:not(:disabled),
.button.subtle:hover:not(:disabled),
.button.ghost:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.button.danger {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.button.topbar-button {
  background: var(--topbar-button);
  border-color: transparent;
  color: white;
}

.button.topbar-button:hover:not(:disabled) {
  background: #1f2937;
}

.button.full {
  width: 100%;
}

.panel-head,
.toolbar,
.manage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.simple-head {
  margin-bottom: 14px;
}

.toolbar {
  margin-top: 18px;
}

.toolbar-note {
  color: var(--muted);
  font-size: 0.95rem;
}

.dropzone {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
}

.dropzone.is-active {
  border-color: #b8c1ce;
  background: #fbfcfe;
}

.dropzone.is-disabled {
  cursor: progress;
}

.dropzone.has-items {
  min-height: 200px;
}

.dropzone-empty {
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 8px 0;
  text-align: center;
}

.dropzone-icon {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f2f4f8;
  color: #6b7280;
  font-size: 2.5rem;
  font-weight: 600;
}

.dropzone h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
}

.dropzone p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.dropzone-footer {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin-top: auto;
}

.dropzone-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 0.92rem;
  cursor: pointer;
}

.dropzone-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.queue-list,
.result-grid,
.manage-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.queue-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.queue-list.upload-queue {
  width: 100%;
  margin-top: 0;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.result-grid,
.manage-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.thumb-card,
.result-card,
.manage-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--panel-border);
}

.thumb-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  padding: 14px;
}

.thumb-card.is-uploading {
  border-color: #cbd5e1;
}

.thumb-card.is-success {
  border-color: #bbf7d0;
}

.thumb-card.is-failed {
  border-color: #fecaca;
}

.result-card,
.manage-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.content-panel .result-card {
  grid-template-columns: 172px 1fr;
  align-items: start;
  border-radius: var(--radius-sm);
}

.content-panel .result-card .card-actions {
  grid-column: 2;
}

.content-panel .preview-frame {
  aspect-ratio: 16 / 10;
}

.preview-tile,
.preview-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.preview-tile {
  aspect-ratio: 1 / 1;
}

.preview-frame {
  aspect-ratio: 4 / 3;
}

.preview-trigger {
  appearance: none;
  border: none;
  padding: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: zoom-in;
}

.preview-tile img,
.preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-body,
.meta-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.thumb-head,
.meta-topline,
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meta-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-chip.status-success {
  background: var(--success-bg);
  color: var(--success);
}

.status-chip.status-failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-chip.status-uploading {
  background: #eff6ff;
  color: #2563eb;
}

.meta-title {
  font-weight: 600;
  color: var(--strong);
  word-break: break-word;
}

.meta-line {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.error-line {
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card-actions .button {
  padding: 9px 13px;
  font-size: 0.92rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
  padding: 20px;
  line-height: 1.75;
  background: #fafbfc;
}

.status-text {
  min-height: 1.6em;
  margin: 14px 0 0;
  color: var(--muted);
}

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

.status-text.is-success {
  color: var(--success);
}

.hidden {
  display: none !important;
}

.search-field {
  display: grid;
  gap: 10px;
  min-width: min(100%, 320px);
  color: var(--strong);
  font-weight: 500;
}

.search-field input {
  width: 100%;
  border: 1px solid #dce2ec;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  color: var(--strong);
  background: #fff;
  outline: none;
}

.search-field input:focus {
  border-color: #94a3b8;
}

.login-brand {
  margin-bottom: 20px;
  color: var(--strong);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.preview-dialog {
  position: relative;
  width: min(960px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 18px;
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  overflow: auto;
  z-index: 1;
}

.preview-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #dce2ec;
  border-radius: 999px;
  background: #fff;
  color: var(--strong);
  font-size: 1.25rem;
  cursor: pointer;
}

.preview-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.preview-caption {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.7;
  word-break: break-word;
}

.select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.select-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

@media (max-width: 900px) {
  .topbar-inner,
  .panel-head,
  .toolbar,
  .manage-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .toolbar-actions,
  .dropzone-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    min-height: 72px;
    padding: 0 14px;
  }

  .panel,
  .login-card {
    padding: 18px;
  }

  .page-shell {
    padding: 20px 14px 0;
    gap: 16px;
  }

  .dropzone {
    min-height: 220px;
    padding: 28px 18px;
  }

  .thumb-card {
    grid-template-columns: 72px 1fr;
  }

  .content-panel .result-card {
    grid-template-columns: 1fr;
  }

  .content-panel .result-card .card-actions {
    grid-column: auto;
  }
}
