:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #202840;
  background: #f3f5fa;
  --ink: #202840;
  --muted: #58647d;
  --line: #dfe5ef;
  --surface: #fff;
  --soft: #f3f5fa;
  --accent: #4746a7;
  --tint: #eeedfb;
  --rail: #202747;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100dvh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid #655bd8; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.1rem); letter-spacing: -.035em; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; }
h3 { font-size: .94rem; }
.muted { color: var(--muted); }
.plain { border: 0; padding: 0; background: none; color: inherit; }
.primary, .secondary, .danger { padding: .66rem .9rem; border-radius: .55rem; border: 1px solid transparent; font-weight: 650; min-height: 2.6rem; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: #383686; }
.secondary { color: var(--ink); border-color: var(--line); background: var(--surface); }
.secondary:hover, .icon-button:hover { background: var(--tint); }
.danger { color: #a42842; background: #fff0f2; }
.icon-button { border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); color: var(--ink); min-width: 2.4rem; min-height: 2.4rem; font-size: 1.25rem; }
.access { max-width: 960px; margin: auto; padding: 2rem; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; align-content: center; }
.access-brand, .access-panel { padding: clamp(1.6rem, 4vw, 3.2rem); }
.access-brand { min-height: 460px; border-radius: 1.1rem 0 0 1.1rem; background: var(--rail); color: #fff; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1.35rem; }
.access-brand h1 { font-size: clamp(2rem, 4.5vw, 3.5rem); line-height: 1.06; max-width: 12ch; }
.access-brand p { color: #d9ddf7; font-weight: 650; }
.access-panel { border: 1px solid var(--line); border-left: 0; border-radius: 0 1.1rem 1.1rem 0; background: var(--surface); display: grid; align-items: center; }
.access-panel form, .modal-content { display: grid; gap: 1rem; }
.access-alternative { color: var(--accent); text-decoration: underline; justify-self: start; }
label { display: grid; gap: .35rem; font-size: .9rem; font-weight: 650; }
input:not([type=checkbox]):not([type=radio]), select, textarea { min-width: 0; width: 100%; padding: .65rem .7rem; border: 1px solid #c9d2e3; border-radius: .5rem; color: var(--ink); background: var(--surface); }
textarea { resize: vertical; }
.error { color: #a42842; font-size: .9rem; }
.error:empty { display: none; }
.shell { display: grid; grid-template-columns: 205px minmax(0, 1fr); min-height: 100dvh; }
.rail { background: var(--rail); color: #fff; display: flex; flex-direction: column; padding: 1.25rem .9rem; gap: 2.3rem; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; white-space: nowrap; padding: 0 .2rem; }
.brand-mark { display: block; border-radius: .65rem; width: 2.5rem; height: 2.5rem; flex: 0 0 auto; }
.rail nav { display: grid; gap: .4rem; }
.rail nav button { display: flex; align-items: center; gap: .75rem; border: 0; color: #e3e7ff; background: transparent; border-radius: .55rem; padding: .74rem .7rem; text-align: left; font-weight: 630; }
.rail nav button[aria-current=true], .rail nav button:hover { background: #373e67; color: white; }
.nav-icon { display: inline-block; width: 1rem; height: .9rem; border: 1.5px solid currentColor; position: relative; }
.chat-icon { border-radius: .24rem; }
.chat-icon::after { content: ''; position: absolute; bottom: -.26rem; left: .2rem; width: .24rem; height: .25rem; border-left: 1.5px solid currentColor; background: inherit; }
.calendar-icon { border-radius: .15rem; }
.calendar-icon::after { content: ''; position: absolute; top: .17rem; left: 0; right: 0; border-top: 1.5px solid currentColor; }
.document-icon { width: .82rem; height: 1rem; margin-inline: .09rem; border-radius: .16rem; }
.document-icon::after { content: ''; position: absolute; top: .3rem; left: .13rem; right: .13rem; height: .16rem; border-block: 1px solid currentColor; }
.account { margin-top: auto; display: flex; gap: .6rem; align-items: center; overflow-wrap: anywhere; }
.account button { display: block; color: #d7dcff; font-size: .86rem; margin-top: .15rem; text-align: left; }
.account button:hover { text-decoration: underline; }
.account button[hidden] { display: none; }
.presence { --presence-dot: #81899d; display: inline-flex; align-items: center; gap: .32rem; color: var(--muted); font-size: .84rem; white-space: nowrap; }
.presence::before { content: ''; width: .52rem; height: .52rem; flex: 0 0 auto; border-radius: 50%; background: var(--presence-dot); }
.presence[data-state=online] { --presence-dot: #16965b; }
.presence[data-state=away] { --presence-dot: #c88412; }
.presence[data-state=dnd] { --presence-dot: #c84261; }
.account .presence { color: #e3e7ff; }
.contact-caption { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.avatar { min-width: 2.3rem; height: 2.3rem; border-radius: 50%; background: #e8e6fb; color: #46449a; display: inline-grid; place-items: center; font-size: .86rem; font-weight: 750; }
.account .avatar { background: #505886; color: #fff; }
.workspace { min-width: 0; display: grid; min-height: 100dvh; }
.chat-layout { display: grid; grid-template-columns: minmax(205px, 280px) minmax(0, 1fr); min-width: 0; }
.contacts { padding: 1.5rem 1rem; background: #f7f8fc; border-right: 1px solid var(--line); min-width: 0; }
.contacts h1 { padding: 0 .22rem; }
.contact-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.4rem; }
.contact-group + .contact-group { margin-top: 1.5rem; }
.contact-group h3 { margin: 0 0 .45rem .28rem; color: var(--muted); }
.contact { border: 0; background: transparent; color: var(--ink); text-align: left; width: 100%; padding: .5rem .4rem; border-radius: .55rem; display: flex; gap: .6rem; align-items: center; overflow-wrap: anywhere; }
.contact[aria-current=true], .contact:hover { background: var(--tint); }
.contact .avatar { min-width: 2rem; height: 2rem; }
.small-empty { color: var(--muted); font-size: .87rem; padding: .45rem .28rem; }
.thread { display: flex; flex-direction: column; min-width: 0; height: 100dvh; background: var(--surface); }
.thread-header, .calendar-header { border-bottom: 1px solid var(--line); padding: 1.2rem clamp(1rem, 3vw, 2rem); display: flex; gap: .8rem; align-items: center; justify-content: space-between; }
.thread-header > div, .calendar-header > div { min-width: 0; }
.thread-header h2, .thread-header p { overflow-wrap: anywhere; }
.thread-header p { font-size: .88rem; margin-top: .25rem; }
.message-list { flex: 1; min-height: 0; overflow: auto; padding: 1rem clamp(.8rem, 3vw, 2rem); }
.message { display: flex; gap: .55rem; margin: 0 0 1rem; align-items: flex-start; }
.message.mine { justify-content: flex-end; }
.message-content { max-width: min(83%, 42rem); min-width: 0; }
.message.mine .message-content { text-align: right; }
.message-meta { color: var(--muted); display: block; font-size: .8rem; padding: .1rem 0 .3rem; }
.message-text { display: inline-block; text-align: left; border-radius: .65rem; padding: .55rem .75rem; background: var(--soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .message-text { background: var(--tint); }
.chat-attachment { display: grid; gap: .5rem; padding: .55rem; border: 1px solid var(--line); border-radius: .65rem; text-align: left; }
.mine .chat-attachment { background: var(--tint); }
.chat-preview { display: block; max-width: 100%; max-height: min(50vh, 25rem); border-radius: .4rem; object-fit: contain; }
video.chat-preview { width: min(100%, 26rem); background: #202747; }
.chat-attachment-details { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.chat-attachment-details small { display: block; margin-top: .18rem; }
.older { display: block; margin: 0 auto 1rem; }
.compose { padding: 1rem clamp(.8rem, 3vw, 2rem); border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: end; }
.compose-actions { display: flex; gap: .45rem; }
.compose textarea { resize: none; min-height: 2.75rem; }
.empty { margin: auto; color: var(--muted); text-align: center; max-width: 28rem; padding: 2rem 1rem; }
.empty h2 { color: var(--ink); margin-bottom: .4rem; }
.calendar { min-width: 0; background: var(--soft); }
.calendar-header { background: var(--surface); flex-wrap: wrap; }
.calendar-header .muted { font-size: .88rem; margin-top: .25rem; }
.row-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.calendar-content { padding: clamp(.65rem, 2.5vw, 1.65rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 275px); gap: 1rem; align-items: start; }
.month, .agenda { border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); min-width: 0; overflow: hidden; }
.month-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem; }
.month-toolbar h2, .agenda-date { text-transform: capitalize; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday { text-align: center; padding: .55rem 0; font-size: .83rem; color: var(--muted); }
.day { display: flex; flex-direction: column; text-align: left; gap: .26rem; min-height: 5rem; align-items: stretch; color: var(--ink); padding: .32rem; border: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.day:nth-child(7n) { border-right: 0; }
.day:hover, .day[aria-pressed=true] { background: #f2f1fb; }
.day.other { color: var(--muted); background: #f9fafd; }
.day-number { display: grid; place-items: center; align-self: flex-start; min-width: 1.45rem; height: 1.45rem; font-size: .87rem; border-radius: 50%; }
.today .day-number { background: var(--accent); color: #fff; }
.day-event, .day-extra { border-radius: .25rem; font-size: .76rem; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.day-event { padding: .14rem .22rem; background: #e8e6fb; color: #323078; }
.day-extra { color: var(--muted); }
.agenda { padding: .9rem; }
.agenda-date { margin-bottom: .8rem; }
.agenda-items { display: grid; gap: .55rem; margin-bottom: .9rem; }
.agenda-items:empty { display: none; }
.event { width: 100%; text-align: left; border: 1px solid var(--line); border-left: 3px solid #6f68c1; background: #f9f9fd; color: var(--ink); border-radius: .45rem; padding: .55rem; overflow-wrap: anywhere; }
.event:hover { background: var(--tint); }
.event span, .event strong { display: block; }
.event span { font-size: .84rem; color: var(--muted); margin-top: .16rem; }
.calendars { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.calendar-row { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; margin-top: .5rem; overflow-wrap: anywhere; font-size: .88rem; }
.calendar-row button { color: var(--accent); text-decoration: underline; }
.document-pane { min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.document-heading { flex: 1; }
.document-header { flex-wrap: wrap; }
.document-list { padding: 0 clamp(.8rem, 3vw, 2rem); margin: .5rem 0; list-style: none; }
.document-list:empty { display: none; }
.document-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .78rem 0; border-bottom: 1px solid var(--line); }
.file-icon { display: grid; place-items: center; min-width: 2.75rem; height: 2.55rem; border-radius: .5rem; background: var(--tint); color: var(--accent); font-size: .72rem; font-weight: 750; }
.document-info { overflow-wrap: anywhere; }
.document-info p { font-size: .88rem; margin-top: .2rem; }
.document-download { display: inline-flex; align-items: center; text-decoration: none; }
.document-download:focus-visible { outline: 2px solid #655bd8; outline-offset: 3px; }
.document-remove { padding: .45rem .25rem; color: #a42842; }
.document-remove:hover { text-decoration: underline; }
.document-empty { margin-top: clamp(2rem, 7vw, 5rem); }
input[type=file] { font-size: .9rem; }
dialog { width: min(94vw, 530px); max-height: 90dvh; overflow: auto; border: 1px solid var(--line); border-radius: .9rem; padding: 1.2rem; color: var(--ink); box-shadow: 0 16px 60px #20274735; }
dialog::backdrop { background: #20274788; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .55rem; justify-content: flex-end; margin-top: 1rem; }
#modal .error { margin-top: .6rem; }
fieldset { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: .5rem; max-height: 13rem; overflow: auto; }
legend { font-weight: 650; }
.choice { display: flex; align-items: center; gap: .55rem; padding: .26rem 0; overflow-wrap: anywhere; }
.choice small { color: var(--muted); font-weight: 400; }
.event-notes { overflow-wrap: anywhere; white-space: pre-wrap; }
.notice { position: fixed; z-index: 2; bottom: 1rem; right: 1rem; max-width: min(90vw, 30rem); color: #fff; background: var(--rail); border-radius: .6rem; padding: .75rem 1rem; box-shadow: 0 6px 18px #20274735; }
.mobile-back, .mobile-profile, .mobile-inbox { display: none; }
@media (max-width: 1050px) {
  .calendar-content { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  :root { background: #0e1728; }
  .shell, dialog {
    color-scheme: dark;
    --ink: #f3f5ff;
    --muted: #adb9d4;
    --line: #2b3852;
    --surface: #131e32;
    --soft: #0e1728;
    --accent: #a8baff;
    --tint: #263657;
    --rail: #17243b;
    color: var(--ink);
    background: var(--soft);
  }
  .shell {
    --bottom-bar: calc(4.25rem + env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    padding-bottom: var(--bottom-bar);
  }
  .rail {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: calc(.42rem + env(safe-area-inset-top)) max(.9rem, env(safe-area-inset-right))
      .42rem max(.9rem, env(safe-area-inset-left));
    background: var(--soft);
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; gap: .55rem; font-size: .96rem; }
  .brand-mark { width: 2rem; height: 2rem; border-radius: .55rem; }
  .account { display: none; }
  .mobile-profile {
    position: relative; display: grid; place-items: center; width: 44px; height: 44px;
    border: 0; border-radius: 50%; background: transparent; padding: 0;
  }
  .rail nav {
    position: fixed; z-index: 2; inset: auto 0 0;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem;
    height: var(--bottom-bar); border-top: 1px solid var(--line); background: var(--rail);
    padding: .25rem max(.45rem, env(safe-area-inset-right)) calc(.25rem + env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left));
  }
  .rail nav button {
    flex-direction: column; justify-content: center; gap: .38rem; padding: .22rem;
    min-height: 44px; color: var(--muted); font-size: .73rem; text-align: center; border-radius: .7rem;
  }
  .rail nav button[aria-current=true] { color: #d8e2ff; background: #2a3e66; }
  .workspace { min-height: 0; overflow: auto; overscroll-behavior-y: contain; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .contacts { border: 0; background: var(--soft); }
  .chat-layout:not(.documents-layout) .contacts { padding: 0; }
  .desktop-contacts { display: none; }
  .mobile-inbox {
    display: block; padding: .85rem max(.9rem, env(safe-area-inset-right)) 5rem max(.9rem, env(safe-area-inset-left));
    background: linear-gradient(165deg, #1d2d4b, var(--soft) 12rem);
    min-height: 100%;
  }
  .mobile-inbox h1 { padding: 0; font-size: 2.1rem; line-height: 1.1; margin: 0 0 .75rem; }
  .inbox-search { position: relative; }
  .inbox-search::before, .inbox-search::after { content: ''; position: absolute; pointer-events: none; }
  .inbox-search::before { left: .89rem; top: .82rem; width: .68rem; height: .68rem; border: 2px solid var(--muted); border-radius: 50%; }
  .inbox-search::after { left: 1.56rem; top: 1.58rem; width: .4rem; height: 2px; background: var(--muted); transform: rotate(45deg); }
  .shell .inbox-search input[type=search] { padding: .65rem .8rem .65rem 2.5rem; min-height: 44px; border-radius: .8rem; }
  .inbox-search input::placeholder { color: var(--muted); }
  .inbox-filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: .62rem 0 .55rem; }
  .inbox-filter {
    background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: .7rem;
    padding: .3rem clamp(.45rem, 2vw, .75rem); min-height: 40px; font-size: .82rem; font-weight: 650;
  }
  .inbox-filter[aria-pressed=true] { background: #2a3e66; color: #e0e8ff; border-color: #576e9c; }
  .inbox-row {
    display: flex; gap: .7rem; align-items: center; width: 100%; min-height: 66px; padding: .56rem .18rem;
    text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--line);
  }
  .inbox-row:active { background: var(--tint); }
  .inbox-avatar { position: relative; display: grid; flex: 0 0 auto; }
  .inbox-avatar .avatar { width: 2.75rem; height: 2.75rem; background: #c6d5fb; color: #223966; }
  .group-avatar .avatar { border-radius: .82rem; background: #c1ece7; color: #173f47; }
  .mobile-profile .avatar { background: #b9cdfa; color: #213960; }
  .presence-marker {
    position: absolute; right: -.07rem; bottom: -.04rem; display: block; overflow: hidden;
    width: .92rem; height: .92rem; border: 2px solid var(--soft); border-radius: 50%;
    background: var(--presence-dot); font-size: 0;
  }
  .mobile-profile .presence-marker { right: .16rem; bottom: .13rem; }
  .presence-marker::before { display: none; }
  .presence[data-state=online] { --presence-dot: #5be2a1; }
  .presence[data-state=away] { --presence-dot: #ffd274; }
  .presence[data-state=dnd] { --presence-dot: #ff8195; }
  .inbox-info { display: grid; gap: .22rem; min-width: 0; flex: 1; }
  .inbox-row-heading { display: flex; gap: .55rem; justify-content: space-between; align-items: baseline; }
  .inbox-row-heading strong, .inbox-preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .inbox-row-heading strong { min-width: 0; font-size: .97rem; }
  .inbox-row-heading time, .inbox-preview, .inbox-empty { color: var(--muted); }
  .inbox-row-heading time { flex: 0 0 auto; font-size: .73rem; font-variant-numeric: tabular-nums; }
  .inbox-preview { font-size: .83rem; }
  .inbox-empty { padding: 1.1rem .25rem; }
  .inbox-create {
    position: fixed; z-index: 1; right: max(.9rem, env(safe-area-inset-right)); bottom: calc(var(--bottom-bar) + .75rem);
    display: flex; align-items: center; gap: .48rem; padding: 0 .9rem; min-height: 48px;
    color: #14274c; background: #b8ccff; border: 0; border-radius: .85rem; font-size: .87rem;
    font-weight: 750; box-shadow: 0 4px 20px #040810a0;
  }
  .inbox-create span { font-size: 1.45rem; line-height: 1; }
  .shell.chat-detail { grid-template-rows: minmax(0, 1fr); padding-bottom: 0; height: var(--thread-viewport, 100dvh); min-height: 0; }
  .chat-detail .rail { display: none; }
  body:has(.chat-detail:not([hidden])) { overscroll-behavior-x: none; }
  .chat-detail .workspace { overflow: hidden; grid-template-rows: minmax(0, 1fr); }
  .thread { display: none; height: 100%; min-height: 0; }
  .chat-layout.open:not(.documents-layout) { height: 100%; grid-template-rows: minmax(0, 1fr); }
  .chat-layout.open .thread { display: flex; }
  .chat-layout.open .contacts { display: none; }
  .mobile-back { display: grid; place-items: center; flex: 0 0 44px; height: 44px; padding: 0; font-size: 1.85rem; }
  .thread-header {
    padding: calc(.55rem + env(safe-area-inset-top)) max(.65rem, env(safe-area-inset-right))
      .55rem max(.65rem, env(safe-area-inset-left));
    justify-content: flex-start;
    background: var(--soft);
  }
  .thread-header h2 { font-size: 1.08rem; }
  .thread-header p { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .thread-header .manage { margin-left: auto; }
  .thread-header, .message-list { touch-action: pan-y pinch-zoom; }
  .message-list { background: var(--soft); }
  .message-text { background: var(--surface); }
  .compose {
    grid-template-columns: minmax(0, 1fr) auto; gap: .4rem;
    padding: .55rem max(.6rem, env(safe-area-inset-right)) calc(.55rem + env(safe-area-inset-bottom))
      max(.6rem, env(safe-area-inset-left));
  }
  .compose button { min-height: 44px; padding-inline: .58rem; }
  .compose textarea { font-size: 16px; }
  .day { min-height: 3rem; padding: .18rem; }
  .day:hover, .day[aria-pressed=true] { background: var(--tint); }
  .day.other { background: var(--soft); }
  .today .day-number, .primary, .primary:hover { color: #14274c; background: var(--accent); }
  .day-event, .event { color: var(--ink); background: var(--tint); }
  .document-remove, .error { color: #ffacba; }
  .access .error { color: #a42842; }
  .contact { min-height: 44px; }
  .documents-layout .document-pane { display: none; }
  .documents-layout.open .document-pane { display: flex; }
  .shell input:not([type=checkbox]):not([type=radio]), .shell textarea, dialog input:not([type=checkbox]):not([type=radio]),
  dialog select, dialog textarea { border-color: #485a79; font-size: 16px; }
  .choice { min-height: 44px; }
  .notice { bottom: calc(8.3rem + env(safe-area-inset-bottom)); }
}
@media (max-width: 570px) {
  .access { padding: .85rem; grid-template-columns: 1fr; }
  .access-brand { min-height: auto; border-radius: .9rem .9rem 0 0; gap: .6rem; }
  .access-brand h1 { max-width: 16ch; font-size: 2rem; }
  .access-panel { border-left: 1px solid var(--line); border-top: 0; border-radius: 0 0 .9rem .9rem; }
  .document-header > .row-actions { flex-basis: 100%; }
  .document-row { grid-template-columns: auto minmax(0, 1fr); }
  .document-row > .row-actions { grid-column: 2; }
}
