:root {
  --brand: #2f6bff;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --text: #1c2433;
  --muted: #6b7486;
  --border: #e3e7ee;
  --danger: #d92d20;
  --ok: #12b76a;
  --mine: var(--brand);
  --mine-text: #fff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218;
    --surface: #171c25;
    --surface-2: #1f2532;
    --text: #e8ecf3;
    --muted: #98a2b3;
    --border: #2a3140;
    --shadow: none;
    color-scheme: dark;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a {
  color: var(--brand);
  text-decoration: none;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
img {
  max-width: 100%;
}
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}
h1 {
  font-size: 20px;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 15px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.center {
  text-align: center;
}
.warn {
  color: #b54708;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.grow {
  flex: 1;
  min-width: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row.between {
  justify-content: space-between;
}
.row.end {
  justify-content: flex-end;
}
.row.center {
  justify-content: center;
}
.stack {
  display: grid;
  gap: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---- layout ---- */
.layout {
  min-height: 100vh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.tabs {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
}
.tabs .brand {
  display: none;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11.5px;
  position: relative;
}
.tab.on {
  color: var(--brand);
  font-weight: 600;
}
.tab .badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
}
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.badge.inline {
  background: var(--brand);
}
main {
  outline: none;
}
.column {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  gap: 12px;
}
.column.wide {
  max-width: 980px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  min-height: 54px;
}
.topbar h1 {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar.transparent {
  position: absolute;
  left: 0;
  right: 0;
  background: none;
  backdrop-filter: none;
}
.topbar.transparent h1 {
  visibility: hidden;
}
.topbar.transparent .icon-btn {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}
@media (min-width: 900px) {
  .layout {
    padding: 0 0 0 232px;
  }
  .tabs {
    top: 0;
    right: auto;
    width: 232px;
    height: 100vh;
    flex-direction: column;
    border-top: 0;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    gap: 4px;
  }
  .tabs .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 18px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
  }
  .tabs .brand img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
  .tab {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 15px;
  }
  .tab.on {
    background: color-mix(in srgb, var(--brand) 12%, transparent);
  }
  .tab .badge {
    position: static;
    margin-left: auto;
  }
  .column {
    padding: 16px;
  }
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

/* ---- controls ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.danger {
  color: var(--danger);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 13.5px;
}
.btn.block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  position: relative;
  flex-shrink: 0;
}
.icon-btn.primary {
  background: var(--brand);
  color: #fff;
}
.icon-btn.small {
  width: 30px;
  height: 30px;
}
.icon-btn .badge {
  position: absolute;
  top: 0;
  right: 0;
}
.link {
  border: 0;
  background: none;
  color: var(--brand);
  cursor: pointer;
  padding: 4px 0;
}
.field {
  display: grid;
  gap: 5px;
}
.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
input:not([type='checkbox']):not([type='radio']),
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  outline: none;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}
textarea {
  resize: vertical;
}
.check {
  display: flex;
  gap: 10px;
  align-items: center;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
legend {
  font-weight: 600;
  margin-bottom: 6px;
}
.switch {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch:checked {
  background: var(--brand);
}
.switch:checked::after {
  transform: translateX(18px);
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.search input {
  border: 0 !important;
  box-shadow: none !important;
  padding: 11px 0 !important;
  background: transparent !important;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13.5px;
}
.chip.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chip button {
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
}
.segmented {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 999px;
}
.segmented label {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
.segmented input {
  display: none;
}
.segmented label:has(input:checked) {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--brand);
}
.small-select {
  width: auto !important;
  padding: 4px 10px !important;
  font-size: 13px;
  margin-left: auto;
}

/* ---- cards / lists ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px;
}
.card.list {
  padding: 4px 0;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text);
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.list-row + .list-row {
  border-top: 1px solid var(--border);
}
.list-row.danger {
  color: var(--danger);
}
.list-row:hover {
  background: var(--surface-2);
}
.section-title {
  margin: 6px 4px -2px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hint {
  border-left: 4px solid var(--brand);
}
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  display: grid;
  gap: 12px;
  justify-items: center;
}
.spinner {
  width: 28px;
  height: 28px;
  margin: 28px auto;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-block;
  background: var(--surface-2);
}
.avatar.initials {
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}
.group-av {
  width: 50px;
  height: 50px;
  background: color-mix(in srgb, var(--brand) 16%, var(--surface)) !important;
  color: var(--brand) !important;
}
.group-av.small {
  width: 38px;
  height: 38px;
}
.group-av.big {
  width: 88px;
  height: 88px;
}
.tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
}

/* ---- welcome ---- */
#main.bare {
  min-height: 100vh;
}
.welcome {
  max-width: 460px;
  margin: 0 auto;
  padding-bottom: 24px;
}
.hero {
  color: #fff;
  text-align: center;
  padding: calc(48px + env(safe-area-inset-top)) 24px 64px;
  border-radius: 0 0 28px 28px;
}
.hero h1 {
  font-size: 28px;
  margin-top: 12px;
}
.hero p {
  opacity: 0.9;
  margin: 8px 0 0;
}
.hero-mark,
.hero-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
}
.auth {
  margin: -36px 16px 0;
  display: grid;
  gap: 14px;
  padding: 22px;
}
.code-input {
  font-size: 24px !important;
  letter-spacing: 0.4em;
  text-align: center;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.browse {
  display: block;
  margin-top: 18px;
}

/* ---- posts ---- */
.composer-start {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
}
.composer-start > span:not(.avatar) {
  flex: 1;
}
.post {
  padding: 0;
  overflow: hidden;
}
.post-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 12px 4px 14px;
}
.post-head .who {
  flex: 1;
  min-width: 0;
}
.name {
  color: var(--text);
  font-weight: 650;
}
.post-text {
  padding: 4px 14px 10px;
  white-space: normal;
  word-wrap: break-word;
}
.media-grid {
  display: grid;
  gap: 2px;
  background: var(--border);
}
.media-grid.n2,
.media-grid.n4 {
  grid-template-columns: 1fr 1fr;
}
.media-grid.n3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.media-grid.n3 .media-cell:first-child {
  grid-row: span 2;
}
.media-cell {
  position: relative;
  border: 0;
  padding: 0;
  background: #000;
  cursor: zoom-in;
  display: block;
  width: 100%;
}
.media-grid.n1 .media-cell img,
.media-grid.n1 video {
  width: 100%;
  max-height: 560px;
  object-fit: cover;
  display: block;
}
.media-grid:not(.n1) .media-cell {
  aspect-ratio: 1;
}
.media-grid:not(.n1) .media-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
video.media-cell {
  width: 100%;
}
.more-count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}
.post-actions {
  display: flex;
  border-top: 1px solid var(--border);
  margin-top: 0;
}
.act {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.act.on {
  color: #e5484d;
}
.act.on svg {
  fill: currentColor;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin: 6px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.comments {
  display: grid;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px 2px;
}
.comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.comment .bubble {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 8px 12px;
  flex: 1;
}
.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.composer textarea {
  border: 0 !important;
  box-shadow: none !important;
  padding: 8px 0 !important;
  font-size: 17px;
}
.composer {
  display: grid;
  gap: 10px;
}
.thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.thumb {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 11px;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.thumb .spinner {
  margin: 0;
  width: 22px;
  height: 22px;
}

/* ---- pages ---- */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.page-card {
  padding: 0;
  overflow: hidden;
  text-align: center;
}
.page-cover {
  display: block;
  height: 70px;
  background-size: cover;
  background-position: center;
}
.page-card-body {
  padding: 0 12px 14px;
  display: grid;
  gap: 4px;
  justify-items: center;
}
.page-card-avatar {
  margin-top: -30px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  display: inline-flex;
}
.page-card .btn {
  margin-top: 6px;
}
.page-head .cover {
  height: 180px;
  background-size: cover;
  background-position: center;
}
@media (min-width: 900px) {
  .page-head .cover {
    height: 240px;
  }
}
.page-id {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}
.page-avatar {
  margin-top: -46px;
  border: 4px solid var(--bg);
  border-radius: 50%;
  display: inline-flex;
}
.page-title {
  flex: 1;
  min-width: 200px;
}
.page-title h1 {
  font-size: 24px;
}
.page-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}
.page-tabs {
  max-width: 980px;
  margin: 10px auto 0;
  padding: 0 12px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.page-tabs a {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.page-tabs a.on {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.about .facts {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}
.about .facts li {
  display: flex;
  gap: 8px;
  align-items: center;
}
.prose {
  white-space: normal;
}

/* ---- shop ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.product-card {
  padding: 0;
  overflow: hidden;
  color: var(--text);
}
.product-img {
  aspect-ratio: 1;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--muted);
  position: relative;
}
.product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sold {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
}
.product-info {
  padding: 10px 12px;
}
.price {
  font-weight: 700;
  color: var(--brand);
}
.price.big {
  font-size: 22px;
  margin: 6px 0 10px;
}
.product-detail {
  display: grid;
  gap: 8px;
}
.gallery-main {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
}
.gallery-main img {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  display: block;
}
.empty-img {
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.gallery-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  overflow-x: auto;
}
.gallery-thumbs button {
  width: 58px;
  height: 58px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.gallery-thumbs button.on {
  border-color: var(--brand);
}
.gallery-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qty-row {
  flex-wrap: nowrap;
  margin-top: 8px;
}
.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.qty button {
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  font-size: 20px;
  cursor: pointer;
}
.qty span {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
}
.qty.small button {
  width: 32px;
  height: 32px;
}
.cart-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  max-width: 616px;
  margin: 0 auto;
}
.cart-bar b {
  margin-left: auto;
}
@media (min-width: 900px) {
  .cart-bar {
    bottom: 20px;
    left: 252px;
  }
}
.cart-line {
  cursor: default;
}
.cart-img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.cart-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.totals {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.totals div {
  display: flex;
  justify-content: space-between;
}
.totals .total {
  font-weight: 800;
  font-size: 17px;
}
.order {
  display: grid;
  gap: 8px;
}
.order-lines {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}
.order-lines li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.status {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
}
.s-new,
.s-confirmed {
  background: #eaf1ff;
  color: #1d4ed8;
}
.s-ready,
.s-shipped {
  background: #fff4e5;
  color: #b54708;
}
.s-done {
  background: #e7f8ef;
  color: #067647;
}
.s-cancelled {
  background: #fdeceb;
  color: #b42318;
}

/* ---- chats ---- */
.chat-row .grow > div {
  gap: 8px;
  flex-wrap: nowrap;
}
.chat-row.unread b {
  font-weight: 800;
}
.chat-avatar {
  position: relative;
  display: inline-flex;
}
.dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--surface);
}
.checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
}
.checkbox.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.pick-list {
  max-height: 50vh;
  overflow-y: auto;
  margin: 10px 0;
}
.thread {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
}
.layout.in-thread .thread {
  height: 100dvh;
}
@media (max-width: 899px) {
  .layout.in-thread {
    padding-bottom: 0;
  }
  .layout.in-thread .tabs {
    display: none;
  }
}
@media (min-width: 900px) {
  .thread,
  .layout.in-thread .thread {
    height: 100dvh;
  }
}
.thread-head {
  border-bottom: 1px solid var(--border);
}
.thread-who {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.thread-who > div {
  min-width: 0;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}
#list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: auto;
}
.center-btn {
  align-self: center;
}
.day {
  align-self: center;
  margin: 12px 0 6px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 999px;
}
.sys {
  align-self: center;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 12px;
}
.msg {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  max-width: 82%;
}
.msg.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-av {
  width: 28px;
  flex-shrink: 0;
}
.msg-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.msg.mine .msg-body {
  justify-items: end;
}
.msg-name {
  font-size: 12px;
  color: var(--muted);
  margin-left: 10px;
}
.bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 6px;
  padding: 7px 12px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  cursor: default;
}
.msg.mine .bubble {
  background: var(--mine);
  color: var(--mine-text);
  border-color: transparent;
  border-radius: 18px 18px 6px 18px;
}
.msg.mine .bubble a {
  color: #fff;
  text-decoration: underline;
}
.bubble.deleted {
  opacity: 0.6;
}
.bubble .time {
  display: block;
  text-align: right;
  font-size: 10.5px;
  opacity: 0.7;
  margin-top: 2px;
}
.msg-img {
  display: block;
  border: 0;
  padding: 0;
  background: none;
  cursor: zoom-in;
  margin: 2px 0 4px;
}
.msg-img img {
  max-width: 260px;
  max-height: 320px;
  border-radius: 12px;
  display: block;
}
.bubble video {
  max-width: 260px;
  border-radius: 12px;
}
.bubble .file-chip {
  margin: 2px 0;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick .chip {
  border-color: var(--brand);
  color: var(--brand);
}
.cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 4px;
}
.mini-card {
  flex-shrink: 0;
  width: 140px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  padding: 0 0 8px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.mini-card img,
.mini-card .ph {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
}
.mini-card b,
.mini-card span {
  padding: 0 10px;
  font-size: 13px;
}
.mini-card span {
  color: var(--brand);
  font-weight: 700;
}
.composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.composer-bar textarea {
  flex: 1;
  border-radius: 22px;
  padding: 10px 14px;
  resize: none;
  max-height: 140px;
  min-width: 0;
}
.pending {
  width: 100%;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  order: -1;
}

/* ---- profile ---- */
.me-card,
.profile-card {
  display: flex;
  gap: 14px;
  align-items: center;
}
.profile-card {
  flex-direction: column;
  text-align: center;
}
.profile-card p {
  margin: 0;
}
.stats {
  display: flex;
  gap: 18px;
  color: var(--muted);
}
.stats b {
  color: var(--text);
}
.avatar-edit {
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}
.avatar-edit span {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
}
.group-card {
  display: grid;
  justify-items: center;
  gap: 6px;
}

/* ---- sheets / menus / toasts ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 22, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.15s ease;
}
.sheet-backdrop.out {
  opacity: 0;
  transition: opacity 0.18s;
}
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up 0.18s ease;
  display: grid;
  gap: 12px;
}
.sheet.wide {
  max-width: 900px;
}
.sheet.dark {
  background: #000;
  padding: 0;
}
@media (min-width: 700px) {
  .sheet-backdrop {
    align-items: center;
  }
  .sheet {
    border-radius: 20px;
  }
}
@keyframes up {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.menu {
  display: grid;
}
.menu button,
.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 8px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  border-radius: 10px;
  font-size: 15.5px;
}
.menu button:hover,
.menu a:hover {
  background: var(--surface-2);
}
.menu .danger {
  color: var(--danger);
}
.confirm-text {
  font-size: 16px;
  margin: 4px 0 8px;
}
.lightbox {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 60vh;
}
.lightbox img {
  max-height: 88dvh;
  object-fit: contain;
}
.lightbox .close {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}
#toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: #1c2433;
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: opacity 0.4s, transform 0.4s;
}
.toast.error {
  background: #b42318;
}
.toast.success {
  background: #067647;
}
.toast.out {
  opacity: 0;
  transform: translateY(8px);
}
.ic {
  flex-shrink: 0;
}
[hidden] {
  display: none !important;
}

/* sign-in: a note when a code could not be sent, and the "New here?" divider */
.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  margin: 4px 0 10px;
}
.notice.warn {
  background: color-mix(in srgb, #f79009 14%, var(--surface));
  border: 1px solid color-mix(in srgb, #f79009 40%, transparent);
}
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0 8px;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* profile: "Pages you edit" */
.list-head {
  padding: 10px 14px 4px;
}
