:root {
  --bg: #f8f6f2;
  --bg-accent: #dad7cb;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --border: rgba(46, 45, 41, 0.2);
  --text: #2e2d29;
  --muted: #5f574f;
  --accent: #8c1515;
  --blue: #006cb8;
  --gold: #b26f16;
  --danger: #b1040e;
  --good: #007c92;
  --shadow: 0 8px 12px -6px rgba(46, 45, 41, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-accent);
}

.app-shell {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding: 12px 0;
}

.workspace {
  display: grid;
  grid-template-columns: 375px 1fr;
  gap: 10px;
  align-items: stretch;
  height: calc(100vh - 24px);
}

.status-panel {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 100%;
  overflow: auto;
}

.status-card {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 750;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-card strong {
  font-size: 0.92rem;
  color: var(--text);
}

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

.hidden {
  display: none !important;
}

.status-note,
.status-disclaimer {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.32;
  color: var(--muted);
}

.clinical-warning {
  display: inline-block;
  margin-top: 6px;
  color: var(--danger);
  font-weight: 850;
}

.author-name {
  margin: 0 0 8px;
  color: rgba(95, 87, 79, 0.72);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.2;
}

.status-lead {
  margin-bottom: 0;
}

.status-lead strong {
  color: var(--accent);
  font-size: 1.35rem;
  line-height: 1.1;
}

.status-disclaimer {
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--danger);
}

.results-section {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.results-section:hover,
.results-section.active {
  border-color: var(--accent);
  background: #fffefe;
}

.results-section.has-image-output {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.results-section.has-image-output:hover,
.results-section.has-image-output.active {
  background: transparent;
}

.results-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 100%;
  gap: 10px;
  place-items: center;
  overflow: auto;
}

.results-grid.empty-results {
  place-items: center;
  grid-template-columns: 1fr;
  overflow: hidden;
}

.empty-panel {
  width: min(300px, 82%);
  display: grid;
  gap: 8px;
  justify-items: center;
}

.empty-state {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 70px;
  padding: 14px 18px;
  border: 2px dashed rgba(140, 21, 21, 0.35);
  border-radius: 0;
  background: var(--bg);
  color: var(--muted);
  overflow: hidden;
}

.empty-state p {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.empty-state .drop-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
}

.empty-state.analyzing {
  gap: 8px;
}

.hourglass-emoji {
  display: inline-block;
  margin-left: 6px;
  animation: blink-hourglass 0.9s ease-in-out infinite;
}

@keyframes blink-hourglass {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

.drop-disclaimer {
  width: 100%;
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
  line-height: 1.28;
  text-align: center;
}

.result-card {
  position: relative;
  min-height: 0;
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.display-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 7px 9px;
  border: 1px solid rgba(140, 21, 21, 0.24);
  background: #ffffff;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.display-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.display-switch {
  position: relative;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(46, 45, 41, 0.24);
  background: #9ca3af;
  transition: background 0.16s ease;
}

.display-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.22);
  transition: transform 0.16s ease;
}

.display-control input:checked + .display-switch {
  background: #16a34a;
}

.display-control input:checked + .display-switch::after {
  transform: translateX(12px);
}

.result-image-wrap {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-image-wrap canvas,
.result-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.error-card {
  display: block;
  min-height: auto;
  border-color: rgba(177, 4, 14, 0.35);
}

.error-text {
  color: var(--danger);
  font-weight: 750;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.32;
}

@media (max-width: 1020px) {
  body {
    overflow: auto;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
  }

  .status-panel {
    max-height: none;
  }

  .results-section {
    min-height: 72vh;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1540px);
  }

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

  .results-section {
    padding: 16px;
  }

  .results-section.has-image-output {
    padding: 0;
  }
}
