:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fbfaf7;
  --surface-2: #ffffff;
  --line: rgba(38, 36, 31, 0.14);
  --line-strong: rgba(38, 36, 31, 0.24);
  --ink: #24231f;
  --muted: #74716a;
  --soft: #eeece6;
  --accent: #5f6f62;
  --accent-ink: #29342b;
  --ok: #2d7b4f;
  --danger: #b94a45;
  --gold: #c48a21;
  --focus: #7c8f80;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

.topbar {
  height: 58px;
  display: grid;
  grid-template-columns: 240px auto minmax(340px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--line);
  background: rgba(251, 250, 247, 0.96);
}

.brand-title {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a9aaa2;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.16);
}

.connection-dot.online {
  background: var(--ok);
}

.connection-dot.offline {
  background: var(--danger);
}

.view-tabs {
  display: inline-flex;
  width: max-content;
  padding: 3px;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.view-tab {
  height: 32px;
  min-width: 98px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}

.view-tab.active {
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 25, 22, 0.07);
}

.top-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 136px auto;
  gap: 10px;
  justify-self: stretch;
}

input,
select,
textarea {
  min-width: 0;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}

input,
select {
  height: 34px;
  padding: 0 10px;
}

textarea {
  padding: 9px 10px;
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid rgba(124, 143, 128, 0.42);
  outline-offset: 2px;
}

.app-shell {
  height: calc(100vh - 90px);
  display: grid;
  grid-template-columns: 238px minmax(360px, 1fr) 340px;
  min-height: 0;
}

.sidebar,
.detail-panel {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}

.sidebar {
  border-right: 0.5px solid var(--line);
  padding: 14px 12px;
}

.sidebar-section {
  margin-bottom: 18px;
}

.sidebar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
}

summary.sidebar-label {
  cursor: pointer;
  list-style: none;
}

summary.sidebar-label::-webkit-details-marker {
  display: none;
}

.filter-list {
  display: grid;
  gap: 3px;
}

