:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --surface: #f5f7fa;
  --panel: #ffffff;
  --orange: #f59e0b;
  --green: #22a06b;
  --blue: #2f80ed;
  --pink: #ec4899;
  --danger: #d92d20;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  font-size: 13px;
  letter-spacing: 0;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.header-status {
  color: var(--muted);
  font-size: 14px;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
}

.dashboard-page {
  width: min(1220px, calc(100% - 32px));
  margin: 26px auto 42px;
}

.simple-dashboard {
  display: grid;
  gap: 18px;
}

.upload-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.inline-upload {
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 360px) auto;
  align-items: end;
  box-shadow: none;
}

.compact-drop {
  min-height: 118px;
}

.upload-panel,
.project-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  align-content: start;
  gap: 28px;
  padding: clamp(20px, 4vw, 32px);
}

.eyebrow {
  margin: 0 0 10px;
  color: #2f80ed;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.upload-form,
.marker-editor {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}

.file-drop {
  display: grid;
  min-height: 136px;
  place-items: center;
  border: 1px dashed #9aa8ba;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.file-drop input {
  max-width: 220px;
  border: 0;
  padding: 0;
  font-size: 12px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.status-choice,
.mode-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: #111827;
}

.ghost-button {
  border-color: var(--line);
  background: #fff;
}

.icon-button {
  width: 42px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
}

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

.project-list {
  padding: 20px;
}

.board-panel {
  box-shadow: none;
}

.project-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 4px;
}

.project-toolbar h1,
.project-toolbar h2,
.project-toolbar p {
  margin: 0;
}

.project-toolbar h1 {
  font-size: 26px;
}

.project-toolbar p {
  color: var(--muted);
  font-size: 14px;
}

