:root {
  --bg: #f7f6f3;
  --card-bg: #ffffff;
  --text: #1f2320;
  --muted: #6b7570;
  --accent: #2f6f4f;
  --accent-dark: #234f38;
  --border: #e2e0da;
  --bubble-user: #2f6f4f;
  --bubble-user-text: #ffffff;
  --bubble-assistant: #ffffff;
  --error: #b3413a;
}

* { box-sizing: border-box; }

/* The browser's own [hidden] rule (display: none) lives in the UA
   stylesheet, which is always lower-priority than any author rule
   regardless of specificity — so .screen's/.offer-buttons' own
   `display: flex` silently wins over an element's hidden attribute,
   leaving every screen visible and stacked at once. This !important
   rule is the standard fix: it guarantees hidden always wins here,
   whatever display value any other class-based rule sets. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem 0;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
}

/* Access gate */
#gate-screen {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

#gate-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

input[type="text"] {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

button {
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
}

button.primary, #gate-form button, #chat-form button {
  background: var(--accent);
  color: #fff;
}
button.primary:hover, #gate-form button:hover, #chat-form button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* Chat screen */
.chat-header {
  padding: 1.25rem 1.5rem 0.5rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bubble {
  max-width: 80%;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.offer-buttons {
  display: flex;
  gap: 0.6rem;
  padding: 0 1.5rem 0.75rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  flex-wrap: wrap;
}

/* Results screen */
#results-screen {
  align-items: center;
  padding: 1.5rem;
}

#results-content {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.total-banner {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.total-banner .figure {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.plan-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.plan-section h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
}

.plan-section .narrative {
  color: var(--text);
  margin-bottom: 0.75rem;
}

.plan-section ol {
  margin: 0;
  padding-left: 1.25rem;
}

.plan-section li {
  margin-bottom: 0.35rem;
}

@media (max-width: 480px) {
  .card { padding: 1.25rem; }
  .chat-header, .chat-log, .chat-input-row, .offer-buttons { padding-left: 1rem; padding-right: 1rem; }
}
