:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #0d0d0f;
  --muted: #77777d;
  --line: #ececef;
  --soft: #f6f6f7;
  --danger: #bd3045;
  --danger-bg: #fdecef;
  --positive: #20884e;
  --negative: #43a963;
  --accent: #0d0d0f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f4f5;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  position: relative;
  width: min(100%, 440px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.topbar {
  height: 58px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
}

.brand {
  padding: 70px 28px 22px;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 28px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #9a9aa0;
  font-size: 17px;
  font-weight: 800;
  padding: 18px 0 16px;
  position: relative;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--ink);
}

.view {
  display: none;
  padding: 32px 28px;
}

.view.is-active {
  display: block;
}

.camera-card {
  width: 100%;
  min-height: 238px;
  border: 0;
  border-radius: 16px;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.camera-icon {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #262629;
  color: #d7d7da;
  font-size: 38px;
}

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

.camera-subtitle {
  color: #9a9aa0;
  font-size: 16px;
  font-weight: 500;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  color: #a1a1a7;
  margin: 38px 0;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.outline-button,
.primary-button {
  width: 100%;
  min-height: 70px;
  border-radius: 16px;
  font-weight: 800;
  border: 1.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
}

.primary-button {
  border-color: #000;
  background: #000;
  color: #fff;
}

.compact {
  min-height: 52px;
  border-radius: 8px;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.gallery-list {
  display: grid;
  gap: 18px;
}

.gallery-card {
  display: grid;
  gap: 10px;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1.45;
  overflow: hidden;
  background: var(--soft);
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.image-date {
  color: #5f6066;
  font-size: 14px;
  font-weight: 500;
}

.gallery-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 42px;
  gap: 10px;
}

.ghost-button,
.delete-button {
  border: 0;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.ghost-button {
  background: var(--soft);
  color: #55565c;
}

.delete-button {
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 22px;
}

.result-view {
  padding-top: 30px;
}

.result-view h2 {
  margin: 0 0 24px;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: 0;
}

.result-preview {
  margin-bottom: 24px;
}

#roiCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 372px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 14px 13px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

th {
  background: #f7f7f8;
  color: var(--ink);
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  color: var(--ink);
  font-weight: 600;
}

.positive {
  color: var(--ink);
}

.negative {
  color: var(--ink);
}

.result-actions {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 12px;
  margin-top: 28px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120px);
  width: min(360px, calc(100vw - 32px));
  background: #151517;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.loading-overlay {
  position: absolute;
  z-index: 20;
  inset: 58px 0 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-panel {
  display: grid;
  justify-items: center;
  gap: 16px;
  transform: translateY(-22px);
}

.loading-spinner {
  position: relative;
  width: 44px;
  height: 44px;
  animation: spin 1s steps(12) infinite;
}

.loading-spinner span {
  position: absolute;
  left: 20px;
  top: 3px;
  width: 5px;
  height: 12px;
  border-radius: 999px;
  background: #f2f2f3;
  transform-origin: 2.5px 19px;
}

.loading-spinner span:nth-child(1) {
  opacity: 1;
  transform: rotate(0deg);
}

.loading-spinner span:nth-child(2) {
  opacity: 0.92;
  transform: rotate(30deg);
}

.loading-spinner span:nth-child(3) {
  opacity: 0.84;
  transform: rotate(60deg);
}

.loading-spinner span:nth-child(4) {
  opacity: 0.76;
  transform: rotate(90deg);
}

.loading-spinner span:nth-child(5) {
  opacity: 0.68;
  transform: rotate(120deg);
}

.loading-spinner span:nth-child(6) {
  opacity: 0.6;
  transform: rotate(150deg);
}

.loading-spinner span:nth-child(7) {
  opacity: 0.52;
  transform: rotate(180deg);
}

.loading-spinner span:nth-child(8) {
  opacity: 0.44;
  transform: rotate(210deg);
}

.loading-spinner span:nth-child(9) {
  opacity: 0.36;
  transform: rotate(240deg);
}

.loading-spinner span:nth-child(10) {
  opacity: 0.28;
  transform: rotate(270deg);
}

.loading-spinner span:nth-child(11) {
  opacity: 0.2;
  transform: rotate(300deg);
}

.loading-spinner span:nth-child(12) {
  opacity: 0.12;
  transform: rotate(330deg);
}

.loading-text {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 360px) {
  .brand,
  .tabs,
  .view {
    padding-left: 20px;
    padding-right: 20px;
  }

  th,
  td {
    padding: 12px 9px;
    font-size: 14px;
  }
}
