:root {
  /* neutral: grey grouped background with white cards (like iOS); orange is the one brand colour */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ececf0;
  --kinari: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e3e3e8;
  --accent: #ff4d01;   /* the logo orange */
  --accent-ink: #ffffff;
  --leaf: #3a9a3e;
  --edit: #7a4bb7;
  --edit-soft: #f1eafa;
  --radius: 18px;
  --accent-text: #d03a00;   /* orange for small text: readable on white and grey */
  --danger: #c0392b;
  --warn-bg: #fff3cd; --warn-ink: #6b5200;
  --star: #f5a623;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --kinari: #000000; --ink: #f5f5f7; --muted: #98989d; --line: #38383a;
    --accent: #ff6a33; --accent-ink: #2a1407; --leaf: #6cc070; --edit: #b592e6; --edit-soft: #2c2338;
    --accent-text: #ff8a5e; --danger: #ff7b6b; --warn-bg: #3a2f12; --warn-ink: #f3d68a; --star: #ffc04d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body.runner-open { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.screen { min-height: 100%; }
#home { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.home-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 2px 0 0; font-size: 30px; letter-spacing: -.02em; }
.ghost { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-height: 150px; transition: transform .12s;
}
.tile:active { transform: scale(.98); }
.tile-icon { font-size: 34px; line-height: 1; }
.tile-name { font-weight: 650; font-size: 16px; }
.tile-meta { margin-top: auto; font-size: 12.5px; color: var(--muted); }

.empty { text-align: center; padding: 48px 8px; color: var(--muted); }
.empty h2 { color: var(--ink); margin: 8px 0; }
.empty-icon { font-size: 48px; }
.prompts { display: grid; gap: 8px; margin-top: 18px; text-align: left; }
.prompt {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--ink);
}
.prompt span { font-size: 14.5px; }
.prompt button { flex: none; border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

.runner { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; background: var(--bg); }
.runner > .run-bar, .runner > .preview-banner, .runner > .save-status { flex-shrink: 0; }
.save-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 14px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.save-status span { flex: 1 1 200px; }
.save-status button { min-height: 36px; border: 1px solid currentColor; border-radius: 8px; padding: 4px 8px; background: transparent; }
/* slim bars above a running app: review an AI's change (Keep / Undo), or a problem in the app (Fix it) */
.runner > .app-bar { flex-shrink: 0; }
.app-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px 6px 14px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.app-bar-text { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.app-bar-text > span { overflow-wrap: anywhere; }
.app-bar-text small { font-size: 12px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar-actions { flex: none; margin-left: auto; display: flex; align-items: center; gap: 6px; }
.app-bar button { min-height: 36px; border: 1px solid currentColor; border-radius: 999px; padding: 4px 11px; background: transparent; color: inherit; font-size: 13px; font-weight: 650; }
.app-bar .app-bar-x { width: 36px; padding: 0; border-color: transparent; display: grid; place-items: center; }
.app-bar .app-bar-x .i { width: 16px; height: 16px; }
.app-review { background: var(--edit-soft); color: var(--edit); }
.app-issue { background: var(--warn-bg); color: var(--warn-ink); }
.app-issue #appIssueFix { background: var(--warn-ink); color: var(--warn-bg); border-color: var(--warn-ink); }
@media (prefers-reduced-motion: no-preference) { .app-bar:not([hidden]) { animation: app-bar-in .2s ease-out; } }
@keyframes app-bar-in { from { opacity: 0; transform: translateY(-4px); } }
.run-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.run-title { flex: 1; display: flex; gap: 8px; align-items: center; font-weight: 650; min-width: 0; }
.run-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 12px; font-size: 20px; }
.icon-btn:hover { background: var(--bg); }
#frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
.preview-banner {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 14px; font-size: 14px;
  background: var(--edit-soft); color: var(--edit); border-bottom: 1px solid var(--line);
}
.preview-banner button { margin-left: auto; border: 1px solid currentColor; background: transparent; color: var(--edit); border-radius: 999px; padding: 4px 10px; font-size: 13px; }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 85dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 18px 28px; max-width: 640px; margin: 0 auto;
}
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 4px 0 12px; font-size: 20px; }
.menu-item {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 14px 4px;
}
.menu-item small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-item .mi-icon { font-size: 22px; width: 28px; text-align: center; }
.edit-box { background: var(--edit-soft); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.edit-box p { margin: 0 0 10px; }
.edit-box .label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--edit); }
.edit-box textarea { width: 100%; min-height: 84px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; background: var(--surface); color: var(--ink); }
.btn { border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 650; background: var(--accent); color: var(--accent-ink); }
.btn.edit { background: var(--edit); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.muted { color: var(--muted); font-size: 14px; }
.versions { list-style: none; margin: 0; padding: 0; }
.versions li { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.versions .v { font-weight: 700; width: 36px; }
.versions .vnote { flex: 1; min-width: 0; }
.versions .vnote small { display: block; color: var(--muted); }
.versions .actions { display: flex; gap: 6px; }
.badge { font-size: 12px; font-weight: 700; color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20;
  display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); white-space: nowrap;
}
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; }

/* sign-in, connect page, account */
.narrow { max-width: 440px; margin: 0 auto; padding: 48px 16px; }
.narrow h1 { font-size: 26px; line-height: 1.2; margin: 12px 0 8px; }
.logo { width: 56px; height: 56px; border-radius: 14px; }
.login { display: grid; gap: 10px; margin-top: 20px; }
.login label { font-weight: 600; font-size: 14px; }
.login input {
  font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.wide { width: 100%; padding: 13px 16px; font-size: 16px; }
.btn:disabled { opacity: .6; }
.error { color: var(--danger); margin: 0; font-size: 14px; }
.small { font-size: 13px; }
.link { color: var(--accent); font-weight: 600; }
.row { display: flex; gap: 10px; margin-top: 18px; }
.perm { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.perm li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; text-transform: uppercase;
}
.field { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.field code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.steps { padding-left: 20px; margin: 8px 0 16px; }
.steps li { margin: 4px 0; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.plan-bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; margin: 8px 0; }
.plan-bar i { display: block; height: 100%; background: var(--accent); }
