/* Messages with parents: a conversation, the same on both sides.

   The reader's own messages sit on the right in the page's colour (the
   colour a family picked, or the team's navy); the other side's on the
   left, white. A line between days, "Seen" under the newest one read, and
   the box to write in stuck to the bottom of the screen.

   Works with the parents' pages (play.css, with blue.css for Modern) and
   the team area (base.css and admin.css): each sets its own colours. */

.chatwrap {
  --chat-mine: var(--acc, var(--dark, #1B2437));
  --chat-on-mine: var(--on-acc, var(--on-dark, #fff));
  --chat-theirs: var(--card, #fff);
  --chat-under: var(--app, #fff);
  --chat-edge: var(--line, #E8EAEE);
  --chat-soft: var(--muted, #878B96);
  max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 230px);
}
/* Modern: the page itself is the grey, with white cards on it. */
.pz--blue .chatwrap { --chat-under: var(--page, #F2F4F8); }
/* The team area: a white card for theirs on the grey page. */
.chatwrap--team {
  --chat-mine: var(--fill, #1B2437);
  --chat-on-mine: var(--on-fill, #fff);
  --chat-theirs: var(--surface, #fff);
  --chat-under: var(--bg, #F2F4F8);
  max-width: 820px; margin: 0;
  min-height: calc(100vh - 170px);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ header */

.chathead {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 22px;
  background: var(--card, var(--surface, #fff)); border: 1px solid var(--chat-edge);
}
.chathead__face {
  width: 46px; height: 46px; flex: none; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: var(--acc-pale, var(--sky, #EDF2FF)); color: var(--acc-ink, var(--ink));
}
.chathead__face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chathead__text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.chathead__text b { font-size: 16.5px; font-weight: 700; line-height: 1.25; }
.chathead__text em { font-style: normal; color: var(--chat-soft); font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.chathead__all {
  flex: none; padding: 7px 14px; border-radius: 999px; text-decoration: none; color: inherit;
  background: var(--chat-theirs); font-weight: 700; font-size: 14px;
}
/* Modern (Poppins) reads heavier at the same weight: one step lighter. */
.pz--blue .chathead__text b { font-weight: 600; }
.pz--blue .chathead__text em, .pz--blue .chat__intro, .pz--blue .composer__note,
.pz--blue .joincard__small { font-weight: 400; }
.pz--blue .chat__day span, .pz--blue .chat__who, .pz--blue .chat__seen, .pz--blue .bubble__time,
.pz--blue .chatnote, .pz--blue .chathead__all, .pz--blue .joinform__label { font-weight: 500; }
.pz--blue .chat__intro b, .pz--blue .chatnote__btn, .pz--blue .joinbtn { font-weight: 600; }

.chatnote {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 10px 12px 10px 16px; border-radius: 18px;
  background: var(--butter, var(--amber-pale, #FFF4C8)); font-size: 14.5px; font-weight: 600;
}
.chatnote span { flex: 1; min-width: 180px; }
.chatnote__btn {
  border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer;
  background: var(--ink); color: var(--card, #fff); font: inherit; font-size: 14px; font-weight: 700;
}

/* -------------------------------------------------------------- talk */

.chat { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 14px 0 12px; }
.chat__intro {
  align-self: center; max-width: 440px; margin: 4px auto 14px; text-align: center;
  display: grid; justify-items: center; gap: 6px;
  color: var(--chat-soft); font-size: 13.5px; font-weight: 600; line-height: 1.45;
}
.chat__intro b { color: var(--ink); font-size: 15px; }
.chat__intro a { text-decoration: underline; text-underline-offset: 2px; }
.chat__intro form { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.chat__lock {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--chat-theirs); color: var(--chat-soft);
}
.chat__unlink {
  border: 0; padding: 0; background: none; cursor: pointer; color: inherit;
  font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.chat__day { text-align: center; margin: 14px 0 6px; }
.chat__day span {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  background: var(--chat-theirs); border: 1px solid var(--chat-edge); color: var(--chat-soft); font-size: 12.5px; font-weight: 700;
}
.chat__who { margin: 8px 0 1px 14px; color: var(--chat-soft); font-size: 12.5px; font-weight: 700; }
.chat__seen { align-self: flex-end; margin: 1px 8px 4px; color: var(--chat-soft); font-size: 12px; font-weight: 600; }

.bubble {
  position: relative; max-width: min(78%, 520px);
  padding: 8px 13px 6px; border-radius: 20px;
  font-size: 16px; line-height: 1.45; overflow-wrap: anywhere;
}
.bubble--theirs {
  align-self: flex-start; background: var(--chat-theirs); color: var(--ink);
  border: 1px solid var(--chat-edge); border-bottom-left-radius: 6px;
}
.bubble--mine {
  align-self: flex-end; background: var(--chat-mine); color: var(--chat-on-mine);
  border-bottom-right-radius: 6px;
}
.bubble--mine + .bubble--theirs, .bubble--theirs + .bubble--mine,
.chat__seen + .bubble--theirs, .chat__who + .bubble { margin-top: 6px; }
.chat__who + .bubble { margin-top: 0; }
.bubble__text { margin: 0; white-space: pre-line; }
.bubble__time { display: block; margin-top: 1px; text-align: right; font-size: 11.5px; font-weight: 600; opacity: .72; }
.bubble--theirs .bubble__time { color: var(--chat-soft); opacity: 1; }
.bubble__photo {
  display: block; width: 250px; max-width: 100%; aspect-ratio: 4 / 3;
  margin: -2px -7px 6px; border-radius: 15px; overflow: hidden;
  background: var(--chat-edge); cursor: zoom-in;
}
.bubble__photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------- writing */

.composer {
  position: sticky; bottom: 0; z-index: 5;
  padding: 10px 0 12px;
  background: linear-gradient(to top, var(--chat-under) 78%, transparent);
}
.composer__note {
  display: flex; align-items: flex-start; gap: 6px; margin: 0 4px 8px;
  color: var(--chat-soft); font-size: 13px; font-weight: 600; line-height: 1.4;
}
.composer__note .icon { flex: none; margin-top: 2px; }
.composer__note a { text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
.composer__photo, .composer__send {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; border: 0; cursor: pointer; padding: 0;
}
.composer__photo {
  position: relative; background: var(--card, var(--surface, #fff)); color: var(--ink);
  border: 1px solid var(--chat-edge);
}
.composer__photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.composer__send { background: var(--chat-mine); color: var(--chat-on-mine); transition: opacity .15s; }
.composer__send:disabled { opacity: .35; cursor: default; }
.composer.is-sending .composer__send { opacity: .6; }
.composer__box {
  flex: 1; min-width: 0; display: flex;
  background: var(--card, var(--surface, #fff)); border: 1px solid var(--chat-edge);
  border-radius: 23px; padding: 0 16px;
}
.composer__box:focus-within { border-color: var(--chat-mine); }
.composer textarea {
  flex: 1; width: 100%; min-height: 44px; max-height: 160px; margin: 0; padding: 11px 0;
  border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.4; box-shadow: none;
}
.composer textarea::placeholder { color: var(--chat-soft); }
.composer__chip {
  position: relative; width: 72px; height: 72px; margin: 0 0 8px 54px;
  border-radius: 14px; overflow: hidden; background: var(--chat-edge);
}
.composer__chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.composer__unchip {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; border: 0;
  border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff;
}
.composer__error { margin: 8px 0 0 54px; color: var(--alert-ink, var(--coral-ink, #C2451F)); font-size: 14px; font-weight: 700; }

/* --------------------------------------------------- a photo, big */

.chatview {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: rgba(8, 10, 14, .94);
}
.chatview[open] { display: grid; place-items: center; }
.chatview::backdrop { background: rgba(8, 10, 14, .94); }
.chatview img { max-width: 96vw; max-height: 88vh; object-fit: contain; border-radius: 8px; }
.chatview__close {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px;
  width: 44px; height: 44px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(255, 255, 255, .16); color: #fff;
}

/* ------------------------------------------------- linking a phone */

.joinwrap { display: grid; gap: 16px; max-width: 560px; margin: 8px auto 0; }
.joincard {
  padding: 26px 26px 24px; border-radius: var(--r-lg, 24px);
  background: var(--card, #fff); box-shadow: var(--shadow-sm, none); border: 1px solid var(--line);
  display: grid; gap: 12px;
}
.joincard h1 { font-size: 24px; line-height: 1.2; }
.joincard h2 { font-size: 18px; }
.joincard__icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--acc-pale, var(--sky)); color: var(--acc-ink, var(--sky-2));
}
.joincard__lead { font-size: 15.5px; line-height: 1.5; color: var(--ink-soft); }
.joincard__small { color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.45; }
.joincode {
  margin: 4px 0; padding: 14px; border-radius: 16px; text-align: center;
  background: var(--panel); font-size: 30px; font-weight: 700; letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
}
.joinerror {
  padding: 12px 14px; border-radius: 14px; background: var(--alert-pale, #FDEDE8);
  color: var(--alert-ink, #C2451F); font-weight: 700; font-size: 15px; line-height: 1.45;
}
.joinform { display: grid; gap: 8px; }
.joinform__label { font-weight: 700; font-size: 14px; }
.joinform input {
  width: 100%; padding: 14px 16px; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 22px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; text-align: center;
}
.joinform input:focus { outline: 0; border-color: var(--acc, var(--ink)); }
.joinform input::placeholder { color: var(--line-strong, #C9CDD6); letter-spacing: .1em; }
.joinbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--acc, var(--dark)); color: var(--on-acc, var(--on-dark));
  font: inherit; font-size: 16px; font-weight: 700; width: 100%;
}
.joinbtn--soft { background: var(--panel); color: var(--ink); }
.joincard--links h1 { margin-bottom: 2px; }
.chip--count {
  min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--acc, var(--dark)); color: var(--on-acc, var(--on-dark));
}

/* ------------------------------------------------------------- phone */

@media (max-width: 760px) {
  .chatwrap, .pz--blue .chatwrap { --chat-under: var(--page, #EEF0F3); min-height: calc(100dvh - 76px); }
  .app.app--chat { padding-bottom: 0; }
  .app--chat .hello { display: none; }
  .chathead { margin-top: 4px; }
  .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .bubble { max-width: 82%; }
  .chatview img { max-width: 100vw; border-radius: 0; }
  .joincard { padding: 22px 18px 20px; }
  .joincard h1 { font-size: 22px; }
}

/* ============================================================ the team */

.chathead--team { gap: 10px; padding: 10px 14px 10px 8px; background: var(--surface); }
.chathead__back {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-soft);
}
.chathead__back:hover { background: var(--bg); }
.chathead__face--initial, .talk__face {
  background: var(--blue-pale); color: var(--blue-ink); font-weight: 600; font-size: 17px;
}
.chathead--team .chathead__text b { font-weight: 600; font-size: 16px; }
.chathead--team .chathead__text em { font-weight: 400; font-size: 13px; }
.chatwrap--team .chathead__all { background: var(--bg); color: var(--ink-soft); font-weight: 500; font-size: 13px; }
.chatwrap--team .chatnote { background: var(--amber-pale); color: var(--amber-ink); font-weight: 500; font-size: 13.5px; }
.chatwrap--team .chat__intro, .chatwrap--team .chat__day span, .chatwrap--team .chat__who,
.chatwrap--team .bubble__time, .chatwrap--team .chat__seen { font-weight: 500; }
.chatwrap--team .bubble--theirs { box-shadow: var(--shadow-sm); }
.chatwrap--team .bubble { font-size: 15px; }
.chatwrap--team .composer textarea { font-size: 15px; }
.chatwrap--team .composer__send, .chatwrap--team button { margin-top: 0; }
.chatwrap--team .composer__note { background: var(--surface); }
.chat__who--mine { align-self: flex-end; margin: 8px 14px 1px 0; }

/* The writing box sits on the very bottom of the screen. */
.main:has(.chatwrap--team) { padding-bottom: 0; }
.chatwrap--team .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.phead .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Every conversation, newest first. */
.block--talks { padding: 8px; }
.talks { list-style: none; margin: 0; padding: 0; display: grid; }
.talk {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 14px;
  color: inherit; text-decoration: none;
}
.talk:hover { background: var(--bg); }
.talks li + li .talk { border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; }
.talks li + li .talk:hover { border-radius: 14px; border-top-color: transparent; }
.talk__face {
  width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center;
}
.talk__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.talk__text b { font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk__text em { font-style: normal; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk.is-unread .talk__text b { font-weight: 600; }
.talk__class, .phead__class { color: var(--muted); font-weight: 400; }
.msgset__who input { width: 200px; margin: 0; }
.msgset--classes { align-items: flex-start; }
.msgclasses { list-style: none; margin: 4px 0 0; padding: 0 0 0 50px; width: 100%; display: grid; gap: 6px; }
.msgclasses li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--bg); }
.msgclasses li span { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.msgclasses form { margin: 0; }
.msgclasses button { margin: 0; padding: 7px 14px; font-size: 12.5px; }
.talk.is-unread .talk__text em { color: var(--ink-soft); }
.talk__meta { flex: none; display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 12px; }
.talk__count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; background: var(--fill); color: var(--on-fill);
  font-style: normal; font-size: 12px; font-weight: 600;
}
.drow__thumb.talk__face { width: 40px; height: 40px; border-radius: 50%; font-size: 16px; }
.parentrows .chip { flex: none; }
.parentrows__do { margin-top: 14px; }
.parentrows__do .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Settings. */
.msgfacts { margin: 12px 0 0; padding-left: 20px; color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.msgsettings h2 { margin-bottom: 4px; }
.msgset {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.msgset:last-of-type { border-bottom: 0; }
.msgset__icon {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--blue-pale); color: var(--blue-ink);
}
.msgset__text { flex: 1; min-width: 220px; display: grid; gap: 2px; }
.msgset__text b { font-weight: 500; font-size: 14px; }
.msgset__text em { font-style: normal; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.msgset button { margin-top: 0; }
.msgset__times { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; width: 100%; padding-left: 50px; }
.msgset__times label { display: grid; gap: 4px; font-size: 12.5px; }
.msgset__times input { width: 130px; margin: 0; }
.msgset__off { margin-top: 8px; }
.msgset__off button { margin-top: 0; }

/* A parent's code, and the slip to print. */
.codeblock { display: grid; gap: 18px; }
.slip {
  display: flex; gap: 26px; align-items: center; flex-wrap: wrap;
  padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: 18px; background: var(--surface);
}
.slip__qr { flex: none; width: 168px; line-height: 0; }
.slip__qr svg { width: 100%; height: auto; border-radius: 8px; }
.slip__text { flex: 1; min-width: 240px; }
.slip__kicker { margin: 0; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.slip__text h2 { margin: 4px 0 10px; font-size: 19px; font-weight: 600; line-height: 1.3; }
.slip__steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; line-height: 1.45; }
.slip__code {
  display: inline-block; margin: 10px 0 8px; padding: 8px 16px; border-radius: 12px;
  background: var(--bg); font-size: 30px; font-weight: 700; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.slip__small { margin: 0; color: var(--muted); font-size: 12.5px; }
.codeblock__do button { display: inline-flex; align-items: center; gap: 6px; }
.codemsg { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.codemsg textarea { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); background: var(--bg); }
.codeagain button { display: inline-flex; align-items: center; gap: 6px; margin-top: 0; }

@media (max-width: 900px) {
  .chatwrap--team { min-height: calc(100dvh - 120px); }
  /* Edge to edge, so the box behind the writing never shows its sides. */
  .chatwrap--team .composer { margin-inline: -16px; padding-inline: 16px; }
  .chathead--team { margin-top: 0; }
  .msgset__times { padding-left: 0; }
  .msgclasses { padding-left: 0; }
  .slip { padding: 18px; gap: 18px; }
  .slip__qr { width: 140px; }
}

/* Printing the slip: only the slip, twice the size of the screen's. */
@media print {
  body { background: #fff !important; }
  .rail, .tbar, .phead, .note, .codeblock__do, .codemsg, .codeagain, .flashes, .page__shade, .onb { display: none !important; }
  .main { padding: 0 !important; }
  .block { box-shadow: none !important; padding: 0 !important; background: none !important; }
  .slip { border: 2px dashed #999; max-width: 640px; break-inside: avoid; }
}
