:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --side: #0f2e2c;
  --side-text: #c9dbd8;
  --side-active: #1d4744;
  --text: #17201f;
  --muted: #66716f;
  --line: #e3e7e6;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f1;
  --danger: #b42318;
  --ok: #067647;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 8px 24px rgb(0 0 0 / .06);
  color-scheme: light;
}

/* Dark theme: follows the system unless the user picked Light or Dark in Settings */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1413;
    --panel: #161d1c;
    --side: #0a1110;
    --side-text: #a9bcb8;
    --side-active: #1b2c2a;
    --text: #e6ecea;
    --muted: #8b9896;
    --line: #26302e;
    --accent: #2bb3a5;
    --accent-ink: #04201d;
    --accent-soft: #15302d;
    --danger: #f97066;
    --ok: #47cd89;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1413;
  --panel: #161d1c;
  --side: #0a1110;
  --side-text: #a9bcb8;
  --side-active: #1b2c2a;
  --text: #e6ecea;
  --muted: #8b9896;
  --line: #26302e;
  --accent: #2bb3a5;
  --accent-ink: #04201d;
  --accent-soft: #15302d;
  --danger: #f97066;
  --ok: #47cd89;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

/* Custom accent colour (set from Settings → Appearance) */
:root[data-accent] {
  --accent: var(--accent-custom);
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent-custom) 14%, var(--panel));
  --side: color-mix(in srgb, var(--accent-custom) 22%, #0a1312);
  --side-active: color-mix(in srgb, var(--accent-custom) 40%, #0a1312);
}

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

html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ auth & unlock screens */
.screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 22px; margin: 12px 0 16px; letter-spacing: -.01em; }
.card p { margin: 0 0 16px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 11h14M9 16h10M9 21h7' stroke='white' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 100%;
}
.logo.lock {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Crect x='6' y='11' width='12' height='8' rx='2'/%3E%3Cpath d='M9 11V8.5a3 3 0 0 1 6 0V11'/%3E%3C/svg%3E");
}

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
form label .hint { font-weight: 400; color: var(--muted); }
form input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  font-size: 15px; font-weight: 400;
}
form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }

button.primary {
  width: 100%; border: 0; border-radius: 9px; padding: 11px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button.primary:disabled { opacity: .6; cursor: progress; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
#login-form .link { display: block; margin: 12px auto 0; }
.card > .link { display: block; margin: 10px auto 0; }

.status { min-height: 1.2em; margin: 14px 0 0 !important; font-size: 14px; color: var(--danger); }
.status.ok { color: var(--ok); }
.status:empty { margin: 0 !important; min-height: 0; }

/* ------------------------------------------------ chat layout */
#chat { display: grid; grid-template-columns: 250px 1fr; height: 100dvh; }

#sidebar {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; min-height: 0;
}
#sidebar header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 12px 18px;
}
#sidebar .brand { font-weight: 700; color: #fff; font-size: 17px; }
#sidebar .icon { color: var(--side-text); }
#sidebar .icon:hover { background: var(--side-active); color: #fff; }
#rooms { flex: 1; overflow-y: auto; padding: 4px 8px; }
.room {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; border-radius: 8px; padding: 7px 10px;
  color: inherit; text-align: left;
}
.room:hover { background: var(--side-active); }
.room.active { background: var(--side-active); color: #fff; font-weight: 600; }
.room .hash { opacity: .55; }
.room .rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room.unread { color: #fff; font-weight: 700; }
.room.unread::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5eead4; }
#sidebar footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid rgb(255 255 255 / .08);
}
#sidebar footer .me { display: flex; align-items: center; gap: 8px; min-width: 0; color: #fff; font-size: 14px; }
#sidebar footer .me span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sidebar footer .link { color: var(--side-text); white-space: nowrap; }

main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }

#room-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--line); min-height: 56px;
}
#room-header h2 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menu { display: none; }
.e2e {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 4px 9px; border-radius: 99px;
}
.e2e svg { width: 13px; height: 13px; }

.icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 9px; background: none; color: var(--muted);
}
.icon:hover { background: var(--bg); color: var(--text); }

/* ------------------------------------------------ messages */
#messages { flex: 1; overflow-y: auto; padding: 12px 0 8px; overscroll-behavior: contain; }
.empty, .older { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 14px; }
.older { padding: 8px; font-size: 12px; }

