/* Colors — light mode first, dark mode below */
:root {
  --bg: #f6f1ea;
  --card: #ffffff;
  --text: #2b2622;
  --muted: #7a716a;
  --border: #e4ddd4;
  --accent: #c2562f;
  --accent-text: #ffffff;
  --error: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --card: #292524;
    --text: #f2ede8;
    --muted: #a8a29e;
    --border: #3f3a36;
    --accent: #e07a52;
    --accent-text: #1c1917;
    --error: #f2938c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h1 { font-size: 1.6rem; margin: 8px 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

/* Writing box */
.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}
.name-row input { flex: 1; }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 17px; /* 16px or more stops iPhones zooming in */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 84px; }

#photo-preview { margin-top: 10px; }
#photo-preview img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; display: block; }

.actions { display: flex; gap: 10px; margin-top: 10px; }
.actions .button { flex: 1; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  white-space: nowrap;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
.button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.button:disabled { opacity: 0.6; cursor: default; }
.button.wide { width: 100%; }

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  padding: 8px 0;
  cursor: pointer;
}

.message { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }
.message:empty { display: none; }
.message.error { color: var(--error); }
.center { text-align: center; margin: 24px 0; }

/* Sign-in and top bar */
#signin-screen p, #not-invited-screen p { margin: 0 0 14px; }
.welcome { font-weight: 600; }
.divider { text-align: center; color: var(--muted); }
#email-form { display: flex; flex-direction: column; gap: 10px; }
input[type="email"] {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.topbar .link-button { margin-left: 12px; }
#invite-result p { margin: 12px 0 0; }
a.button { text-decoration: none; }

/* Posts */
.post-header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.post-header time { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.post-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post img { display: block; width: 100%; height: auto; border-radius: 10px; margin-top: 10px; background: var(--bg); }

/* Editing, reactions and comments */
.post textarea { margin-top: 4px; }
.link-button.small { font-size: 0.9rem; margin-left: 10px; padding: 0; }
.reaction-bar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.reaction {
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.reaction.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.reaction:disabled { opacity: 0.6; }
.comments { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.comment { margin: 6px 0; overflow-wrap: anywhere; }
.comment time { color: var(--muted); font-size: 0.85rem; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

/* Footer shown to everyone */
.site-footer {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer a { color: var(--accent); }

/* Members page */
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}
.tag.paused { border-color: var(--error); color: var(--error); }
.member-details { margin: 0; color: var(--muted); font-size: 0.95rem; }
.button.danger { background: var(--bg); color: var(--error); border: 1px solid var(--error); }

/* Top bar: greeting and links each stay on one line; links move below when space is short */
.topbar { flex-wrap: wrap; row-gap: 2px; }
.topbar > span { white-space: nowrap; }
.topbar .link-button { margin-left: 0; margin-right: 14px; }
.topbar > span:last-child .link-button:last-child { margin-right: 0; }
