/* Colours, type and component styles follow deepcheck_API/frontend/styles.css. */
:root {
  --ink: #001439;
  --muted: #52627a;
  --line: #d9e6f5;
  --navy: #001439;
  --blue: #00309c;
  --cyan: #00b3fe;
  --rose: #d94d56;
  --card-border: rgba(198, 215, 238, 0.95);
  --gap: 20px;
  /* Reference and canvas are always this same square: as big as fits two side
     by side with the header, task bar and toolbars still on screen. */
  --box: clamp(300px, min(calc((100vw - 3 * var(--gap)) / 2), calc(100vh - 252px)), 900px);
}

@supports (height: 100dvh) {
  :root {
    --box: clamp(300px, min(calc((100vw - 3 * var(--gap)) / 2), calc(100dvh - 252px)), 900px);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f7fbff;
  color: var(--ink);
  font-family: "Inter", Arial, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

code {
  border-radius: 6px;
  background: #eaf6ff;
  padding: 2px 6px;
  color: var(--blue);
  font-size: 0.92em;
}

/* ---------------------------------------------------------------- header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 0 var(--gap);
  border-bottom: 1px solid rgba(217, 230, 245, 0.86);
  background: rgba(247, 251, 255, 0.9);
}

.brand {
  color: var(--navy);
  font-size: 1.12rem;
  font-weight: 800;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.drawer-info {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.drawer-info strong {
  color: var(--navy);
  font-weight: 800;
}

.link-button {
  border: 0;
  background: none;
  padding: 0 0 0 4px;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: underline;
}

.lab-logo {
  display: block;
  height: 30px;
  width: auto;
}

/* ------------------------------------------------------------- workspace */

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px var(--gap) 10px;
}

.task-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  width: calc(2 * var(--box) + var(--gap));
  max-width: 100%;
}

.task-title {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--navy);
  font-size: 1.9rem;
  line-height: 1.1;
}

h1 small {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.helper-text {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-pill {
  border-radius: 999px;
  background: #eaf6ff;
  padding: 7px 12px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, var(--box));
  gap: var(--gap);
  justify-content: center;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.box {
  position: relative;
  width: var(--box);
  height: var(--box);
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 58px rgba(0, 20, 57, 0.11);
}

.ref-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ref-box img[hidden] {
  display: none;
}

.box-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.box-message[hidden] {
  display: none;
}

.canvas-box {
  border-color: #93cdec;
}

.canvas-box canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --------------------------------------------------------------- buttons */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-spacer {
  flex: 1;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 26px rgba(0, 48, 156, 0.24);
}

.secondary-button {
  border: 1px solid #c6d7ee;
  background: #fff;
  color: var(--ink);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.secondary-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: #eaf6ff;
  color: var(--blue);
}

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

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.image-id {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px var(--gap) 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer a {
  color: var(--muted);
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 30;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  border-radius: 8px;
  background: var(--navy);
  padding: 12px 18px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 20, 57, 0.3);
}

.toast.is-error {
  background: #aa2630;
}

.toast[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- dialog */

.drawer-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 26px;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 20, 57, 0.25);
}

.drawer-dialog::backdrop {
  background: rgba(0, 20, 57, 0.45);
}

.drawer-dialog h2 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 1.4rem;
}

.drawer-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
}

.drawer-dialog input {
  width: 100%;
  margin-bottom: 14px;
  border: 1px solid #c6d7ee;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drawer-dialog .primary-button {
  width: 100%;
}

.drawer-dialog .field-error {
  margin-top: -6px;
  color: #aa2630;
  font-size: 0.88rem;
  font-weight: 600;
}

/* -------------------------------------------------------------- narrow */

@media (max-width: 760px) {
  :root {
    --gap: 16px;
    --box: min(calc(100vw - 2 * var(--gap)), 560px);
  }

  .panels {
    grid-template-columns: var(--box);
  }

  .task-bar {
    flex-wrap: wrap;
    gap: 6px 16px;
    width: var(--box);
  }

  .helper-text {
    order: 3;
    flex-basis: 100%;
  }

  .lab-logo {
    display: none;
  }
}