.day { display: flex; align-items: center; gap: 12px; margin: 18px 18px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.msg {
  position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 10px;
  padding: 6px 48px 2px 18px;
}
.msg.grouped { padding-top: 1px; }
.msg:hover { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.avatar {
  --h: 170;
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 55% 25%);
  font-weight: 700; font-size: 13px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 60% 82%); } }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 60% 82%); }
#sidebar .avatar { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
.avatar-space { width: 36px; }

.body { min-width: 0; }
.meta { display: flex; align-items: baseline; gap: 8px; }
.who { font-weight: 650; }
.meta time { color: var(--muted); font-size: 12px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }

.del {
  position: absolute; right: 14px; top: 4px; width: 26px; height: 26px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px;
  color: var(--muted); font-size: 16px; line-height: 1; opacity: 0;
}
.msg:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); }
@media (hover: none) { .del { opacity: .5; } }

.img {
  margin-top: 6px; max-width: 360px; border-radius: 10px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line);
}
.img img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.img.loading { min-height: 120px; background: linear-gradient(90deg, var(--bg), var(--line), var(--bg)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.img.loading img { opacity: 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.file {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; max-width: 100%;
  padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left;
}
.file:hover { border-color: var(--accent); }
.file.loading { opacity: .6; cursor: progress; }
.ficon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 800;
}
.fmeta { display: flex; flex-direction: column; min-width: 0; }
.fmeta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta small { color: var(--muted); }

.sending { margin: 6px 18px 6px 64px; font-size: 13px; color: var(--muted); }
.sending::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ composer */
#pending { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px; }
#pending:not(:empty) { padding-top: 8px; }
.chip {
  display: flex; align-items: center; gap: 8px; max-width: 240px;
  padding: 4px 4px 4px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13px;
}
.chip img, .chip .ficon { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; font-size: 9px; }
.chip .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; color: var(--muted); font-size: 18px; width: 26px; height: 26px; border-radius: 6px; }
.chip button:hover { background: var(--line); color: var(--text); }

#composer {
  display: flex; align-items: flex-end; gap: 6px;
  margin: 10px 16px calc(14px + env(safe-area-inset-bottom));
  padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
#composer:focus-within { border-color: var(--accent); }
#composer label.icon { margin: 0; cursor: pointer; }
#text {
  flex: 1; resize: none; border: 0; background: none; outline: none;
  padding: 8px 4px; max-height: 200px; line-height: 1.4; font-size: 15px;
}
.icon.send { background: var(--accent); color: var(--accent-ink); }
.icon.send:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }

#drop {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: color-mix(in srgb, var(--accent) 12%, transparent); backdrop-filter: blur(2px);
}
#drop div { padding: 18px 26px; border: 2px dashed var(--accent); border-radius: 14px; background: var(--panel); font-weight: 600; color: var(--accent); }

#lightbox {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgb(0 0 0 / .85); cursor: zoom-out;
}
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--panel); font-size: 14px; box-shadow: var(--shadow);
}

#scrim { display: none; }

/* ------------------------------------------------ phone */
@media (max-width: 760px) {
  #chat { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 82vw); z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / .4); }
  #menu { display: inline-grid; margin-left: -8px; }
  #room-header { padding: 8px 12px; }
  .e2e { font-size: 0; padding: 6px; gap: 0; }
  .msg { padding-left: 12px; padding-right: 40px; }
  .day { margin-left: 12px; margin-right: 12px; }
  #composer { margin-left: 10px; margin-right: 10px; }
  #pending { padding: 0 10px; }
  .img { max-width: 100%; }
}

