:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #68736f;
  --line: #dce4df;
  --panel: #f7faf8;
  --paper: #ffffff;
  --accent: #007f73;
  --accent-strong: #005f57;
  --accent-soft: #dff4ef;
  --warn: #a35d00;
  --shadow: 0 20px 45px rgba(21, 38, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: #eaf0ed;
}

button,
input {
  font: inherit;
}

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

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 44%, rgba(255, 255, 255, 0.55) 45% 55%, transparent 56%),
    var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.15rem;
  line-height: 1.2;
}

.brand p,
.status,
.credits,
.drop-zone small,
.range-row,
.stats span,
.topbar span {
  color: var(--muted);
}

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 160px;
  padding: 22px;
  text-align: center;
  background: var(--paper);
  border: 1px dashed #a8bab4;
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: #fafdfe;
  transform: translateY(-1px);
}

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

.drop-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0;
}

.control-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  font-size: 0.9rem;
}

output {
  color: var(--accent-strong);
  font-weight: 800;
}

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

.range-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  background: #edf3f0;
  border-radius: 8px;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 9px 6px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 2px 7px rgba(24, 47, 43, 0.12);
}

.checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #31403b;
}

.checks input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

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

button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #b8c7c1;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats div {
  display: grid;
  gap: 5px;
  padding: 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats strong {
  font-size: 1.08rem;
}

.status {
  min-height: 42px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: var(--paper);
  border-radius: 6px;
  line-height: 1.35;
}

.status.warn {
  border-left-color: var(--warn);
}

.credits {
  margin-top: auto;
  font-size: 0.74rem;
  line-height: 1.35;
  text-align: center;
}

.credits a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

.viewport-wrap {
  position: relative;
  min-width: 0;
  background: #dfe8e4;
}

.topbar {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(204, 216, 211, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

#fileName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  font-size: 0.85rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.source-dot {
  background: #587fba;
}

.solid-dot {
  background: var(--accent);
}

.viewer {
  position: absolute;
  inset: 0;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.lasso-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lasso-overlay polyline {
  fill: rgba(0, 127, 115, 0.12);
  stroke: #005f57;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hidden-defaults {
  display: none;
}

.progress-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(223, 232, 228, 0.55);
  backdrop-filter: blur(5px);
}

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

.progress-box {
  display: grid;
  gap: 10px;
  width: min(360px, 100%);
  padding: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(188, 204, 198, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-box span {
  color: var(--muted);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  background: #dce7e2;
  border-radius: 999px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 180ms ease;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(460px, 62vh);
  }

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

  .viewport-wrap {
    min-height: 460px;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 16px;
  }

  .actions,
  .stats {
    grid-template-columns: 1fr;
  }

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