:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f6f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #ffffff 0%, #f6f7fb 45%, #eef1f7 100%);
}

button, input, select { font: inherit; }

/*
 * Full-bleed shell. The page used to cap itself at 1180px, which left wide
 * empty margins on a laptop or projector. Three side-by-side panels need that
 * width, so keep only a small, fluid gutter.
 */
.page-shell {
  width: 100%;
  margin: 0;
  padding: 32px clamp(16px, 2.4vw, 40px) 40px;
}

/* ------------------------------------------------------------------ *
 * Hero
 * ------------------------------------------------------------------ */

.hero {
  max-width: 900px;
  margin-bottom: 24px;
}

.eyebrow, .section-kicker {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #52627a;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.lede {
  max-width: 720px;
  margin: 20px 0 0;
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  line-height: 1.6;
  color: #4b5563;
}

.lesson-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.lesson-strip span {
  padding: 8px 11px;
  border: 1px solid #dfe4ec;
  border-radius: 999px;
  background: rgba(255, 255, 255, .76);
  color: #52627a;
  font-size: .86rem;
}

.lesson-strip b {
  color: #111827;
  margin-right: 4px;
}

/* ------------------------------------------------------------------ *
 * Cards + controls
 * ------------------------------------------------------------------ */

.card {
  border: 1px solid #e0e5ed;
  border-radius: 22px;
  background: rgba(255, 255, 255, .93);
  box-shadow: 0 18px 50px rgba(26, 39, 63, 0.08);
}

.controls { padding: 22px 24px; }

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.7fr);
  gap: 32px;
}

.control-block + .control-block {
  padding-left: 32px;
  border-left: 1px solid #eceff4;
}

.step {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}

.step-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #111827;
  color: white;
  font-size: 0.82rem;
  font-weight: 750;
}

.grow { flex: 1; }
.control-label { font-weight: 700; }
.sample-title { margin: 0; }

.helper {
  margin: 6px 0 0;
  color: #667085;
  font-size: 0.92rem;
  line-height: 1.5;
}

.file-input {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  border: 1px dashed #bac3d2;
  border-radius: 14px;
  background: #fafbfc;
}

.meta-field { margin-top: 18px; }

.meta-input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #dfe4ec;
  border-radius: 12px;
  background: #f6f8fb;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  cursor: text;
}

.meta-input:focus {
  outline: 2px solid #111827;
  outline-offset: 1px;
}

.divider {
  height: 1px;
  margin: 20px 0;
  background: #eceff4;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-top: 14px;
}

.slider-row label { font-weight: 650; }

.slider-row output {
  min-width: 48px;
  text-align: right;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.slider-row + input[type="range"] {
  width: 100%;
  margin-top: 9px;
  accent-color: #111827;
}

.run-button {
  width: 100%;
  margin-top: 20px;
  padding: 13px 18px;
  border: 0;
  border-radius: 14px;
  background: #111827;
  color: white;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}

.run-button:not(:disabled):hover { transform: translateY(-1px); }
.run-button:disabled { opacity: .38; cursor: not-allowed; }

.status {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: #52627a;
  font-size: .9rem;
}

.progress-wrap {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #111827;
  transition: width .2s ease;
}

.run-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eceff4;
}

/* ------------------------------------------------------------------ *
 * Image picking
 * ------------------------------------------------------------------ */

.or-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: #98a2b3;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.or-row::before, .or-row::after {
  content: '';
  height: 1px;
  flex: 1;
  background: #eceff4;
}

.sample-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.coco-head { margin-top: 18px; }

.input-kicker {
  margin: 0 0 4px;
  color: #344054;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.shuffle-button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
}

.shuffle-button:hover { background: #f7f8fa; }

/* Four examples across on a wide screen, two on a phone. */
.sample-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sample-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e0e5ed;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.sample-card:hover {
  transform: translateY(-1px);
  border-color: #aeb8c6;
  box-shadow: 0 8px 18px rgba(26,39,63,.08);
}

.sample-card.selected {
  border-color: #111827;
  box-shadow: 0 0 0 2px #111827;
}

.sample-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef1f5;
}

