@font-face {
  font-family: 'DM Sans';
  src: url('/assets/dm-sans-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: 'DM Sans', sans-serif;
  --wine: #44152d;
  --wine-deep: #280f20;
  --sidebar: #23131e;
  --surface: #2e1926;
  --field: #21121c;
  --edge: #543145;
  --edge-soft: #472a3c;
  --text: #fff2f5;
  --muted: #c3a2b1;
  --accent: #f1a8bb;
  --accent-bright: #ffc1d0;
  --accent-ink: #351321;
  --error: #ffb2b5;
  --avatar-rose: #523047;
  --avatar-clay: #5b3741;
  --avatar-plum: #473450;
  --avatar-dust: #4b3b4e;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  display: flow-root;
  min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(ellipse at 22% 7%, #622443 0%, transparent 57%),
    linear-gradient(138deg, var(--wine), var(--wine-deep) 86%);
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
input, textarea { min-width: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-library { width: 0; height: 0; position: absolute; pointer-events: none; }
.icon {
  flex: none;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button, .quiet, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  gap: 8px;
  border-radius: 10px;
}

.icon-button { width: 40px; height: 40px; padding: 0; background: none; color: var(--muted); flex: none; }
.icon-button:hover:not(:disabled) { background: #f4b1c41a; color: var(--text); }
.icon-button:disabled { opacity: .5; }
.quiet { padding: 8px 12px; background: transparent; color: var(--muted); font-size: .86rem; }
.quiet:hover { color: var(--text); background: #f4b1c411; }
.quiet .icon { width: 16px; height: 16px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 750; }
.primary:hover:not(:disabled) { background: var(--accent-bright); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .52; }

.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(100%, 408px);
  padding: 43px 38px 36px;
  border-radius: 23px;
  border: 1px solid #754258;
  background: linear-gradient(158deg, #3c2132, #2a1623 76%);
  box-shadow: 0 28px 84px #17061363, inset 0 1px #ffced41c;
  text-align: center;
}

.auth-mark, .empty-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #9b547a29;
  border: 1px solid #9b547a66;
  border-radius: 17px;
  width: 59px;
  height: 59px;
  margin: 0 auto;
}

.auth-mark .icon { width: 26px; height: 26px; }
.auth-card h1 { font-size: 2.38rem; letter-spacing: .115em; margin: 22px 0 6px; line-height: 1.15; font-weight: 750; }
.auth-caption { margin: 0; color: var(--muted); font-size: .96rem; line-height: 1.5; }
.auth-form { margin: 29px 0 0; display: grid; gap: 17px; text-align: left; }
.field { display: grid; gap: 7px; }
.field label { font-size: .85rem; font-weight: 680; color: #f0d3de; }
.field-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  background: var(--field);
  border: 1px solid var(--edge);
  border-radius: 10px;
  color: var(--muted);
}
.field-control:focus-within, .composer:focus-within { border-color: #d58ba9; }
.field-control > .icon { width: 17px; height: 17px; }
.field-control input, .composer textarea { width: 100%; border: 0; background: transparent; padding: 0; outline: none; }
.field-control input { height: 44px; }
input::placeholder, textarea::placeholder { color: #b695a6; opacity: 1; }
.password-toggle { width: 32px; height: 32px; margin-right: -5px; }
.password-toggle .icon { width: 18px; height: 18px; }
.auth-submit { min-height: 48px; margin-top: 4px; }
.auth-submit .icon { width: 18px; height: 18px; }
#auth-retry { margin-top: 12px; }
.form-error { color: var(--error); margin: 0; font-size: .87rem; line-height: 1.4; overflow-wrap: anywhere; }

.workspace {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: clamp(232px, 21vw, 295px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
}

.sidebar { display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--edge); min-height: 0; }
.sidebar-header { height: 83px; display: flex; align-items: center; padding: 0 24px; flex: none; }
.site-title { font-size: 1.29rem; font-weight: 800; letter-spacing: .145em; }
.directory { flex: 1; overflow-y: auto; min-height: 0; padding: 10px 13px 23px; }
.directory h2 { color: var(--muted); font-size: .69rem; font-weight: 800; letter-spacing: .105em; text-transform: uppercase; margin: 0 10px 9px; }
.directory .direct-heading { margin-top: 27px; }
.room-button {
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  margin-bottom: 3px;
  color: #efd5e0;
  min-height: 54px;
  font-weight: 640;
  font-size: .91rem;
}
.room-button:hover { background: #382132; }
.room-button[aria-current="true"] { background: #49273c; border-color: #6c3c57; color: var(--text); }
.room-button:focus-visible { outline-offset: -2px; }
.room-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.unread { display: grid; place-items: center; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 800; min-width: 18px; height: 18px; padding: 0 5px; }
.directory-empty { color: var(--muted); font-size: .88rem; padding: 5px 10px; margin: 0; }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 35px;
  height: 35px;
  border-radius: 10px;
  border: 1px solid #ffcee522;
  background: var(--avatar-rose);
  color: #f8d0df;
  font-size: .76rem;
  font-weight: 800;
  line-height: 1;
}
.avatar[data-tone="1"] { background: var(--avatar-clay); }
.avatar[data-tone="2"] { background: var(--avatar-plum); }
.avatar[data-tone="3"] { background: var(--avatar-dust); }
.room-avatar { background: #693c55; color: #ffd1df; }
.room-avatar .icon { width: 19px; height: 19px; }
.account { display: flex; align-items: center; gap: 10px; min-height: 72px; padding: 10px 15px 10px 22px; border-top: 1px solid var(--edge-soft); }
.account-name { flex: 1; min-width: 0; font-size: .91rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-avatar { background: #64394f; }

.chat {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(ellipse at 77% 15%, #45243755, transparent 65%), #2b1926;
}
.chat-header { display: flex; gap: 13px; align-items: center; min-height: 83px; padding: 13px 25px; border-bottom: 1px solid var(--edge-soft); background: #33202ee0; }
.header-avatar { width: 45px; height: 45px; border-radius: 12px; font-size: .88rem; }
.header-avatar .icon { width: 23px; height: 23px; }
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h1 { margin: 0; font-size: 1.09rem; line-height: 1.3; font-weight: 770; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading p { color: var(--muted); margin: 3px 0 0; font-size: .81rem; }
.mobile-back { display: none; }
.timeline { min-height: 0; overflow-y: auto; flex: 1; padding: 22px 25px; display: flex; flex-direction: column; scrollbar-color: #754961 transparent; }
.empty { text-align: center; padding: 22px; margin: auto; }
.empty-icon { width: 64px; height: 64px; border-radius: 19px; }
.empty-icon .icon { width: 28px; height: 28px; }
.empty h2 { font-size: 1.13rem; margin: 15px 0 4px; }
.empty p { color: var(--muted); font-size: .91rem; margin: 0; line-height: 1.4; }
.messages { display: flex; flex-direction: column; gap: 14px; margin-top: auto; }
.empty:not([hidden]) + .messages:empty { display: none; }
.older { align-self: center; margin-bottom: 12px; }
.latest { position: absolute; left: 50%; bottom: 91px; transform: translateX(-50%); z-index: 1; white-space: nowrap; background: #57334c; color: var(--text); }
.latest:hover { background: #69425e; }
.day {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 650;
  text-align: center;
  margin: 7px 0;
}
.day::before, .day::after { content: ''; flex: 1; height: 1px; background: var(--edge-soft); }
.message-row { display: flex; gap: 8px; align-items: flex-end; }
.message-row .avatar { width: 31px; height: 31px; border-radius: 9px; margin-bottom: 2px; }
.message-row.own { justify-content: flex-end; }
.bubble {
  min-width: 82px;
  max-width: min(82%, 560px);
  padding: 9px 12px 7px;
  border-radius: 14px 14px 14px 4px;
  border: 1px solid #684359;
  background: #43293b;
  overflow-wrap: anywhere;
}
.own .bubble { border-color: #8c536d; background: #60374e; border-radius: 14px 14px 4px 14px; }
.bubble-author { display: block; color: #ffbad0; font-size: .75rem; margin-bottom: 3px; }
.bubble-text { margin: 0; white-space: pre-wrap; font-size: .96rem; line-height: 1.45; }
.bubble time { display: block; text-align: right; font-size: .66rem; color: #e0bdcd; margin-top: 4px; }
.bubble audio { display: block; width: min(265px, 52vw); height: 38px; margin-top: 5px; }
.image-button { display: block; border: 0; border-radius: 8px; padding: 0; background: var(--field); overflow: hidden; }
.image-button img { display: block; width: auto; max-width: 100%; max-height: 320px; }

.composer-wrap { padding: 14px 25px 17px; border-top: 1px solid var(--edge-soft); background: #33202ee0; }
.composer { display: flex; align-items: flex-end; gap: 3px; padding: 5px; background: var(--field); border: 1px solid var(--edge); border-radius: 13px; }
.composer textarea { padding: 9px 6px; line-height: 22px; resize: none; height: auto; max-height: 128px; field-sizing: content; }
.composer .send { width: 40px; height: 40px; flex: none; }
.send .icon { width: 20px; height: 20px; }
.record[data-recording="true"] { color: #ffd1d4; background: #813f54; }
.attachment-preview { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 8px; background: #44293b; border: 1px solid var(--edge); border-radius: 10px; }
.attachment-preview img { width: 43px; height: 43px; object-fit: cover; border-radius: 6px; }
.attachment-preview audio { width: min(260px, 100%); height: 38px; }
.attachment-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; color: #f3dbe5; }
.attachment-preview .icon-button { margin-left: auto; }
.composer-error { margin-bottom: 8px; }
.image-dialog { padding: 0; max-width: min(95vw, 1100px); border-radius: 14px; border: 1px solid var(--edge); background: var(--field); overflow: visible; }
.image-dialog::backdrop { background: #11060de8; }
.image-dialog img { display: block; max-width: 100%; max-height: 85dvh; object-fit: contain; border-radius: 13px; }
.image-dialog form { position: absolute; right: 8px; top: 8px; }
.image-dialog .icon-button { background: #21121ceb; color: var(--text); }

@media (max-width: 860px) {
  .chat-header, .timeline, .composer-wrap { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 640px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace[data-mobile="list"] .chat, .workspace[data-mobile="chat"] .sidebar { display: none; }
  .sidebar { border-right: 0; }
  .sidebar-header { height: 73px; }
  .mobile-back { display: inline-flex; margin-left: -8px; }
  .chat-header { gap: 8px; min-height: 68px; padding: 9px 13px; }
  .header-avatar { width: 38px; height: 38px; }
  .chat-heading h1 { font-size: 1rem; }
  .timeline { padding: 14px 12px; }
  .composer-wrap { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .latest { bottom: 76px; }
  .composer textarea, .field-control input { font-size: 16px; }
  .auth-card { padding: 35px 23px 26px; }
}
