* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
  color: #fff;
  margin: 0;
  padding: 2rem 1.25rem 6rem;
}

main {
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

h1 {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 1.5rem;
}

h2 {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 2.5rem 0 1rem;
}

/* ---------- Login ---------- */

#login-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.chai-logo {
  width: 140px;
  align-self: flex-start;
}

.tagline {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 2.1rem;
  letter-spacing: 0.06em;
  margin: 2.5rem 0 0;
}

.spacer {
  flex: 1;
  min-height: 15vh;
}

.sign-in-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sign-in-buttons button {
  background: #fff;
  color: #000;
  border-radius: 999px;
  padding: 1rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.sign-in-buttons svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ---------- Feed ---------- */

.feed-header {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

#feed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.feed-tile {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #131313;
}

.feed-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-tile span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.4rem 0.7rem 0.6rem;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#feed-sentinel {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.85rem;
}

/* ---------- Bottom nav ---------- */

#bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.7rem 0 calc(0.7rem + env(safe-area-inset-bottom));
  background: #000;
  border-top: 1px solid #1c1c1e;
}

#bottom-nav button {
  background: none;
  color: #fff;
  padding: 0.3rem 1.5rem;
}

#bottom-nav svg {
  width: 26px;
  height: 26px;
}

/* ---------- Builder ---------- */

.chai-logo-small {
  width: 90px;
}

label {
  display: block;
  margin-bottom: 1.1rem;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9a9aa0;
}

input[type="text"],
input[type="url"],
textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.85rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  color: #fff;
  background: #131313;
  border: 1px solid #2b2b2b;
  border-radius: 12px;
  resize: vertical;
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  color: #9a9aa0;
  font-size: 0.9rem;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: #1c1c1e;
  border: 1px solid #2b2b2b;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  margin-right: 0.8rem;
  cursor: pointer;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #6e6e73;
}

input::placeholder,
textarea::placeholder {
  color: #55555a;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  letter-spacing: normal;
  font-family: inherit;
  font-size: 0.95rem;
  color: #fff;
}

label.checkbox input {
  accent-color: #fff;
  width: 1.05rem;
  height: 1.05rem;
}

button {
  font: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

#publish-btn {
  width: 100%;
  background: #fff;
  color: #000;
  border-radius: 999px;
  padding: 1rem;
  font-size: 1.05rem;
  margin-top: 0.5rem;
}

button.secondary {
  background: #1c1c1e;
  color: #fff;
  border: 1px solid #2b2b2b;
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---------- Profile ---------- */

.profile-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

button.danger {
  background: #e0334e;
  color: #fff;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-size: 0.95rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 10;
}

.modal {
  background: #1c1c1e;
  border: 1px solid #2b2b2b;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 340px;
  width: 100%;
}

.modal h2 {
  margin: 0 0 0.8rem;
}

.modal p {
  color: #9a9aa0;
  margin: 0 0 1.5rem;
  overflow-wrap: anywhere;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

/* ---------- Bot list / status ---------- */

#bot-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#bot-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  background: #131313;
  border: 1px solid #2b2b2b;
  border-radius: 12px;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

#bot-list a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

#bot-list a:hover {
  text-decoration: underline;
}

.bot-delete {
  margin-left: auto;
  background: none;
  color: #6e6e73;
  padding: 0 0.3rem;
  display: flex;
  align-items: center;
}

.bot-delete svg {
  width: 18px;
  height: 18px;
}

.bot-delete:hover {
  color: #f87171;
}

#status {
  min-height: 1.2em;
  margin-top: 1rem;
}

.ok {
  color: #4ade80;
}

.error {
  color: #f87171;
}

.muted {
  color: #6e6e73;
}

/* ---------- Chat page ---------- */

.chat-card {
  text-align: center;
  justify-content: center;
}

.chat-card img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
}

.chat-card h1 {
  text-transform: none;
  font-family: inherit;
  letter-spacing: normal;
  margin: 1rem 0;
}

.open-buttons {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.open-btn {
  display: inline-block;
  background: #fff;
  color: #000;
  font-weight: 700;
  padding: 0.8rem 2rem;
  border-radius: 999px;
  margin: 0.5rem 0 1rem;
}

.open-btn-outline {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
}

.chat-card a {
  text-decoration: none;
}
