:root {
  --bg: #0b2545;
  --accent: #3b82f6;
  --text: #1a1a1a;
  --muted: #666;
  --bubble-user: #e8f0fe;
  --bubble-assistant: #f3f4f6;
  --border: #d9dee4;
}

* { box-sizing: border-box; }

/* .gate and .app both set their own `display`, which otherwise overrides
   the browser's default [hidden] { display: none } behavior (an author
   stylesheet rule always wins over the UA default for a matched property).
   Without this, toggling the `hidden` attribute in app.js does nothing
   visually. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #fafafa;
}

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}

.gate-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.gate-card h1 { font-size: 1.3rem; margin: 0 0 8px; }
.gate-card p { color: var(--muted); margin: 0 0 16px; font-size: 0.9rem; }

#access-code-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}

#access-code-submit {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.error { color: #b91c1c; font-size: 0.85rem; margin-top: 10px; }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header h1 { font-size: 1.2rem; margin: 8px 0 4px; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin: 0 0 16px; }

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.45;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--bubble-user);
}

.message.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
}

.message.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
}

.download-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.composer {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

#message-input {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}

#send-button {
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

#send-button:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 480px) {
  .app { padding: 12px; }
  .message { max-width: 92%; }
}