.filter-button {
  width: 100%;
  min-height: 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.filter-button:hover,
.filter-button.active {
  background: var(--soft);
  color: var(--ink);
}

.filter-count {
  min-width: 26px;
  padding: 1px 6px;
  border: 0.5px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.main-panel {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.content-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 14px;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--line);
  background: rgba(246, 245, 241, 0.96);
}

.result-title {
  font-weight: 500;
}

.result-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.button,
.tool-button,
.quick-button,
.reviewer-button {
  height: 32px;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 500;
}

.button {
  padding: 0 12px;
}

.reviewer-button {
  max-width: 170px;
  padding: 0 10px;
  overflow: hidden;
  color: var(--accent-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button.primary {
  border-color: rgba(95, 111, 98, 0.42);
  background: #eef1ec;
  color: var(--accent-ink);
}

.button.subtle {
  color: var(--muted);
}

.button:disabled,
.tool-button:disabled,
.quick-button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.asset-card {
  position: relative;
  display: grid;
  grid-template-rows: 148px 42px;
  overflow: hidden;
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.asset-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 18px rgba(37, 34, 29, 0.08);
}

.asset-card.selected {
  border-color: rgba(95, 111, 98, 0.78);
  box-shadow: 0 0 0 2px rgba(95, 111, 98, 0.16);
}

.asset-card.multi-selected {
  box-shadow: 0 0 0 2px rgba(196, 138, 33, 0.22);
}

.asset-card.pulse {
  animation: pulse 1s ease-out 1;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(95, 111, 98, 0.42); }
  100% { box-shadow: 0 0 0 18px rgba(95, 111, 98, 0); }
}

.thumb-area,
.preview-checker,
.compare-image-wrap,
.lightbox-stage.checker {
  background-color: #deddd8;
  background-image:
    linear-gradient(45deg, #c8c7c2 25%, transparent 25%),
    linear-gradient(-45deg, #c8c7c2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c8c7c2 75%),
    linear-gradient(-45deg, transparent 75%, #c8c7c2 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.thumb-area {
  width: 100%;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.thumb-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.select-box {
  position: absolute;
  top: 9px;
  left: 9px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  opacity: 0;
  transition: opacity 120ms ease;
}

.asset-card:hover .select-box,
.asset-card.multi-selected .select-box {
  opacity: 1;
}

.status-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #9b9890;
}

.status-mark.passed {
  border-color: var(--ok);
  background: var(--ok);
}

.status-mark.rejected {
  border-color: var(--danger);
  background: var(--danger);
}

.star-mark {
  position: absolute;
  top: 24px;
  right: 7px;
  color: var(--gold);
  font-size: 15px;
  line-height: 1;
}

.consensus-badge {
  position: absolute;
  top: 8px;
  left: 34px;
  min-width: 48px;
  max-width: 78px;
  padding: 2px 6px;
  border: 0.5px solid rgba(38, 36, 31, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.quick-actions {
  position: absolute;
  left: 50%;
  top: 104px;
  display: inline-flex;
  gap: 5px;
  padding: 5px;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  opacity: 0;
  transform: translate(-50%, 6px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.asset-card:hover .quick-actions {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.quick-button,
.tool-button {
  width: 32px;
  padding: 0;
}

.quick-button.active,
.tool-button.active {
  border-color: rgba(95, 111, 98, 0.52);
  background: #eef1ec;
}

.quick-button.pass.active,
.tool-button.pass.active {
  border-color: var(--ok);
  color: var(--ok);
}

.quick-button.reject.active,
.tool-button.reject.active {
  border-color: var(--danger);
  color: var(--danger);
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 9px 10px;
  border-top: 0.5px solid var(--line);
}

.filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.chip {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
}

.detail-panel {
  border-left: 0.5px solid var(--line);
  position: relative;
}

.detail-close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  font-weight: 500;
}

.detail-close-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.detail-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.detail-content {
  display: grid;
  gap: 16px;
  padding: 52px 14px 14px;
}

.detail-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}

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

.preview-checker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 238px;
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
}

.preview-checker img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  image-rendering: pixelated;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.consensus-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.meta-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 12px;
}

.meta-row dd,
.meta-row dt {
  margin: 0;
}

.meta-row dd {
  color: var(--ink);
  word-break: break-all;
}

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

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.segment {
  height: 31px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.segment.active {
  background: var(--surface-2);
  color: var(--ink);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.promote-grid {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 8px;
}

.promote-grid .button {
  grid-column: 1 / -1;
}

.statusbar {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-top: 0.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(36, 35, 31, 0.42);
}

.gate-panel {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: 0 18px 48px rgba(37, 34, 29, 0.18);
}

.gate-panel h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.gate-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.gate-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

.gate-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 8px;
}

.modal,
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  background: rgba(31, 30, 27, 0.94);
  color: #fbfaf7;
}

.modal {
  grid-template-rows: 48px 1fr;
}

.modal-bar,
.lightbox-toolbar {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.18);
}

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

.modal-title,
.lightbox-title {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 10px;
}

.compare-item {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.compare-image-wrap {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.compare-image-wrap img {
  max-width: none;
  max-height: none;
  image-rendering: pixelated;
}

.compare-caption {
  padding: 8px 10px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.lightbox {
  grid-template-rows: auto minmax(0, 1fr);
}

.lightbox-toolbar {
  grid-template-columns: auto auto minmax(0, 1fr) repeat(10, auto);
  min-height: 48px;
}

.lightbox-back-button {
  min-width: 86px;
  height: 36px;
  padding: 0 14px;
  border: 0.5px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fbfaf7;
  cursor: pointer;
  font-weight: 600;
}

.lightbox-back-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-stage {
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.lightbox-stage.dragging {
  cursor: grabbing;
}

.lightbox-stage.checker {
  background-color: #3c3b38;
  background-image:
    linear-gradient(45deg, #4a4945 25%, transparent 25%),
    linear-gradient(-45deg, #4a4945 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #4a4945 75%),
    linear-gradient(-45deg, transparent 75%, #4a4945 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.image-layer {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#fullImage {
  display: block;
  max-width: none;
  image-rendering: pixelated;
  user-select: none;
}

.pixel-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
  opacity: 0.8;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 210px minmax(320px, 1fr);
  }

  .detail-panel {
    position: fixed;
    top: 58px;
    right: 0;
    bottom: 32px;
    z-index: 20;
    width: min(360px, 92vw);
    transform: translateX(100%);
    transition: transform 160ms ease;
    box-shadow: -10px 0 26px rgba(38, 36, 31, 0.12);
  }

  .detail-panel.open {
    transform: translateX(0);
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    grid-template-columns: 1fr;
  }

  .top-controls {
    grid-template-columns: 1fr;
  }

  .reviewer-button {
    max-width: none;
  }

  .app-shell {
    height: auto;
    min-height: calc(100vh - 126px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 260px;
    border-right: 0;
    border-bottom: 0.5px solid var(--line);
  }

  .statusbar {
    position: sticky;
    bottom: 0;
  }

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