/* ------------------------------------------------ sidebar sections & private chats */
#rooms .section {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: color-mix(in srgb, var(--side-text) 70%, transparent);
}
#rooms .section:first-child { margin-top: 2px; }
.friends-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgb(255 255 255 / .14); background: none; border-radius: 99px;
  padding: 2px 9px; font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--side-text);
}
.friends-btn:hover { background: var(--side-active); color: #fff; }
.badge {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 99px; background: #f97066; color: #fff; font-size: 10px; font-weight: 800;
}
.room.dm .avatar { width: 22px; height: 22px; font-size: 9px; border-radius: 6px; }
.hint-btn {
  display: block; width: calc(100% - 4px); margin: 2px; padding: 9px 10px; text-align: left;
  border: 1px dashed rgb(255 255 255 / .18); border-radius: 8px; background: none;
  color: var(--side-text); font-size: 13px;
}
.hint-btn:hover { background: var(--side-active); color: #fff; }

#menu { position: relative; }
#menu.dot::after {
  content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px;
  border-radius: 50%; background: #f97066; border: 2px solid var(--panel);
}

#room-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
#room-name > span:not(.avatar):not(.private) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#room-name .avatar { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
.private {
  flex: none; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px;
}

/* ------------------------------------------------ friends dialog */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgb(0 0 0 / .45);
}
.sheet {
  width: 100%; max-width: 460px; max-height: min(640px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 18px 10px; box-shadow: var(--shadow);
}
.sheet header { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet > p { margin: 6px 0 14px; font-size: 14px; }
#people-search {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); font-size: 15px; margin-bottom: 8px;
}
#people-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#people-list { overflow-y: auto; margin: 0 -8px; padding: 0 0 6px; }
.person { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; }
.person.incoming { background: var(--accent-soft); }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinfo strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinfo small { color: var(--muted); font-size: 12px; }
.pactions { display: flex; gap: 6px; flex: none; }
button.small {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 6px 11px; font-size: 13px; font-weight: 600;
}
button.small:hover { border-color: var(--accent); }
button.small.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.small.subtle { color: var(--muted); }
button.small.subtle:hover { color: var(--danger); border-color: var(--danger); }
.center { text-align: center; padding: 24px 8px; }

@media (max-width: 760px) {
  .modal { place-items: end center; padding: 0; }
  .sheet { max-width: none; border-radius: 16px 16px 0 0; max-height: 85dvh; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

.center-hint { text-align: center; margin: 12px 0 0 !important; font-size: 13px; color: var(--muted); }
.person.pending { background: color-mix(in srgb, #f59e0b 12%, transparent); }

/* ------------------------------------------------ emoji & GIF pickers */
.icon.on { background: var(--accent-soft); color: var(--accent); }
.gif-btn { font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.gif-btn::before { content: ""; }
#composer .gif-btn { border: 0; }
#composer .gif-btn { box-shadow: inset 0 0 0 1.6px currentColor; width: 30px; height: 22px; margin: 7px 3px; border-radius: 5px; }

.popover {
  position: absolute; z-index: 15; left: 16px; bottom: calc(76px + env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 8px;
}
.emoji-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.emoji-tabs button {
  flex: 1; border: 0; background: none; border-radius: 8px; padding: 5px 0; font-size: 18px; line-height: 1.2;
  filter: grayscale(.7); opacity: .75;
}
.emoji-tabs button:hover, .emoji-tabs button.active { background: var(--bg); filter: none; opacity: 1; }
.emoji-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 8px 4px 4px; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  max-height: 228px; overflow-y: auto;
}
.emoji-grid button {
  border: 0; background: none; border-radius: 8px; font-size: 24px; line-height: 1; height: 38px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-grid button:hover { background: var(--bg); transform: scale(1.12); }

.gif-pop { width: min(420px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 8px; }
.gif-pop input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); font-size: 15px;
}
.gif-pop input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.gif-grid {
  columns: 3 110px; column-gap: 6px; max-height: 320px; overflow-y: auto; min-height: 120px;
}
.gif-item {
  display: block; width: 100%; margin: 0 0 6px; padding: 0; border: 0; border-radius: 8px; overflow: hidden;
  background: var(--bg); break-inside: avoid; cursor: pointer;
}
.gif-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gif-item:hover { outline: 2px solid var(--accent); }
.gif-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; column-span: all; }
.gif-footer { font-size: 11px; font-weight: 700; color: var(--muted); text-align: right; letter-spacing: .02em; }

.text.jumbo { font-size: 40px; line-height: 1.15; }

/* ------------------------------------------------ calls */
.call-btn { color: var(--accent); }
.call-btn:hover { background: var(--accent-soft); color: var(--accent); }

#callbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 18px; background: var(--accent); color: var(--accent-ink);
}
#callbar .pulse { width: 10px; height: 10px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; } }
#call-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
#call-who .avatar { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; }
#call-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#call-status { flex: 1; font-variant-numeric: tabular-nums; opacity: .85; font-size: 14px; }
#callbar .icon { color: inherit; background: rgb(255 255 255 / .16); }
#callbar .icon:hover { background: rgb(255 255 255 / .28); }
#callbar .icon .slash { display: none; }
#callbar .icon.on { background: #fff; color: var(--accent); }
#callbar .icon.on .slash { display: inline; }
#callbar .hang, #callbar .hang:hover { background: #d92d20; color: #fff; }

.incoming-sheet { max-width: 340px; align-items: center; text-align: center; padding: 28px 24px 24px; }
#incoming-who { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#incoming-who .avatar { width: 72px; height: 72px; font-size: 24px; border-radius: 22px; margin-bottom: 8px; animation: ringing 1.2s ease-in-out infinite; }
#incoming-who strong { font-size: 19px; }
#incoming-who span { color: var(--muted); }
@keyframes ringing { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
.incoming-actions { display: flex; gap: 40px; margin-top: 26px; }
button.round {
  display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
button.round svg { width: 58px; height: 58px; padding: 16px; border-radius: 50%; color: #fff; stroke-width: 2.2; }
button.round.accept svg { background: #12b76a; }
button.round.decline svg { background: #d92d20; }
button.round:hover svg { filter: brightness(1.1); }

@media (max-width: 760px) {
  .popover { left: 10px; width: calc(100% - 20px); }
  .incoming-sheet { border-radius: 16px 16px 0 0; max-width: none; }
  #composer .icon { width: 32px; }
}

/* ------------------------------------------------ screen sharing */
#call-share.on { background: #fff; color: var(--accent); }
#screenview {
  position: relative; display: flex; flex-direction: column;
  flex: 0 1 62%; min-height: 200px; background: #0b0f0e; border-bottom: 1px solid var(--line);
}
#screenview:fullscreen { flex: 1; }
.sv-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px;
  color: #d5e2df; font-size: 13px; font-weight: 600;
}
.sv-bar span { flex: 1; }
.sv-bar .icon { color: #d5e2df; }
.sv-bar .icon:hover { background: rgb(255 255 255 / .1); color: #fff; }
#sv-video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }

/* ------------------------------------------------ status */
.avatar { position: relative; }
.sdot {
  position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--side); background: #98a2b3;
}
.person .sdot, #room-name .sdot, #group-list .sdot { border-color: var(--panel); }
.status-opt .sdot, .sdot.inline { position: static; display: inline-block; border: 0; width: 10px; height: 10px; flex: none; }
.s-available { background: #12b76a !important; }
.s-busy { background: #f04438 !important; }
.s-away { background: #f79009 !important; }
.s-dnd { background: #f04438 !important; box-shadow: inset 0 0 0 2.5px #f04438, inset 0 0 0 4px #fff; }
.s-offline { background: transparent !important; box-shadow: inset 0 0 0 2px #98a2b3; }
.room.dm .sdot { width: 9px; height: 9px; right: -3px; bottom: -3px; }

#sidebar footer { position: relative; }
.me {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  border: 0; background: none; color: #fff; text-align: left; padding: 4px 6px; margin: -4px -6px; border-radius: 9px;
}
.me:hover { background: var(--side-active); }
.me .avatar { width: 30px; height: 30px; font-size: 11px; border-radius: 8px; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text > span, .me-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text > span { font-size: 14px; font-weight: 600; }
.me-text small { font-size: 12px; color: var(--side-text); }

.status-pop {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); z-index: 30;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.status-opt {
  display: grid; grid-template-columns: 14px 1fr; align-items: center; column-gap: 10px; text-align: left;
  border: 0; background: none; border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 500;
}
.status-opt small { grid-column: 2; color: var(--muted); font-size: 12px; }
.status-opt:hover { background: var(--bg); }
.status-opt.on { background: var(--accent-soft); }
#status-form { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 4px 2px; }
#status-text { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 14px; }
#status-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.status-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }

/* header */
.htitle { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.htitle > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htitle small { font-size: 12px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members-btn {
  flex: none; border: 1px solid var(--line); background: none; border-radius: 99px; padding: 3px 10px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.members-btn:hover { border-color: var(--accent); color: var(--accent); }

/* groups in sidebar & header */
.gicon {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 6px;
  background: rgb(255 255 255 / .12); color: #fff; font-size: 9px; font-weight: 800;
}
#room-name .gicon { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; background: var(--accent-soft); color: var(--accent); }
.in-call { color: #5eead4; font-size: 10px; animation: pulse 1.6s infinite; }

/* join bar */
#joinbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 18px;
  background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--line); font-size: 14px;
}
#joinbar .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; flex: none; }
#joinbar .jtext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* call bar with several people */
.call-faces { display: inline-flex; gap: 4px; margin-left: 4px; }
.call-faces .avatar.connecting { opacity: .45; }
#call-who strong { margin-right: 2px; }

/* group dialog */
.glabel-input { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 10px; }
.glabel-input input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); font-size: 15px; font-weight: 400;
}
.glabel-input input:focus, #group-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#group-search {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); font-size: 15px; margin: 10px 0 8px;
}
#group-list { overflow-y: auto; margin: 0 -8px; min-height: 120px; }
.glabel { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 10px 8px 4px; }
.person.pick { cursor: pointer; }
.person.pick:hover { background: var(--bg); }
.person.pick.on { background: var(--accent-soft); }
.person.pick input { width: 18px; height: 18px; accent-color: var(--accent); }
.group-actions { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.group-actions .primary { margin-left: auto; }
.group-actions button:disabled { opacity: .5; cursor: default; }

/* small buttons never stretch like the login button */
button.small { width: auto; flex: none; white-space: nowrap; }

/* =====================================================================
   Profiles, friends, settings, admin, calendar & meetings
   ===================================================================== */

.clickable { cursor: pointer; }
.avatar.has-img { color: transparent; background-size: cover; background-position: center; }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; border-radius: 26px; }
.avatar.xl .sdot { width: 18px; height: 18px; right: -2px; bottom: -2px; border-width: 3px; border-color: var(--panel); }
.msg .who { cursor: pointer; }
.msg .who:hover { text-decoration: underline; }
.htitle.clickable:hover > span:first-child { text-decoration: underline; }

.badge-pill {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; vertical-align: 1px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.badge-pill.admin { background: color-mix(in srgb, #f59e0b 16%, var(--panel)); color: #b45309; border-color: transparent; }
.badge-pill.wait { background: color-mix(in srgb, #3b82f6 14%, var(--panel)); color: #1d4ed8; border-color: transparent; }
.badge-pill.blocked { background: color-mix(in srgb, #ef4444 14%, var(--panel)); color: #b91c1c; border-color: transparent; }
.badge-pill.tiny { font-size: 9.5px; padding: 0 5px; margin-left: 0; }
:root[data-theme="dark"] .badge-pill.admin { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge-pill.admin { color: #fbbf24; } }

button.small.danger, .link-btn.danger, .menu-pop .danger { color: var(--danger); }
button.small.danger:hover { border-color: var(--danger); }
.link-btn { border: 0; background: none; padding: 4px 6px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--text); }

/* chat header menu */
#room-header { position: relative; }
.menu-pop {
  position: absolute; right: 12px; top: calc(100% - 4px); z-index: 25; min-width: 230px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
  display: flex; flex-direction: column;
}
.menu-pop button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.menu-pop button:hover { background: var(--bg); }

/* moderation */
.del.mod { border-style: dashed; }
.blocked-msg { border: 1px dashed var(--line); background: none; border-radius: 8px; padding: 4px 10px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.blocked-msg:hover { color: var(--text); }

/* chat backgrounds: keep messages readable on pictures */
#messages.bg-image .msg .body, #messages.bg-tinted.bg-image .msg .body {
  background: color-mix(in srgb, var(--panel) 86%, transparent); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 6px 12px 8px; width: fit-content; max-width: 100%;
}
#messages.bg-image .msg.grouped .body { padding-top: 6px; }
#messages.bg-image .day span, #messages.bg-tinted .day span { background: var(--panel); padding: 2px 10px; border-radius: 99px; }
#messages.bg-image .msg:hover, #messages.bg-tinted .msg:hover { background: transparent; }

/* sidebar: calendar link & favorites */
.room.cal-link { margin-bottom: 4px; }
.cal-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.cal-ico svg { width: 18px; height: 18px; }
.room.cal-link .rname { display: flex; flex-direction: column; line-height: 1.25; }
.room.cal-link small { font-size: 11px; font-weight: 500; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .badge { margin-left: auto; }

/* ------------------------------------------------ friends sheet */
.people-sheet { max-width: 560px; }
.ptabs { display: flex; gap: 4px; overflow-x: auto; margin: 12px 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.ptabs button {
  flex: none; border: 1px solid var(--line); background: none; border-radius: 99px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
}
.ptabs button:hover { color: var(--text); }
.ptabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ptabs .tcount { font-size: 11px; background: color-mix(in srgb, currentColor 16%, transparent); border-radius: 99px; padding: 0 6px; }
.ptabs button.alert:not(.on) .tcount { background: #f04438; color: #fff; }
.person.clickable:hover { background: var(--bg); }
.pactions.quick { gap: 2px; }
.qa {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: none; color: var(--muted);
}
.qa svg { width: 18px; height: 18px; }
.qa:hover { background: var(--accent-soft); color: var(--accent); }
.qa.on { color: #f59e0b; }
.qa.on svg { fill: #f59e0b; }
.fav-mark { color: #f59e0b; margin-left: 5px; font-size: 13px; }

/* ------------------------------------------------ profile card */
.profile-sheet { max-width: 380px; padding: 0 0 16px; overflow: hidden; position: relative; }
.pc-cover { height: 84px; background: linear-gradient(135deg, hsl(var(--h) 55% 55%), hsl(calc(var(--h) + 40) 60% 45%)); }
.pc-close { position: absolute; top: 8px; right: 8px; color: #fff; background: rgb(0 0 0 / .2); }
.pc-close:hover { background: rgb(0 0 0 / .35); color: #fff; }
.pc-main { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 22px; margin-top: -46px; }
.pc-main .avatar.xl { border: 4px solid var(--panel); box-sizing: content-box; }
.pc-main h2 { margin: 10px 0 2px; font-size: 20px; }
.pc-handle { color: var(--muted); font-size: 13px; }
.pc-status { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 14px; }
.pc-about { margin: 12px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 18px 16px 6px; }
.pc-act {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 72px; padding: 10px 8px 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 12px; font-weight: 600; color: var(--text);
}
.pc-act svg { width: 20px; height: 20px; color: var(--accent); }
.pc-act:hover { border-color: var(--accent); background: var(--accent-soft); }
.pc-act.on svg { fill: #f59e0b; color: #f59e0b; }
.pc-more { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------ settings */
.settings-sheet { max-width: 620px; max-height: min(760px, 100%); }
#settings-body { overflow-y: auto; margin: 0 -18px; padding: 0 18px 8px; }
.set-pane { display: flex; flex-direction: column; gap: 10px; }
.set-section { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 18px; }
.set-section.first { margin-top: 4px; }
.small-note { font-size: 13px; margin: 0; }
.avatar-edit { display: flex; align-items: center; gap: 18px; }
.avatar-edit > div { display: flex; flex-direction: column; gap: 2px; }
.avatar-edit strong { font-size: 17px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.btn-row.end { justify-content: flex-end; margin-top: 0; }
label.as-btn { display: inline-flex; align-items: center; cursor: pointer; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; margin: 0; }
.field > span { display: flex; justify-content: space-between; align-items: baseline; }
.field input, .field select, .field textarea, .pw-row input, .set-pane > input[type=search], #md-search, #md-group {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  font: inherit; font-size: 15px; font-weight: 400; color: var(--text);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus, .pw-row input:focus, .set-pane > input[type=search]:focus, #md-search:focus, #md-group:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
.counter { font-weight: 400; }
.pw-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-row input { flex: 1 1 180px; width: auto; }

.seg { display: inline-flex; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; gap: 2px; width: fit-content; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--c);
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px transparent; transition: box-shadow .15s;
}
.swatch:hover { transform: scale(1.06); }
.swatch.on { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c); }

.bg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.bg-tile {
  position: relative; height: 68px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: flex-end; padding: 6px; cursor: pointer; overflow: hidden;
}
.bg-tile span { font-size: 11px; font-weight: 700; background: var(--panel); color: var(--text); padding: 1px 7px; border-radius: 99px; }
.bg-tile.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.bg-tile.own { border-style: dashed; justify-content: center; align-items: center; }
.dim-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.dim-row input { flex: 1; accent-color: var(--accent); min-width: 140px; }

.admin-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.admin-row:first-child { border-top: 0; }
.admin-row .pinfo { min-width: 140px; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.admin-actions .small { padding: 5px 9px; font-size: 12px; }
.gicon.solid { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* ------------------------------------------------ calendar mode */
#calview { display: none; }
body.cal-mode #calview { display: flex; flex-direction: column; flex: 1; min-height: 0; }
body.cal-mode #room-header, body.cal-mode #joinbar, body.cal-mode #messages,
body.cal-mode #pending, body.cal-mode #composer, body.cal-mode .popover { display: none !important; }

.cal-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); min-height: 56px;
}
.cal-head h2 { margin: 0; font-size: 17px; }
.cal-menu { display: none; }
.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-label { font-weight: 700; font-size: 15px; flex: 1; min-width: 120px; }
.cal-head .seg { margin-left: auto; }
.cal-body { flex: 1; min-height: 0; display: flex; }
.cal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.cal-side { width: 280px; flex: none; border-left: 1px solid var(--line); padding: 6px 14px 14px; overflow-y: auto; }
.cal-side .glabel { margin: 14px 0 6px; }
.side-empty { font-size: 13px; margin: 0; }
.invite-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.invite-card strong { cursor: pointer; }
.invite-card small { color: var(--muted); font-size: 12px; }
.next-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left;
  padding: 7px 8px; border-radius: 9px; margin: 0 -8px; width: calc(100% + 16px);
}
.next-item:hover { background: var(--bg); }
.nx-time { display: flex; flex-direction: column; width: 56px; flex: none; }
.nx-time small { font-size: 11px; color: var(--muted); }
.nx-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.live { font-size: 10px; font-weight: 800; color: #fff; background: #12b76a; border-radius: 99px; padding: 1px 7px; }

/* response colours */
.r-organizer, .r-accepted { --rc: var(--accent); }
.r-tentative { --rc: #f79009; }
.r-pending { --rc: #6172f3; }
.r-declined { --rc: #98a2b3; }

.rpill { flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: var(--rc); background: color-mix(in srgb, var(--rc) 13%, var(--panel)); white-space: nowrap; }

.rsvp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rsvp > span { font-size: 14px; font-weight: 600; margin-right: 4px; }
.rsvp-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.rsvp.mini { margin-top: 6px; }
.rsvp.mini .rsvp-btn { padding: 4px 9px; font-size: 12px; }
.rsvp-btn:hover { border-color: var(--accent); }
.rsvp-btn.on.v-accepted { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rsvp-btn.on.v-tentative { background: #f79009; border-color: #f79009; color: #fff; }
.rsvp-btn.on.v-declined { background: #667085; border-color: #667085; color: #fff; }

/* month */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(6, minmax(96px, 1fr)); flex: 1; min-height: 600px; }
.mhead { padding: 8px 10px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.mday {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; min-width: 0;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; overflow: hidden;
}
.mday:nth-child(7n) { border-right: 0; }
.mday:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.mday.other { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.mday.other .dnum { color: var(--muted); opacity: .6; }
.dnum { font-size: 12px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 2px; }
.mday.today .dnum { background: var(--accent); color: var(--accent-ink); }
.mchip {
  display: flex; gap: 5px; align-items: baseline; width: 100%; min-width: 0; text-align: left; border: 0;
  padding: 2px 6px; border-radius: 6px; font-size: 12px; line-height: 1.35;
  background: color-mix(in srgb, var(--rc) 14%, var(--panel)); color: var(--text); border-left: 3px solid var(--rc);
}
.mchip:hover { background: color-mix(in srgb, var(--rc) 24%, var(--panel)); }
.mchip.r-pending { background: var(--panel); border: 1px dashed var(--rc); border-left-width: 3px; border-left-style: solid; }
.mchip.r-declined .mtitle { text-decoration: line-through; opacity: .7; }
.mtime { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; color: color-mix(in srgb, var(--rc) 75%, var(--text)); }
.mtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { border: 0; background: none; font-size: 11px; font-weight: 700; color: var(--muted); text-align: left; padding: 0 6px; }
.more:hover { color: var(--accent); }
.mday .dots { display: none; }

/* week */
.week { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wk-head { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.wk-dayhead { padding: 6px 4px; text-align: center; display: flex; flex-direction: column; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.wk-dayhead strong { font-size: 18px; color: var(--text); letter-spacing: 0; }
.wk-dayhead.today strong { color: var(--accent); }
.wk-scroll { flex: 1; overflow-y: auto; min-height: 400px; }
.wk-grid { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.wk-gutter { min-width: 0; }
.wk-hour { font-size: 10.5px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.wk-col {
  position: relative; border-left: 1px solid var(--line); cursor: pointer;
  background: repeating-linear-gradient(to bottom, transparent 0 47px, var(--line) 47px 48px);
}
.wk-col.today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.wk-ev {
  position: absolute; display: flex; flex-direction: column; align-items: flex-start; gap: 0; overflow: hidden;
  border: 0; border-left: 3px solid var(--rc); border-radius: 6px; padding: 3px 6px; text-align: left; font-size: 12px;
  background: color-mix(in srgb, var(--rc) 18%, var(--panel)); color: var(--text); z-index: 1;
}
.wk-ev:hover { z-index: 2; box-shadow: var(--shadow); }
.wk-ev strong { font-size: 12px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.wk-ev span { font-size: 11px; color: var(--muted); }
.wk-ev.r-pending { background: var(--panel); outline: 1px dashed var(--rc); }
.wk-ev.r-declined strong { text-decoration: line-through; opacity: .7; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #f04438; z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #f04438; }

/* agenda */
.agenda { padding: 8px 18px 24px; max-width: 860px; }
.agenda-day { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.agenda-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--rc);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; background: var(--panel);
}
.agenda-row:hover { box-shadow: var(--shadow); }
.agenda-time { display: flex; flex-direction: column; width: 52px; flex: none; font-variant-numeric: tabular-nums; }
.agenda-time span { font-size: 12px; color: var(--muted); }
.agenda-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agenda-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-main small { color: var(--muted); font-size: 12px; }
.faces { display: flex; }
.faces .avatar { width: 26px; height: 26px; font-size: 10px; border-radius: 50%; border: 2px solid var(--panel); margin-left: -8px; }
.cal-empty { padding: 60px 20px; text-align: center; color: var(--muted); }

/* meeting banner */
#meetbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px;
  background: color-mix(in srgb, #6172f3 12%, var(--panel)); border-bottom: 1px solid var(--line); font-size: 14px;
}
#meetbar .ico { width: 18px; height: 18px; color: #6172f3; flex: none; }
#meetbar .jtext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* meeting dialogs */
.meeting-sheet { max-width: 560px; max-height: min(780px, 100%); overflow-y: auto; }
#md-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 140px; }
.field-row.tight > * { flex: 1 1 180px; width: auto; }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 3px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.pchip .avatar { width: 22px; height: 22px; font-size: 9px; border-radius: 50%; }
.pchip button { border: 0; background: none; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); font-size: 15px; line-height: 1; }
.pchip button:hover { background: var(--line); color: var(--text); }
.pchip.me { padding-right: 10px; background: var(--accent-soft); border-color: transparent; }
.pchip.r-accepted { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.pchip.r-declined { opacity: .6; }
#md-results { border: 1px solid var(--line); border-radius: 10px; max-height: 240px; overflow-y: auto; }
#md-results:empty { display: none; }
#md-results .person { width: 100%; border: 0; background: none; text-align: left; border-radius: 0; }
#md-results .add { font-size: 12px; font-weight: 700; color: var(--accent); }
.small-pad { padding: 12px; }

#mv-body { display: flex; flex-direction: column; gap: 14px; }
#mv-body header h2 { font-size: 20px; overflow-wrap: anywhere; }
.mv-when, .mv-org { display: flex; align-items: center; gap: 12px; }
.mv-when .ico { width: 22px; height: 22px; color: var(--accent); flex: none; }
.mv-when div, .mv-org span { display: flex; flex-direction: column; }
.mv-when small, .mv-org small { color: var(--muted); font-size: 12px; }
.mv-org { cursor: pointer; }
.mv-desc { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.join-big { display: flex; align-items: center; justify-content: center; gap: 10px; }
.join-big .ico { width: 18px; height: 18px; }
.mv-people { display: flex; flex-direction: column; margin: -6px -8px 0; }
.mv-people .person { cursor: pointer; }
.mv-people .person:hover { background: var(--bg); }
#mv-body .group-actions { flex-wrap: wrap; }
#mv-body .group-actions .small:first-child { margin-right: auto; }
#mv-body .group-actions .primary { margin-left: 0; }

svg.ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ phone */
@media (max-width: 760px) {
  .cal-menu { display: inline-grid; margin-left: -8px; }
  .cal-head { padding: 8px 12px; gap: 8px; }
  .cal-head .seg { margin-left: 0; order: 5; }
  .cal-head > .small.primary { order: 6; margin-left: auto; }
  .cal-side { display: none; }
  .month { grid-template-rows: auto repeat(6, minmax(58px, 1fr)); min-height: 420px; }
  .mday .mchip, .mday .more { display: none; }
  .mday .dots { display: flex; gap: 3px; flex-wrap: wrap; padding: 0 2px; }
  .mday .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--rc); }
  .wk-scroll, .wk-head { min-width: 640px; }
  .week { overflow-x: auto; }
  .agenda { padding: 4px 12px 24px; }
  .agenda-row { gap: 10px; }
  .agenda-row .faces { display: none; }
  .menu-pop { right: 8px; left: 8px; }
  .settings-sheet, .meeting-sheet, .people-sheet { max-height: 92dvh; }
  .admin-actions { margin-left: 0; }
  #meetbar .small:not(.primary) { display: none; }
}
.wk-ev { justify-content: flex-start; }
.wk-ev.short { padding: 2px 6px; justify-content: center; }
.wk-ev.short strong { font-weight: 600; }
.wk-ev.short .t { font-weight: 800; color: color-mix(in srgb, var(--rc) 75%, var(--text)); }
.pchip { white-space: nowrap; }
label.as-btn.small {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; padding: 6px 11px; font-size: 13px; font-weight: 600;
}
label.as-btn.small:hover { filter: brightness(1.08); }
.admin-row .pinfo { flex: 1 1 200px; }
.admin-row .pinfo strong { white-space: normal; overflow: visible; }
