:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #657282;
  --line: #d9e0e7;
  --accent: #d9363e;
  --accent-dark: #b5252c;
  --blue: #2563a9;
  --green: #148461;
  --shadow: 0 18px 50px rgba(23, 33, 43, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(217, 54, 62, 0.06), transparent 36%),
    var(--bg);
  color: var(--ink);
}

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

.color-text-field {
  display: none;
}

.color-picker {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.color-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.color-chip input {
  width: auto;
  margin: 0;
}

.color-chip:has(input:checked) {
  border-color: var(--blue);
  background: rgba(37, 99, 169, 0.08);
}

.color-chip:has(input:disabled:not(:checked)) {
  opacity: 0.45;
}

.swatch {
  width: 16px;
  height: 16px;
  border: 1px solid #c8d1da;
  border-radius: 50%;
  background: var(--swatch);
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 26px;
  font-weight: 900;
}

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

.brand h1 {
  font-size: 21px;
}

.brand p,
.tool-panel p,
.empty-state p {
  color: var(--muted);
  line-height: 1.6;
}

.mode-tabs {
  display: grid;
  gap: 10px;
}

.tab-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: 0.18s ease;
}

.tab-button:hover,
.tab-button.active {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.06);
}

.filter-panel,
.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 33, 43, 0.05);
}

.filter-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel-heading,
.topbar,
.button-row,
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading h2 {
  font-size: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 169, 0.13);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

.content-area {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 48px);
}

.topbar {
  margin-bottom: 22px;
}

.price-progress {
  min-height: 22px;
  margin: -10px 0 18px;
  font-weight: 800;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(26px, 4vw, 42px);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 11px 15px;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.ghost-button,
.icon-button {
  background: transparent;
  color: var(--muted);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 25px;
}

.full-width {
  width: 100%;
}

.file-button {
  cursor: pointer;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.summary-strip div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
}

.summary-strip strong {
  display: block;
  font-size: 28px;
}

.summary-strip span {
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.car-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 26px rgba(23, 33, 43, 0.07);
}

.car-image {
  display: grid;
  height: 170px;
  place-items: center;
  overflow: hidden;
  background: #e9eef3;
}

.car-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  padding: 6px;
  background: white;
}

.fallback-car {
  position: relative;
  width: 138px;
  height: 58px;
  border-radius: 18px 28px 12px 12px;
  background: currentColor;
  color: #d9363e;
}

.fallback-car::before {
  position: absolute;
  top: 10px;
  left: 34px;
  width: 52px;
  height: 22px;
  border-radius: 16px 16px 4px 4px;
  background: rgba(255, 255, 255, 0.72);
  content: "";
}

.fallback-car::after {
  position: absolute;
  right: 16px;
  bottom: -10px;
  left: 18px;
  height: 20px;
  background:
    radial-gradient(circle at 10px 10px, #17212b 0 9px, transparent 10px),
    radial-gradient(circle at calc(100% - 10px) 10px, #17212b 0 9px, transparent 10px);
  content: "";
}

.car-body {
  display: grid;
  gap: 10px;
  padding: 15px;
}

.car-title {
  display: block;
  min-height: 48px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-data {
  display: grid;
  gap: 6px;
}

.card-data p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.info-list {
  display: grid;
  gap: 8px;
}

.info-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.info-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.info-row strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef2f6;
  color: #42505e;
  font-size: 12px;
  font-weight: 800;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.source-link-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.source-link-row a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.workflow-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr);
  gap: 18px;
}

.tool-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.upload-zone {
  display: grid;
  min-height: 112px;
  place-items: center;
  border: 2px dashed #b9c4cf;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
}

.upload-zone input {
  display: none;
}

.preview-frame,
.dialog-preview,
.image-result {
  display: grid;
  overflow: hidden;
  min-height: 180px;
  place-items: center;
  border-radius: 8px;
  background: #e9eef3;
}

.preview-frame img,
.dialog-preview img,
.image-result img {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.result-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.result-row span,
.status-line {
  color: var(--muted);
}

.lens-results {
  display: grid;
  gap: 10px;
}

.lens-main-link,
.lens-link-list a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.lens-link-list {
  display: grid;
  gap: 8px;
}

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

.batch-queue {
  display: grid;
  gap: 8px;
}

.camera-panel {
  display: grid;
  gap: 10px;
}

.camera-panel video {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  object-fit: cover;
}

.batch-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.batch-file-list {
  display: grid;
  max-height: 150px;
  overflow: auto;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.batch-file-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.batch-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.batch-item.error {
  border-color: rgba(217, 54, 62, 0.35);
  background: rgba(217, 54, 62, 0.06);
}

.batch-item img {
  width: 96px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f6;
}

.batch-item strong,
.batch-item p {
  display: block;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.batch-item p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.duplicate-box {
  display: grid;
  gap: 6px;
  border-radius: 8px;
  padding: 18px;
}

.duplicate-box.neutral {
  background: #eef2f6;
}

.duplicate-box.hit {
  background: rgba(217, 54, 62, 0.1);
  color: #961c23;
}

.duplicate-box.clear {
  background: rgba(20, 132, 97, 0.1);
  color: #0e694d;
}

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-match {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.mini-match img {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f6;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  text-align: center;
}

.hidden {
  display: none;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(14, 24, 35, 0.44);
}

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mode-tabs,
  .summary-strip,
  .workflow-grid,
  .form-grid,
  .source-link-row {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .content-area,
  .sidebar {
    padding: 18px;
  }

  .card-actions,
  .button-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }
}
