:root {
  color-scheme: light;
  --ink: #101010;
  --muted: #666a70;
  --line: #171717;
  --soft-line: #d7d9dc;
  --panel: #f8f8f5;
  --page: #e8e8e3;
  --accent: #c8ff00;
  --accent-2: #155bff;
  --danger: #ff3b30;
  --warn: #ff8c00;
  --ok: #138a45;
  --shadow: 8px 8px 0 #111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  background:
    linear-gradient(rgba(16, 16, 16, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 16, 16, .055) 1px, transparent 1px),
    var(--page);
  background-size: 28px 28px;
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.upload-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.upload-card {
  width: min(720px, 100%);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 20px;
}

.studio-return {
  width: max-content;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.studio-return:hover,
.studio-return:focus-visible {
  background: var(--accent);
  outline: 0;
}

.sidebar-return {
  margin-top: -12px;
}

.upload-brand {
  padding-bottom: 4px;
}

.upload-brand h1 {
  font-size: 24px;
}

.start-dropzone {
  min-height: 260px;
}

.start-actions {
  display: flex;
  justify-content: flex-end;
}

.start-file-list {
  margin-top: 0;
}

.upload-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upload-summary div {
  border: 2px solid var(--line);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.upload-summary strong {
  font-size: 18px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.upload-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

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

.sidebar {
  background: #f4f4ef;
  border-right: 2px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--accent);
  border-radius: 0;
  font-weight: 800;
  letter-spacing: -1px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.notice,
small,
#previewMeta {
  color: var(--muted);
}

.panel,
.viewer,
.results,
.metric {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
}

.panel {
  padding: 16px;
  box-shadow: 4px 4px 0 rgba(16, 16, 16, .14);
}

.section-title,
.viewer-toolbar,
.results-header,
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.section-title {
  margin-bottom: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 12px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 0;
  font-weight: 800;
  background: #fff;
  text-transform: uppercase;
}

.status-pill.ready {
  color: var(--ink);
  background: var(--accent);
  border-color: var(--line);
}

.dropzone {
  min-height: 158px;
  border: 2px dashed var(--line);
  border-radius: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  cursor: pointer;
  background:
    linear-gradient(135deg, rgba(16, 16, 16, .06) 25%, transparent 25%) 0 0 / 12px 12px,
    #ffffff;
}

.dropzone.dragging {
  border-color: var(--line);
  background: var(--accent);
}

.dropzone input {
  display: none;
}

.upload-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: var(--ink);
  color: var(--accent);
  font-size: 26px;
  line-height: 1;
  margin-bottom: 8px;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 9px 10px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

.file-list li.active {
  border-color: var(--line);
  background: var(--accent);
}

.file-list button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.file-list strong,
.file-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.pipeline-list li {
  padding-left: 2px;
}

.pipeline-list li.done {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
}

.pipeline-list li.active {
  color: var(--accent-2);
}

label {
  display: grid;
  gap: 7px;
  color: #202020;
  font-size: 13px;
  font-weight: 800;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

select,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

.detected-fields {
  display: grid;
  gap: 8px;
}

.scope-editor {
  display: grid;
  gap: 2px;
}

.scope-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sheet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet-tags span {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.icon-button,
.secondary-button,
.primary-button,
.segmented button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover,
.secondary-button:hover,
.segmented button:hover {
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 0;
}

.workspace {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  min-height: 72px;
}

.eyebrow {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

h2 {
  font-size: 32px;
  line-height: 1.08;
  max-width: 780px;
  letter-spacing: -1px;
  text-transform: uppercase;
}

.primary-button,
.secondary-button {
  border-radius: 0;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.primary-button {
  background: var(--accent);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-button:disabled {
  background: #b8bab5;
  border-color: var(--line);
  box-shadow: none;
  cursor: not-allowed;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
  display: grid;
  gap: 6px;
  background:
    linear-gradient(90deg, var(--ink) 0 7px, transparent 7px),
    var(--panel);
}

.metric strong {
  font-size: 36px;
  line-height: 1;
  letter-spacing: -1px;
}

.metric-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.metric.high strong {
  color: var(--danger);
}

.metric.medium strong {
  color: var(--warn);
}

.metric.low strong,
.metric.score strong {
  color: var(--accent-2);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(380px, 0.9fr);
  gap: 16px;
  min-height: 560px;
}

.viewer,
.results {
  min-width: 0;
  overflow: hidden;
}

.viewer-toolbar,
.results-header {
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
  background: #fff;
}

.viewer-toolbar > div:first-child {
  display: grid;
  gap: 3px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  height: 34px;
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 10px;
  font-size: 12px;
  min-width: 64px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented .active {
  background: var(--ink);
  color: var(--accent);
  font-weight: 800;
}

.preview-stage {
  height: calc(100% - 63px);
  min-height: 495px;
  padding: 18px;
  background:
    linear-gradient(rgba(16, 16, 16, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 16, 16, .08) 1px, transparent 1px),
    #d9dbd5;
  background-size: 18px 18px;
  display: grid;
  place-items: center;
}

.sheet-frame {
  position: relative;
  width: min(100%, 780px);
  height: 100%;
  min-height: 455px;
  display: grid;
  place-items: center;
}

.sheet-frame iframe,
.sheet-frame img {
  width: 100%;
  height: 100%;
  border: 2px solid var(--line);
  object-fit: contain;
  background: white;
  box-shadow: 5px 5px 0 rgba(16, 16, 16, .28);
}

.pdf-page-surface {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 455px;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 5px 5px 0 rgba(16, 16, 16, .28);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.pdf-page-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 16, 16, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 16, 16, .08) 1px, transparent 1px);
  background-size: 34px 34px;
}

.pdf-page-header {
  position: absolute;
  left: 18px;
  top: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 10px;
  font-weight: 850;
  text-transform: uppercase;
  z-index: 1;
}

.pdf-page-title {
  border: 2px solid var(--line);
  background: var(--accent);
  padding: 14px 18px;
  font-size: 28px;
  font-weight: 850;
  z-index: 1;
}

.pdf-page-surface small {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 1;
  color: var(--muted);
}

.markup-layer,
.ocr-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.markup-region {
  position: absolute;
  border: 3px solid;
  border-radius: 18px;
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 999px rgba(23, 33, 43, .02);
}

.markup-region::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px dashed currentColor;
  border-radius: 24px;
  opacity: .85;
}

.markup-region.high {
  border-color: var(--danger);
  background: rgba(180, 35, 24, .11);
}

.markup-region.medium {
  border-color: var(--warn);
  background: rgba(181, 71, 8, .10);
}

.markup-region.low {
  border-color: var(--accent-2);
  background: rgba(49, 95, 151, .10);
}

.markup-pin {
  position: absolute;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border-radius: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 900;
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 var(--ink);
}

.markup-pin.high {
  background: var(--danger);
}

.markup-pin.medium {
  background: var(--warn);
}

.markup-pin.low {
  background: var(--accent-2);
}

.redline-leader {
  position: absolute;
  width: 86px;
  height: 2px;
  transform: rotate(-18deg);
  transform-origin: left center;
  background: currentColor;
}

.redline-leader::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.redline-note {
  position: absolute;
  min-width: 132px;
  max-width: 210px;
  border: 2px solid currentColor;
  background: #fff;
  color: var(--danger);
  padding: 8px 9px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
  align-items: center;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--ink);
}

.redline-note strong {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid currentColor;
}

.redline-leader.high,
.redline-note.high {
  color: var(--danger);
}

.redline-leader.medium,
.redline-note.medium {
  color: var(--warn);
}

.redline-leader.low,
.redline-note.low {
  color: var(--accent-2);
}

.ocr-token {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  background: rgba(200, 255, 0, .88);
  color: var(--ink);
  border-radius: 0;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.blueprint {
  position: relative;
  width: min(100%, 720px);
  aspect-ratio: 1.32;
  background: #0f1720;
  border: 10px solid #fff;
  box-shadow: 8px 8px 0 var(--ink);
  overflow: hidden;
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(200,255,0,.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,255,0,.13) 1px, transparent 1px);
  background-size: 24px 24px;
}

.plan-line {
  position: absolute;
  border: 3px solid #f6f6f0;
  color: #f6f6f0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}

.living {
  inset: 12% 45% 48% 8%;
}

.kitchen {
  inset: 56% 45% 12% 8%;
}

.stair {
  inset: 22% 10% 46% 62%;
}

.corridor {
  left: 47%;
  top: 12%;
  width: 10%;
  height: 76%;
}

.callout {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 2px solid var(--accent);
  color: var(--accent);
  border-radius: 0;
  display: grid;
  place-items: center;
  font-weight: 850;
  background: rgba(16, 16, 16, .84);
}

.c1 { left: 50%; top: 17%; }
.c2 { left: 73%; top: 36%; }
.c3 { left: 25%; top: 52%; }

.results {
  display: flex;
  flex-direction: column;
}

.results-header h3 {
  font-size: 18px;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  padding: 28px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.analysis-summary {
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  background: #efefea;
}

.analysis-summary div {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0;
  padding: 10px;
}

.analysis-summary strong {
  font-size: 15px;
}

.analysis-summary span {
  color: var(--muted);
  font-size: 12px;
}

.extracted-data {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.extracted-data h4 {
  margin: 2px 0 0;
  font-size: 14px;
}

.extracted-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.topic-tags span {
  border: 1px solid var(--line);
  background: var(--accent);
  color: var(--ink);
  border-radius: 0;
  padding: 5px 8px;
  font-weight: 760;
}

.extracted-sheets {
  display: grid;
  gap: 8px;
}

.extracted-sheet {
  display: grid;
  gap: 4px;
}

.extracted-sheet small {
  color: var(--muted);
  line-height: 1.35;
}

.code-summary {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0;
  padding: 10px;
}

.code-summary span,
.code-summary small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.issue-list {
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.issue {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 0;
  padding: 14px;
  display: grid;
  gap: 9px;
  background: #fff;
  cursor: pointer;
}

.issue.active {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 var(--ink);
}

.issue.high {
  border-left-color: var(--danger);
}

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

.issue.low {
  border-left-color: var(--accent-2);
}

.issue-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.severity {
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  border-radius: 0;
  padding: 4px 8px;
  white-space: nowrap;
}

.high .severity {
  color: #fff;
  background: var(--danger);
}

.medium .severity {
  color: var(--ink);
  background: var(--warn);
}

.low .severity {
  color: #fff;
  background: var(--accent-2);
}

.issue h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.issue p {
  color: #40505f;
  line-height: 1.45;
}

.issue-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.issue-meta span {
  font-size: 12px;
  color: var(--ink);
  background: #f2f2ed;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 8px;
  font-weight: 760;
}

.notice {
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .summary-grid,
  .main-grid {
    grid-template-columns: 1fr 1fr;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .sidebar,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .workspace,
  .sidebar {
    padding: 16px;
  }

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

  h2 {
    font-size: 24px;
  }

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

  .segmented {
    width: 100%;
  }

  .result-actions,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .analysis-summary {
    grid-template-columns: 1fr;
  }

  .extracted-grid {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    min-height: 360px;
  }
}
