:root {
  color-scheme: light;
  --bg: #f2f6fb;
  --panel: rgba(255,255,255,.92);
  --soft: #edf3fa;
  --ink: #172033;
  --muted: #65738a;
  --line: #d6e0ec;
  --blue: #1677ff;
  --green: #0aa872;
  --red: #d84c4c;
  --shadow: 0 22px 60px rgba(44, 64, 96, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22,119,255,.08), transparent 32%),
    linear-gradient(315deg, rgba(10,168,114,.10), transparent 34%),
    var(--bg);
}

button, input, textarea {
  font: inherit;
}

.app {
  width: min(1320px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 16px;
}

.capturePanel, .resultPanel {
  background: var(--panel);
  border: 1px solid rgba(214,224,236,.9);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.capturePanel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 14px 30px rgba(22,119,255,.22);
}

.logo span {
  width: 24px;
  height: 24px;
  border: 5px solid white;
  border-radius: 50%;
  position: relative;
}

.logo span::before, .logo span::after {
  content: "";
  position: absolute;
  background: white;
}

.logo span::before {
  width: 11px;
  height: 5px;
  left: 1px;
  top: -11px;
  border-radius: 3px;
}

.logo span::after {
  width: 5px;
  height: 5px;
  right: -12px;
  top: -5px;
  border-radius: 50%;
}

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

h1 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p, .footnote {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.badges span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.modePanel, .apiPanel {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.modeButtons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.modeButtons button {
  min-height: 40px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
}

.modeButtons button.active {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(22,119,255,.18);
}

.modeButtons button:disabled {
  cursor: wait;
  opacity: .68;
}

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

.apiRow {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 76px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus, textarea:focus {
  border-color: rgba(22,119,255,.72);
  box-shadow: 0 0 0 4px rgba(22,119,255,.10);
}

.modePanel p, .apiPanel p {
  color: var(--blue);
  font-size: 12px;
  line-height: 1.5;
}

button, .fileButton {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
}

.apiRow button, .wideButton, .primary {
  color: white;
  background: var(--blue);
}

.sourceTabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.sourceTabs button {
  height: 42px;
  color: var(--muted);
  background: white;
  border-radius: 0;
}

.sourceTabs button.active {
  color: white;
  background: var(--blue);
}

.cameraFrame {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #e7f1ff, #effaf5);
}

video, #preview, canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

video.active, #preview.active {
  display: block;
}

.emptyState {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.emptyState strong {
  color: var(--ink);
  font-size: 20px;
}

.captureActions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.captureActions button, .fileButton, .wideButton {
  min-height: 44px;
}

.captureActions button, .fileButton {
  display: grid;
  place-items: center;
  color: var(--ink);
  border: 1px solid var(--line);
  background: white;
}

.captureActions button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--soft);
  opacity: .68;
}

.wideButton {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

#fileInput {
  display: none;
}

.resultPanel {
  min-height: calc(100vh - 32px);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metrics div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metrics strong {
  font-size: 22px;
}

.resultCard, .historyPanel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.resultCard {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.resultHero {
  display: grid;
  grid-template-columns: 154px 1fr;
  gap: 18px;
  align-items: center;
}

.thumbBox {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.thumbBox img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.thumbBox img.active {
  display: block;
}

.resultLabel {
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}

h2 {
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.15;
}

.resultMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.resultMeta span, .chips span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#descriptionText {
  color: #263247;
  line-height: 1.72;
}

.sectionBlock {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sectionBlock h3, .historyHeader h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

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

ul {
  margin: 0;
  padding-left: 20px;
  color: #263247;
  line-height: 1.7;
}

.safety {
  padding: 14px;
  border: 1px solid rgba(10,168,114,.25);
  border-radius: 12px;
  background: #eefaf5;
}

.historyPanel {
  padding: 16px;
}

.historyHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.historyHeader button {
  height: 34px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

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

.historyItem {
  width: 82px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.historyItem img {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid transparent;
}

.historyItem:hover img {
  border-color: var(--blue);
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    width: min(100vw - 18px, 640px);
    margin: 9px auto;
  }

  .resultPanel {
    min-height: 680px;
  }

  .resultHero {
    grid-template-columns: 110px 1fr;
  }

  h2 {
    font-size: 23px;
  }
}

@media (max-width: 520px) {
  .capturePanel, .resultPanel {
    padding: 14px;
    border-radius: 12px;
  }

  .captureActions, .metrics {
    grid-template-columns: 1fr;
  }

  .sourceTabs, .apiRow {
    grid-template-columns: 1fr;
  }

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

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

  .thumbBox {
    max-width: 180px;
  }
}

/* MoonToTop Lab skin */
:root {
  color-scheme: dark;
  --bg: #020609;
  --panel: rgba(7, 17, 23, .82);
  --panel-strong: rgba(10, 24, 31, .94);
  --soft: rgba(255,255,255,.055);
  --ink: #f6fbff;
  --muted: #9aa7b4;
  --line: rgba(99, 237, 255, .18);
  --blue: #63edff;
  --green: #86ffbf;
  --red: #ff6d6d;
  --shadow: 0 30px 90px rgba(0,0,0,.46);
}

html {
  background: #020609;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 18%, rgba(99,237,255,.12), transparent 28%),
    radial-gradient(circle at 78% 72%, rgba(134,255,191,.08), transparent 26%),
    linear-gradient(180deg, rgba(7,17,23,.92), #020609 42%, #000);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .32;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.65) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(99,237,255,.38) 0 1px, transparent 1.4px);
  background-size: 140px 140px, 220px 220px;
  background-position: 20px 36px, 80px 120px;
}

.labShell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.labHeader {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.labBrand, .labNav {
  display: flex;
  align-items: center;
}

.labBrand {
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.labBrand b,
.eyebrow {
  color: var(--blue);
}

.labMark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.48);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.04), 0 0 24px rgba(99,237,255,.12);
  position: relative;
}

.labMark::before,
.labMark::after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(99,237,255,.72);
  border-radius: 50%;
}

.labMark::after {
  inset: 18px 8px;
  border-radius: 999px;
}

.labNav {
  gap: 10px;
}

.labNav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: rgba(246,251,255,.78);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
}

.labNav a:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(99,237,255,.08);
}

.app {
  width: 100%;
  min-height: calc(100vh - 116px);
  margin: 0;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 18px;
}

.capturePanel,
.resultPanel,
.resultCard,
.historyPanel,
.metrics div,
.modePanel,
.apiPanel {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.capturePanel {
  border-radius: 18px;
}

.resultPanel {
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(99,237,255,.08), transparent 28%),
    var(--panel);
}

.brand {
  align-items: flex-start;
}

.logo {
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(99,237,255,.08);
  border: 1px solid var(--line);
  box-shadow: 0 0 28px rgba(99,237,255,.12);
}

.logo span {
  border-color: var(--blue);
}

.logo span::before,
.logo span::after {
  background: var(--blue);
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 11px;
  font-weight: 900;
}

h1, h2, h3,
.emptyState strong {
  color: var(--ink);
}

.brand p,
.footnote,
label,
.badges span,
.resultMeta span,
.chips span,
.historyItem,
.metrics span {
  color: var(--muted);
}

.badges span,
.resultMeta span,
.chips span,
.sourceTabs,
.captureActions button,
.fileButton,
input,
textarea,
.thumbBox,
.historyHeader button {
  border-color: var(--line);
  background: rgba(255,255,255,.055);
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: rgba(154,167,180,.72);
}

input:focus,
textarea:focus {
  border-color: rgba(99,237,255,.78);
  box-shadow: 0 0 0 4px rgba(99,237,255,.10);
}

.modePanel p,
.apiPanel p,
.resultLabel {
  color: var(--blue);
}

.modeButtons button,
.sourceTabs button {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255,255,255,.05);
}

.modeButtons button.active,
.sourceTabs button.active,
.apiRow button,
.wideButton,
.primary {
  color: #001014;
  border-color: rgba(99,237,255,.82);
  background: linear-gradient(135deg, #63edff, #86ffbf);
  box-shadow: 0 12px 28px rgba(99,237,255,.16);
}

.cameraFrame {
  border-color: var(--line);
  background:
    linear-gradient(145deg, rgba(99,237,255,.10), rgba(134,255,191,.05)),
    rgba(0,0,0,.30);
}

#descriptionText,
ul {
  color: rgba(246,251,255,.82);
}

.safety {
  border-color: rgba(134,255,191,.24);
  background: rgba(134,255,191,.06);
}

.historyItem:hover img {
  border-color: var(--blue);
  box-shadow: 0 0 18px rgba(99,237,255,.22);
}

@media (max-width: 920px) {
  .labShell {
    width: min(100vw - 18px, 680px);
    padding: 12px 0;
  }

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

  .app {
    width: 100%;
    grid-template-columns: 1fr;
  }
}
