/* Phone-first. Everything is sized for a thumb before it is sized for a mouse. */
:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --ink: #23201d;
  --muted: #6b645c;
  --line: #e4ded6;
  --accent: #b5651d;
  --accent-ink: #ffffff;
  --danger: #a33a2a;
  --ok: #2f6b45;
  --pad: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --card: #211e1b;
    --ink: #f0ece6;
    --muted: #a49c92;
    --line: #363029;
    --accent: #d78b45;
    --accent-ink: #1a1613;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main { padding: var(--pad); max-width: 44rem; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--pad) 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.topbar nav a:hover { color: var(--ink); }

h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: var(--pad); margin-bottom: 16px;
}
.narrow { max-width: 26rem; margin-inline: auto; }

label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
textarea { resize: vertical; }

button {
  margin-top: 12px; padding: 11px 16px; font: inherit; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 8px; cursor: pointer; min-height: 44px;
}
button.danger { background: var(--danger); }
button.linkish {
  background: none; color: var(--muted); font-weight: 400;
  text-decoration: underline; padding: 4px; min-height: 0; margin: 0;
}
form.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form button { margin-top: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-weight: 600; }
.warn { color: var(--danger); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Message screen */
.class-switcher { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.class-switcher h1 { margin: 0; text-align: center; flex: 1; }
.arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; font-size: 26px; text-decoration: none;
  color: var(--accent); border-radius: 50%;
}
.arrow.spacer { visibility: hidden; }

.messages { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.message { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.message.mine { border-color: var(--accent); }
.message .meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.message .who { font-weight: 600; color: var(--ink); }
.message .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.empty { text-align: center; padding: 24px 0; }

/* Attachments. Thumbnails are capped rather than full-bleed so that a photo
   does not push the rest of the conversation off a phone screen. */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment-image { display: block; line-height: 0; }
.attachment-image img {
  max-width: 220px; max-height: 220px; width: auto; height: auto;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
}
.attachment-file {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); background: var(--bg);
  /* Thumb-sized, like every other tap target in here. */
  min-height: 40px;
}
.attachment-file::before { content: "\1F4CE"; }
.attachment-name { overflow-wrap: anywhere; }

.composer { position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-foot button { margin-top: 0; }

.member-list { list-style: none; margin: 8px 0; padding: 0; }
.member-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line);
}
.member-list li:last-child { border-bottom: 0; }

.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.tag.pending { color: var(--danger); border-color: var(--danger); }
.tag.ok { color: var(--ok); border-color: var(--ok); }

.health { list-style: none; padding: 0; margin: 8px 0; }
.health li::before { content: "\25CF "; }
.health li.ok { color: var(--ok); }
.health li.bad { color: var(--danger); }

#install-button { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.hint {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 14px;
}

/* --- surveys ------------------------------------------------------------ */
.survey-title, .event-title { font-weight: 600; margin: 2px 0 8px; }
.survey-options { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.option {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 0; padding: 10px 12px; min-height: 44px;
  text-align: left; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; font: inherit; cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option.chosen { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.option-num {
  flex: 0 0 auto; min-width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 50%; font-size: 12px;
  background: var(--line); color: var(--muted);
}
.option.chosen .option-num { background: var(--accent-ink); color: var(--accent); }
.option-text { overflow-wrap: anywhere; }

.tally { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tally-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.tally-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.tally li.mine .tally-label { font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 3px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.voters { margin: 3px 0 0; }
.tally-foot { margin-top: 8px; }

.survey-page { max-width: 34rem; margin: 0 auto; }
.confirm-one { margin: 12px 0; }
.ok-note { color: var(--ok); font-weight: 600; }

/* --- events ------------------------------------------------------------- */
.event-card { margin: 2px 0 0; }
.event-when { font-weight: 600; margin: 0 0 2px; }
.event-where, .event-notes { margin: 2px 0; }
.event-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.event-invite {
  display: inline-block; margin-top: 8px; padding: 8px 12px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--ink); background: var(--bg);
}
.event-invite::before { content: "\1F4C5  "; }

/* --- composer modes ----------------------------------------------------- */
.composer-wrap { position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.composer-wrap .composer { position: static; padding-top: 0; }
.composer-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.mode-tab {
  flex: 1; margin: 0; padding: 8px 4px; min-height: 40px; font: inherit; cursor: pointer;
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
}
.mode-tab.is-active { background: var(--card); color: var(--ink); border-color: var(--accent); font-weight: 600; }
#survey-options { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 8px; flex-wrap: wrap; }
.field-row label { flex: 1 1 8rem; font-size: 13px; color: var(--muted); }
.field-row input { width: 100%; }
.attach { cursor: pointer; color: var(--accent); white-space: nowrap; }
button.secondary { background: var(--bg); color: var(--accent); border: 1px solid var(--line); }
