/* canvas · the frame: a rail of rooms, the room's column, the main column, the people in the room.
   Rooms are tiles of the logo's grid; the room the page is in is the lit one. Loaded after app.css. */

:root {
  --rail: #dfe4ec;
  --side: #eef1f5;
  --main: #ffffff;
  --members: #eef1f5;
  --panel: #e5e9f0;
  --tile: #ffffff;
  --hover: rgb(20 30 50 / 6%);
  --selected: rgb(20 30 50 / 10%);
  --glow: color-mix(in srgb, var(--lit) 40%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --rail: #0e131c;
    --side: #141a24;
    --main: #19202b;
    --members: #141a24;
    --panel: #10151e;
    --tile: #1f2734;
    --hover: rgb(255 255 255 / 5%);
    --selected: rgb(255 255 255 / 9%);
  }
}

/* The frame */
.frame { display: grid; grid-template-columns: 68px 248px minmax(0, 1fr) 248px; height: 100dvh; background: var(--main); }
.rail { background: var(--rail); overflow-y: auto; scrollbar-width: none; --ring: var(--rail); }
.side { background: var(--side); border-right: 1px solid var(--line); min-width: 0; --ring: var(--side); }
.main { background: var(--main); min-width: 0; min-height: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; --ring: var(--main); }
.main > * { flex: 1; min-height: 0; }
.members { background: var(--members); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; padding: 0 .75rem 1rem; --ring: var(--members); }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.side-toggle { display: none; }

/* Section labels: sentence case, quiet */
h3, .section-head h3, .column-head { text-transform: none; letter-spacing: 0; font-weight: 650; font-size: .8rem; color: var(--muted); }
.column-head { margin: 1.1rem .25rem .5rem; }
.plain { list-style: none; margin: 0; padding: 0; }

/* The rail: tiles, the room the page is in lit like the logo's centre cell */
.rail-inner { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .75rem 0 1rem; }
.rail-btn { position: relative; width: 48px; height: 48px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 15px; background: var(--tile); color: var(--text); font-weight: 700; font-size: .95rem; transition: border-radius .15s ease, background-color .15s ease, box-shadow .2s ease; }
.rail-btn:hover:not(:disabled) { border-radius: 12px; }
.rail-btn.room { --hue: 210; background: hsl(var(--hue) 40% 86%); color: hsl(var(--hue) 45% 22%); }
.rail-btn.room.emoji { font-size: 1.35rem; }
.rail-btn .logo { width: 26px; height: 26px; }
.rail-btn.on { border-radius: 12px; box-shadow: 0 0 0 2px var(--lit), 0 0 16px var(--glow); }
.rail-btn.add { color: var(--ok); font-size: 1.5rem; font-weight: 500; }
.rail-btn.add:hover { background: var(--ok); color: #fff; }
.rail-btn .pill { position: absolute; left: -10px; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0; background: var(--text); transform: translateY(-50%); transition: height .15s ease; }
.rail-btn:hover .pill { height: 18px; }
.rail-btn.in .pill { height: 8px; }
.rail-btn.on .pill { height: 34px; background: var(--lit); }
.rail-btn .hosting-dot { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 4px; background: var(--lit); box-shadow: 0 0 0 3px var(--ring); }
.rail-btn .count { position: absolute; right: -4px; bottom: -4px; box-shadow: 0 0 0 3px var(--ring); }
.rail-sep { width: 30px; height: 2px; border-radius: 1px; background: var(--line); flex: none; }
@media (prefers-color-scheme: dark) {
  .rail-btn.room { background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 70% 88%); }
}

.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1; }

/* The room's column */
.side-inner { display: flex; flex-direction: column; height: 100dvh; }
.side-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 .5rem .75rem; }
.room-head { display: grid; gap: .3rem; margin: 0 -.5rem .5rem; padding: .8rem 1rem .75rem; border-bottom: 1px solid var(--line); }
.room-title { display: flex; align-items: center; gap: .4rem; font-size: 1rem; }
.room-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem; }
.room-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .2rem; }
.room-actions button { padding: .2rem .6rem; font-size: .78rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: .9rem .45rem .25rem; }
.section-head h3 { margin: 0; }
.channel { display: flex; align-items: center; gap: .45rem; padding: .32rem .5rem; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: .9rem; }
.channel .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel:hover { background: var(--hover); color: var(--text); }
.channel.on { background: var(--selected); color: var(--text); font-weight: 600; }
.channel .hash { width: 1.15rem; flex: none; text-align: center; opacity: .75; }
.side .device { margin-top: .25rem; padding: .7rem; background: var(--main); }
.side .big-actions { gap: .4rem; }
.side .big { min-height: 0; padding: .5rem .55rem; }
.side .big-title { font-size: .86rem; }
.side .big-sub { font-size: .72rem; }
.side .cell { padding: 0 .45rem; }
.side .cell .section-head { margin-inline: 0; }
.side .preflight { margin: .25rem 0 .5rem; }

