:root {
  --bg0: #0f1410;
  --bg1: #172019;
  --bg2: #1f2a22;
  --line: rgba(214, 232, 198, 0.14);
  --text: #e7f0df;
  --muted: #9aaf95;
  --accent: #c6f26d;
  --accent-ink: #14200a;
  --warn: #f0c27a;
  --card: rgba(255, 255, 255, 0.03);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(198, 242, 109, 0.16), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(110, 180, 140, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0), #121a14 40%, #0d120f);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

.page {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 11rem;
  position: relative;
}

.hero {
  margin-bottom: 1.75rem;
  animation: rise 0.7s ease both;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.9rem 1.05rem;
  margin: 0 0 0.85rem;
}

.brand-icon {
  flex: 0 0 auto;
  width: clamp(2.75rem, 6vw, 3.5rem);
  height: clamp(2.75rem, 6vw, 3.5rem);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.brand-copy {
  min-width: 0;
}

.brand {
  margin: 0 0 0.35rem;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.lede code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--accent);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  animation: rise 0.7s ease both;
}

.panel:nth-of-type(2) { animation-delay: 0.05s; }
.panel:nth-of-type(3) { animation-delay: 0.1s; }
.panel:nth-of-type(4) { animation-delay: 0.15s; }

.drop-panel {
  min-height: 150px;
  display: grid;
  place-items: center;
  border-style: dashed;
  border-width: 1.5px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.drop-panel:hover,
.drop-panel:focus-visible,
.drop-panel.dragover {
  border-color: rgba(198, 242, 109, 0.55);
  background: rgba(198, 242, 109, 0.06);
  outline: none;
}

.drop-panel.has-file {
  border-style: solid;
  border-color: rgba(198, 242, 109, 0.35);
}

.plan-panel.hidden {
  display: none;
}

.plan-panel .force-hint {
  margin-top: 0.35rem;
  color: color-mix(in srgb, var(--accent) 55%, var(--muted));
}

.plan-toolbar {
  gap: 1rem;
  flex-wrap: wrap;
}

.plan-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.scan-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin: 0.15rem 0 0.35rem;
}

.scan-status-row .hint {
  margin: 0;
}

.btn-skip-scan {
  appearance: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.btn-skip-scan[hidden] {
  display: none !important;
}

.btn-skip-scan:hover {
  filter: brightness(1.06);
}

.btn-skip-scan:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.write-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  cursor: pointer;
}

.write-mode-label {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
}

.scan-live {
  margin-top: 0.35rem;
  min-height: 1.35em;
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
  font-family: var(--mono);
  font-size: 0.86rem;
}


.plan-panel.plan-ready {
  animation: plan-settle 0.55s ease both;
}

.sweeps-layout.sequence-reveal {
  animation: sweep-slide 0.55s ease both;
  animation-delay: 0.12s;
}

@keyframes sweep-slide {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes plan-settle {
  from {
    opacity: 0.65;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.plan-reasons {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.plan-reasons li {
  margin: 0.25rem 0;
}

.drop-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.drop-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.row.between { justify-content: space-between; }

.hint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
}

.sweeps-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 800px) {
  .sweeps-layout { grid-template-columns: 1fr; }
}

.palette, .sequence {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 4rem;
}

.sweep-card, .seq-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sweep-card:hover, .seq-item:hover {
  transform: translateY(-1px);
  border-color: rgba(198, 242, 109, 0.4);
}

.sweep-label, .seq-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.sweep-desc, .seq-desc {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.sequence {
  counter-reset: sweep;
}

.seq-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  cursor: grab;
}

.seq-item:active { cursor: grabbing; }

.seq-item.dragging {
  opacity: 0.45;
}

.seq-num {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.seq-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
}

.seq-remove:hover { color: var(--warn); }

.seq-main {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
}

.seq-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.seq-opt-label {
  font-weight: 600;
}

.seq-locale {
  font: inherit;
  color: inherit;
  background: var(--panel, transparent);
  border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 0.35rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
}

.empty-seq.hidden { display: none; }

.actions-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  margin: 0;
  width: 100%;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg1) 72%, transparent), color-mix(in srgb, var(--bg0) 94%, #050805)),
    rgba(12, 16, 12, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.4);
  animation: rise 0.7s ease both;
  animation-delay: 0.2s;
}

.actions-dock-inner {
  width: min(1100px, calc(100% - 0.5rem));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1rem;
}

.run-estimate {
  margin: 0;
  color: color-mix(in srgb, var(--accent) 65%, var(--muted));
  font-family: var(--mono);
  font-size: 0.82rem;
  flex: 1 1 auto;
  min-width: 10rem;
}

.run-estimate.is-empty {
  color: var(--muted);
}

.run-progress {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel, var(--bg2)) 88%, transparent);
}

.run-progress.hidden { display: none; }

@media (max-width: 640px) {
  .actions-row .status {
    flex: 1 1 100%;
    order: 3;
  }
  .run-estimate {
    flex: 1 1 calc(100% - 9rem);
    font-size: 0.75rem;
  }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.45rem;
}

.progress-phase {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.progress-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.progress-bar {
  position: relative;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(214, 232, 198, 0.12);
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8fbf4a, var(--accent));
  transition: width 0.35s ease;
  box-shadow: 0 0 16px rgba(198, 242, 109, 0.35);
}

.progress-bar[data-indeterminate="1"] .progress-bar-fill {
  width: 28% !important;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

.progress-times {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.progress-eta {
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
}

.progress-last {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.2em;
}

.primary, .ghost {
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 30px rgba(198, 242, 109, 0.2);
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.primary:not(:disabled):hover {
  filter: brightness(1.05);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

a.primary.download {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.status {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.88rem;
}

.result.hidden { display: none; }

.summary {
  margin: 0.75rem 0 1rem;
  color: var(--text);
}

.table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, var(--bg2)) var(--bg1);
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--bg1);
  border-radius: 0 12px 12px 0;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 45%, var(--bg2));
  border: 2px solid var(--bg1);
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 40%, var(--muted));
}

.table-wrap::-webkit-scrollbar-corner {
  background: var(--bg1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #1a241c;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
}

td {
  font-family: var(--mono);
  word-break: break-word;
}

td code.report-from,
td code.report-to {
  display: inline;
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
  padding: 0;
  color: inherit;
}

td code.report-to {
  color: var(--accent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
