:root {
  color-scheme: light dark;
  --background: var(--tg-theme-secondary-bg-color, light-dark(#eef2f6, #151e28));
  --surface: var(--tg-theme-bg-color, light-dark(#fff, #202e3c));
  --ink: var(--tg-theme-text-color, light-dark(#172539, #edf5fc));
  --muted: var(--tg-theme-subtitle-text-color, light-dark(#536476, #b1c0d1));
  --line: color-mix(in srgb, var(--ink) 14%, var(--surface));
  --accent: var(--tg-theme-button-color, light-dark(#2059ac, #a9cbff));
  --accent-ink: var(--tg-theme-button-text-color, light-dark(#fff, #132945));
  --link: var(--tg-theme-link-color, light-dark(#2059ac, #a9cbff));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, p, dl, dd { margin: 0; }

.layout {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(17px, var(--tg-content-safe-area-inset-top, 0px)) 16px
    max(30px, env(safe-area-inset-bottom));
}
.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.app-header h1 { font-size: clamp(23px, 5.5vw, 32px); letter-spacing: -.035em; }
.app-header p { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.wordmark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: #132843;
  color: #d7f7ad;
  box-shadow: inset 0 0 0 1px #3c5475;
  font-size: .89rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.status-panel { padding: 20px; line-height: 1.55; color: var(--muted); }
.status-panel h2 { margin-bottom: 5px; color: var(--ink); font-size: 1.16rem; }
.status-panel button, .status-panel a { margin-top: 13px; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(105px, 30%); gap: 8px; margin-bottom: 13px; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 11px;
  background: var(--surface);
  color: var(--ink);
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder { color: var(--muted); }
.idea-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 8px; }
.idea-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 70px;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}
.idea-button:hover { border-color: var(--link); }
.idea-label { display: grid; gap: 4px; overflow-wrap: anywhere; }
.idea-label strong { font-weight: 700; line-height: 1.32; }
.idea-label small { color: var(--muted); line-height: 1.32; }
.chevron { color: var(--link); font-size: 1.38rem; }
.stage {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 112px;
  padding: 4px 8px;
  border-radius: 20px;
  background: var(--background);
  color: var(--ink);
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.25;
}
.stage[data-stage=assessment] { background: #e1edfc; color: #254a77; }
.stage[data-stage=validation] { background: #fff0ce; color: #745009; }
.stage[data-stage=pilot] { background: #e5f3d5; color: #375412; }
.stage[data-stage=paused] { background: #eee8f3; color: #5a4369; }
.detail-panel { padding: clamp(15px, 4.3vw, 26px); overflow-wrap: anywhere; }
.detail-panel h2 { font-size: clamp(23px, 5.4vw, 32px); line-height: 1.17; letter-spacing: -.028em; }
.idea-heading { margin-bottom: 16px; }
.idea-heading h2 { margin-top: 8px; }
.fields { display: grid; gap: 14px; }
.fields dt { margin-bottom: 5px; color: var(--muted); font-weight: 700; font-size: .77rem; }
.fields dd { line-height: 1.5; white-space: pre-wrap; }
.next-step {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--background);
  border-inline-start: 3px solid var(--link);
}
details { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
details .fields { margin-top: 11px; }
summary { min-height: 32px; cursor: pointer; font-weight: 650; }
.source { font-size: .78rem; color: var(--muted); margin: 18px 0 14px; }
.primary, .quiet, .back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.quiet { background: var(--surface); border-color: var(--line); color: var(--link); }
.back { color: var(--link); background: transparent; padding-left: 0; margin-bottom: 7px; }
form { display: grid; gap: 13px; }
form label { display: grid; gap: 5px; font-weight: 650; }
form input, form select, form textarea { font-weight: 400; }
form > button { justify-self: start; }
#new-title { margin-bottom: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-message { color: var(--muted); }
.form-message:empty { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 370px) {
  .layout { padding-left: 12px; padding-right: 12px; }
  .idea-button { grid-template-columns: minmax(0, 1fr) auto; padding: 10px; }
  .idea-button .chevron { display: none; }
}