/* The person, at the column's foot */
.user-panel { display: grid; gap: .4rem; padding: .5rem .6rem; background: var(--panel); border-top: 1px solid var(--line); --ring: var(--panel); }
.user-panel .who { display: flex; align-items: center; gap: .55rem; }
.user-panel .who b, .user-panel .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lending { display: flex; align-items: center; gap: .45rem; padding: .35rem .5rem; border-radius: 8px; background: color-mix(in srgb, var(--lit) 14%, transparent); }
.live-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--lit); flex: none; box-shadow: 0 0 8px var(--glow); }

/* Faces and how people are */
.avatar.face { position: relative; width: 36px; height: 36px; font-size: .78rem; }
.status { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--ring, var(--main)); }
.status.online { background: var(--ok); }
.status.idle { background: var(--warn); }
.status.busy { background: var(--danger); }
.status.offline { background: color-mix(in srgb, var(--muted) 70%, transparent); }

/* Cards in the main column: reaching a room, joining it */
.center { display: grid; place-items: center; align-content: center; min-height: 100%; padding: 1.5rem; overflow-y: auto; }
.room-card { display: grid; gap: .6rem; justify-items: center; text-align: center; max-width: 440px; }
.room-card .logo { width: 40px; height: 40px; }
.notice { margin: 0; padding: .6rem .75rem; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: .88rem; }

