:root {
  color-scheme: dark;
  --mark-ink: #d5e3fc;
  --mark-wave: #72cbd6;
  --page: #0b1020;
  --panel: #11192d;
  --surface: #17223b;
  --line: #2c3a59;
  --ink: #f3f6ff;
  --text: #dce5fb;
  --muted: #abb8d2;
  --blue: #a5b7ff;
  --violet: #c0c6fc;
  --primary: linear-gradient(115deg, #3b51ba, #5c56b7);
  --gutter: clamp(22px, 5.25vw, 80px);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 75% 0, #283a6f66, transparent 42rem),
    var(--page);
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
[hidden] { display: none !important; }
main, .header-inner, .site-footer { width: min(100% - var(--gutter) * 2, 1280px); margin-inline: auto; }

.header { border-bottom: 1px solid var(--line); background: #0e1528; --nav-hover: #a3adff1f; --nav-active: #9992ea2d; --nav-ink: #e4e3ff; }
.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.36;
  white-space: nowrap;
  transition: background .18s, border-color .18s, box-shadow .18s, color .18s;
}
.button.primary {
  background: var(--primary);
  box-shadow: 0 4px 14px #0608105c, inset 0 1px #ffffff37;
  border-color: #b0a6fa54;
  color: white;
}
.button.primary:not(:disabled):hover { box-shadow: 0 4px 18px #7a64d14d, inset 0 1px #ffffff60; }
.button.primary:disabled { background: #343957; border-color: #555b7e; color: #bdc1d7; box-shadow: none; }
.button.subtle { color: var(--text); background: #242737; border-color: #35394d; }
.button.subtle:hover { background: #2d3249; border-color: #4c5273; }
.button.quiet-button { color: var(--muted); }
.button.quiet-button:hover { color: var(--ink); background: #a3adff12; }
.button.full { width: 100%; min-height: 46px; }
.upload-button { background: #2b3e78; color: #f2f5ff; border-color: #5064a7; }
.upload-button:hover { background: #868bff2b; border-color: var(--blue); }
.notice {
  margin-bottom: 16px;
  border: 1px solid #7267ad69;
  border-radius: 10px;
  background: #342b53;
  color: #efebff;
  padding: 11px 15px;
  line-height: 1.6;
}

.viewer-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 22px 56px #0005;
  overflow: clip;
}
.viewer-toolbar {
  background: #151e35;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
}
.viewer-toolbar:has(.loading:not([hidden])) { flex-wrap: wrap; }
.viewer-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; margin-left: auto; }
.return-button { font-size: 13px; }
.drawn-icon { width: 16px; height: 16px; display: inline-block; flex: none; position: relative; }
.fullscreen-icon {
  background:
    linear-gradient(currentColor, currentColor) left top / 5px 1.5px,
    linear-gradient(currentColor, currentColor) left top / 1.5px 5px,
    linear-gradient(currentColor, currentColor) right top / 5px 1.5px,
    linear-gradient(currentColor, currentColor) right top / 1.5px 5px,
    linear-gradient(currentColor, currentColor) left bottom / 5px 1.5px,
    linear-gradient(currentColor, currentColor) left bottom / 1.5px 5px,
    linear-gradient(currentColor, currentColor) right bottom / 5px 1.5px,
    linear-gradient(currentColor, currentColor) right bottom / 1.5px 5px;
  background-repeat: no-repeat;
  width: 13px;
  height: 13px;
}
.camera-icon::before {
  content: "";
  position: absolute;
  inset: 4px 0 1px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.camera-icon::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  inset: 7px 5px auto;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.upload-icon { border: 1.5px solid currentColor; border-width: 0 1.5px 1.5px; height: 8px; border-radius: 0 0 3px 3px; margin-top: 6px; }
.upload-icon::before, .upload-icon::after { content: ""; position: absolute; left: 50%; }
.upload-icon::before { width: 1.5px; height: 10px; background: currentColor; top: -7px; transform: translateX(-50%); }
.upload-icon::after { width: 6px; height: 6px; top: -7px; border: 1.5px solid currentColor; border-width: 1.5px 0 0 1.5px; transform: translate(-50%) rotate(45deg); }

.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 288px; }
.stage { min-width: 0; height: clamp(470px, 41vw, 620px); position: relative; background: #000; }
.stage canvas { display: block; width: 100%; height: 100%; background: #000; cursor: grab; touch-action: none; }
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline-offset: -4px; }
.stage:fullscreen { width: 100vw; height: 100vh; background: #000; }
.exit-fullscreen { display: none; }
.stage:fullscreen .exit-fullscreen { position: absolute; display: inline-flex; top: 16px; right: 16px; }
.point-card {
  position: absolute;
  top: 18px;
  left: 18px;
  border: 1px solid #5d608578;
  border-radius: 12px;
  background: #1e2033;
  padding: 13px 42px 13px 15px;
  color: var(--text);
}
.point-card span, .point-card small { display: block; font-size: 12px; color: var(--muted); }
.point-card strong { display: block; font-size: 25px; padding: 4px 0; font-variant-numeric: tabular-nums; color: var(--ink); }
.point-card .icon-button { position: absolute; top: 5px; right: 4px; }

.control-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 20px 19px 17px;
  background: linear-gradient(170deg, #17233e, #111a2d 75%);
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-heading h2 { font-size: 17px; font-weight: 650; margin: 0; }
.text-button { border: 0; background: none; color: #b6bef5; min-height: 34px; padding: 5px 0; font-size: 13px; }
.text-button:hover { color: #f0ecff; }
.control-group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.control-group label, .control-label { color: var(--text); font-size: 14px; }
.control-panel select, .upload-options select {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #3a3f57;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 10px;
  font-size: 14px;
}
.control-panel select { display: block; width: 100%; margin-top: 8px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 11px; }
.response-controls .control-row { margin-top: 0; }
.stepper { display: inline-grid; grid-template-columns: 34px 47px 34px; align-items: center; background: #121b30; border: 1px solid #3a4a6a; border-radius: 8px; overflow: hidden; }
.stepper button { height: 40px; padding: 0; border: 0; border-radius: 0; background: #263450; color: #e3e4ff; font-size: 16px; }
.stepper button:hover { background: #373b56; }
.stepper :focus-visible { outline-offset: -2px; }
.stepper output, .stepper input { text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); }
.stepper input { appearance: textfield; min-width: 0; width: 100%; height: 40px; background: none; border: 0; padding: 0 2px; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.view-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 9px; }
.view-grid button {
  min-height: 40px;
  padding: 0 2px;
  background: #22304a;
  color: var(--text);
  border: 1px solid #364768;
  border-radius: 7px;
  white-space: nowrap;
  font-size: 13px;
  transition: background .18s, color .18s;
}
.view-grid button:is(:hover, [aria-pressed="true"]) { background: #394d7e; border-color: #778abe; color: white; }
.heat-legend { margin-top: 13px; }
.heat-spectrum {
  height: 5px;
  border-radius: 5px;
  border: 1px solid #ffffff24;
  background: linear-gradient(90deg, #382131, #931b3e 33%, #df402c 63%, #ffd879);
}
.heat-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.panel-note { color: var(--muted); font-size: 14px; line-height: 1.64; margin: 14px 0 0; }

.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px 24px;
  padding: 8px 16px;
  min-height: 47px;
  background: #151f36;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.data-info, .loading { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; }
.loading { font-size: 13px; color: var(--muted); }
.data-info span:first-child, .loading strong { font-weight: 600; color: var(--text); }
.data-info span:first-child::before { content: ""; display: inline-block; margin-right: 8px; vertical-align: 2px; width: 6px; height: 6px; border-radius: 50%; background: #a091f7; }
.loading small { font-size: 12px; }
.loading .text-button { padding: 0; }
.gesture-note { text-align: right; }
.gesture-note:only-child, .data-info[hidden] + .gesture-note { margin-left: auto; }
.gesture-note span { padding-inline: 4px; color: #7a82a7; }
.spinner { width: 14px; height: 14px; flex: none; border: 1.5px solid #747da857; border-top-color: #b2a3ff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.history-card {
  margin-top: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 15px;
  padding: 23px 25px 4px;
}
table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; }
th, td { padding: 11px 8px; border-top: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; }
th:first-child { width: 56%; }
th:last-child { width: 130px; }
th:last-child, td:last-child { text-align: right; }
.job-name { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-size, .job-error { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.job-error { color: #f2acb8; }
.job-stage { color: var(--text); font-size: 13px; line-height: 1.5; }
.job-stage.done { color: #c4b6fc; }
.job-stage.failed { color: #f4b3bf; }
.row-action { min-height: 40px; padding: 0 11px; background: #252940; color: #dadbff; border: 1px solid #383c59; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.row-action:hover { background: #343b60; }
.empty-state { padding: 28px 0; color: var(--muted); }
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 26px 0 34px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  background: #1b1e30;
  color: var(--ink);
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 23px;
  border: 1px solid #434763;
  border-radius: 17px;
  box-shadow: 0 20px 65px #0009;
}
dialog::backdrop { background: #090a14c9; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; font-size: 21px; font-weight: 650; }
dialog p { color: var(--muted); margin: 10px 0 14px; line-height: 1.65; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 7px; padding: 0; flex: none; color: var(--text); background: none; font-size: 21px; }
.icon-button:hover { background: #35394e; color: var(--ink); }
.dropzone {
  padding: 20px 12px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 9px;
  background: #262941;
  border: 1px dashed #636a99;
  border-radius: 11px;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.dropzone:is(:hover, .dragging) { background: #2f3455; border-color: #a2adff; }
.dropzone strong { font-size: 16px; }
.dropzone small { color: var(--muted); font-size: 13px; line-height: 1.6; }
.drop-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; background: #3a3f65; color: #cccaff; }
.file-detail { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; margin-top: 10px; background: #292d43; border-radius: 8px; }
.file-detail > span { min-width: 0; }
.file-detail strong, .file-detail small { display: block; }
.file-detail strong { overflow-wrap: anywhere; font-size: 13px; }
.file-detail small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.upload-options, .upload-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0; color: var(--text); }
.upload-status { justify-content: flex-start; margin-bottom: 0; font-size: 13px; }
.upload-status button { margin-left: auto; }
.upload-error { color: #ffb7c3; font-size: 12px; }
.upload-error:empty { display: none; }
.upload-note { font-size: 14px; margin-bottom: 0; }
#creditsList p { border-top: 1px solid var(--line); padding-top: 10px; margin-block: 10px; font-size: 13px; }
#creditsList a { color: #c4c6ff; text-decoration: underline; text-underline-offset: 3px; }
.toast {
  position: fixed;
  inset: auto auto 22px 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 10;
  border: 1px solid #68678e;
  background: #313552;
  color: white;
  border-radius: 10px;
  padding: 12px 17px;
  box-shadow: 0 9px 25px #0006;
}

@media (max-width: 1000px) {
  .viewer-body { grid-template-columns: minmax(0, 1fr) 256px; }
  .control-panel { padding-inline: 15px; }
}
@media (max-width: 760px) {
  .viewer-body { grid-template-columns: minmax(0, 1fr); }
  .stage { height: clamp(290px, 65vw, 510px); }
  .control-panel {
    border: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 14px;
    padding: 14px 16px;
  }
  .panel-heading, .panel-note { grid-column: 1 / -1; }
  .control-group { display: flex; flex-direction: column; }
  .view-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-group:not(.response-controls) .control-row { margin-top: auto; padding-top: 11px; }
  .response-controls .control-row { flex-wrap: wrap; }
  .panel-note { margin-top: 10px; }
  .viewer-footer { flex-wrap: wrap; }
  .gesture-note { text-align: left; }
}
@media (max-width: 570px) {
  .intro .upload-button { justify-self: start; }
  .viewer-card { border-radius: 12px; }
  .viewer-toolbar { padding: 8px; gap: 5px; }
  .viewer-toolbar .button { min-height: 42px; padding: 0 8px; font-size: 13px; gap: 6px; }
  .viewer-toolbar .loading { order: 1; flex-basis: 100%; padding: 3px 4px 4px; }
  .viewer-toolbar:has(.return-button:not([hidden])) { flex-wrap: wrap; }
  .viewer-toolbar:has(.return-button:not([hidden])) .viewer-tools { margin-left: auto; }
  .control-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; padding: 10px 12px; }
  .control-group .control-row { flex-wrap: wrap; align-items: center; gap: 7px; }
  .control-group select, .upload-options select, .stepper input { font-size: 16px; }
  .response-controls { grid-column: 1 / -1; }
  .response-controls .control-row { flex-wrap: nowrap; }
  .stepper { grid-template-columns: 32px 43px 32px; }
  .viewer-footer { padding: 10px 12px; gap: 8px; }
  .gesture-note { flex-basis: 100%; }
  .history-card { padding-inline: 13px; margin-top: 23px; }
  th, td { padding-inline: 3px; }
  th:first-child { width: 43%; }
  th:last-child { width: 84px; }
  .row-action { padding-inline: 6px; }
  .site-footer { flex-wrap: wrap; gap: 5px 12px; }
}
@media (max-width: 355px) {
  :root { --gutter: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
