:root {
  --home-bg: #faf8f4;
  --home-panel: #fffefa;
  --home-soft: #f0eee9;
  --home-text: #302d27;
  --home-muted: #918a7f;
  --home-accent: #cd704b;
  --home-line: rgba(72, 67, 58, .09);
}

.plain-icon {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #4b463e;
  font: 24px/1 ui-sans-serif, system-ui, sans-serif;
}

.shell > .shell-update {
  position: absolute;
  z-index: 29;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: auto;
  min-height: 38px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(72, 51, 43, .16);
}

.hub {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--home-bg);
}

.hub[hidden] { display: none; }

.hub-header {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
}

.hub-header h1 {
  margin: 0;
  font: 500 26px/1.15 Georgia, "Songti SC", serif;
  letter-spacing: .04em;
}

.hub-header .eyebrow { margin-bottom: 3px; }
.hub-state { color: var(--home-muted); font-size: 11px; white-space: nowrap; }
.hub-state.ok { color: #61885d; }
.hub-state.bad { color: #a45f50; }

.hub-search-wrap { position: relative; padding: 4px 18px 12px; }
.hub-search-wrap label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.hub-search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 17px;
  border: 1px solid var(--home-line);
  border-radius: 16px;
  outline: 0;
  background: #f1efeb;
  color: var(--home-text);
  font: 14px inherit;
}

.hub-content { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 18px 105px; }
.conversation-list { display: grid; }
.conversation-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--home-line);
  background: transparent;
  color: var(--home-text);
  text-align: left;
}
.conversation-row:active { background: rgba(77, 70, 60, .04); }
.conversation-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 18px;
  background: #e7e2d8;
  color: #746c60;
  font: 21px Georgia, "Songti SC", serif;
}
.conversation-avatar,.conversation-avatar.room { border-radius: 50%; }
.group-avatar { position: relative; overflow: hidden; border-radius: 50%; background: #eceae5; border: 1px solid rgba(74, 70, 63, .08); }
.room-avatar-member { position: absolute; display: grid; width: 24px; height: 24px; overflow: hidden; place-items: center; border: 2px solid #fcfbf8; border-radius: 50%; background: #e4e1da; color: #6f6a61; font: 11px Georgia,"Songti SC",serif; }
.room-avatar-member img { width: 100%; height: 100%; object-fit: cover; }
.room-avatar-member:nth-child(1) { top: 2px; left: 3px; }
.room-avatar-member:nth-child(2) { top: 2px; right: 3px; }
.room-avatar-member:nth-child(3) { right: 50%; bottom: 1px; transform: translateX(50%); }
.resident-avatar.group-avatar .room-avatar-member { width: 17px; height: 17px; border-width: 1px; font-size: 8px; }
.resident-avatar.group-avatar .room-avatar-member:nth-child(1) { top: 1px; left: 1px; }
.resident-avatar.group-avatar .room-avatar-member:nth-child(2) { top: 1px; right: 1px; }
.resident-avatar.group-avatar .room-avatar-member:nth-child(3) { bottom: 0; }
.conversation-avatar.room { background: #dfe7dc; color: #58705a; }
.conversation-copy { min-width: 0; }
.conversation-copy strong { display: block; margin-bottom: 6px; overflow: hidden; font-size: 16px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.conversation-copy small { display: block; overflow: hidden; color: var(--home-muted); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { align-self: start; padding-top: 7px; color: #aaa49a; font-size: 10px; white-space: nowrap; }
.contact-directory { display: grid; gap: 22px; padding-top: 5px; }
.contact-section { display: grid; }
.contact-section h2 { margin: 0 2px 7px; color: var(--home-muted); font-size: 12px; font-weight: 500; letter-spacing: .08em; }
.contact-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 18px; gap: 12px; align-items: center; min-height: 67px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--home-line); background: transparent; color: var(--home-text); text-align: left; }
.contact-row .conversation-avatar { width: 46px; height: 46px; }
.contact-row .conversation-copy strong { margin-bottom: 4px; }
.contact-arrow { color: #b3ada4; font-size: 24px; font-weight: 300; text-align: right; }
.contact-row:active { background: rgba(77, 70, 60, .04); }

.hub-tabs {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 9px 15px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--home-line);
  background: rgba(250, 248, 244, .96);
  backdrop-filter: blur(18px);
}
.hub-tabs button {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-height: 50px;
  padding: 3px;
  border: 0;
  background: transparent;
  color: #8b857b;
  font: 11px inherit;
}
.hub-tabs button span { font-size: 19px; line-height: 1; }
.hub-tabs button[aria-current="page"] { color: var(--home-accent); }

.profile-summary,
.section-card {
  margin: 8px 0 14px;
  padding: 18px;
  border: 1px solid var(--home-line);
  border-radius: 22px;
  background: rgba(255, 254, 250, .78);
}
.profile-summary h2,.section-card h2 { margin: 0 0 7px; font: 500 20px Georgia, "Songti SC", serif; }
.profile-summary p,.section-card p { margin: 5px 0; color: var(--home-muted); font-size: 12px; line-height: 1.6; }
.avatar-editor { display: grid; margin: 15px 0 3px; }
.avatar-editor-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 11px; min-height: 61px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--home-line); background: transparent; color: var(--home-text); text-align: left; }
.avatar-editor-preview { display: grid; width: 44px; height: 44px; place-items: center; overflow: hidden; border-radius: 50%; background: #e7e2d8; color: #746c60; font: 18px Georgia,"Songti SC",serif; }
.avatar-editor-row > span:nth-child(2) { font-size: 14px; }
.avatar-editor-row small { color: var(--home-muted); font-size: 11px; }
.avatar-editor-status { min-height: 18px; margin: 4px 0 10px !important; color: var(--home-muted); }
.quota-list { display: grid; gap: 9px; margin-top: 14px; }
.quota-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--home-soft); font-size: 12px; }
.quota-item span:last-child { color: var(--home-muted); text-align: right; }

.profile-tools { display: grid; margin: 0 0 10px; }
.profile-tools[hidden] { display: none; }
.profile-tools button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--home-line);
  background: transparent;
  color: var(--home-text);
  text-align: left;
}
.profile-tools button span { font-size: 14px; }
.profile-tools button small { color: var(--home-muted); font-size: 11px; }

