:root {
  --ink: #141414;
  --muted: #6b6b6b;
  --bubble: #f3f2ee;
  --line: #e6e4df;
  --paper: #ffffff;
  --accent: #e8731a;
  --focus: #8fb4e0;
  --error: #b42318;
  --letter: #6f8f9a;
  color-scheme: light;
}

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

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 16px;
  background: rgba(0, 0, 0, .75);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar .text-button { color: #f2f2f2; }
.topbar .text-button:hover { color: #fff; }
.topbar .account { background: #1c1c1c; border-color: rgba(255, 255, 255, .25); }
.topbar .brand { line-height: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.logo { width: 28px; height: 28px; display: block; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.actions { display: flex; align-items: center; gap: 12px; }
.actions form { margin: 0; }

.text-button {
  background: none; border: 0; padding: 6px 4px; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--ink); }

.status {
  margin: 0; padding: 6px 16px; font-size: 13px; color: var(--muted); text-align: center;
  min-height: 0;
}
.notice {
  margin: 0; padding: 8px 16px; font-size: 13px; color: var(--ink);
  background: #fff4e5; border-bottom: 1px solid #f5d9b5; text-align: center;
}
.status:empty { display: none; }
.status.error { color: var(--error); }

/* Feed */
.feed {
  max-width: 980px; margin: 0 auto;
  padding: 8px 16px 170px;
}
.earlier { text-align: center; margin: 8px 0 0; }
.messages { list-style: none; margin: 0; padding: 0; }

/* Day separators: a rule with a pill label on top */
.day {
  display: flex; align-items: center; gap: 0;
  margin: 26px 0 14px;
}
.day::before, .day::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.day span {
  margin: 0 10px; padding: 7px 16px; white-space: nowrap;
  background: var(--bubble); border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}

/* Messages */
.msg {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px;
  max-width: 100%;
}
.msg.grouped { margin-top: 3px; }
.msg.mine { flex-direction: row-reverse; }

.avatar, .avatar-spacer, .letter {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%;
}
.avatar { object-fit: cover; display: block; }
.letter {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; background: var(--letter);
  user-select: none;
}
.avatar-spacer { visibility: hidden; }

.col {
  display: flex; flex-direction: column; min-width: 0;
  max-width: min(78%, 640px);
}
.msg.mine .col { align-items: flex-end; }

.meta {
  display: flex; align-items: baseline; gap: 6px;
  margin: 0 0 4px 2px; font-size: 13px; color: var(--muted); white-space: nowrap;
}
.meta strong { color: var(--ink); font-size: 14px; }

.bubble {
  background: var(--bubble);
  border-radius: 18px;
  padding: 9px 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.bubble:empty { display: none; }
.body { margin: 0; white-space: pre-wrap; }
.msg.grouped .bubble { border-top-left-radius: 18px; }

.photo {
  display: block; max-width: 100%; max-height: 360px; height: auto;
  border-radius: 12px; margin: 2px 0;
}
.bubble a.photo-link { display: block; }
.file {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink); text-decoration: underline; text-underline-offset: 3px;
  margin: 2px 0;
}
.bubble p + .photo, .bubble p + .file, .bubble .photo + .photo, .bubble .file + .file { margin-top: 8px; }

/* Reactions */
.reactions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 5px; min-height: 0;
}
.reactions:empty { display: none; }
.msg.mine .reactions { justify-content: flex-end; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px 0 4px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 14px; cursor: pointer; color: var(--ink);
}
.reaction.mine { border-color: var(--accent); }
.reaction:hover { border-color: #cfccc5; }
.who { display: inline-flex; align-items: center; }
.ravatar {
  width: 18px; height: 18px; border-radius: 50%; object-fit: cover;
  margin-left: -4px; border: 1px solid var(--paper);
}
.who > :first-child { margin-left: 0; }
.ravatar.letter { flex: none; width: 18px; height: 18px; font-size: 10px; margin-left: -4px; border: 1px solid var(--paper); }
.count { font-size: 12px; color: var(--muted); }

.add-reaction {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--line); color: var(--muted); cursor: pointer; padding: 0;
  opacity: .75;
}
.add-reaction:hover, .add-reaction[aria-expanded="true"] { opacity: 1; color: var(--ink); }
.add-reaction svg { width: 15px; height: 15px; }

.picker {
  display: inline-flex; gap: 2px; margin-top: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 5px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}
.pick {
  width: 32px; height: 30px; border: 0; background: none; cursor: pointer;
  font-size: 18px; border-radius: 999px; padding: 0;
}
.pick:hover { background: var(--bubble); }

/* Composer */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #fff 75%, rgba(255, 255, 255, 0));
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 980px; margin: 0 auto 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--bubble); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chip button {
  width: 22px; height: 22px; border-radius: 50%; border: 0; background: none;
  cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0;
}

.bar {
  display: flex; align-items: flex-end; gap: 6px;
  max-width: 980px; margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line); border-radius: 26px;
  padding: 6px 6px 6px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
.bar:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(143, 180, 224, .28); }

.bar textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: none;
  font: inherit; color: var(--ink); padding: 8px 0; line-height: 1.4;
  max-height: 160px; overflow-y: auto;
}
.bar textarea::placeholder { color: #9a9a9a; }

.icon-button {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); cursor: pointer; position: relative;
}
.icon-button:hover { background: var(--bubble); }
.icon-button svg { width: 20px; height: 20px; }
.attach input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.send {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--ink); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: .4; cursor: default; }

