/* Echo web — monochrome black & white, mobile-first, theme-aware. */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --soft: #f2f2f2;
  --accent: #000000;
  --on-accent: #ffffff;
  --danger: #b00020;
  --maxw: 640px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #9a9a9a;
    --line: #222222;
    --soft: #141414;
    --accent: #ffffff;
    --on-accent: #000000;
    --danger: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Splash */
.splash {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.echo-mark { font-size: 40px; font-weight: 800; letter-spacing: 0.5px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--fg);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  /* Push the whole header BELOW the phone's status bar (notch/time/battery). */
  padding-top: max(env(safe-area-inset-top), 20px);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-size: 24px; font-weight: 800; letter-spacing: 0.5px; }
.iconbtn {
  background: none; border: none; color: var(--fg); font-size: 20px; cursor: pointer;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; position: relative;
}
.iconbtn:hover { background: var(--soft); }
.iconbtn { position: relative; }
.notif-badge {
  position: absolute; top: 0; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Auth screens */
.auth { max-width: 400px; margin: 0 auto; padding: 40px 22px; display: flex; flex-direction: column; gap: 14px; min-height: 100dvh; justify-content: center; }
.auth h1 { font-size: 30px; font-weight: 800; margin: 0 0 4px; }
.auth p.sub { color: var(--muted); margin: 0 0 10px; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 6px; }
input, textarea {
  width: 100%; padding: 12px 14px; font-size: 16px;
  background: var(--soft); color: var(--fg);
  border: 1px solid transparent; border-radius: 12px; outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--fg); }
textarea { resize: none; }

.btn {
  width: 100%; padding: 13px 16px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: 999px; cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.secondary { background: transparent; color: var(--fg); border: 1.5px solid var(--line); }
.btn.link { background: none; color: var(--fg); border: none; text-decoration: underline; width: auto; padding: 4px; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; min-height: 18px; }
.center { text-align: center; }

/* Feed */
.feed { max-width: var(--maxw); margin: 0 auto; padding-bottom: 90px; }
.card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card .head { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  background: var(--soft); color: var(--fg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  object-fit: cover; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 4px; }
.handle { color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; }
.card .body { margin: 8px 0 8px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.card .media { margin: 8px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.card .media img { width: 100%; display: block; }
.actions { display: flex; gap: 22px; align-items: center; color: var(--muted); font-size: 14px; }
.actions button { background: none; border: none; color: inherit; cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 14px; padding: 4px 0; }
.actions button.on { color: var(--fg); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 70px 20px; }

/* Composer (floating button + modal) */
.fab {
  position: fixed; right: 18px; bottom: 78px; z-index: 20;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: var(--maxw);
  border-radius: 18px 18px 0 0; padding: 16px; max-height: 90dvh; overflow: auto;
}
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet h2 { font-size: 18px; margin: 0; }
.audience-row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.chip {
  padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: none; color: var(--fg); cursor: pointer; font-size: 13px;
}
.chip.sel { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Bottom nav */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.tabbar button { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabbar button.sel { color: var(--fg); }
.tabbar .glyph { font-size: 18px; line-height: 0; }
.tabbar .glyph svg { width: 25px; height: 25px; display: block; }

/* Install button */
.install-btn {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 40;
  background: var(--accent); color: var(--on-accent); border: none;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}

.hidden { display: none !important; }
.spacer { flex: 1; }

/* Shared rows */
.who { min-width: 0; }
.who .name, .who .handle { overflow: hidden; text-overflow: ellipsis; }
/* Clickable links + @mentions: underlined so people know they can tap them. */
.mention { color: var(--fg); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
a { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }

/* Search + person rows */
.searchbar { padding: 10px 16px; }
.searchbar input { border-radius: 999px; }
.person {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.person .who { flex: 1; }

/* Circle */
.circle-head { padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.circle-head b { color: var(--fg); }

/* Profile header */
.profile-head { padding: 18px 16px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.profile-head .avatar { margin-bottom: 4px; }
.name.big { font-size: 22px; font-weight: 800; }
.profile-head .bio { font-size: 15px; line-height: 1.45; margin: 2px 0; white-space: pre-wrap; }
.prow { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.prow .btn { width: auto; padding: 9px 18px; }
.prow .chip { padding: 9px 18px; }

/* Sponsor card */
.card.sponsor .avatar { background: var(--soft); }
.card.sponsor .btn { width: auto; display: inline-block; text-decoration: none; text-align: center; margin-top: 6px; }

/* Reply card */
.reply-card { padding-left: 16px; }

/* Messages thread */
.thread { display: flex; flex-direction: column; height: calc(100dvh - 54px - 62px); }
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 76%; padding: 9px 13px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--soft); color: var(--fg); border-bottom-left-radius: 4px; }

/* Inline composer bar (reply + message) */
.composer-bar { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); align-items: center; }
.composer-bar input { flex: 1; }
.composer-bar .btn { width: auto; padding: 10px 16px; }

/* content wrapper leaves room for the tab bar */
#content { padding-bottom: 84px; }

/* Manual theme overrides (Settings → Appearance) */
:root[data-theme="light"] {
  --bg: #ffffff; --fg: #000000; --muted: #6b6b6b; --line: #e6e6e6; --soft: #f2f2f2;
  --accent: #000000; --on-accent: #ffffff; --danger: #b00020;
}
:root[data-theme="dark"] {
  --bg: #000000; --fg: #ffffff; --muted: #9a9a9a; --line: #222222; --soft: #141414;
  --accent: #ffffff; --on-accent: #000000; --danger: #ff6b6b;
}

/* Profile header + banner */
.profile-wrap { border-bottom: 1px solid var(--line); }
.banner { height: 130px; background: var(--soft); background-size: cover; background-position: center; }
.avatar-lg { margin-top: -44px; }
.avatar-lg .avatar { border: 3px solid var(--bg); }
.links { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0; }
.link { color: var(--fg); font-size: 14px; text-decoration: underline; text-underline-offset: 2px; }
/* Anything styled as a button should not look like a text link. */
a.btn, .btn { text-decoration: none; }

/* Profile tabs */
.ptabs { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ptab { background: none; border: none; color: var(--muted); font-size: 14px; padding: 8px 10px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
.ptab.sel { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }
.about { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.about p { margin: 0; }

/* Settings */
.settings { display: flex; flex-direction: column; }
.setting-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--fg); font-size: 16px; padding: 15px 16px; cursor: pointer; text-align: left;
}
.setting-row .glyph { font-size: 18px; }
.setting-row.danger { color: var(--danger); }
.setting-info { display: flex; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.setting-info b { color: var(--fg); }
.setting-row input[type="checkbox"] { width: 20px; height: 20px; }

/* Action menu sheet */
.menu-sheet { padding-bottom: 24px; }
.menu { display: flex; flex-direction: column; margin-bottom: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--fg); font-size: 16px; padding: 15px 6px; cursor: pointer; text-align: left;
}
.menu-item.danger { color: var(--danger); }
.card .head .more { font-size: 18px; padding: 2px 8px; }

/* GIF picker */
.gif-sheet { max-height: 80dvh; }
.gif-sheet input { margin-bottom: 10px; }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; overflow-y: auto; max-height: 56dvh; }
.gif-cell { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; cursor: pointer; background: var(--soft); }
.gif-cell:hover { outline: 2px solid var(--accent); }

/* Media preview in composers */
.media-preview { margin: 8px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.media-preview img { width: 100%; display: block; max-height: 300px; object-fit: cover; }

/* GIPHY attribution link stays subtle */
.gif-sheet .handle a { text-decoration: none; }