.sample-card span {
  display: block;
  padding: 8px 9px 4px;
  overflow: hidden;
  color: #475467;
  font-size: .78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-card small {
  display: block;
  padding: 0 9px 9px;
  color: #8a94a4;
  font-size: .67rem;
  line-height: 1.2;
  letter-spacing: .01em;
}

/* ------------------------------------------------------------------ *
 * Results — three panels side by side
 * ------------------------------------------------------------------ */

.results { margin-top: 24px; }

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.results-head .section-kicker { margin-bottom: 6px; }

.results-head h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.55rem);
  letter-spacing: -0.02em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-family {
  margin: 0 0 2px;
  color: #7a8595;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -.02em;
}

.panel-tagline {
  margin: 3px 0 0;
  color: #667085;
  font-size: .76rem;
  line-height: 1.35;
}

.badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #536176;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ready { background: #e8f7ef; color: #17623c; }
.badge.running { background: #fff4df; color: #805600; }
.badge.error { background: #fdecec; color: #9b2c2c; }

.view-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #e0e5ed;
  border-radius: 11px;
  background: #f2f4f7;
}

/* An author `display` beats the UA rule behind the `hidden` attribute. */
.view-switch[hidden] { display: none; }

.view-option {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #52627a;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.view-option:hover { color: #111827; }

.view-option.selected {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(26, 39, 63, .12);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  overflow: hidden;
  border-radius: 14px;
  background: #101318;
}

/*
 * Size the canvas by its intrinsic aspect ratio, never by a fixed box: the
 * element box must match the painted image exactly, because SlimSAM converts a
 * click through getBoundingClientRect() into image coordinates. A letterboxed
 * box (from `width:100%` + `object-fit:contain`) would offset every click on a
 * portrait photo. max-height only caps how tall a portrait frame can get.
 */
.panel-card canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 46vh;
}

.panel-card canvas.clickable { cursor: crosshair; }

.canvas-wrap.empty canvas { display: none; }

.canvas-placeholder {
  margin: 0;
  padding: 26px;
  color: #9aa4b2;
  text-align: center;
  font-size: .86rem;
}

.canvas-wrap:not(.empty) .canvas-placeholder { display: none; }

.sam-hint {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid #ffe0b2;
  border-radius: 11px;
  background: #fff8ec;
  color: #7a4d00;
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.4;
}

.summary {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f8fa;
  color: #344054;
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #e8ebf0;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fafbfc;
  color: #52627a;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
.empty-row td { color: #7d899a; text-align: center; }

.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #f7f8fa; }

/* ------------------------------------------------------------------ *
 * Explanation + footer
 * ------------------------------------------------------------------ */

.explain {
  margin-top: 20px;
  padding: 22px 24px;
}

.explain-title {
  max-width: 820px;
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1.25;
  letter-spacing: -.025em;
}

.explain-copy {
  max-width: 900px;
  margin: 12px 0 18px;
  color: #536176;
  line-height: 1.65;
}

.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.flow span:not(.arrow) {
  padding: 8px 11px;
  border-radius: 10px;
  background: #f2f4f7;
}

.arrow { color: #98a2b3; }

.extension-note {
  max-width: 900px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid #eceff4;
  color: #5d6879;
  font-size: .92rem;
  line-height: 1.55;
}

footer {
  padding: 22px 2px 0;
  color: #7a8595;
  font-size: .84rem;
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 1050px) {
  .controls-grid { grid-template-columns: 1fr; gap: 22px; }

  .control-block + .control-block {
    padding-left: 0;
    padding-top: 20px;
    border-left: 0;
    border-top: 1px solid #eceff4;
  }
}

@media (max-width: 900px) {
  .result-grid { grid-template-columns: 1fr; }
  .sample-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .results-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .page-shell { padding-top: 24px; }
  .card { border-radius: 17px; }
  .controls, .panel-card, .explain { padding: 16px; }
  .sample-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  th, td { padding: 7px 8px; }
}