/* Sign-in */
body.signin { background: var(--bubble); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.card {
  width: 100%; max-width: 360px; background: var(--paper); border-radius: 18px;
  padding: 26px 24px; box-shadow: 0 6px 24px rgba(0, 0, 0, .06);
}
.card .brand { margin-bottom: 18px; font-size: 17px; }
.card label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.card input {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.card input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(143, 180, 224, .28); }
.primary {
  width: 100%; margin-top: 4px; padding: 11px; border: 0; border-radius: 10px;
  background: var(--ink); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.error { color: var(--error); font-size: 14px; margin: 0 0 12px; }

@media (max-width: 600px) {
  .feed { padding-left: 10px; padding-right: 10px; }
  .col { max-width: 84%; }
  .composer { padding-left: 8px; padding-right: 8px; }
}

/* Account menu in the header */
.account-menu { position: relative; }
.account {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; border: 1px solid var(--line);
  background: var(--paper); cursor: pointer; overflow: hidden; display: inline-flex;
  align-items: center; justify-content: center;
}
.account:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.account-face { width: 100%; height: 100%; display: inline-flex; align-items: center; justify-content: center; }
.account-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-face .letter { width: 100%; height: 100%; border-radius: 0; font-size: 14px; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px; z-index: 10;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); padding: 6px; margin: 0;
}
.menu-who { margin: 6px 10px 8px; font-size: 13px; color: var(--muted); }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--ink); font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bubble); outline: none; }
.menu-form { margin: 0; }

/* Profile page */
body.page { background: var(--paper); }
.brand { color: var(--ink); text-decoration: none; }
.profile { max-width: 560px; margin: 0 auto; padding: 20px 16px 60px; }
.profile h1 { font-size: 22px; margin: 8px 0 16px; }
.profile-form fieldset {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 0 0 16px;
}
.profile-form legend { font-weight: 700; padding: 0 6px; }
.profile-form label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0; }
.profile-form input[type="text"], .profile-form input[type="password"], .profile-form input[type="email"] {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.profile-form input:disabled { color: var(--muted); background: var(--bubble); }
.profile-form input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(143, 180, 224, .28); }
.photo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar.big, .letter.big { width: 72px; height: 72px; flex: none; }
.letter.big { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 28px; font-weight: 700; border-radius: 50%; background: var(--letter); }
.file-pick { font-size: 14px; font-weight: 600; cursor: pointer; }
.file-pick input { display: block; margin-top: 6px; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.saved { color: #1e6b3a; background: #e8f5ec; padding: 10px 12px; border-radius: 10px; }
.profile .error { background: #fdecea; padding: 10px 12px; border-radius: 10px; }
