:root {
  --bg: #fbf7f1;
  --bg-2: #f3ece2;
  --card: #ffffff;
  --ink: #2f2a25;
  --ink-2: #6b625a;
  --ink-3: #a0958a;
  --line: #eadfd2;
  --accent: #ff8a5b;
  --accent-ink: #fff;
  --accent-soft: #ffe7dc;
  --ok: #4fb286;
  --warn: #e9b949;
  --bad: #e4605e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 8px 24px -12px rgba(60, 40, 20, .18);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  display: grid; grid-template-columns: 260px 1fr; font-size: 15px; line-height: 1.45;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 14px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-3); }
.hidden { display: none !important; }
.muted { color: var(--ink-3); font-size: 13px; }

/* sidebar */
.side { background: var(--bg-2); border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; height: 100vh; position: sticky; top: 0; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; padding: 4px; }
.brand-mark { width: 40px; height: 40px; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
.sites { display: flex; flex-direction: column; gap: 4px; overflow: auto; flex: 1; }
.site-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: inherit; border: 0; background: none; text-align: left; width: 100%; cursor: pointer; }
.site-link:hover { background: rgba(255,255,255,.6); }
.site-link.active { background: var(--card); box-shadow: var(--shadow); }
.site-link .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.site-link .dot.ready { background: var(--ok); }
.site-link .dot.building { background: var(--warn); animation: pulse 1.2s infinite; }
.site-link .dot.error { background: var(--bad); }
.site-link .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { color: var(--ink-3); font-size: 12px; text-align: center; }
.sites .none { color: var(--ink-3); font-size: 13px; padding: 10px; text-align: center; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: transform .08s, background .15s; white-space: nowrap; }
.btn:hover { background: var(--bg-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.btn-primary:hover { background: #f77a4a; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn.danger:hover { color: var(--bad); }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

/* main */
.main { padding: 20px 24px; min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.site { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.welcome { min-height: 80vh; display: grid; place-items: center; }
.welcome-card { text-align: center; max-width: 440px; }
.welcome-emoji { font-size: 56px; }
.welcome h1 { font-size: 32px; margin: 8px 0 12px; }
.welcome p { color: var(--ink-2); margin: 0 0 22px; }

.site-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; flex: none; }
.site-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.name-input { font-size: 26px; font-weight: 700; border: 0; background: transparent; padding: 4px 6px; border-radius: 8px; min-width: 0; width: min(100%, 26ch); }
.name-input:hover, .name-input:focus { background: var(--card); outline: none; box-shadow: inset 0 0 0 1px var(--line); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); text-transform: capitalize; }
.pill.ready { background: #dff3ea; color: #24774f; }
.pill.building { background: #fff1c9; color: #7a5c00; }
.pill.error { background: #fde0df; color: #9b2f2d; }
.site-actions { display: flex; gap: 8px; }
.rename { opacity: .6; }
.site-title:hover .rename, .rename:focus { opacity: 1; }

.columns { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(360px, 1.4fr); gap: 20px; align-items: stretch; flex: 1; min-height: 0; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; min-height: 0; }
.col-left { overflow-y: auto; padding-right: 4px; }
.col-right { height: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

textarea, .name-small { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); resize: vertical; }
textarea:focus, .name-small:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.name-small { margin: 8px 0; }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; background: var(--bg); transition: background .15s, border-color .15s; }
.drop.over { background: var(--accent-soft); border-color: var(--accent); }
.drop p { margin: 2px 0; }
.paste { margin-top: 10px; }
.paste summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.paste .btn { margin-top: 8px; }

.resources { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.resources li { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 13px; max-width: 100%; }
.resources li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resources li button { border: 0; background: rgba(0,0,0,.06); border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 1; font-size: 12px; }
.resources li button:hover { background: var(--bad); color: #fff; }

.build-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; font-size: 13.5px; }
.activity li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 10px; }
.activity li .ic { width: 20px; flex: none; text-align: center; }
.activity li.tool { color: var(--ink-2); }
.activity li.text { background: var(--bg); white-space: pre-wrap; }
.activity li.error { background: #fde0df; color: #9b2f2d; }
.activity li.done { background: #dff3ea; color: #24774f; white-space: pre-wrap; }
.activity li.log { color: var(--ink-3); font-family: var(--mono); font-size: 12px; }
.activity li .meta { margin-top: 6px; color: var(--ink-3); font-size: 12px; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-left: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* preview */
.preview-card { padding: 0; overflow: hidden; flex: 1; display: flex; flex-direction: column; min-height: 360px; }
.preview-bar { flex: none; }
.preview-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.dots i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--line); margin-right: 4px; }
.url { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--card); padding: 4px 10px; border-radius: 999px; }
.preview-stage { position: relative; flex: 1; min-height: 0; display: flex; }
#preview { display: block; width: 100%; flex: 1; min-height: 0; border: 0; background: #fff; }
.files-card summary { cursor: pointer; list-style: none; }
.files-card summary::-webkit-details-marker { display: none; }
.files-card summary h2 { margin: 0; display: inline; }
.files-card summary h2::after { content: ' ▸'; color: var(--ink-3); }
.files-card[open] summary h2::after { content: ' ▾'; }
.files-card[open] summary { margin-bottom: 8px; }
.files { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); columns: 2; }
.files li { padding: 2px 0; break-inside: avoid; }
.files a { color: inherit; text-decoration: none; }
.files a:hover { color: var(--accent); }

/* dialog */
dialog { border: 0; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); width: min(92vw, 380px); }
dialog::backdrop { background: rgba(47, 42, 37, .35); }
dialog h2 { margin-bottom: 12px; }
dialog input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 16px 0 0; padding: 0; }

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .main { height: auto; display: block; padding: 18px; }
  .site { display: block; }
  .columns { grid-template-columns: 1fr; }
  .col-left { overflow: visible; }
  .col-right { height: auto; }
  #preview { height: 75vh; }
}

/* edit mode */
.edit-tools { display: flex; align-items: center; gap: 8px; }
.edit-tools #editActive { display: inline-flex; align-items: center; gap: 8px; }
.preview-card.editing .preview-bar { background: var(--accent-soft); }
.preview-card.editing #preview { box-shadow: inset 0 0 0 3px var(--accent); }
.edit-note { padding: 10px 14px; font-size: 13px; background: #fff7ed; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.edit-note.ok { background: #dff3ea; color: #24774f; }
.edit-note.warn { background: #fff1c9; color: #7a5c00; }

/* auth */
.auth-card { width: min(92vw, 420px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.auth-form input { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; background: var(--bg); }
.auth-form input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.code-input { text-align: center; font-size: 26px !important; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.captcha:empty { display: none; }
.captcha { display: flex; justify-content: center; }
.auth-error { margin-top: 12px; background: #fde0df; color: #9b2f2d; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.providers { margin-top: 18px; }
.or { position: relative; text-align: center; color: var(--ink-3); font-size: 12px; margin: 6px 0 12px; }
.or::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.or span { position: relative; background: var(--card); padding: 0 10px; }
.provider-buttons { display: flex; flex-direction: column; gap: 8px; }
.provider-buttons .btn { justify-content: center; width: 100%; }
.tiny { font-size: 11px; margin-top: 16px; }

/* signed out: no sidebar, landing page with an intro beside the sign-in card */
body.signed-out { grid-template-columns: 1fr; }
body.signed-out .side { display: none; }
.landing { min-height: calc(100vh - 40px); display: grid; grid-template-columns: minmax(0, 520px) auto; gap: 56px; align-items: center; justify-content: center; }
.intro-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 22px; }
.intro-brand img { image-rendering: pixelated; }
.intro h1 { font-size: 40px; line-height: 1.1; margin-bottom: 14px; }
.intro .lead { font-size: 17px; color: var(--ink-2); margin: 0 0 24px; }
.steps { list-style: none; counter-reset: step; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; }
.steps li::before { content: counter(step); grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: #c4552b; font-weight: 700; display: grid; place-items: center; }
.steps span { color: var(--ink-2); font-size: 14px; }
.intro-foot { color: var(--ink-2); font-size: 14px; margin: 0; }
.landing .auth-card { text-align: center; }
.landing .auth-card h1 { margin: 4px 0 8px; }
.pitch { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pitch .bubble { min-height: 4.4em; display: grid; place-items: center; width: min(100%, 300px); }
.pitch-tiny.swap img { animation: swapin .25s ease; }
@media (prefers-reduced-motion: reduce) { .pitch .bubble, .pitch-tiny img { animation: none !important; } }
@media (max-width: 980px) {
  .landing { grid-template-columns: 1fr; gap: 28px; justify-items: center; padding: 8px 0 24px; min-height: 0; }
  .intro { max-width: 520px; }
  .intro h1 { font-size: 30px; }
}
.side-foot { display: flex; flex-direction: column; gap: 8px; }
.account { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); background: var(--card); border-radius: 999px; padding: 6px 10px 6px 6px; text-align: left; }
.account .avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; text-transform: uppercase; }
.account .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .link { font-size: 12px; text-decoration: underline; }
.model-note { font-size: 12px; color: var(--ink-3); }

/* api keys */
.keys-dialog { width: min(92vw, 520px); }
.keys-dialog code { background: var(--bg-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.keys { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.keys li { display: flex; align-items: center; gap: 10px; font-size: 13px; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.keys li .kname { flex: 1; font-weight: 600; }
.keys li .kmeta { color: var(--ink-3); font-family: var(--mono); font-size: 12px; }
.new-key:empty { display: none; }
.new-key { background: #dff3ea; color: #24774f; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; word-break: break-all; }
.new-key code { background: #fff; color: var(--ink); font-size: 13px; }
.key-form { display: flex; gap: 8px; }
.key-form input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }

/* ---------- Tiny, the build mascot (sprite animations by the author) ---------- */
.build-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(180deg, rgba(251,247,241,.6), rgba(251,247,241,.88)); backdrop-filter: blur(2px) saturate(.9); pointer-events: none; z-index: 3; animation: fadein .3s ease; }
.build-overlay.leaving { animation: fadeout .6s ease forwards; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; } }
.tiny-scene { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(100%, 440px); padding: 0 20px; }
.tiny img { display: block; width: 240px; height: 240px; image-rendering: pixelated; filter: drop-shadow(0 10px 14px rgba(60,40,20,.18)); transition: transform .3s; }
.tiny[data-state="ready"] img { transform: scale(1.06); }
.tiny.swap img { animation: swapin .25s ease; }
@keyframes swapin { from { transform: scale(.94); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.hero-tiny img { display: block; margin: 0 auto 6px; image-rendering: pixelated; filter: drop-shadow(0 10px 14px rgba(60,40,20,.15)); }
.brand-mark { image-rendering: pixelated; border-radius: 10px; }
.bubble { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; font-size: 14px; box-shadow: var(--shadow); max-width: 300px; text-align: center; transition: opacity .3s, transform .3s; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 14px; height: 14px; background: var(--card); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: translateX(-50%) rotate(45deg); }
.bubble.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.85); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }
.tiny-meta { text-align: center; }
.timer { font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: .02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.step { font-size: 13px; color: var(--ink-2); min-height: 18px; }
.tiny-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.06); overflow: hidden; }
.tiny-progress i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 2px; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
@media (prefers-reduced-motion: reduce) { .tiny-progress i, .tiny img { animation: none !important; } }

/* beta: corner ribbon on every screen + footnotes */
.beta-ribbon { position: fixed; top: 0; right: 0; width: 120px; height: 120px; overflow: hidden; pointer-events: none; z-index: 50; }
.beta-ribbon span { position: absolute; top: 24px; right: -36px; width: 160px; transform: rotate(45deg); background: var(--accent); color: var(--accent-ink); text-align: center; font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; padding: 5px 0; box-shadow: 0 2px 6px rgba(60, 40, 20, .2); }
.beta-note { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.intro .beta-note { margin: 18px 0 0; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--card); color: var(--ink-2); }
.welcome .beta-note { margin: 18px 0 0; color: var(--ink-3); font-size: 12px; }
@media (max-width: 980px) { .beta-ribbon { width: 90px; height: 90px; } .beta-ribbon span { top: 16px; right: -44px; font-size: 11px; padding: 4px 0; } }
