/* The maker itself. Phone first: everything below is written for a 390px screen,
   and the one media query at the bottom spreads it out on a big one.
   Tokens and the z-* classes come from kit/zettel.css, which loads first. */

body { overflow-x: hidden; }
main { display: block; }
.view[hidden] { display: none !important; }

/* ---- top bar ---------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
  border-bottom: 1px solid var(--ink);
}
.wordmark { grid-column: 2; text-align: center; font: 500 13px/1 var(--sans); letter-spacing: .46em; margin-right: -.46em; color: var(--ink); text-decoration: none; }
.bar button {
  width: 44px; height: 44px; border: 0; background: none; color: var(--ink);
  font: 400 18px/1 var(--sans); cursor: pointer; padding: 0;
}
.bar button[hidden] { display: none; }
#account-btn { grid-column: 3; font-size: 12px; letter-spacing: .1em; }
#account-btn .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
#account-btn.out .dot { background: none; border: 1px solid var(--muted); }

.view { max-width: 560px; margin: 0 auto; padding: 0 20px calc(40px + env(safe-area-inset-bottom, 0px)); }

/* ---- home ------------------------------------------------------------- */
.hero { padding: 40px 0 24px; }
.hero h1 { font: 400 clamp(44px, 15vw, 64px)/.95 var(--serif); letter-spacing: -.02em; margin: 0; }
.hero h1 em { font-style: italic; }
.hero p { margin: 14px 0 0; color: var(--muted); font-size: 16px; }

.ask { border-top: 1px solid var(--ink); padding-top: 18px; }
#idea {
  width: 100%; border: 0; background: none; resize: none; padding: 0 0 12px;
  font: 400 20px/1.35 var(--sans); color: var(--ink);
  border-bottom: 1px solid var(--line); border-radius: 0;
}
#idea:focus { outline: none; border-bottom-color: var(--ink); }
#idea::placeholder { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 2px; margin: 0 -20px; padding-inline: 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: none; color: var(--muted);
  padding: 9px 13px; font: 400 13px/1 var(--sans); cursor: pointer; white-space: nowrap; border-radius: 0;
}
.chip:hover, .chip:active { border-color: var(--ink); color: var(--ink); }

.ask-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 14px; }
.seg { display: flex; border: 1px solid var(--line); }
.seg button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 9px 12px; font: 500 10px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.est { font: 400 13px/1.3 var(--sans); color: var(--muted); text-align: right; }
.est b { font-weight: 400; color: var(--ink); }
.note { margin: 12px 0 0; font-size: 13px; color: var(--muted); min-height: 1.3em; }
.note.bad { color: var(--ink); }