.app-sidebar {
  position: absolute;
  z-index: 31;
  inset: 0 auto 0 0;
  width: min(82%, 330px);
  padding: max(30px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  background: #f3f0e9;
  box-shadow: 18px 0 45px rgba(47, 39, 29, .18);
}
.app-sidebar[hidden],.sidebar-shade[hidden] { display: none; }
.sidebar-shade { position: absolute; z-index: 30; inset: 0; background: rgba(35, 31, 25, .25); backdrop-filter: blur(3px); }
.app-sidebar header { display: flex; align-items: center; gap: 12px; margin: 5px 4px 28px; }
.sidebar-home-mark { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 16px; background: #e4dfd4; font: 25px Georgia, serif; }
.app-sidebar header strong,.app-sidebar header small { display: block; }
.app-sidebar header strong { font: 500 20px Georgia, "Songti SC", serif; }
.app-sidebar header small { margin-top: 3px; color: var(--home-muted); font-size: 10px; }
.app-sidebar nav { display: grid; gap: 5px; }
.app-sidebar nav button { display: flex; align-items: center; gap: 13px; min-height: 50px; padding: 0 13px; border: 0; border-radius: 15px; background: transparent; color: #514c44; font: 15px inherit; }
.app-sidebar nav button span { width: 24px; font-size: 20px; text-align: center; }
.app-sidebar nav button[aria-current="page"] { background: #e5e0d6; }
.app-sidebar > p { position: absolute; right: 22px; bottom: max(18px, env(safe-area-inset-bottom)); left: 22px; color: var(--home-muted); font-size: 10px; line-height: 1.65; }

.conversation-back { margin-right: 2px; font-size: 34px; }
.approval-drawer,
.work-drawer,
.project-drawer {
  position: absolute;
  z-index: 24;
  inset: 0;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: var(--home-bg);
}
body[data-screen="hub"] > .shell > .topbar,
body[data-screen="hub"] > .shell > .residents,
body[data-screen="hub"] > .shell > .chat,
body[data-screen="hub"] > .shell > .composer { visibility: hidden; }
body[data-screen="conversation"] .hub { display: none; }
body[data-screen="conversation"] .residents { display: none; }
body[data-screen="conversation"] .topbar { align-items: center; padding: max(18px, env(safe-area-inset-top)) 18px 10px; }
body[data-screen="conversation"] .topbar > div { flex: 1; text-align: center; }
body[data-screen="conversation"] .topbar .eyebrow { display: none; }
body[data-screen="conversation"] .topbar h1 { font: 500 17px/1.2 ui-sans-serif, system-ui, sans-serif; letter-spacing: .04em; }
body[data-screen="conversation"] .service-state { padding: 6px 8px; font-size: 10px; }
body[data-screen="conversation"] .chat { height: calc(min(860px, var(--app-viewport-height, 100dvh)) - 85px); padding-top: 18px; }
body[data-screen="conversation"] .composer { z-index: 4; }

@media (min-width: 521px) {
  .hub,.app-sidebar,.sidebar-shade { border-radius: 31px; }
}

@media (max-width: 360px) {
  .hub-header { padding-right: 13px; padding-left: 13px; }
  .hub-search-wrap,.hub-content { padding-right: 13px; padding-left: 13px; }
  .conversation-row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; }
  .conversation-avatar { width: 46px; height: 46px; border-radius: 50%; }
  .room-avatar-member { width: 25px; height: 25px; }
}
