:root {
  color-scheme: dark;
  --bg: #151817;
  --panel: #222725;
  --panel-2: #292f2c;
  --line: #3c4540;
  --text: #eef2ed;
  --muted: #aeb9b1;
  --accent: #7fd5b2;
  --accent-2: #f0c36a;
  --danger: #ff8f70;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 14px;
  min-height: calc(100vh - 36px);
}

.controls,
.metrics,
.viewer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls,
.metrics {
  padding: 18px;
}

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

.mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background:
    linear-gradient(35deg, transparent 45%, rgba(127, 213, 178, 0.85) 46% 54%, transparent 55%),
    #1b211f;
}

h1,
h2,
p {
  margin: 0;
}

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

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}

.preset-row button,
.actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #303731;
  color: var(--text);
  cursor: pointer;
}

.preset-row button.active {
  border-color: var(--accent);
  color: #102019;
  background: var(--accent);
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  margin: 15px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.field input {
  grid-column: 1 / -1;
  width: 100%;
}

.field.compact {
  grid-template-columns: 1fr;
  margin: 0;
}

.field.compact input {
  grid-column: auto;
}

input[type="number"] {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151817;
  color: var(--text);
}

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

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.linked-area {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1b201d;
}

.sectioning-controls {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202622;
  overflow: hidden;
}

.sectioning-controls summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  list-style: none;
  text-transform: uppercase;
}

.sectioning-controls summary::-webkit-details-marker {
  display: none;
}

.sectioning-controls summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.8rem;
}

.sectioning-controls summary span {
  min-width: 0;
}

.sectioning-controls summary small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
}

.sectioning-controls[open] summary {
  border-bottom: 1px solid var(--line);
}

.sectioning-controls[open] summary::before {
  content: "-";
  color: var(--accent);
}

.sectioning-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.sectioning-controls .field {
  margin: 0;
}

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

.slice-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151817;
  color: var(--accent);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
}

.slice-actions button:hover {
  border-color: var(--accent);
}

.section-label {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.actions button:first-child {
  background: var(--accent);
  color: #102019;
  border-color: var(--accent);
  font-weight: 700;
}

.actions .secondary {
  background: #202521;
}

.agent-trace {
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.agent-trace h2,
.verdict h2 {
  font-size: 0.92rem;
  margin-bottom: 10px;
}

.agent-trace ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.82rem;
}

.viewer {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar div {
  display: grid;
  gap: 4px;
}

.toolbar strong {
  color: var(--accent);
}

.toolbar span {
  color: var(--muted);
  font-size: 0.86rem;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 16px;
  background: #101211;
  position: relative;
  overflow: hidden;
}

.canvas-wrap img {
  width: 100%;
  max-height: calc(100vh - 118px);
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid #050605;
  transition: opacity 0.16s ease;
}

.canvas-wrap.is-generating img {
  opacity: 0.45;
}

.generation-overlay {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 26px;
  border: 1px solid rgba(127, 213, 178, 0.35);
  border-radius: 6px;
  background:
    linear-gradient(rgba(127, 213, 178, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 213, 178, 0.07) 1px, transparent 1px),
    rgba(10, 13, 12, 0.74);
  background-size: 34px 34px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.985);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.canvas-wrap.is-generating .generation-overlay {
  opacity: 1;
  transform: scale(1);
}

.scan-frame {
  position: relative;
  width: min(360px, 72%);
  aspect-ratio: 1.9;
  border: 1px solid rgba(127, 213, 178, 0.58);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(127, 213, 178, 0.14), rgba(240, 195, 106, 0.08)),
    rgba(16, 18, 17, 0.8);
  overflow: hidden;
  box-shadow: 0 0 34px rgba(127, 213, 178, 0.12);
}

.scan-frame::before,
.scan-frame::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.9;
}

.scan-frame::before {
  top: 12px;
  left: 12px;
  border-width: 2px 0 0 2px;
}

.scan-frame::after {
  right: 12px;
  bottom: 12px;
  border-width: 0 2px 2px 0;
}

.scan-line {
  position: absolute;
  top: -18%;
  left: 0;
  width: 100%;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(127, 213, 178, 0.36), transparent);
  animation: scan-pass 1.45s ease-in-out infinite;
}

.scan-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(127, 213, 178, 0.9);
  animation: dot-pulse 1.2s ease-in-out infinite;
}

.dot-a {
  left: 24%;
  top: 38%;
}

.dot-b {
  left: 52%;
  top: 58%;
  animation-delay: 0.18s;
}

.dot-c {
  left: 73%;
  top: 34%;
  animation-delay: 0.36s;
}

.generation-copy {
  display: grid;
  gap: 6px;
  text-align: center;
}

.generation-copy strong {
  color: var(--text);
  font-size: 1.02rem;
}

.generation-copy span {
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-rail {
  width: min(360px, 72%);
  height: 6px;
  border-radius: 999px;
  background: rgba(60, 69, 64, 0.75);
  overflow: hidden;
}

.progress-rail span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: progress-pass 1.1s ease-in-out infinite;
}

@keyframes scan-pass {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(360%);
  }
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1.25);
  }
}

@keyframes progress-pass {
  0% {
    transform: translateX(-105%);
  }
  100% {
    transform: translateX(250%);
  }
}

.metrics {
  display: grid;
  align-content: start;
  gap: 12px;
}

.metric,
.verdict {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 13px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 7px;
}

.metric strong {
  font-size: 1.15rem;
}

.split strong {
  color: var(--accent-2);
}

.verdict p {
  color: var(--text);
  line-height: 1.5;
  font-size: 0.92rem;
}

.verdict small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 310px 1fr;
  }

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

  .verdict {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

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

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

  .canvas-wrap {
    min-height: 280px;
  }
}
