:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #657084;
  --line: #d9e0ea;
  --line-strong: #bac6d8;
  --accent: #176b87;
  --accent-strong: #0d5068;
  --accent-soft: #e4f3f7;
  --danger: #b42318;
  --shadow: 0 18px 46px rgba(23, 32, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4f8 0, rgba(245, 247, 251, 0) 320px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.page-header h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 280px;
}

.header-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  width: auto;
  min-height: 32px;
  margin: 0;
  padding: 0 12px;
  box-shadow: none;
  font-size: 0.88rem;
}

.auth-shell {
  display: grid;
  width: min(920px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0;
  place-items: center;
}

.auth-panel {
  width: 100%;
  max-width: 560px;
  padding: 26px;
}

.auth-panel h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

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

.auth-form {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-form h2 {
  margin-bottom: 16px;
  font-size: 1.12rem;
}

.auth-form label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}

.auth-form input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(23, 107, 135, 0.16);
}

.auth-message {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(23, 107, 135, 0.22);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.auth-message.error {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff1f0;
  color: var(--danger);
}

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

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.uploader,
.results {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
  line-height: 1.25;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.dropzone {
  display: flex;
  min-height: 214px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    transform 140ms ease;
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.dropzone input {
  display: none;
}

.dropzone-kicker {
  width: fit-content;
  margin-bottom: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #dcebf0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.dropzone-title {
  margin-bottom: 8px;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.35;
}

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

button {
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  transition:
    background-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
  box-shadow: 0 12px 24px rgba(23, 107, 135, 0.2);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(23, 107, 135, 0.2);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.button-link:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.button-link.secondary {
  border: 1px solid rgba(23, 107, 135, 0.24);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.button-link.secondary:hover {
  background: #d7ecf2;
}

.button-link.compact {
  width: auto;
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.62;
  cursor: progress;
  transform: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.preview-shell {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.preview-shell img {
  display: block;
  width: 100%;
  max-height: 420px;
  border-radius: 6px;
  object-fit: contain;
  background: #e8edf4;
}

.result-preview-grid .preview-shell img {
  max-height: 360px;
}

.status {
  max-width: 260px;
  min-height: 36px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.result-block,
.raw-output-shell {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.batch-panel {
  margin-top: 18px;
  padding: 20px;
}

.batch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 20px;
  align-items: start;
}

.batch-layout h2 {
  margin-bottom: 8px;
  font-size: 1.28rem;
}

.batch-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.7;
}

.batch-form {
  display: grid;
  gap: 12px;
}

.folder-picker {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.35;
  padding: 0 14px;
  text-align: center;
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}

.folder-picker:hover,
.folder-picker:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.folder-picker input {
  display: none;
}

.batch-form button {
  margin-top: 0;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 0 0 14px;
}

.filter-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.filter-form select,
.filter-form input {
  min-height: 36px;
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.filter-form button {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 0 14px;
  box-shadow: none;
  font-size: 0.88rem;
}

.batch-progress-shell {
  margin-top: 18px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.table-shell {
  margin-top: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}

.inline-form {
  margin: 0;
}

.inline-form button {
  width: auto;
  min-height: 34px;
  margin: 0;
  padding: 0 12px;
  background: var(--danger);
  box-shadow: none;
  font-size: 0.84rem;
}

.recharge-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.recharge-form input {
  width: 86px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font: inherit;
}

.recharge-form input[name="note"] {
  width: 120px;
}

.recharge-form button {
  background: var(--accent);
}

.muted-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(5, 56px);
  gap: 8px;
  margin-bottom: 8px;
}

.thumb-button {
  display: block;
  width: 56px;
  height: 76px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.thumb-button:focus-visible {
  outline: 3px solid rgba(23, 107, 135, 0.35);
  outline-offset: 2px;
}

.oss-thumb {
  display: block;
  width: 56px;
  height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  contain: paint;
  object-fit: cover;
}

.lazy-thumb:not([src]) {
  background:
    linear-gradient(135deg, rgba(23, 107, 135, 0.08), rgba(148, 163, 184, 0.12)),
    var(--surface-soft);
}

.oss-link {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.image-viewer-open {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-viewer.hidden {
  display: none;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
}

.image-viewer-panel {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  grid-template-rows: minmax(0, 1fr) 32px;
  align-items: center;
  width: min(100%, 1180px);
  height: min(94vh, 900px);
  padding: 20px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.14);
}

.image-viewer-image {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
  box-shadow: none;
}

.image-viewer-close,
.image-viewer-nav {
  appearance: none;
  display: grid;
  place-items: center;
  position: relative;
  min-height: 0;
  margin-top: 0;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.08);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.image-viewer-close:hover,
.image-viewer-nav:hover:not(:disabled) {
  border-color: rgba(23, 107, 135, 0.38);
  background: #fff;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.14);
  transform: translateY(-1px);
}

.image-viewer-close::before,
.image-viewer-close::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.image-viewer-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.image-viewer-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.image-viewer-nav::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: "";
}

.image-viewer-prev::before {
  transform: translate(-35%, -50%) rotate(-135deg);
}

.image-viewer-next::before {
  transform: translate(-65%, -50%) rotate(45deg);
}

.image-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
}

.image-viewer-nav {
  justify-self: center;
  width: 42px;
  height: 42px;
}

.image-viewer-prev {
  grid-column: 1;
  grid-row: 1;
}

.image-viewer-next {
  grid-column: 3;
  grid-row: 1;
}

.image-viewer-nav:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}

.image-viewer-counter {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: center;
  align-self: end;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

td {
  line-height: 1.55;
}

td:has(.thumb-grid) {
  min-width: 344px;
}

tr:last-child td {
  border-bottom: 0;
}

.batch-title-cell {
  min-width: 280px;
  color: var(--accent-strong);
  font-weight: 800;
}

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

.result-block.highlight {
  border-color: rgba(23, 107, 135, 0.26);
  background: var(--accent-soft);
}

.result-block h3,
.raw-output-shell h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.result-block p {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.7;
  word-break: break-word;
}

#formatted-output-text {
  color: var(--accent-strong);
  font-size: 1.08rem;
  font-weight: 850;
}

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

.fact {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.fact-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.fact-value {
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

pre {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: #273348;
  font-size: 0.86rem;
  line-height: 1.6;
}

.hidden {
  display: none;
}

@media (max-width: 940px) {
  .workspace-grid,
  .dropzone-grid,
  .preview-grid,
  .facts-grid,
  .batch-layout {
    grid-template-columns: 1fr;
  }

  .page-header,
  .result-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-meta {
    justify-content: flex-start;
    min-width: 0;
  }

  .status {
    max-width: none;
  }

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

}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 24px, 1480px);
    padding-top: 24px;
  }

  .uploader,
  .results {
    padding: 16px;
  }

  .thumb-grid {
    grid-template-columns: repeat(3, 56px);
  }

  td:has(.thumb-grid) {
    min-width: 216px;
  }

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