: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, textarea { font: inherit; }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.guide-linkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 24px;
  padding: 11px 15px;
  border: 1px solid #d6e3f4;
  border-radius: 14px;
  background: #edf5ff;
  color: #334965;
  font-size: .9rem;
  font-weight: 700;
}
.guide-linkbar a { display: inline-flex; align-items: center; gap: 5px; border-radius: 8px; color: #174f9e; font-weight: 800; text-decoration: none; }
.guide-linkbar a:hover { text-decoration: underline; }
.guide-linkbar a:focus-visible { outline: 3px solid #f7b844; outline-offset: 3px; }

.hero { width: 100%; margin-bottom: 20px; }
.eyebrow, .section-kicker {
  margin: 0 0 10px;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #52627a;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.lede {
  max-width: 940px;
  margin: 14px 0 0;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.5;
  color: #4b5563;
}

.lesson-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.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 { margin-right: 4px; color: #111827; }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(0, 1.45fr);
  gap: 20px;
  align-items: start;
}

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

.controls, .result { padding: 24px; }
.result { position: sticky; top: 16px; }
.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: #fff;
  font-size: .82rem;
  font-weight: 750;
}

.grow { flex: 1; min-width: 0; }
.control-label { font-weight: 700; }
.helper { margin: 6px 0 0; color: #667085; font-size: .92rem; line-height: 1.5; }
.sample-title { margin: 0; }
.sample-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.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:not(:disabled) { background: #f7f8fa; }
.shuffle-button:disabled { opacity: .45; cursor: not-allowed; }
.input-kicker {
  margin: 0 0 4px;
  color: #344054;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.example-head { margin-top: 18px; }

.sample-grid {
  display: grid;
  grid-template-columns: repeat(2, 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 9px;
  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; }

.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; }
.file-input { width: 100%; margin-top: 16px; padding: 11px; border: 1px dashed #bac3d2; border-radius: 14px; background: #fafbfc; }
.divider { height: 1px; margin: 22px 0; background: #eceff4; }
.model-select, textarea {
  width: 100%;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid #cfd7e3;
  border-radius: 12px;
  background: #fff;
  color: #111827;
}
.model-select:focus, textarea:focus { outline: 2px solid #111827; outline-offset: 2px; }
.clip-controls { margin-top: 18px; }
textarea { resize: vertical; line-height: 1.45; }
.slider-row { display: flex; justify-content: space-between; gap: 12px; }
#top-k-value { min-width: 48px; text-align: right; color: #334155; font-variant-numeric: tabular-nums; }
#top-k { width: 100%; margin-top: 13px; accent-color: #111827; }

.run-button {
  width: 100%;
  margin-top: 24px;
  padding: 13px 18px;
  border: 0;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  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: 14px 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; }

.result-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.result h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; }
.badge { padding: 7px 10px; border-radius: 999px; background: #eef2f7; color: #536176; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge.ready { background: #e8f7ef; color: #17623c; }
.badge.running { background: #fff4df; color: #805600; }
.badge.error { background: #fdecec; color: #9b2c2c; }

.preview-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  overflow: hidden;
  border-radius: 16px;
  background: #101318;
}
#preview-image { display: block; max-width: 100%; max-height: 560px; object-fit: contain; }
.preview-wrap.empty #preview-image { display: none; }
#preview-placeholder { margin: 0; padding: 32px; color: #9aa4b2; text-align: center; }
.preview-wrap:not(.empty) #preview-placeholder { display: none; }
.summary { margin: 16px 0; padding: 13px 15px; border-radius: 13px; background: #f7f8fa; color: #344054; font-weight: 650; line-height: 1.5; }
.run-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -5px 0 16px;
}
.run-meta[hidden] { display: none; }
.run-meta > span { min-width: 0; padding: 9px 10px; border: 1px solid #e8ebf0; border-radius: 11px; background: #fff; }
.run-meta b { display: block; margin-bottom: 3px; color: #7a8595; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
.run-meta span span { display: block; overflow: hidden; color: #344054; font-size: .82rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid #e8ebf0; border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 11px 13px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; }
th { background: #fafbfc; color: #52627a; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row td { color: #7d899a; text-align: center; }
.score-wrap { display: grid; grid-template-columns: 58px minmax(70px, 1fr); gap: 9px; align-items: center; font-variant-numeric: tabular-nums; }
.score-track { display: block; height: 7px; overflow: hidden; border-radius: 999px; background: #edf0f5; }
.score-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #111827, #5e6c84); }

.explain { margin-top: 16px; padding: 18px 24px; }
.explain-title { margin: 0; font-size: clamp(1.15rem, 1.8vw, 1.45rem); line-height: 1.25; letter-spacing: -.02em; }
.explain-copy { margin: 10px 0 14px; color: #536176; line-height: 1.55; }
.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 { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid #eceff4; color: #5d6879; font-size: .92rem; line-height: 1.5; }
.history { margin-top: 16px; padding: 20px 24px 24px; }
.history-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 15px; }
.history-copy { margin: 8px 0 0; color: #5d6879; font-size: .92rem; line-height: 1.5; }
.secondary-button { flex: 0 0 auto; padding: 9px 12px; border: 1px solid #cfd7e3; border-radius: 11px; background: #fff; color: #344054; font-weight: 700; cursor: pointer; }
.secondary-button:hover:not(:disabled) { border-color: #8f9bad; }
.secondary-button:disabled { opacity: .45; cursor: not-allowed; }
.runtime-note { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 16px; overflow: hidden; background: #e5e9f0; }
.runtime-note div { padding: 16px 18px; background: rgba(255,255,255,.96); }
.runtime-note b { display: block; margin-bottom: 5px; color: #111827; font-size: .88rem; }
.runtime-note span { color: #667085; font-size: .84rem; line-height: 1.45; }
footer { padding: 14px 2px 0; color: #7a8595; font-size: .84rem; }

@media (max-width: 820px) {
  .page-shell { width: min(100% - 20px, 720px); padding: 22px 0 20px; }
  .workspace { grid-template-columns: 1fr; }
  .result { position: static; }
  .preview-wrap { min-height: 280px; }
  .runtime-note { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .card { border-radius: 17px; }
  .controls, .result, .explain, .history { padding: 18px; }
  .result-head { align-items: center; }
  .run-meta { grid-template-columns: 1fr; }
  .history-head { display: block; }
  .secondary-button { margin-top: 12px; }
  th, td { padding: 9px 10px; }
}
