:root {
  --ink: #000;
  --bg: #fff;
  --line: #d8d8d8;
  --line-soft: #ededed;
  --muted: #8a8a8a;
  --stage: #f4f4f4;
  --strip-h: 120px;
  --col: 480px;
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

* { box-sizing: border-box; border-radius: 0 !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* full-height flex column: content scrolls in its own region, strip pins to the bottom */
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* the scrolling content region — its scrollbar lives here, above the strip (never overlaps it) */
.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

a { color: inherit; }
button { font-family: var(--font); }

/* ---------------- Top bar ---------------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 50px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.brand-mark { height: 17px; width: auto; color: var(--ink); display: block; }
.brand-text { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------------- App column ---------------- */
.app {
  max-width: var(--col);
  margin: 0 auto;
  padding: 16px;
}

/* ---------------- Input ---------------- */
.input-row { display: flex; gap: 8px; }
.input {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--ink); }

.btn {
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  padding: 12px 18px;
  white-space: nowrap;
}
.btn:active { opacity: 0.85; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn-go { padding: 12px 20px; }

.status {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 55%;
  font-size: 15px;       /* same as the title */
  font-weight: 400;      /* but normal weight */
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.error { color: #c0392b; }
.brand { flex: 0 0 auto; }

/* ---------------- Intro ---------------- */
.intro { padding: 28px 2px; }
.intro-lead { font-size: 14px; color: var(--ink); margin: 0 0 14px; }
.credit { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.examples button {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.examples button:hover { border-color: var(--ink); }
.intro-note { font-size: 13px; color: var(--muted); max-width: 42ch; }
.intro-note code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: var(--stage);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
}

/* ---------------- Composer ---------------- */
.exporter { padding-top: 14px; }

.stage {
  background-color: #fbfbfb;
  background-image:
    linear-gradient(45deg, #e9e9e6 25%, transparent 25%),
    linear-gradient(-45deg, #e9e9e6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9e9e6 75%),
    linear-gradient(-45deg, transparent 75%, #e9e9e6 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  border: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
#canvas {
  display: block;
  max-width: 100%;
  max-height: 46vh;
  width: auto;
  height: auto;
  border: 1px solid var(--line);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.meta-line {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-line:hover { color: var(--ink); }
.btn-download { width: 100%; padding: 14px; text-align: center; }

/* ---------------- Options ---------------- */
.options {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.opt-label { font-size: 14px; color: var(--ink); }

.select {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='black' stroke-width='1.4'/></svg>")
    no-repeat right 12px center;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  min-width: 150px;
}

.seg { display: inline-flex; border: 1px solid var(--line); }
.seg-btn {
  font-size: 13px;
  padding: 9px 16px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.is-active { background: var(--ink); color: #fff; }

.opt-row-chips { justify-content: flex-start; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip:disabled { opacity: 0.35; cursor: default; }
.chip-mark { height: 11px; width: auto; display: block; color: currentColor; }

/* ---------------- Bottom strip (block selector) ---------------- */
.strip {
  /* a flex item that hugs its content at the bottom of the column — not a fixed overlay,
     so the content scrollbar stops above it and never overlaps the thumbnails */
  flex: 0 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.strip-inner {
  /* full-bleed: no horizontal padding here, so the scroller reaches both edges.
     no bottom padding either — the track owns it, so its scrollbar bottoms out flush */
  padding: 9px 0 0;
  display: flex;
  flex-direction: column;
}
.strip-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
}
.strip-track {
  display: flex;
  gap: 8px;
  /* padding lives on the scroll container itself — edges stay flush, thumbs aren't clipped;
     even 16px on the sides and bottom so the gap around the thumbs matches */
  padding: 0 16px 16px;
  scroll-padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.cell {
  position: relative;
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}
.cell:hover { border-color: var(--muted); }
.cell.is-selected { box-shadow: inset 0 0 0 2px var(--ink); border-color: var(--ink); }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .cell-text {
  position: absolute; inset: 0;
  padding: 5px;
  font-size: 7px;
  line-height: 1.25;
  color: var(--ink);
  text-align: left;
  overflow: hidden;
}
.cell .play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.cell .play::after {
  content: "";
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.6));
  margin-left: 2px;
}

/* ---------------- Desktop niceties ---------------- */
@media (min-width: 540px) {
  #canvas { max-height: 56vh; }
}
