:root {
  --bg: #eef1e8;
  --ink: #17211d;
  --muted: #5e6a62;
  --panel: rgba(255, 252, 245, 0.82);
  --line: rgba(23, 33, 29, 0.12);
  --shadow: 0 18px 50px rgba(31, 44, 38, 0.12);
  --accent: #236a52;
  --accent-2: #d96c38;
  --accent-soft: rgba(35, 106, 82, 0.12);
  --warn: #a85b2a;
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-ui: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 108, 56, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(35, 106, 82, 0.18), transparent 30%),
    linear-gradient(180deg, #f6f0e6 0%, #eef1e8 48%, #e5ede6 100%);
}

.app-shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

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

.hero h1 {
  margin: 0;
  max-width: 980px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
}

.hero-text,
.panel-head p,
.summary-text,
.progress-note,
.file-drop-meta,
.zoom-meta,
#labelCountText {
  color: var(--muted);
}

.hero-text {
  max-width: 820px;
  margin-top: 14px;
  font-size: 16px;
  line-height: 1.6;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px);
}

.status-ok {
  color: var(--accent);
}

.status-warn {
  color: var(--warn);
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.upload-panel,
.result-summary {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 22px;
}

.upload-form {
  display: grid;
  gap: 16px;
}

.file-drop {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 146px;
  padding: 24px;
  border: 1px dashed rgba(35, 106, 82, 0.4);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 250, 241, 0.72)),
    var(--accent-soft);
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop-title {
  font-size: 22px;
  font-weight: 800;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.primary-btn,
.ghost-btn,
.card-btn,
.close-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-btn {
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #184c3d);
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.primary-btn:hover,
.ghost-btn:hover,
.card-btn:hover,
.close-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

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

.progress-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(23, 33, 29, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 240ms ease;
}

.fill-upload {
  background: linear-gradient(90deg, #d96c38, #efab66);
}

.fill-analysis {
  background: linear-gradient(90deg, #236a52, #5fb887);
}

.result-shell {
  margin-top: 22px;
  display: grid;
  gap: 18px;
}

.result-shell.is-hidden {
  display: none;
}

.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 430px);
  gap: 18px;
  align-items: start;
}

.page-panel,
.labels-panel {
  min-height: 520px;
  padding: 20px;
}

.page-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.page-stage {
  overflow: auto;
  max-height: 78vh;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(17, 24, 21, 0.03), rgba(17, 24, 21, 0.08));
}

.page-canvas {
  position: relative;
  min-height: 120px;
}

.page-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 18px 38px rgba(12, 19, 16, 0.2);
}

.overlay-box {
  position: absolute;
  border: 2px solid var(--box-color, var(--accent));
  background: color-mix(in srgb, var(--box-color, var(--accent)) 16%, transparent);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.overlay-box:hover,
.overlay-box.is-active {
  transform: translateZ(0) scale(1.01);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

.overlay-tag {
  position: absolute;
  top: -11px;
  left: -2px;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--box-color, var(--accent));
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.labels-panel {
  position: sticky;
  top: 14px;
}

.label-cards {
  display: grid;
  gap: 12px;
  max-height: 76vh;
  overflow: auto;
  padding-right: 4px;
}

.label-card {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(23, 33, 29, 0.08);
  background: rgba(255, 255, 255, 0.76);
  transition: transform 130ms ease, border 130ms ease, box-shadow 130ms ease;
}

.label-card:hover,
.label-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(35, 106, 82, 0.24);
  box-shadow: 0 16px 28px rgba(31, 44, 38, 0.08);
}

.label-thumb {
  width: 136px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  background: #f1f3ed;
  border: 1px solid var(--line);
}

.label-body {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.label-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.label-title h3 {
  margin: 0;
  font-size: 16px;
}

.label-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.meta-list {
  display: grid;
  gap: 6px;
}

.meta-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
}

.meta-row--highlight {
  grid-template-columns: 52px minmax(0, 1fr);
  background: rgba(35, 106, 82, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 4px 6px 4px 8px;
  margin: 0 -6px;
}

.meta-row--highlight .meta-key {
  color: var(--accent);
}

.meta-row--highlight .meta-value {
  font-weight: 700;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: 12px;
  color: var(--ink);
}

.meta-key {
  color: var(--muted);
  font-weight: 700;
}

.meta-value {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.card-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(23, 33, 29, 0.06);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.card-btn.primary {
  background: rgba(35, 106, 82, 0.14);
  color: var(--accent);
}

.zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.zoom-modal.is-hidden {
  display: none;
}

.zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 15, 0.68);
  backdrop-filter: blur(4px);
}

.zoom-dialog {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: 16px auto;
  padding: 18px;
  display: grid;
  gap: 14px;
  border-radius: 24px;
  background: #fffdf9;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(23, 33, 29, 0.08);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.zoom-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding-right: 56px;
}

.zoom-header h3 {
  margin: 0;
  font-size: 26px;
}

.zoom-body {
  overflow: auto;
  max-height: calc(100vh - 180px);
  border-radius: 18px;
  background: linear-gradient(180deg, #f5f1e9, #eceee7);
  border: 1px solid var(--line);
  padding: 18px;
}

.zoom-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  box-shadow: 0 18px 34px rgba(18, 26, 22, 0.18);
}

@media (max-width: 1080px) {
  .result-layout {
    grid-template-columns: 1fr;
  }

  .labels-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 18px;
  }

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

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

  .label-card {
    grid-template-columns: 1fr;
  }

  .label-thumb {
    width: 100%;
    height: auto;
    max-height: 220px;
  }
}
