:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f7f8fa;
  --accent: #16181d;
  --danger: #b42318;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* ---------- top bar ---------- */

.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 650; letter-spacing: -0.01em;
  color: var(--fg); text-decoration: none;
}
.bar-nav { display: flex; gap: 18px; }
.bar-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.bar-nav a:hover { color: var(--fg); }

/* ---------- layout ---------- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* ---------- tool: first screen ---------- */

.tool { padding: 36px 0 8px; }

h1 {
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 15px;
}
.sub strong { color: var(--fg); }

/* ---------- the file drop target ---------- */

.drop { margin: 0; }

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 148px;
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  background: var(--soft);
  border: 2px dashed #cfd3da;
  border-radius: var(--radius);
  transition: border-color .15s ease, background .15s ease;
}
.pick:hover { border-color: #9aa1ac; }
.pick:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 24, 29, 0.08);
}

/* Drag state is driven from app.js: the browser only fires the drag events on
   the drop target, but the dashed box is the thing that should light up. */
.drop.over .pick { border-color: var(--accent); background: #eef0f4; }

.pick-icon { color: var(--muted); margin-bottom: 4px; line-height: 0; }
.pick-main { font-weight: 600; font-size: 16px; }
.pick-sub { font-size: 13.5px; color: var(--muted); }

.chosen {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--fg);
  overflow-wrap: anywhere;
}

.opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}
.opts label { display: inline-flex; align-items: center; gap: 7px; }
.opts input[type="checkbox"] { accent-color: var(--accent); }

.sel-wrap select {
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  /* wide enough for the longest option text — a select that clips its own
     label ("Better accuracy — 79.7 M") is worse than a slightly wider row */
  max-width: 260px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.hint.warn { color: var(--danger); }
.hint.warn[hidden] { display: none; }

/* ---------- model loading ---------- */

.mstatus { margin: 18px 0 0; }
.mstatus[hidden] { display: none; }

.mbar {
  height: 5px;
  overflow: hidden;
  background: var(--line);
  border-radius: 999px;
}
.mbar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s ease;
}
/* Before the first byte arrives there is no percentage to show, so the bar
   sweeps instead of sitting at zero and looking broken. */
.mbar.indet span {
  width: 35%;
  animation: sweep 1.2s ease-in-out infinite;
}
@keyframes sweep {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}

#mtext {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- errors ---------- */

.err {
  margin: 16px 0 0;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--danger);
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius);
}

/* ---------- busy ---------- */

.busy {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.busy[hidden] { display: none; }
.busy p { margin: 0; }
.spinner {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- output ---------- */

.out {
  margin: 24px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.out-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.out-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

.out-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.out-actions button {
  padding: 6px 11px;
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
}
.out-actions button:hover { background: var(--soft); }

.meta {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.meta:empty { display: none; }

.text {
  margin: 0;
  padding: 16px 14px;
  font: 14px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
  background: var(--bg);
}

button {
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: opacity .15s ease;
}

/* ---------- prose ---------- */

.prose { margin-top: 56px; }
.prose h2 {
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
}
.prose h3 {
  font-size: 15.5px;
  margin: 24px 0 6px;
}
.prose p, .prose li { color: #33363d; font-size: 15px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose code {
  font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.prose a { color: var(--fg); }

.foot {
  border-top: 1px solid var(--line);
  padding: 22px 20px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.foot p { margin: 0; }

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  main { padding: 0 16px 48px; }

  .tool { padding: 24px 0 4px; }

  h1 { font-size: 23px; }

  .sub { font-size: 14.5px; margin-bottom: 18px; }

  .pick { min-height: 132px; padding: 18px 14px; }
  .pick-main { font-size: 15.5px; }

  .opts { gap: 12px; font-size: 13.5px; }
  /* the two selects sit on their own lines rather than being squeezed */
  .sel-wrap { width: 100%; justify-content: space-between; }
  .sel-wrap select { max-width: 62%; font-size: 16px; }

  .out-head { flex-direction: column; align-items: stretch; }
  .out-actions { display: grid; grid-template-columns: repeat(4, 1fr); }
  .out-actions button { padding: 8px 4px; font-size: 12.5px; }

  .text { font-size: 13px; max-height: 55vh; }
  .meta { font-size: 12px; }

  .prose { margin-top: 40px; }
  .prose h2 { font-size: 17.5px; }
}

/* Narrow phones (iPhone SE and friends). Four export buttons in a row leaves
   about 68px each and "Copy text" wraps onto two lines, which looks untidy and
   makes the row uneven. Two columns keep every label on one line. */
@media (max-width: 380px) {
  .out-actions { grid-template-columns: repeat(2, 1fr); }
  .out-actions button { padding: 10px 6px; }
}
