:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #66736d;
  --line: #d8e0da;
  --panel: #ffffff;
  --bg: #f5f7f3;
  --green: #245e3d;
  --lime: #b6d96c;
  --blue: #235b77;
  --red: #a83f36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-busy {
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: rgba(245, 247, 243, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand, nav, nav form {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

main {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.hero, .detail-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 760px; font-size: clamp(2rem, 5vw, 4.8rem); line-height: 0.97; margin-bottom: 0; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.98rem; margin-bottom: 6px; }

.eyebrow {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.grid, .result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 3vw, 24px);
  box-shadow: 0 12px 28px rgba(27, 42, 34, 0.06);
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 700;
}

.coach-profile {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.coach-profile legend {
  margin-bottom: 2px;
  font-weight: 800;
}

.coach-profile label {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.coach-profile input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.coach-profile span {
  display: grid;
  gap: 2px;
}

.coach-profile small {
  color: var(--muted);
  font-weight: 500;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  background: #fbfcfa;
}

.dropzone {
  min-height: 160px;
  place-items: center;
  padding: 22px;
  border: 2px dashed #9caf9f;
  border-radius: 8px;
  background: #f8faf5;
  text-align: center;
}

.dropzone input { max-width: 320px; }
.dropzone span { font-size: 1.15rem; }
.dropzone small, .muted { color: var(--muted); }

.primary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary:disabled {
  background: #95a29a;
  cursor: not-allowed;
}

.quota-box {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #bfd0c2;
  border-radius: 8px;
  background: #f7fbf0;
}

.quota-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.quota-box span, .quota-box small {
  color: var(--muted);
}

meter {
  width: 100%;
  height: 12px;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 27, 0.52);
  backdrop-filter: blur(6px);
}

.busy-overlay[hidden] {
  display: none;
}

.busy-dialog {
  width: min(460px, 100%);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  text-align: center;
}

.busy-dialog h2 {
  margin: 12px 0 8px;
}

.busy-dialog p {
  color: var(--muted);
  margin-bottom: 18px;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 4px solid #dce8dc;
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee8;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.25s ease;
}

.busy-dialog small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.user-chip, .status {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: white;
  color: var(--muted);
  font-style: normal;
  font-size: 0.86rem;
}

.status.complete { color: var(--green); border-color: #93b48f; }
.status.error { color: var(--red); border-color: #d6aaa5; }
.status.analyzing, .status.pending { color: var(--blue); border-color: #9bbccc; }

.analysis-list {
  display: grid;
  gap: 10px;
}

.analysis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.analysis-row span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.analysis-row strong {
  overflow-wrap: anywhere;
}

.analysis-row small {
  color: var(--muted);
}

.summary-panel {
  margin-bottom: 18px;
  border-left: 6px solid var(--lime);
}

.result-grid {
  margin-bottom: 18px;
}

.frame-panel {
  margin-bottom: 18px;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.frame-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.frame-card.has-note {
  border-color: #aac0ad;
}

.frame-image-wrap {
  position: relative;
  background: #0f1712;
}

.frame-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.frame-overlay line {
  stroke: #e9ff64;
  stroke-width: 1.2;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.frame-overlay circle {
  fill: rgba(233, 255, 100, 0.14);
  stroke: #e9ff64;
  stroke-width: 1.1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.frame-overlay polygon {
  fill: #e9ff64;
}

.frame-copy {
  padding: 14px;
}

.frame-copy .eyebrow {
  margin-bottom: 6px;
}

.frame-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.marker-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.marker-labels span {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  background: #edf5df;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

.finding {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.finding h3 span {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
}

.clean-list {
  display: grid;
  gap: 10px;
  padding-left: 18px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.message.error, .error-panel {
  border-color: #d6aaa5;
  color: #7d241d;
}

.login-shell {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.login-panel {
  width: min(440px, 100%);
}

.changelog pre {
  white-space: pre-wrap;
  font: inherit;
  color: var(--ink);
}

@media (max-width: 780px) {
  .topbar, .hero, .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    justify-content: space-between;
  }

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

  h1 {
    font-size: 2.35rem;
  }

  .analysis-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .quota-box div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
