:root {
  --bg: #f5efe7;
  --card: #fffaf4;
  --card-strong: #f0e7dc;
  --text: #231c17;
  --muted: #6e6258;
  --line: #ddd1c4;
  --accent: #8f6f5a;
  --accent-strong: #6e4f3b;
  --shadow: 0 12px 30px rgba(35, 28, 23, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { min-height: 100vh; }
button, textarea, input { font: inherit; }
ul { margin: 0; padding-left: 18px; }

.app-shell {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 108px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 18px; }

.main-content { display: block; }
.screen { display: none; gap: 14px; }
.screen-active { display: grid; }

.card, .hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.hero-card { background: linear-gradient(180deg, #fffaf4 0%, #f4ebe0 100%); }
.hero-kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.hero-text, .muted { color: var(--muted); }
.hero-card h2 { margin-bottom: 8px; }

.state-grid, .quick-actions, .stack-form, .notes-list, .media-grid {
  display: grid;
  gap: 10px;
}

.state-grid { grid-template-columns: 1fr 1fr; margin-top: 14px; }

.state-btn, .action-btn, .nav-btn, .ghost-btn, .primary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
}

.state-btn-active, .nav-btn-active, .primary-btn {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}

.ghost-btn { background: transparent; }
.nav-btn:disabled, .action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.card-head { display: grid; gap: 6px; margin-bottom: 12px; }
.tall-card { min-height: 64vh; }
.chat-log { display: grid; gap: 10px; margin-bottom: 14px; }

.bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
}

.bubble-assistant { background: var(--card-strong); }
.bubble-user {
  background: #fff;
  justify-self: end;
  border: 1px solid var(--line);
}

.composer, .stack-form { display: grid; gap: 10px; }

textarea, .text-input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  color: var(--text);
}

textarea { resize: vertical; min-height: 100px; }
.field-label { font-size: 14px; color: var(--muted); }
.gate-card { min-height: 52vh; align-content: start; }
.gate-form { margin-top: 12px; }
.gate-status { margin-top: 8px; }

.upload-box {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--accent);
  border-radius: 18px;
  background: #fff;
  color: var(--accent-strong);
  text-align: center;
  padding: 20px;
}
.upload-box input { display: none; }

.note-card, .media-card, .drawing-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.note-meta, .media-meta, .drawing-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.media-grid img, .drawing-preview {
  width: 100%;
  border-radius: 14px;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.empty-state { padding: 8px 2px; }

.draw-toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.draw-surface {
  min-height: 220px;
  border-radius: 20px;
  border: 1px dashed var(--accent);
  background: linear-gradient(180deg, #fff 0%, #f4ebe0 100%);
  display: block;
  padding: 10px;
}

#drawCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  background: #fffdf9;
  touch-action: none;
}

.architecture-card { margin-top: 12px; }
.architecture-list { display: grid; gap: 8px; color: var(--muted); }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(245, 239, 231, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(221, 209, 196, 0.9);
}

@media (max-width: 420px) {
  .bottom-nav { font-size: 12px; }
}

@media (max-width: 360px) {
  .state-grid, .draw-toolbar { grid-template-columns: 1fr; }
}
