:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #ecece7;
  --text: #1c1e22;
  --muted: #666a72;
  --line: #dcdcd6;
  --accent: #2f5fd0;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --good: #1f7a4d;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #20232a;
    --surface-2: #2b2f38;
    --text: #eceef2;
    --muted: #9ea3ad;
    --line: #363a44;
    --accent: #7ea2f5;
    --accent-text: #10131a;
    --danger: #f2877f;
    --good: #6fcf9f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); margin: 0; }

button, .button {
  font: inherit;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.ghost { background: none; border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea {
  /* 16px stops iOS from zooming the page when a field is focused. */
  font: inherit;
  font-size: 16px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; min-height: 96px; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.section-title { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

.idea form { display: grid; gap: 10px; }
.idea button { justify-self: end; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 118px;
  text-decoration: none;
  color: inherit;
  text-align: left;
  min-width: 0;
}
.tile .icon { font-size: 1.75rem; line-height: 1.2; }
.tile .name { font-weight: 600; overflow-wrap: anywhere; }
.tile .meta { font-size: 0.8rem; color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 180px; }
.list { display: grid; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status { font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.status.bad { color: var(--danger); }

.chat { display: grid; gap: 12px; }
.bubble { padding: 10px 14px; border-radius: 14px; max-width: 88%; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.you { justify-self: end; background: var(--accent); color: var(--accent-text); }
.bubble.claude { justify-self: start; background: var(--surface); border: 1px solid var(--line); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { min-height: 40px; height: auto; padding: 8px 14px; text-align: left; border-radius: 20px; }
.reply { display: grid; gap: 10px; }
.reply .actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.thinking { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.plan ul { margin: 0; padding-left: 20px; }
.plan .title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; }
.progress { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); max-height: 45vh; overflow-y: auto; }
.progress div { overflow-wrap: anywhere; }

/* The running mini app takes the whole screen, under one slim bar. */
.app-frame { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.app-bar { display: flex; align-items: center; gap: 4px; padding: env(safe-area-inset-top) 6px 0; min-height: 48px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.app-bar .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar button { padding: 0 10px; min-height: 40px; }
.app-frame iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 18px; }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stats strong { display: block; font-size: 1.15rem; }
.stats span { font-size: 0.75rem; color: var(--muted); }

.notice { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 0.9rem; }
.notice code { overflow-wrap: anywhere; }

.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.login-card img { justify-self: center; border-radius: 14px; }
.login-card h1 { text-align: center; }