.section-heading,
.card-meta,
.topbar,
.legend,
.stats-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading span,
.muted,
.project-card p,
.tool-panel p {
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.project-card {
  display: grid;
  gap: 10px;
  min-height: 172px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.refined-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.refined-card {
  position: relative;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.project-card-link {
  display: grid;
  gap: 12px;
  min-height: 188px;
  padding: 16px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.delete-project-form {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.delete-project-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid rgba(217, 45, 32, 0.24);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--danger);
  background: rgba(217, 45, 32, 0.06);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.delete-project-button:hover {
  background: rgba(217, 45, 32, 0.12);
}

.project-card:hover {
  border-color: #8ea3bc;
}

.project-card h3 {
  margin-bottom: 0;
}

.file-pill {
  width: max-content;
  border-radius: 999px;
  padding: 5px 9px;
  color: #0f5132;
  background: #d1fADF;
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.polished-empty {
  border: 1px dashed #c4ccd8;
  border-radius: 8px;
  background: #f9fafb;
}

.list-panel {
  padding: 18px;
}

.project-table {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.project-row:hover {
  border-color: #8ea3bc;
}

.project-row-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 14px;
}

.project-row-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.project-row-main strong,
.project-row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row-main strong {
  font-size: 16px;
}

.project-row-main small {
  color: var(--muted);
  font-size: 13px;
}

.open-project {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.project-row .delete-project-form {
  position: static;
  padding-right: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 65px);
}

.tool-panel {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.tool-panel h1 {
  margin: 12px 0 8px;
  font-size: 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.tool-block {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.tool-block h2 {
  margin: 0;
  font-size: 15px;
}

.status-options,
.mode-tabs {
  display: grid;
  gap: 8px;
}

.status-choice,
.mode-choice {
  justify-content: flex-start;
  border-color: var(--line);
  background: #fff;
}

.status-choice.active,
.mode-choice.active {
  border-color: #111827;
  box-shadow: inset 0 0 0 1px #111827;
}

.dot,
.legend b {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.orange { background: var(--orange); }
.green { background: var(--green); }
.blue { background: var(--blue); }
.pink { background: var(--pink); }
.marking {
  background: transparent;
  border: 2px solid #d1d5db;
}

.canvas-shell {
  min-width: 0;
  background: #e9edf3;
}

.topbar {
  position: sticky;
  top: 65px;
  z-index: 15;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.legend {
  flex-wrap: wrap;
  justify-content: flex-start;
  color: #344054;
  font-size: 13px;
}

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

.viewer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.zoom-value {
  min-width: 52px;
  text-align: center;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.viewer-wrap {
  overflow: auto;
  height: calc(100vh - 123px);
  padding: 18px;
}

.viewer-wrap.is-panning,
.viewer-wrap.is-panning .annotation-layer,
.viewer-wrap.is-panning .marker {
  cursor: grabbing;
}

.viewer-stage {
  position: relative;
  width: 760px;
  height: 520px;
  margin: 0 auto;
  border: 1px solid #c4ccd8;
  background: #fff;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.14);
  touch-action: manipulation;
}

#project-image,
#pdf-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.annotation-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 2;
  cursor: crosshair;
}

.marker {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  min-width: 18px;
  min-height: 18px;
  overflow: visible;
  border: 2px solid currentColor;
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  opacity: 0.78;
}

.marker.selected {
  outline: 3px solid #111827;
  outline-offset: 3px;
  opacity: 0.92;
}

.marker.marking,
.draw-preview.marking {
  color: rgba(17, 24, 39, 0.84);
  background: rgba(255, 255, 255, 0.04);
  border-style: dashed;
}

.marker.orange,
.draw-preview.orange {
  color: var(--orange);
  background: rgba(245, 158, 11, 0.22);
}

.marker.green,
.draw-preview.green {
  color: var(--green);
  background: rgba(34, 160, 107, 0.22);
}

.marker.blue,
.draw-preview.blue {
  color: var(--blue);
  background: rgba(47, 128, 237, 0.2);
}

.marker.pink,
.draw-preview.pink {
  color: var(--pink);
  background: rgba(236, 72, 153, 0.2);
}

.draw-preview {
  position: absolute;
  border: 2px dashed #111827;
  background: rgba(47, 128, 237, 0.12);
  cursor: pointer;
}

.draw-preview {
  pointer-events: none;
}

.quick-status {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 6px;
  width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(16, 24, 40, 0.22);
}

.quick-status-button {
  min-height: 30px;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 5px 7px;
  color: #111827;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.quick-status-button.orange {
  background: rgba(245, 158, 11, 0.22);
}

.quick-status-button.green {
  background: rgba(34, 160, 107, 0.22);
}

.quick-status-button.blue {
  background: rgba(47, 128, 237, 0.2);
}

.quick-status-button.pink {
  background: rgba(236, 72, 153, 0.2);
}

.quick-status-button.marking {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.42);
}

.quick-status-button.active {
  box-shadow: inset 0 0 0 2px #111827;
}

.pdf-error {
  max-width: 720px;
  padding: 24px;
  color: var(--danger);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .home-layout,
  .workspace {
    grid-template-columns: 1fr;
  }

  .header-status {
    display: none;
  }

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

  .status-options,
  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .viewer-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .viewer-wrap {
    height: auto;
    min-height: 62vh;
    padding: 10px;
  }

  .viewer-stage {
    margin: 0;
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: 58px;
  }

  .home-layout {
    width: calc(100% - 20px);
    margin: 10px auto;
  }

  .upload-panel,
  .project-list,
  .tool-panel {
    padding: 16px;
  }

  .status-options,
  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .topbar {
    top: 58px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.project-screen {
  overflow: hidden;
  background: #0b0f17;
}

.project-screen .app-header {
  display: none;
}

.project-screen main {
  height: 100vh;
  overflow: hidden;
}

.fullscreen-workspace {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.fullscreen-canvas {
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #0b0f17;
}

.project-screen .viewer-wrap {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
  background: #0b0f17;
}

.project-screen .viewer-stage {
  margin: 0 auto;
  border: 0;
  background: #fff;
  box-shadow: none;
}

.project-home-button {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 32;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 8px 11px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.58);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 800;
}

.project-home-button:hover {
  background: rgba(15, 23, 42, 0.78);
}

.floating-palette {
  position: fixed;
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.floating-palette {
  right: 12px;
  bottom: 12px;
  align-items: center;
}

.floating-palette .status-choice {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.floating-palette .status-choice {
  border-radius: 50%;
}

.floating-palette .status-choice.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.34);
}

.floating-palette .dot {
  width: 18px;
  height: 18px;
}

.color-reference {
  position: fixed;
  top: 50%;
  right: 12px;
  z-index: 24;
  display: grid;
  gap: 7px;
  width: 176px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.32);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(10px);
  opacity: 0.58;
  pointer-events: none;
  transform: translateY(-50%);
}

.color-reference div {
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 8px;
  align-items: center;
}

.color-reference b {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-reference small {
  grid-column: 2;
  margin-top: 1px;
  overflow: hidden;
  color: rgba(248, 250, 252, 0.72);
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-swatch {
  display: inline-block;
  grid-row: span 2;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

@media (max-width: 640px) {
  .dashboard-page {
    width: calc(100% - 20px);
    margin-top: 10px;
  }

  .inline-upload,
  .project-row,
  .project-row-link {
    grid-template-columns: 1fr;
  }

  .inline-upload {
    align-items: stretch;
  }

  .project-row-link {
    gap: 9px;
    min-height: 0;
  }

  .open-project {
    justify-content: flex-start;
  }

  .project-row .delete-project-form {
    padding: 0 14px 14px;
  }

  .floating-palette {
    left: 12px;
    right: auto;
  }

  .color-reference {
    top: 12px;
    right: 12px;
    width: 152px;
    transform: none;
  }
}
