@font-face {
  font-family: "Azusa Pixel";
  src: url("/assets/fonts/unifont-17.0.04.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Azusa Natsuzemi";
  src: url("/assets/fonts/natsuzemi-maru-gothic.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Azusa IPix";
  src: url("/assets/fonts/ipix.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Azusa Mengshen";
  src: url("/assets/fonts/mengshen-handwritten.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Azusa StarLove Pencil";
  src: url("/assets/fonts/starlove-pencil.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Azusa Maoken Assorted";
  src: url("/assets/fonts/maoken-assorted-sans.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #111419;
  --rail: #0d1015;
  --sidebar: #171b21;
  --surface: #1c2128;
  --surface-2: #242a32;
  --surface-3: #2c333d;
  --line: #343c47;
  --line-soft: #282f38;
  --text: #edf1f5;
  --muted: #9aa4af;
  --faint: #697480;
  --accent: #2fb3bc;
  --accent-strong: #59c7ce;
  --accent-soft: #18383c;
  --green: #58c78d;
  --yellow: #e4b95f;
  --red: #ed7770;
  --blue: #73a7ee;
  --shadow: 0 20px 64px rgba(0, 0, 0, .42);
  --font-size-delta: 0px;
  --app-font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-family: var(--app-font-family);
  font-size: calc(16px + var(--font-size-delta));
  font-synthesis: weight;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable="true"],
.message-user-text,
.message-user-text * {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

img { -webkit-user-drag: none; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

html.font-bold body,
html.font-bold :where(button, input, textarea, select, p, span, small, label, td, th, time) {
  font-weight: 620;
}

html.font-bold :where(strong, h1, h2, h3, h4) {
  font-weight: 800;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.hidden {
  display: none !important;
}

.loading-screen,
.auth-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #14171a;
}

.auth-screen { overflow-y: auto; }

.loading-screen {
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.loading-screen p {
  margin: 0;
  font-size: calc(14px + var(--font-size-delta));
}

.loading-screen .brand-mark {
  position: relative;
  animation: azusa-loading-pulse 1.8s ease-in-out infinite;
}

@keyframes azusa-loading-pulse {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(1.04); filter: saturate(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-screen .brand-mark { animation: none; }
}

.brand-mark,
.brand-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #071719;
  font-size: calc(21px + var(--font-size-delta));
  font-weight: 800;
}

.auth-panel {
  width: min(410px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.auth-brand h1,
.auth-brand p {
  margin: 0;
}

.auth-brand h1 {
  font-size: calc(24px + var(--font-size-delta));
  line-height: 1.3;
}

.auth-brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: calc(13px + var(--font-size-delta));
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  border-radius: 7px;
  background: var(--bg);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface-3);
  color: var(--text);
}

.stack-form {
  display: grid;
  gap: 18px;
}

.stack-form label,
.field {
  display: grid;
  gap: 8px;
  color: #cdd2d6;
  font-size: calc(13px + var(--font-size-delta));
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

.password-field {
  position: relative;
  display: block;
}

.verification-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.verification-field .secondary-button {
  min-width: 112px;
  white-space: nowrap;
}

.auth-text-action {
  justify-self: center;
}

.password-field input {
  padding-right: 46px;
}

.password-field .icon-button {
  position: absolute;
  top: 3px;
  right: 3px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.send-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 650;
}

.primary-button,
.send-button {
  background: var(--accent);
  color: #071719;
}

.primary-button:hover,
.send-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.danger-button {
  border-color: rgba(237, 109, 102, .45);
  background: rgba(237, 109, 102, .11);
  color: #ff9c96;
}

.text-button {
  min-height: 32px;
  padding: 0 8px;
  background: transparent;
  color: var(--accent-strong);
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(20px + var(--font-size-delta));
}

.icon-button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.notice-block {
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #d8eef0;
  font-size: calc(13px + var(--font-size-delta));
}

.notice-block p {
  margin: 5px 0 0;
  color: #a9c9cc;
  line-height: 1.6;
}

.registration-notice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.registration-notice > .lucide {
  width: 20px;
  height: 20px;
  color: var(--accent-strong);
}

.registration-notice strong,
.registration-notice p { margin: 0; }
.registration-notice strong { font-size: calc(13px + var(--font-size-delta)); }
.registration-notice p {
  margin-top: 4px;
  color: var(--muted);
  font-size: calc(12px + var(--font-size-delta));
  line-height: 1.6;
}

.agreement-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--muted);
  font-size: calc(12px + var(--font-size-delta));
  line-height: 1.5;
}

.agreement-row input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0 2px 0 0;
  padding: 0;
  accent-color: var(--accent);
}

.agreement-row label { display: inline; color: var(--muted); cursor: pointer; }
.agreement-link {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  line-height: inherit;
}
.agreement-link:hover { text-decoration: underline; text-underline-offset: 2px; }

.agreement-document { display: grid; gap: 18px; color: var(--muted); line-height: 1.75; }
.agreement-document > p,
.agreement-document section p,
.agreement-document section ul { margin: 0; }
.agreement-document section {
  display: grid;
  gap: 7px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.agreement-document section:last-of-type { padding-bottom: 0; border-bottom: 0; }
.agreement-document h3 { margin: 0; color: var(--text); font-size: calc(14px + var(--font-size-delta)); }
.agreement-document ul { padding-left: 20px; }
.agreement-version { color: var(--faint); font-size: calc(11px + var(--font-size-delta)); }

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 72px 310px minmax(0, 1fr);
  background: var(--bg);
}

.rail {
  position: relative;
  z-index: 5;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 9px;
  border-right: 1px solid var(--line-soft);
  background: var(--rail);
}

.brand-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.rail-main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 14px;
}

.rail-button {
  position: relative;
  width: 100%;
  height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.rail-button > span {
  font-size: calc(21px + var(--font-size-delta));
  line-height: 1;
}

.rail-button small {
  font-size: calc(10px + var(--font-size-delta));
}

.rail-button:hover,
.rail-button.active {
  background: var(--surface-2);
  color: var(--text);
}

.rail-button.active::before {
  content: "";
  position: absolute;
  left: -9px;
  width: 3px;
  height: 25px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.nav-dot {
  position: absolute;
  top: 7px;
  right: 10px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--rail);
  border-radius: 50%;
  background: var(--red);
}

.rail-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 2px solid var(--line);
  cursor: pointer;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-header {
  height: 78px;
  flex: 0 0 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px 8px 18px;
}

.sidebar-header h2,
.sidebar-header p {
  margin: 0;
}

.sidebar-header h2 {
  margin-top: 2px;
  font-size: calc(20px + var(--font-size-delta));
}

.sidebar-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-network-route {
  min-width: 30px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: calc(9px + var(--font-size-delta));
  font-weight: 700;
  line-height: 1;
}

.client-network-route::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.client-network-route.route-v6 { border-color: rgba(86, 199, 160, .28); color: #78d5b3; }
.client-network-route.route-v4 { border-color: rgba(224, 184, 101, .28); color: #dec27d; }

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#sidebar-refresh.refreshing .lucide { animation: azusa-spin 1s linear infinite; }

.eyebrow {
  color: var(--accent-strong);
  font-size: calc(11px + var(--font-size-delta));
  font-weight: 700;
}

.search-wrap {
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 14px 10px;
  padding: 0 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg);
  color: var(--faint);
}

.search-wrap input {
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
}

.sidebar-content {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin: 6px 9px 3px;
  color: var(--faint);
  font-size: calc(11px + var(--font-size-delta));
  font-weight: 700;
  text-transform: uppercase;
}

.conversation-item,
.contact-item,
.request-item {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.conversation-item:hover,
.contact-item:hover,
.conversation-item.active,
.contact-item.active {
  background: var(--surface-2);
}

.item-copy {
  min-width: 0;
}

.item-copy strong,
.item-copy p {
  display: block;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-copy strong {
  font-size: calc(14px + var(--font-size-delta));
  font-weight: 650;
}

.item-copy p {
  margin-top: 5px;
  color: var(--muted);
  font-size: calc(12px + var(--font-size-delta));
}

.item-meta {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  color: var(--faint);
  font-size: calc(10px + var(--font-size-delta));
}

.badge {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #071719;
  font-size: calc(10px + var(--font-size-delta));
  font-weight: 800;
}

.avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  overflow: visible;
  border-radius: 50%;
  background: #3e474d;
  color: #ecf8f9;
  font-size: calc(15px + var(--font-size-delta));
  font-weight: 750;
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  object-fit: cover;
}

.avatar-identity-badge {
  position: absolute;
  z-index: 3;
  min-width: calc(16px + var(--font-size-delta));
  height: calc(14px + var(--font-size-delta));
  display: inline-grid;
  place-items: center;
  padding: 0 3px;
  border: 2px solid var(--surface);
  border-radius: 4px;
  color: #fff;
  font-size: calc(7px + var(--font-size-delta));
  font-weight: 800;
  line-height: 1;
}

.avatar-identity-badge.bot {
  top: -4px;
  left: -5px;
  background: #527daa;
}

.identity-tag {
  min-height: 16px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0 4px;
  font-size: calc(8px + var(--font-size-delta));
  font-weight: 750;
  line-height: 1;
}

.identity-tag.owner { border-color: rgba(218, 168, 83, .3); background: rgba(183, 129, 50, .17); color: #e4bc72; }
.identity-tag.admin { border-color: rgba(145, 158, 222, .28); background: rgba(99, 115, 181, .17); color: #b7c0ef; }
.profile-identity-tags { display: flex; justify-content: center; gap: 5px; margin: 7px 0 1px; }

.presence-dot {
  position: absolute;
  right: -1px;
  bottom: 0;
  width: 12px;
  height: 12px;
  border: 3px solid var(--sidebar);
  border-radius: 50%;
  background: var(--faint);
}

.presence-online .presence-dot { background: var(--green); }
.presence-busy .presence-dot { background: var(--yellow); }
.presence-dnd .presence-dot { background: var(--red); }

.group-avatar {
  border-radius: 7px;
  background: #3b5559;
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.empty-state {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-symbol {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: calc(38px + var(--font-size-delta));
}

.empty-symbol:has(img) {
  padding: 7px;
  overflow: hidden;
  border-radius: 18px;
}

.empty-symbol img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 11px;
  object-fit: cover;
}

.azusa-status-state {
  min-height: 180px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

.azusa-status-state.compact {
  min-height: 150px;
  padding: 24px 14px;
}

.azusa-status-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: 0 9px 24px rgba(0, 0, 0, .14);
}

.azusa-status-state.compact .azusa-status-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.azusa-status-mark img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 9px;
  object-fit: cover;
}

.azusa-status-copy {
  display: grid;
  gap: 5px;
}

.azusa-status-copy strong {
  color: var(--text);
  font-size: calc(14px + var(--font-size-delta));
  font-weight: 650;
}

.azusa-status-copy small {
  color: var(--muted);
  font-size: calc(11px + var(--font-size-delta));
  line-height: 1.55;
}

.messages > .azusa-status-state {
  min-height: calc(100% - 1px);
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state h2 {
  color: #cbd0d4;
  font-size: calc(18px + var(--font-size-delta));
}

.empty-state p {
  margin-top: 7px;
  font-size: calc(13px + var(--font-size-delta));
}
