:root {
  color-scheme: light;
  --white: #fff;
  --ink: #111;
  --muted: #86868b;
  --page: #f2f2f4;
  --glass: rgba(245, 245, 247, .84);
  --line: rgba(17, 17, 17, .08);
  --blue: #0a9fe8;
  --violet: #7468f5;
  --danger: #d70015;
  --green: #30d158;
  --shadow: 0 12px 34px rgba(20, 22, 32, .08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #e9e9ed; color: var(--ink); }
button, input, textarea { font: inherit; }
button { color: inherit; }
body { min-height: 100dvh; }

#app {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 0 50px rgba(0, 0, 0, .06);
  overflow: hidden;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; background: var(--white); }
.screen--gray { background: var(--page); }
.screen__body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; }
.safe-top { padding-top: max(14px, env(safe-area-inset-top)); }
.safe-bottom { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

.topbar {
  min-height: 72px; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line);
}
.topbar__title { flex: 1; text-align: center; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn, .text-btn {
  border: 0; background: var(--glass); border-radius: 14px; min-width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.text-btn { padding: 0 15px; font-weight: 600; }
.text-btn--primary { background: var(--ink); color: var(--white); }
.text-btn--danger { color: var(--danger); }

.home { background: var(--white); padding: max(18px, env(safe-area-inset-top)) 20px 0; }
.home__scroll { flex: 1; overflow-y: auto; }
.widget {
  padding: 22px; border: 1px solid rgba(255,255,255,.75); border-radius: 28px;
  background: linear-gradient(145deg, rgba(247,247,250,.96), rgba(232,238,246,.75));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9); backdrop-filter: blur(18px);
}
.clock { font-size: clamp(42px, 13vw, 58px); font-weight: 750; letter-spacing: -2px; }
.date { margin-top: 2px; color: var(--muted); font-size: 15px; }
.greeting { margin: 18px 0 0; font-size: 17px; line-height: 1.55; }
.app-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px 10px; margin: 40px 0; }
.app-entry { border: 0; background: none; padding: 0; cursor: pointer; }
.app-icon {
  width: 64px; height: 64px; margin: auto; border-radius: 22px; display: grid; place-items: center;
  color: #fff; font-size: 29px; box-shadow: inset 0 1px 1px rgba(255,255,255,.35);
}
.app-icon--chat { background: linear-gradient(145deg,#39b8ff,#0086df); }
.app-icon--char { background: linear-gradient(145deg,#8f86ff,#6558e8); }
.app-icon--settings { background: linear-gradient(145deg,#a7a7ad,#74747a); }
.app-icon--phone { background: linear-gradient(145deg,#55dc7a,#19a948); }
.app-label { margin-top: 8px; font-size: 13px; }
.dock {
  margin: auto 16px max(12px, env(safe-area-inset-bottom)); min-height: 76px; border-radius: 28px;
  background: rgba(238,238,242,.82); backdrop-filter: blur(22px); display: flex; justify-content: center;
  align-items: center; gap: 14px; padding: 10px 18px;
}
.dock .app-icon { width: 50px; height: 50px; border-radius: 17px; font-size: 22px; }

.form { display: grid; gap: 8px; }
.form label { margin-top: 12px; font-size: 14px; font-weight: 700; }
.input {
  width: 100%; border: 1px solid var(--line); background: #f7f7f9; color: var(--ink);
  border-radius: 14px; padding: 14px; outline: none;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(10,159,232,.12); }
textarea.input { min-height: 110px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.actions { display: flex; gap: 10px; margin-top: 22px; }
.actions > * { flex: 1; }
.primary { border: 0; border-radius: 15px; padding: 15px; background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; }
.secondary { border: 1px solid var(--line); border-radius: 15px; padding: 14px; background: #fff; font-weight: 650; cursor: pointer; }
.danger { color: var(--danger); }

.list { display: grid; gap: 1px; overflow: hidden; border-radius: 18px; }
.list-row {
  width: 100%; min-height: 76px; border: 0; background: #fff; display: flex; align-items: center;
  gap: 13px; padding: 12px 14px; text-align: left; cursor: pointer;
}
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__sub { margin-top: 4px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { border-radius: 999px; background: #e8f7ff; color: #087cb6; padding: 5px 9px; font-size: 12px; white-space: nowrap; }
.avatar { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 18px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(145deg,#e8e8ee,#cfcfd7); color: #686873; font-size: 23px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 96px; height: 96px; border-radius: 32px; font-size: 34px; }
.empty { min-height: 45vh; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 32px; }

.chat-header { background: #fff; padding: max(14px, env(safe-area-inset-top)) 18px 16px; }
.chat-header[hidden] { display: none; }
.chat-identity { display: flex; align-items: center; gap: 13px; }
.chat-identity__main { flex: 1; }
.chat-identity__name { font-size: 21px; font-weight: 750; }
.online { color: var(--muted); font-size: 14px; margin-top: 4px; }
.online::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); margin-right: 6px; }
.plus { border: 0; background: none; font-size: 42px; font-weight: 250; line-height: 1; cursor: pointer; }
.search { height: 48px; margin-top: 13px; border-radius: 16px; background: #f6f6f9; display: flex; align-items: center; justify-content: center; gap: 8px; color: #929298; font-size: 17px; }
.chat-content { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; background: var(--page); contain: layout paint; }
.mine-active .chat-content { padding-top: max(18px, env(safe-area-inset-top)); }
.chat-panel { min-height: 100%; contain: layout style; }
.chat-panel--me { display: flex; flex-direction: column; }
.chat-panel[hidden] { display: none; }
.tabbar { display: grid; grid-template-columns: repeat(4,1fr); min-height: 76px; background: rgba(255,255,255,.94); backdrop-filter: blur(18px); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); contain: layout paint; }
.tab { border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 3px; font-size: 12px; cursor: pointer; }
.tab__icon { font-size: 22px; }
.tab.active { color: var(--blue); }
.tab:active { background: rgba(10,159,232,.06); }
.quick-menu { position: fixed; z-index: 20; top: max(82px, calc(env(safe-area-inset-top) + 68px)); right: max(16px, calc((100vw - 480px)/2 + 16px)); width: 170px; padding: 7px; border-radius: 16px; background: rgba(255,255,255,.97); box-shadow: var(--shadow); border: 1px solid var(--line); }
.quick-menu button { width: 100%; border: 0; background: none; text-align: left; padding: 13px; border-radius: 11px; cursor: pointer; }
.quick-menu button:hover { background: var(--page); }

.profile-card { background: #fff; padding: 24px 22px; display: flex; align-items: center; gap: 18px; }
.profile-card__main { flex: 1; min-width: 0; }
.profile-card__name { font-size: 25px; font-weight: 750; }
.mine-profile { background: #fff; padding: 24px 22px; display: flex; align-items: center; gap: 18px; }
.mine-signature { margin-top: 14px; }
.mine-functions { margin-top: 18px; }
.mine-spacer { flex: 1 1 auto; min-height: 18px; }
.profile-hero { min-height: 220px; background: #fff; position: relative; display: grid; place-items: center; padding: 45px 20px 18px; }
.profile-hero__name { position: absolute; left: 22px; top: 18px; font-size: 22px; font-weight: 750; }
.profile-back { position: absolute; right: 18px; top: max(14px, env(safe-area-inset-top)); border: 0; border-radius: 14px; min-width: 58px; height: 40px; background: var(--glass); color: var(--ink); font-weight: 650; cursor: pointer; }

.messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 11px 14px; border-radius: 17px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble--user { align-self: flex-end; background: var(--violet); color: #fff; border-bottom-right-radius: 5px; }
.bubble--assistant { align-self: flex-start; background: #f1f1f4; border-bottom-left-radius: 5px; }
.bubble--error { align-self: center; max-width: 100%; background: #fff0f1; color: var(--danger); text-align: center; font-size: 13px; }
.composer { display: flex; gap: 8px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: #f5f5f7; }
.composer textarea { flex: 1; min-height: 48px; max-height: 130px; resize: none; }
.composer button { width: 68px; border: 0; border-radius: 14px; background: var(--violet); color: #fff; font-weight: 700; }
.status { text-align: center; color: var(--muted); font-size: 13px; padding: 5px; }

.check { width: 25px; height: 25px; accent-color: var(--blue); }
.bottom-actions { display: flex; gap: 12px; padding: 12px 18px max(12px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.bottom-actions button { flex: 1; }
.group-head { display: flex; align-items: center; gap: 18px; padding: 22px; background: #fff; }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.34); }
.modal { width: min(100%, 420px); border-radius: 22px; background: #fff; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 8px; font-size: 21px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: rgba(17,17,17,.9); color: #fff; border-radius: 999px; padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s ease; white-space: nowrap; max-width: 88vw; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .app-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-card, .mine-profile { align-items: flex-start; }
}
@media (min-width: 700px) {
  body { padding: 24px 0; }
  #app { min-height: calc(100dvh - 48px); border-radius: 34px; }
  .screen { min-height: calc(100dvh - 48px); }
}
