:root {
  --bg: #ffffff;
  --fg: #1c1c1e;
  --muted: #6e6e73;
  --line: #d1d1d6;
  --card: #f2f2f7;
  --accent: #0a64d8;
  --error: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #f2f2f7;
    --muted: #98989f;
    --line: #38383a;
    --card: #1c1c1e;
    --accent: #4c9bff;
    --error: #ff6b60;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
header {
  position: sticky;
  top: 0;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
header .title { font-weight: 600; }
.tabs { display: flex; gap: 4px; }
/* The current tab is marked by an underline and colour; the weight never changes, so nothing shifts. */
.tabs a {
  padding: 6px 10px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: currentColor; }
main { padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); max-width: 720px; margin: 0 auto; }
a { color: var(--accent); }

.ideas { list-style: none; margin: 0; padding: 0; }
.ideas li + li { margin-top: 8px; }
.ideas a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 44px;
  background: var(--card);
  border-radius: 12px;
  color: var(--fg);
  text-decoration: none;
}
.ideas .meta { color: var(--muted); font-size: 14px; }

/* Status is shown as a word, so it never relies on colour alone. */
.status {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}

.back { display: inline-block; margin-bottom: 12px; }
.muted { color: var(--muted); }
.error { color: var(--error); }

details {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

.md { overflow-wrap: anywhere; }
.md pre { overflow-x: auto; background: var(--card); padding: 12px; border-radius: 8px; font-size: 14px; }
.md code { font-size: 0.9em; }
.md table { display: block; overflow-x: auto; border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; }

form label { display: block; font-weight: 600; margin-bottom: 8px; }
form input {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
}
button {
  margin-top: 12px;
  min-height: 44px;
  padding: 0 20px;
  font: inherit;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; margin: 0; }
.link-button { background: none; color: var(--accent); padding: 0; margin-top: 24px; }

.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
button:disabled { opacity: 0.45; }

.msg { margin-bottom: 16px; }
.msg .who { font-size: 13px; font-weight: 600; color: var(--muted); }
.msg.user p { margin: 4px 0 0; padding: 10px 12px; background: var(--card); border-radius: 12px; }
form textarea {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  resize: vertical;
}
#chat-status { min-height: 2.9em; margin: 8px 0 0; } /* two lines reserved, so status text never moves the button */
