:root {
  --paper: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f0eadc;
  --ink: #23211d;
  --muted: #6f675b;
  --line: #d8cfbd;
  --blue: #1f5d7a;
  --blue-soft: #e5eef2;
  --rust: #b85d3b;
  --rust-soft: #f3dfd3;
  --green: #5f6f52;
  --shadow: 0 1px 0 rgba(35,33,29,.06), 0 18px 45px rgba(35,33,29,.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(35,33,29,.035) 1px, transparent 1px) 0 0 / 100% 34px,
    var(--paper);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  color: var(--rust);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72rem;
  font-weight: 800;
}
h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vw, 4.9rem);
  line-height: .95;
  letter-spacing: -.045em;
  font-weight: 700;
}
h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: -.03em;
}
h3, h4 { margin-top: 0; }
.lede {
  max-width: 650px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}
.hero-card {
  min-width: 142px;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  background: var(--surface);
  box-shadow: 5px 5px 0 var(--ink);
  text-align: left;
}
.hero-card span {
  display: block;
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
}
.hero-card small { color: var(--muted); }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tab, .secondary, .primary, .danger {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 13px;
  font-weight: 750;
  background: var(--surface);
  color: var(--ink);
}
.tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.screen { display: none; }
.screen.active { display: block; }

.panel, .toolbar, .detail-layout {
  background: rgba(255,253,248,.86);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.panel { padding: clamp(18px, 4vw, 32px); }
.split {
  display: grid;
  grid-template-columns: .78fr 1.22fr;
  gap: clamp(20px, 5vw, 48px);
  align-items: start;
}
.muted { color: var(--muted); line-height: 1.5; }
.form-card, .detail-form { display: grid; gap: 15px; }
label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 750;
}
.field-label { color: var(--ink); font-weight: 750; }
.photo-input-group { display: grid; gap: 8px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-actions .import-label { flex: 1 1 140px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
textarea { resize: vertical; line-height: 1.45; }
.hint { color: var(--muted); font-size: .83rem; font-weight: 500; line-height: 1.35; }
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31,93,122,.13);
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.secondary, .import-label {
  background: var(--surface);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.danger {
  background: var(--rust-soft);
  color: #7f351f;
  border-color: #e0b9a7;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
.actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.actions input { min-width: 230px; }
.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.column {
  background: rgba(255,253,248,.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 180px;
}
.column h3 {
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  font-size: .95rem;
  color: var(--ink);
}
.count { color: var(--rust); }
.idea-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 13px;
  margin-bottom: 11px;
}
.idea-card h4 { margin: 0 0 8px; font-size: 1rem; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.pill {
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1f526a;
  padding: 4px 8px;
  font-size: .72rem;
  font-weight: 750;
}
.card-notes {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-actions { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.card-actions button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: .8rem;
  font-weight: 750;
  color: var(--ink);
}

.detail-layout {
  display: grid;
  grid-template-columns: 285px 1fr;
  min-height: 620px;
  overflow: hidden;
}
.idea-list-panel {
  background: rgba(240,234,220,.7);
  padding: 20px;
  border-right: 1px solid var(--line);
}
.idea-list {
  display: grid;
  gap: 9px;
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
}
.idea-list button {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 11px;
}
.idea-list button.active {
  border-color: var(--blue);
  background: #f7fbfc;
}
.empty-state {
  display: grid;
  place-content: center;
  text-align: center;
  padding: 30px;
  color: var(--muted);
}
.detail-form { padding: 22px; }
.hidden { display: none !important; }
.detail-header {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 14px;
  align-items: start;
}
.title-input {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -.03em;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding-left: 0;
}
.status-select {
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  border-color: var(--ink);
}
.enrichment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.photo-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(240,234,220,.42);
}
.photo-section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}
.photo-section-head .muted { margin: 0; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
}
.photo-empty { margin: 0; }
.photo-item {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}
.photo-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}
.photo-item figcaption {
  display: grid;
  gap: 7px;
  padding: 8px;
  color: var(--muted);
  font-size: .78rem;
}
.photo-item figcaption span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.photo-item button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--rust-soft);
  color: #7f351f;
  font-weight: 750;
}
.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.related-section { display: block; }
.related-list { display: grid; gap: 9px; }
.related-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}
.related-item summary {
  cursor: pointer;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.related-item summary span { color: var(--muted); font-weight: 650; font-size: .82rem; }
.related-item pre {
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.45;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 10px;
  max-height: 340px;
  overflow: auto;
}
.nested-photos { margin-top: 10px; }
.db-list { display: grid; gap: 8px; margin-top: 10px; }
.db-list > div { background: var(--surface-2); border-radius: 7px; padding: 9px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.empty-board {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 7px;
  box-shadow: var(--shadow);
  transition: transform .2s ease;
  z-index: 10;
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 22px, 1120px); padding-top: 20px; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-card { width: 100%; box-shadow: 3px 3px 0 var(--ink); }
  .split, .detail-layout, .enrichment-grid, .detail-header { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .actions { justify-content: stretch; }
  .actions > * { flex: 1 1 100%; }
  .idea-list-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .idea-list { max-height: 260px; }
}
