:root {
  --bg: #f3f7fc;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --border: #d8e5f4;
  --border-strong: #b8cce4;
  --text: #10233f;
  --muted: #667b96;
  --blue: #2563eb;
  --blue-dark: #1746b6;
  --blue-soft: #e7f0ff;
  --cyan: #0f8ea8;
  --green: #16835b;
  --red: #c2413d;
  --amber: #a16207;
  --shadow: 0 18px 60px rgba(15, 35, 64, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 0 14px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.ghost-button {
  background: var(--panel-soft);
}

#file-input {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  min-height: 0;
  padding: 22px;
  gap: 16px;
}

.topbar,
.site-footer {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

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

.topbar h1,
.panel h2,
.result-summary h2,
.result-block h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 5px;
}

.topbar-actions,
.queue-actions,
.block-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 4px;
}

.mode-segments {
  display: flex;
  gap: 4px;
}

.mode-button {
  border-color: transparent;
  background: transparent;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.mode-button.active {
  border-color: var(--blue);
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(330px, 420px);
  min-height: 0;
  overflow: hidden;
  gap: 16px;
}

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

.queue-panel,
.result-panel,
.preview-panel {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.queue-panel,
.result-panel {
  flex-direction: column;
  padding: 16px;
}

.preview-panel {
  flex-direction: column;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.queue-head-actions,
.summary-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-head-actions .primary-button {
  min-height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.summary-head {
  justify-content: space-between;
}

.summary-head .section-kicker {
  margin-bottom: 0;
}

.summary-head button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.25;
}

.count-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  min-height: 28px;
  padding: 0 10px;
  white-space: nowrap;
}

.count-pill {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill {
  background: #eef2f7;
  color: var(--muted);
}

.status-pill.done {
  background: #e8f7ef;
  color: var(--green);
}

.status-pill.ai {
  background: #fff1f0;
  color: var(--red);
}

.status-pill.processing {
  background: #e6f5ff;
  color: var(--cyan);
}

.status-pill.error {
  background: #fff6db;
  color: var(--amber);
}

.queue-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 14px 0;
}

.queue-actions button {
  flex: 1;
}

#clear-queue {
  grid-column: 1 / -1;
}

.review-button {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.review-button:hover:not(:disabled) {
  background: var(--blue);
  color: #fff;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: center;
  padding: 16px;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone strong {
  color: var(--text);
  font-size: 16px;
}

.drop-zone span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.drop-zone.dragging {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.queue-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  margin-top: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.queue-item {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  transition: border-color 160ms ease, background 160ms ease;
}

.queue-item:hover,
.queue-item.active {
  border-color: var(--blue);
  background: #f7fbff;
}

.queue-select {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  width: 100%;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.queue-select:hover {
  border-color: transparent;
  color: inherit;
}

.queue-select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.queue-item img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #eef2f7;
}

.queue-item-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.queue-item-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.queue-meta {
  min-width: 0;
}

.queue-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tiny-meter {
  flex: 1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.tiny-meter span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
}

.preview-head {
  align-items: center;
}

.file-title {
  min-width: 0;
}

.file-title h2 {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-stage {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 420px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #f2f6fb 25%, transparent 25%),
    linear-gradient(-45deg, #f2f6fb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f2f6fb 75%),
    linear-gradient(-45deg, transparent 75%, #f2f6fb 75%),
    #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  overflow: hidden;
}

.image-stage img {
  align-self: center;
  justify-self: center;
  display: none;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 28px);
  border: 1px solid rgba(16, 35, 63, 0.12);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.image-stage.has-image img {
  display: block;
}

.empty-state {
  align-self: center;
  justify-self: center;
  max-width: 320px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 17px;
  margin-bottom: 0;
}

.image-stage.has-image .empty-state {
  display: none;
}

.result-summary {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
  padding: 16px;
}

.result-summary h2 {
  font-size: 22px;
  line-height: 1.25;
}

.cloud-progress {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.cloud-progress[hidden] {
  display: none;
}

.cloud-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.cloud-progress-head span,
.cloud-progress p {
  color: var(--muted);
}

.cloud-progress-track {
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #edf3fa;
}

.cloud-progress-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 500ms ease;
}

.cloud-progress p {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(0, 1fr);
  align-items: end;
  gap: 14px;
  margin-top: 16px;
}

#score-number {
  display: block;
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
}

.score-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 6px;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef6;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 220ms ease;
}

.meter span.ai {
  background: linear-gradient(90deg, #f59e0b, #dc2626);
}

.detail-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  margin: 14px 0 0;
}

.feedback-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 10px;
  background: #f3f8ff;
}

.feedback-strip[hidden] {
  display: none;
}

.feedback-strip strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.feedback-strip span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.feedback-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.feedback-actions button {
  min-height: 32px;
  padding: 0 12px;
  border-color: rgba(37, 99, 235, 0.24);
  color: #1d4ed8;
  background: #fff;
}

.feedback-actions button:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.44);
  background: #eaf2ff;
}

.result-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.block-head {
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  padding: 0 14px;
}

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

.block-head button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  max-height: 300px;
  overflow: auto;
  margin: 0;
}

.metric-grid div {
  border-bottom: 1px solid var(--border);
  min-width: 0;
  padding: 12px 14px;
}

.metric-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
}

.metric-grid dd {
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.evidence-block {
  flex: 1;
}

.evidence-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.evidence-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
}

.evidence-item + .evidence-item {
  margin-top: 10px;
}

.evidence-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.evidence-category {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.evidence-impact {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.evidence-message {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
  margin: 0;
  overflow-wrap: anywhere;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-height: 42px;
  padding: 12px 16px;
}

.site-footer {
  overflow: hidden;
}

.release-privacy {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(420px, 1.65fr);
  border-bottom: 1px solid var(--border);
}

.release-privacy section {
  min-width: 0;
  padding: 12px 16px;
}

.release-privacy section + section {
  border-left: 1px solid var(--border);
}

.release-privacy h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.release-privacy p:last-child {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.legal-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 34px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 16px;
}

.legal-line a {
  color: var(--muted);
  text-decoration: none;
}

.legal-line a:hover {
  color: var(--blue);
  text-decoration: underline;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(260px, 320px) minmax(420px, 1fr);
    grid-template-rows: minmax(460px, 1fr) minmax(420px, auto);
    overflow: auto;
  }

  .result-panel {
    grid-column: 1 / -1;
    min-height: 420px;
  }
}

@media (max-width: 880px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-actions button {
    flex: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: visible;
  }

  .queue-panel,
  .preview-panel,
  .result-panel {
    min-height: 360px;
  }

  .queue-panel {
    height: min(560px, calc(100vh - 24px));
  }

  .image-stage {
    min-height: 340px;
  }

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

  .release-privacy {
    grid-template-columns: 1fr;
  }

  .release-privacy section + section {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .statusbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

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