.strip { margin-top: 48px; }
.rail { display: flex; gap: 14px; overflow-x: auto; margin: 16px -20px 0; padding: 2px 20px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.tcard { flex: none; width: 150px; color: inherit; text-decoration: none; scroll-snap-align: start; }
.tcard .shot { position: relative; width: 150px; height: 250px; border: 1px solid var(--ink); border-radius: 18px; overflow: hidden; background: #fff; }
.tcard iframe { position: absolute; top: 0; left: 0; width: 390px; height: 844px; border: 0; transform: scale(.3846); transform-origin: 0 0; pointer-events: none; }
.tcard b { display: block; font: 400 19px/1.2 var(--serif); margin-top: 10px; }
.tcard span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.mine { margin-top: 48px; }
.mine ul { list-style: none; margin: 0; padding: 0; }
.mine li a { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.mine img { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.mine b { display: block; font: 400 19px/1.2 var(--serif); }
.mine span { font-size: 12px; color: var(--muted); }

/* ---- writing ----------------------------------------------------------- */
.writing-head { padding: 36px 0 18px; }
.writing-head h1 { font: 400 clamp(36px, 11vw, 52px)/1 var(--serif); margin: 0 0 10px; }
.writing-head p { margin: 0; color: var(--muted); font-size: 15px; }
.meter { display: flex; gap: 18px; padding: 14px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); font: 400 13px/1 var(--sans); color: var(--muted); }
.meter b { display: block; font: 400 22px/1.1 var(--serif); color: var(--ink); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.stream {
  height: 44vh; min-height: 220px; overflow: hidden; position: relative;
  margin-top: 18px; padding: 14px; background: var(--soft);
  font: 400 11px/1.45 ui-monospace, 'Cascadia Code', Consolas, monospace;
  color: var(--muted); white-space: pre-wrap; word-break: break-all;
}
.stream::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 40px; background: linear-gradient(var(--soft), transparent); }
.writing-actions { margin-top: 18px; }

/* ---- preview ------------------------------------------------------------ */
#preview { padding: 0; max-width: none; }
.preview-frame { width: 100%; height: calc(100dvh - 52px - 76px - env(safe-area-inset-top, 0px)); border: 0; display: block; background: #fff; }
.preview-bar {
  position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ink); background: var(--bg);
}
.preview-bar .z-btn { flex: 1; }
.preview-cost { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---- make (name, icon, look) -------------------------------------------- */
.step { margin-top: 30px; }
.step:first-child { margin-top: 24px; }
.name-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--ink); background: none;
  padding: 4px 0 10px; font: 400 30px/1.1 var(--serif); border-radius: 0;
}
.name-input:focus { outline: none; }
.search { width: 100%; border: 1px solid var(--line); background: none; padding: 12px 14px; font-size: 15px; border-radius: 0; -webkit-appearance: none; }
.search:focus { outline: none; border-color: var(--ink); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; margin-top: 10px; max-height: 232px; overflow: auto; padding: 1px; }
.icon-grid button { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; padding: 0; }
.icon-grid button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-grid svg { width: 24px; height: 24px; }
.icon-grid .mono { font: 400 22px/1 var(--serif); }
.icon-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 1.3em; }
.looks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.look { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); background: none; cursor: pointer; text-align: left; }
.look[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.swatch { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border: 1px solid var(--ink); font: 400 18px/1 var(--serif); }
.swatch.noir { background: #0b0b0b; color: #f4f2ee; }
.swatch.paper { background: #fff; color: #0b0b0b; }
.look b { display: block; font: 500 11px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; }
.look span { font-size: 12px; color: var(--muted); }
.homes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.home { background: var(--soft); padding: 16px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.home img { width: 58px; height: 58px; display: block; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.home.ios img { border-radius: 13px; }
.home.android img { border-radius: 50%; }
.app-label { font: 400 12px/1.2 -apple-system, 'SF Pro Text', Roboto, system-ui, sans-serif; max-width: 92px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home small { font: 500 9px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.sticky-go { position: sticky; bottom: 0; padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, var(--bg) 22%); }

/* ---- done ---------------------------------------------------------------- */
#done h1 { font: 400 clamp(56px, 18vw, 96px)/.9 var(--serif); margin: 24px 0 0; letter-spacing: -.03em; }
.qr { border: 1px solid var(--ink); padding: 12px; background: #fff; max-width: 260px; margin: 24px auto 0; }
.qr svg { display: block; width: 100%; height: auto; }
.done-url { display: block; margin-top: 22px; font: 400 18px/1.35 var(--serif); color: var(--ink); overflow-wrap: anywhere; }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.done-actions .z-btn { flex: 1 1 140px; }
.install { margin-top: 28px; border-top: 1px solid var(--ink); }
.install > div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.install ol { margin: 8px 0 0; padding-left: 18px; font-size: 15px; }
.keynote { margin: 24px 0 0; font: italic 400 16px/1.45 var(--serif); color: var(--muted); }

/* ---- account ------------------------------------------------------------- */
.acc-head { padding: 32px 0 16px; }
.acc-head h1 { font: 400 clamp(40px, 12vw, 56px)/1 var(--serif); margin: 0; }
.acc-head p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.field { display: block; margin-top: 16px; }
.field span { display: block; font: 500 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field input { width: 100%; border: 1px solid var(--line); background: none; padding: 13px 14px; font-size: 16px; border-radius: 0; -webkit-appearance: none; }
.field input:focus { outline: none; border-color: var(--ink); }
.stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--ink); margin-top: 20px; }
.stats > div { padding: 16px 12px 16px 0; border-bottom: 1px solid var(--line); }
.stats > div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
.stats b { display: block; font: 400 30px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stats span { display: block; font: 500 9px/1.3 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.spark { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-items: end; height: 60px; margin-top: 18px; }
.spark i { background: var(--ink); min-height: 1px; display: block; }
.spark i.none { background: var(--line); }
.budget { margin-top: 10px; height: 6px; background: var(--soft); position: relative; }
.budget i { display: block; height: 100%; background: var(--ink); }
.rows { margin-top: 10px; }
.row {
  display: flex; gap: 12px; align-items: baseline; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 400; font-size: 15px; overflow-wrap: anywhere; }
.row .grow span { font-size: 12px; color: var(--muted); }
.row .num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: 13px; }
.row .z-btn--text { padding: 0; min-height: 0; }
.row.bad .grow b::after { content: ' · failed'; color: var(--muted); font-size: 12px; }
.debug { margin-top: 12px; font: 400 12px/1.7 ui-monospace, Consolas, monospace; color: var(--muted); }
.debug div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 3px 0; }
.debug b { font-weight: 400; color: var(--ink); overflow-wrap: anywhere; }
details.block { margin-top: 26px; }
details.block > summary { list-style: none; cursor: pointer; }
details.block > summary::-webkit-details-marker { display: none; }

/* ---- big screens ---------------------------------------------------------- */
@media (min-width: 860px) {
  .view { max-width: 900px; padding-inline: 32px; }
  .hero { padding: 64px 0 28px; }
  .hero h1 { font-size: 76px; }
  #idea { font-size: 24px; }
  .rail { flex-wrap: wrap; overflow: visible; }
  #preview { max-width: none; }
  .preview-frame { height: calc(100dvh - 52px - 76px); max-width: 460px; margin: 0 auto; border-inline: 1px solid var(--line); }
  .preview-bar { max-width: 460px; margin: 0 auto; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stats > div:nth-child(even) { padding-left: 16px; }
  .stats > div + div { padding-left: 16px; border-left: 1px solid var(--line); }
  .homes { max-width: 380px; }
}

/* ---- "keep Zettel itself on the home screen" ------------------------------- */
.install-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line);
}
.install-row b { display: block; font: 400 19px/1.25 var(--serif); }
.install-row span { font-size: 13px; color: var(--muted); }
.install-row .z-btn { flex: none; }
