:root {
  color: #171816;
  background: #e8e9e3;
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", sans-serif;
  font-synthesis: none;
  --ink: #171816;
  --muted: #666a63;
  --paper: #f7f7f2;
  --line: #cfd1ca;
  --accent: #e9342b;
  --signal: #b8f238;
  --panel-width: 360px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(23, 24, 22, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 24, 22, 0.035) 1px, transparent 1px),
    #e8e9e3;
  background-size: 24px 24px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
.drop-zone:focus-visible {
  outline: 3px solid rgba(233, 52, 43, 0.28);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.topbar {
  height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  color: #fff;
  background: var(--ink);
  border-bottom: 3px solid var(--accent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.brand-name > span {
  font-size: 16px;
}

.brand-name > strong {
  color: var(--signal);
  font-size: 12px;
}

.brand-mark {
  width: 27px;
  height: 18px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 74% 100%, 0 100%, 24% 50%);
}

.site-domain {
  padding: 5px 9px 4px;
  color: #fff;
  border-bottom: 2px solid var(--signal);
  font-family: Impact, "Microsoft YaHei UI", sans-serif;
  font-size: 17px;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.site-domain:hover {
  color: var(--signal);
}

.topbar-actions,
.zoom-actions,
.capture-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  justify-self: end;
}

.privacy-badge {
  color: #d8dbd3;
  font-size: 12px;
}

.privacy-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--signal);
}

.icon-button,
.reset-view-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid #555850;
  background: transparent;
  cursor: pointer;
}

.language-button {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.app-shell {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: var(--panel-width) minmax(0, 1fr);
}

.control-panel {
  overflow-y: auto;
  padding: 28px 24px 40px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.intro {
  padding-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Impact, "Microsoft YaHei UI", sans-serif;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
}

.intro > p:last-child,
.capture-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.control-section {
  padding: 21px 0;
  border-top: 1px solid var(--line);
}

.control-section h2 {
  display: flex;
  gap: 9px;
  margin: 0 0 15px;
  font-size: 12px;
  text-transform: uppercase;
}

.control-section h2 > span:first-child {
  color: var(--accent);
}

.source-tabs,
.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  background: #e5e6df;
  border: 1px solid var(--line);
}

.source-tab,
.segmented button {
  min-height: 36px;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.source-tab.is-active,
.segmented button.is-active {
  color: #fff;
  background: var(--ink);
}

.source-panel {
  margin-top: 12px;
}

.drop-zone {
  min-height: 122px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px dashed #9b9f96;
  background: #eeefe9;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #fff;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong {
  font-size: 13px;
}

.drop-zone > span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.drop-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-size: 20px;
  font-weight: 300;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  color: #fff;
  background: var(--ink);
}

.secondary-button {
  background: transparent;
}

.danger-button {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}

.capture-actions {
  margin-top: 9px;
}

.capture-actions > button {
  flex: 1;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.color-field,
.range-field,
.option-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.color-control {
  height: 39px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

input[type="color"] {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.range-field {
  margin-top: 16px;
}

.option-field {
  margin-top: 16px;
}

.range-field > span {
  display: flex;
  justify-content: space-between;
}

.range-field output {
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.full-width {
  width: 100%;
  margin-top: 15px;
}

.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.text-button {
  margin-top: 10px;
  padding: 2px 0;
  color: var(--muted);
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

.segmented.segmented-two {
  grid-template-columns: repeat(2, 1fr);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr) 34px;
  padding: 16px 18px 12px;
}

.workspace-toolbar,
.workspace-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #a6aaa1;
}

.status-dot.is-active {
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(184, 242, 56, 0.18);
}

.workspace .icon-button,
.reset-view-button {
  height: 30px;
  min-width: 30px;
  border-color: var(--line);
  background: rgba(247, 247, 242, 0.65);
}

.reset-view-button {
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
}

.zoom-actions output {
  min-width: 43px;
  text-align: center;
}

.viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.05), transparent 55%),
    #252723;
  border: 1px solid #3b3e37;
  touch-action: none;
  user-select: none;
}

.viewport.has-source {
  cursor: grab;
}

.viewport.is-dragging {
  cursor: grabbing;
}

.viewport.is-sampling {
  cursor: crosshair;
}

.stage {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  transform-origin: center;
  will-change: transform;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#originalCanvas {
  pointer-events: none;
}

.compare-line {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  pointer-events: none;
}

.compare-line::after {
  content: "↔";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #eef0e9;
  text-align: center;
}

.empty-state strong {
  margin-top: 18px;
  font-size: 17px;
}

.empty-state p {
  max-width: 430px;
  margin: 7px 0 0;
  color: #aeb2a8;
  font-size: 12px;
  line-height: 1.55;
}

.map-glyph {
  width: 84px;
  height: 58px;
  opacity: 0.55;
  background:
    linear-gradient(65deg, transparent 43%, var(--signal) 44% 49%, transparent 50%),
    linear-gradient(115deg, transparent 43%, #697066 44% 49%, transparent 50%);
  border: 1px solid #697066;
  transform: skewY(-8deg);
}

.sample-cursor {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--signal);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 15px;
  color: #fff;
  background: var(--ink);
  border-left: 4px solid var(--accent);
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}

[hidden] {
  display: none !important;
}

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

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

  .control-panel {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: 72vh;
    min-height: 480px;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    display: none;
  }

  .brand-name {
    display: grid;
    gap: 0;
    line-height: 1.05;
  }

  .brand-name > span {
    font-size: 12px;
  }

  .brand-name > strong {
    font-size: 10px;
  }

  .site-domain {
    padding-inline: 4px;
    font-size: 14px;
  }

  .privacy-badge {
    display: none;
  }

  .control-panel {
    padding: 23px 18px 30px;
  }

  h1 {
    font-size: 30px;
  }

  .workspace {
    height: 68vh;
    min-height: 420px;
    padding: 10px;
  }

  .workspace-toolbar {
    gap: 8px;
  }

  .reset-view-button {
    max-width: 90px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}