/* The friends' page */
.home { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.main-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; min-height: 50px; padding: .5rem 1.25rem; border-bottom: 1px solid var(--line); }
.main-title { font-weight: 700; }
.main-tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.main-tabs .tab { flex: none; padding: .25rem .7rem; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: .88rem; }
.main-tabs .tab:hover { background: var(--hover); color: var(--text); }
.main-tabs .tab.on { background: var(--selected); color: var(--text); box-shadow: none; }
.main-tabs .tab.add { background: var(--ok); color: #fff; font-weight: 600; }
.main-tabs .tab.add.on { background: none; color: var(--ok); }
.home-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.5rem 2rem; }
.home-body > * { max-width: 760px; }
.friends h3, .invites h3, .add-friend h3, .my-link h3 { margin: .6rem 0 .5rem; }
.friend { display: flex; align-items: center; gap: .75rem; padding: .6rem .55rem; border-top: 1px solid var(--line); }
.friend:hover { background: var(--hover); border-radius: 10px; border-top-color: transparent; }
.friend:hover + .friend { border-top-color: transparent; }
.friend .activity { display: block; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend button.small { white-space: nowrap; }
.empty-friends { display: grid; gap: .6rem; justify-items: start; padding: 1rem 0; }
.invites { margin-bottom: 1rem; }
.invite { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; padding: .6rem .75rem; border: 1px solid color-mix(in srgb, var(--lit) 55%, var(--line)); border-radius: 12px; }
.add-friend { display: grid; gap: .75rem; }
.add-form { grid-template-columns: 1fr auto; align-items: end; }
.found { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .7rem .8rem; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); }
.my-link { display: grid; gap: .55rem; margin-top: .75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.my-link .row { align-items: center; }
.link-text { min-width: 0; padding: .4rem .55rem; border-radius: 7px; background: var(--raised); font: .8rem ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.words { font-size: 1.1rem; }
.you-are { margin-top: 2rem; }
.active-now { padding-top: .1rem; }
.active-card { display: grid; gap: .5rem; margin-bottom: .55rem; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--main); --ring: var(--main); }
.activity-room { display: flex; align-items: center; gap: .5rem; }
.activity-room small { display: block; }

/* The first visit */
.welcome.card { width: min(540px, 100%); margin: 6dvh auto; padding: 1.75rem; display: grid; gap: 1rem; }
.welcome h1 { font-size: 1.6rem; line-height: 1.2; }
details.bring summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
details.bring[open] summary { margin-bottom: .75rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatch { --hue: 210; width: 28px; height: 28px; padding: 0; border: 2px solid transparent; border-radius: 9px; background: hsl(var(--hue) 55% 48%); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.profile { padding: 1rem 1.1rem 1.2rem; display: grid; gap: .8rem; }
.code-box { display: grid; gap: .5rem; }

/* Making a room: presets */
.create { padding: 1rem 1.1rem 1.2rem; display: grid; gap: .9rem; }
.presets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: .6rem; }
.preset-card { position: relative; display: grid; align-content: start; gap: .25rem; padding: .8rem .85rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.preset-card:hover { border-color: var(--accent); }
.preset-card.on { border-color: var(--lit); box-shadow: 0 0 0 1px var(--lit) inset, 0 0 14px var(--glow); }
.preset-card.saved { border-style: dashed; }
.preset-card.saved.on { border-style: solid; }
.preset-icon { font-size: 1.6rem; line-height: 1.2; }
.preset-card .who { color: var(--accent); }
.preset-card .preview { color: var(--text); font-weight: 600; }
.preset-card .forget { position: absolute; top: .3rem; right: .3rem; }
.invite-sheet { padding: 1rem 1.1rem 1.2rem; display: grid; gap: .75rem; }

/* Narrower: the people's column goes; a phone: the room's column slides over */
@media (max-width: 1180px) {
  .frame { grid-template-columns: 68px 248px minmax(0, 1fr); }
  .members { display: none; }
}
@media (max-width: 760px) {
  .frame { grid-template-columns: 60px minmax(0, 1fr); }
  .rail-btn { width: 44px; height: 44px; }
  .side { display: none; position: fixed; z-index: 15; top: 0; bottom: 0; left: 60px; width: min(300px, calc(100vw - 60px)); box-shadow: var(--shadow); }
  .frame.side-open .side { display: block; }
  .side-toggle { display: grid; place-items: center; position: fixed; z-index: 16; top: .45rem; left: 64px; width: 36px; height: 36px; border-radius: 9px; background: var(--side); }
  .main-head, .chat-head { padding-left: 3.25rem; }
  .home-body { padding: .75rem 1rem 1.5rem; }
  .add-form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .rail-btn, .rail-btn .pill { transition: none; }
}

/* The chat's head: its title; the list of chats here only where the room's column is out of sight */
.chat-title { display: flex; align-items: center; gap: .4rem; font-weight: 650; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-title .hash { color: var(--muted); }
.chat-head .conversations { display: none; }
.channel.two .room-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.channel.two small { display: block; }
@media (max-width: 760px) {
  .chat-head .conversations { display: block; max-width: 45%; }
  .chat-title { display: none; }
}

/* Passing notices sit above the message box, never over it */
#toasts { bottom: 6.75rem; }

/* Notes between friends: a thread grouped as a chat app groups messages; the friend beside it */
.rail-btn.friend { border-radius: 50%; background: hsl(var(--hue) 55% 45%); color: #fff; }
.rail-btn.friend:hover { border-radius: 16px; }
.channel.dm { padding-block: .26rem; }
.channel.dm .avatar.face { width: 30px; height: 30px; font-size: .7rem; }
.channel.dm.unread { color: var(--text); font-weight: 650; }
.note-btn { position: relative; font-size: 1rem; }
.note-btn .count { position: absolute; right: -6px; top: -6px; box-shadow: 0 0 0 2px var(--main); }
.notes .chat-head-row { gap: .6rem; max-width: none; }
.note-title { min-width: 0; }
.note-title b { display: block; }
.note-title .activity { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-back { display: none; }
.note-lines { gap: 0; align-content: end; }
.note-intro { display: grid; gap: .35rem; justify-items: start; padding: 1rem .5rem 1.25rem; }
.note-intro .avatar.face { width: 68px; height: 68px; font-size: 1.4rem; }
.note-intro h2 { margin: .35rem 0 0; }
.note-intro p { max-width: 60ch; margin: 0; }
.day-line { display: flex; align-items: center; gap: .6rem; margin: 1rem auto .35rem; color: var(--muted); font-size: .74rem; font-weight: 650; }
.day-line::before, .day-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: .7rem; padding: .12rem .5rem; border-radius: 6px; }
.note:hover { background: var(--hover); }
.note.first { margin-top: .7rem; }
.note.first .avatar.face { width: 38px; height: 38px; margin-top: .15rem; }
.note-who { display: flex; align-items: baseline; gap: .5rem; }
.note-time { visibility: hidden; padding-top: .18rem; color: var(--muted); font-size: .66rem; text-align: right; }
.note.cont:hover .note-time { visibility: visible; }
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.notes .composer textarea { min-height: 2.75rem; }
.friend-profile { display: grid; gap: .2rem; justify-items: start; margin: 0 -.75rem; padding: 0 1rem 1rem; }
.friend-profile .banner { justify-self: stretch; height: 64px; margin: 0 -1rem; background: hsl(var(--hue) 45% 55%); }
.friend-profile > .avatar.face { width: 72px; height: 72px; margin-top: -36px; font-size: 1.4rem; box-shadow: 0 0 0 5px var(--members); --ring: var(--members); }
.friend-profile h2 { margin: .4rem 0 0; font-size: 1.15rem; }
.friend-profile p { margin: 0; }
.friend-profile .column-head { margin: .9rem 0 .25rem; }
.friend-profile .activity-room { margin-bottom: .35rem; }
@media (prefers-color-scheme: dark) {
  .friend-profile .banner { background: hsl(var(--hue) 35% 30%); }
}
@media (max-width: 760px) {
  .note-back { display: inline-grid; }
  .notes .chat-head { padding-left: 3.25rem; }
}

/* The members' column never scrolls sideways: long lines end in an ellipsis */
.members { overflow-x: hidden; }
.device-row .grow, .person-head .grow, .activity-room .grow { min-width: 0; }
.members .devices { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) {
  /* The room's column leaves a strip of the page beside it, and its button moves into that strip */
  .side { width: min(300px, calc(100vw - 60px - 3rem)); }
  .frame.side-open .side-toggle { left: calc(60px + min(300px, 100vw - 60px - 3rem) + .3rem); }
}
