:root {
  --bg: #08110d;
  --panel: rgba(17, 31, 24, 0.82);
  --panel-solid: #111f18;
  --line: rgba(206, 236, 217, 0.13);
  --text: #f2f7f3;
  --muted: #92a69a;
  --lime: #b8f34b;
  --lime-deep: #8fc72a;
  --orange: #ff9f43;
  --red: #ff6b6b;
  --radius: 20px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 5%, rgba(94, 152, 73, 0.13), transparent 27rem),
    linear-gradient(135deg, #07100c 0%, #0a1510 50%, #07100c 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
a { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.1;
  pointer-events: none;
}
.ambient-one { top: 30%; right: -12rem; background: var(--lime); }
.ambient-two { bottom: -10rem; left: -10rem; background: #2b8b57; }

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(184, 243, 75, 0.45);
  border-radius: 50%;
  color: var(--lime);
  font: 700 20px Georgia, serif;
  box-shadow: inset 0 0 18px rgba(184, 243, 75, 0.08);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: 0.04em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }

.topbar-actions { display: flex; align-items: center; gap: 18px; }
.service-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 10px var(--orange); }
.service-status.ready .status-dot { background: var(--lime); box-shadow: 0 0 10px var(--lime); }
.service-status.offline .status-dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.ghost-link { color: var(--muted); font-size: 12px; text-underline-offset: 4px; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero { padding: 70px 0 48px; display: flex; align-items: end; justify-content: space-between; gap: 48px; }
.eyebrow, .step-label { margin: 0 0 10px; color: var(--lime); font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.hero h1 { margin: 0; max-width: 760px; font: 500 clamp(44px, 7vw, 82px)/0.98 Georgia, "Times New Roman", serif; letter-spacing: -0.045em; }
.hero h1 span { color: var(--lime); font-style: italic; }
.hero-copy { max-width: 620px; margin: 26px 0 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.pipeline-strip { display: flex; align-items: center; gap: 9px; padding-bottom: 10px; color: var(--muted); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; }
.pipeline-strip i { width: 20px; height: 1px; background: var(--line); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.75fr); gap: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.upload-panel, .recent-panel, .job-panel, .result-card, .artifacts-card { padding: 26px; }
.panel-heading, .job-header, .section-heading, .result-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { margin-bottom: 20px; }
.panel-heading.compact { margin-bottom: 14px; }
h2, h3 { margin: 0; font-weight: 550; letter-spacing: -0.02em; }
h2 { font-size: 23px; }
h3 { font-size: 18px; }
.format-note { color: var(--muted); font-size: 9px; letter-spacing: 0.12em; }

#uploadForm { display: grid; gap: 12px; }
.ground-method { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 5px 1px 0; }
.field-title { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.method-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #0a1510; }
.method-button { padding: 7px 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }
.method-button.active { color: #10180d; background: var(--lime); font-weight: 800; }
.file-field, .fps-field {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.018);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.file-field { cursor: pointer; }
.file-field:hover, .file-field.dragover { border-color: rgba(184, 243, 75, 0.5); background: rgba(184, 243, 75, 0.04); transform: translateY(-1px); }
.file-field input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--lime); background: rgba(184,243,75,0.08); font-size: 14px; }
.line-icon { font-size: 26px; }
.file-copy { min-width: 0; flex: 1; }
.file-copy strong, .file-copy small, .fps-field strong, .fps-field small { display: block; }
.file-copy strong, .fps-field strong { font-size: 13px; }
.file-copy small, .fps-field small { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.file-action { color: var(--lime); font-size: 11px; }
.fps-field { justify-content: space-between; }
.fps-field input { width: 110px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: #0a1510; text-align: center; }
.fps-field input:focus { border-color: rgba(184,243,75,0.5); }

.position-selector { margin: 0; padding: 15px 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.018); }
.position-selector-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.position-selector-heading strong, .position-selector-heading small { display: block; }
.position-selector-heading strong { font-size: 13px; }
.position-selector-heading small, .position-selection-summary { margin-top: 5px; color: var(--muted); font-size: 10px; }
.position-selector-actions { display: flex; gap: 11px; }
.position-options { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.position-chip { position: relative; }
.position-chip input { position: absolute; opacity: 0; pointer-events: none; }
.position-chip span { min-height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #0a1510; cursor: pointer; font-size: 10px; font-weight: 800; transition: 150ms ease; }
.position-chip input:checked + span { border-color: rgba(184,243,75,0.55); color: #10180d; background: var(--lime); }
.position-chip input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }
.position-selection-summary { display: block; }
.job-positions { max-width: 620px; margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }

.ground-editor { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #0b1711; }
.ground-editor.expanded {
  position: fixed;
  z-index: 100;
  inset: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: rgba(184,243,75,0.35);
  border-radius: 18px;
  background: #08110d;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,0.82), 0 30px 100px rgba(0,0,0,0.65);
}
.ground-editor.expanded #groundCanvasPanel { min-height: 0; display: flex; flex: 1; flex-direction: column; }
.ground-editor.expanded .ground-instructions { flex: 0 0 auto; padding: 10px 16px; background: rgba(8,17,13,0.96); }
.ground-editor.expanded .ground-instructions ol { display: none; }
.ground-placeholder { padding: 22px; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: center; }
.ground-instructions { padding: 15px 17px; border-bottom: 1px solid var(--line); }
.ground-instructions strong { font-size: 12px; }
.ground-instructions ol { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.canvas-shell { position: relative; min-height: 180px; margin: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #040806; }
#groundCanvas { width: auto; height: auto; max-width: 100%; max-height: 620px; display: block; cursor: crosshair; }
.ground-editor.expanded .canvas-shell { min-height: 0; flex: 1 1 auto; margin: 8px 12px; }
.ground-editor.expanded #groundCanvas { max-width: none; max-height: none; }
.canvas-hint { position: absolute; left: 12px; bottom: 12px; padding: 7px 9px; border-radius: 7px; color: #fff; background: rgba(0,0,0,0.68); pointer-events: none; font-size: 9px; }
.source-video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.timeline-control { display: flex; align-items: center; gap: 12px; padding: 0 15px 12px; }
.ground-editor.expanded .timeline-control { flex: 0 0 auto; padding-bottom: 8px; }
.timeline-control input { min-width: 0; flex: 1; accent-color: var(--lime); }
.timeline-control span { width: 52px; color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.ground-editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 15px; border-top: 1px solid var(--line); }
.ground-editor.expanded .ground-editor-footer { flex: 0 0 auto; padding: 9px 15px; }
.ground-editor-footer > span { min-width: 0; overflow: hidden; color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.ground-editor-actions { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.editor-size-button { padding: 8px 11px; font-size: 10px; }
body.editor-open { overflow: hidden; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, opacity 160ms ease;
}
.primary-button { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; color: #10180d; background: var(--lime); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.secondary-button { padding: 10px 15px; color: #10180d; background: var(--lime); font-size: 12px; }
.text-button { padding: 0; border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 11px; text-decoration: underline; text-underline-offset: 4px; }

.recent-list { display: grid; gap: 8px; }
.recent-job { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: rgba(255,255,255,0.018); cursor: pointer; text-align: left; }
.recent-job:hover { border-color: rgba(184,243,75,0.35); }
.recent-job strong, .recent-job small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-job strong { font-size: 12px; }
.recent-job small { margin-top: 6px; color: var(--muted); font-size: 9px; }
.empty-copy { margin: 24px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.job-panel { margin-top: 20px; }
.job-id { display: block; max-width: 460px; margin: 8px 0 0; padding: 0; overflow: hidden; border: 0; color: var(--muted); background: none; cursor: pointer; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; min-height: 29px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.badge.processing { border-color: rgba(184,243,75,0.35); color: var(--lime); }
.badge.completed, .badge.complete { color: #10180d; background: var(--lime); border-color: var(--lime); }
.badge.failed { border-color: rgba(255,107,107,0.4); color: var(--red); }
.progress-area { margin-top: 26px; }
.progress-copy { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 10px; font-size: 12px; }
.progress-copy span { color: var(--lime); font-variant-numeric: tabular-nums; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,0.06); }
.progress-bar { width: 5%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--lime-deep), var(--lime)); box-shadow: 0 0 18px rgba(184,243,75,0.35); transition: width 450ms ease; }
.stage-timeline { display: grid; grid-template-columns: repeat(6, 1fr); margin-top: 14px; gap: 5px; }
.stage-item { color: #536259; font-size: 8px; letter-spacing: 0.07em; text-transform: uppercase; }
.stage-item.active, .stage-item.done { color: var(--lime); }
.job-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }

.message { padding: 12px 14px; border-radius: 10px; font-size: 11px; line-height: 1.5; }
.error-message { border: 1px solid rgba(255,107,107,0.25); color: #ffadad; background: rgba(255,107,107,0.07); }

.results-section { margin-top: 54px; }
.section-heading { margin-bottom: 20px; }
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-solid); box-shadow: var(--shadow); }
.media-card video, .media-card img { width: 100%; max-height: 540px; display: block; background: #040806; object-fit: contain; }
.media-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.media-caption strong { font-size: 12px; }
.download-link { color: var(--lime); font-size: 10px; text-decoration: none; }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.metrics-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.metric { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,0.018); }
.metric small, .metric strong { display: block; }
.metric small { color: var(--muted); font-size: 9px; }
.metric strong { margin-top: 6px; color: var(--lime); font-size: 17px; font-variant-numeric: tabular-nums; }
details { margin-top: 16px; color: var(--muted); font-size: 10px; }
summary { cursor: pointer; }
pre { white-space: pre-wrap; word-break: break-word; }
#metricsJson { max-height: 300px; overflow: auto; padding: 12px; border-radius: 10px; color: #b7c5bc; background: #08110d; font-size: 9px; }
.text-report { max-height: 410px; margin: 18px 0 0; overflow: auto; color: #c5d0c9; font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.artifacts-card { margin-top: 20px; }
.artifact-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 18px; }
.artifact { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.artifact:hover { border-color: rgba(184,243,75,0.35); }
.artifact span { min-width: 0; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.artifact small { flex: 0 0 auto; color: var(--muted); font-size: 8px; }

footer { width: min(1180px, calc(100% - 40px)); margin: 70px auto 0; padding: 24px 0 34px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #5e7065; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .hero { align-items: start; flex-direction: column; padding-top: 48px; }
  .workspace, .results-grid { grid-template-columns: 1fr; }
  .pipeline-strip { display: none; }
  .artifact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar, .shell, footer { width: min(100% - 24px, 1180px); }
  .topbar-actions .service-status { display: none; }
  .hero { padding: 38px 0 32px; }
  .hero h1 { font-size: 44px; }
  .upload-panel, .recent-panel, .job-panel, .result-card, .artifacts-card { padding: 18px; }
  .media-grid { grid-template-columns: 1fr; }
  .artifact-list { grid-template-columns: 1fr; }
  .stage-timeline { grid-template-columns: repeat(3, 1fr); row-gap: 8px; }
  .format-note { display: none; }
  .position-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  footer { gap: 12px; flex-direction: column; }
}
