:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --on-accent: #052e16;
  --warn-bg: #2a2410;
  --warn-text: #fde68a;
  --bad: #f87171;
  --ok-text: #86efac;
  --radius: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #475569;
    --accent: #16a34a;
    --accent-strong: #15803d;
    --on-accent: #ffffff;
    --warn-bg: #fef9c3;
    --warn-text: #713f12;
    --bad: #b91c1c;
    --ok-text: #166534;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { flex: 1; }
a { color: var(--accent); text-underline-offset: 3px; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
h1, h2 { line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
.muted { color: var(--muted); }
.i { flex: none; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

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

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span, .hero h1 span { color: var(--accent); }
.top .search { flex: 1; min-width: 0; }

@media (max-width: 560px) {
  .top-inner { flex-direction: column; align-items: stretch; gap: 8px; }
}

/* Search */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 4px 4px 14px;
  transition: border-color 150ms var(--ease);
}
.search:focus-within { border-color: var(--accent); }
.search .i { color: var(--muted); }
.search input {
  flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--text);
  font: inherit; outline: none;
}
.search input::placeholder { color: var(--muted); opacity: 0.8; }
.search-big { padding: 6px 6px 6px 18px; }
.search-big input { height: 48px; font-size: 1.05rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  touch-action: manipulation;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 100ms var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* Home */
.hero { padding: 14vh 0 48px; text-align: center; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); margin: 0 0 8px; letter-spacing: -0.03em; }
.lede { color: var(--muted); font-size: 1.15rem; margin: 0 auto 32px; max-width: 32ch; }
.points { list-style: none; padding: 0; margin: 40px auto 0; display: grid; gap: 14px; max-width: 520px; text-align: left; }
.points li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.points .i { color: var(--accent); margin-top: 2px; }
.points strong { color: var(--text); }

/* Results */
.page-title { font-size: 1.6rem; margin: 28px 0 16px; }
.results { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.result {
  display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.result:hover { border-color: var(--accent); }
.result-text { display: flex; flex-direction: column; min-width: 0; }
.result-title { font-weight: 600; }
.result-dev, .result-pkg { color: var(--muted); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-pkg { font-family: ui-monospace, monospace; font-size: 0.8rem; }

.app-icon { border-radius: 22%; background: var(--surface-2); object-fit: cover; flex: none; }
.app-icon-empty.s56 { width: 56px; height: 56px; }
.app-icon-empty.s96 { width: 96px; height: 96px; }

.empty { text-align: center; padding: 48px 0; }

/* App page */
.app-head { display: flex; gap: 18px; align-items: center; margin-top: 28px; }
.app-head h1 { margin: 0; font-size: 1.6rem; }
.app-head p { margin: 2px 0 0; }
.app-head-text { min-width: 0; }
.pkg { font: 0.85rem ui-monospace, monospace; color: var(--muted); word-break: break-all; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 24px 0 12px; }
.summary { color: var(--muted); }

.note {
  display: flex; gap: 10px; align-items: flex-start; margin: 12px 0;
  padding: 12px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-text); font-size: 0.925rem;
}
.note .i { margin-top: 3px; }
.note a { color: inherit; }
.note-ok { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ok-text); }
.note-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.shots { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0 12px; margin: 16px 0 0; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
.shots img { height: 300px; width: auto; border-radius: 10px; scroll-snap-align: start; background: var(--surface-2); }

.versions { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.version { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); }
.version + .version { border-top: 1px solid var(--border); }
.version-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.version-name { font-weight: 600; }
.version-meta { color: var(--muted); font-size: 0.85rem; }
.version .btn { min-height: 40px; padding: 0 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-ok { color: var(--ok-text); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.badge-build { color: var(--warn-text); background: var(--warn-bg); }

@media (max-width: 480px) {
  .version { flex-wrap: wrap; }
  .version-main { flex-basis: 100%; }
  .version .btn { margin-left: auto; }
}

.desc { margin: 28px 0; }
.desc summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.desc p { color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; color: var(--muted); text-decoration: none; min-height: 44px; }
.back:hover { color: var(--text); }

/* Build page */
.build { max-width: 560px; }
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 24px 0 10px; }
.progress-bar { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 300ms var(--ease); }
.progress.indeterminate .progress-bar { width: 35%; transform: none; animation: slide 1.2s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.build-status { color: var(--muted); font-variant-numeric: tabular-nums; }
.build-done, .build-failed { margin-top: 20px; }

.files { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.files li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.files .btn { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 0.85rem ui-monospace, monospace; }
.steps { padding-left: 1.4rem; }
.steps li { margin: 8px 0; }
.steps code, .ready code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

.prose { max-width: 65ch; }
.prose li { margin: 6px 0; }
.fingerprint { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }

.foot { padding-top: 32px; padding-bottom: 32px; color: var(--muted); font-size: 0.85rem; }
.foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
