/*
 * Romashka on the web. The app's own colours, written out by hand rather than imported from a
 * framework, so this looks like the same product rather than a different one wearing its name.
 * Dark by default, light when the browser says the person prefers it.
 */
:root {
  --bg: #09090c;
  --raised: #131318;
  --raised2: #1c1c24;
  --raised3: #262630;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f4f7;
  --muted: #8e8e9c;
  --faint: #5b5b68;
  --petal: #ffd35c;
  --amber: #ff9e45;
  --danger: #ff5f6d;
  --on-accent: #1a1308;
  --accent: linear-gradient(135deg, var(--petal), var(--amber));
  --radius: 18px;
}

/* Chosen explicitly. The media query below still answers for the very first paint, before the
   stored choice has been read, so the page never flashes the wrong shade. */
:root[data-mood="light"] {
  --bg: #f5f5f8;
  --raised: #ffffff;
  --raised2: #ececf2;
  --raised3: #e1e1ea;
  --line: rgba(0, 0, 0, 0.08);
  --text: #14141a;
  --muted: #6a6a78;
  --faint: #9b9ba8;
  --danger: #e23b4a;
}

:root[data-mood="dark"] {
  --bg: #09090c;
  --raised: #131318;
  --raised2: #1c1c24;
  --raised3: #262630;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f4f7;
  --muted: #8e8e9c;
  --faint: #5b5b68;
  --danger: #ff5f6d;
}

@media (prefers-color-scheme: light) {
  :root:not([data-mood]) {
    --bg: #f5f5f8;
    --raised: #ffffff;
    --raised2: #ececf2;
    --raised3: #e1e1ea;
    --line: rgba(0, 0, 0, 0.08);
    --text: #14141a;
    --muted: #6a6a78;
    --faint: #9b9ba8;
    --danger: #e23b4a;
  }
}

* { box-sizing: border-box; }

/*
 * `hidden` must win. The browser hides a [hidden] element with a rule of its own, but several
 * rules below give those same elements a display of flex or grid — and a class beats an attribute
 * from the browser's stylesheet, so without this the call overlay, the appearance sheet and the
 * app shell all paint at once over a page nobody has signed in to yet.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  height: 100dvh;
  overflow: hidden;
}

.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: var(--danger); font-size: 13px; }

/* The chamomile itself, the same drawing the app's icon uses. */
.mark { width: 48px; height: 48px; display: block; }
.mark.small { width: 28px; height: 28px; }
.mark.big { width: 84px; height: 84px; }

/* ── Signing in ─────────────────────────────────────────────────────────── */
/* Not a flat sheet: two soft pools of the theme's own colours, so the page belongs to the theme
   rather than merely carrying a coloured button. */
body {
  background-image:
    radial-gradient(60vw 60vw at 12% -10%, color-mix(in srgb, var(--petal) 20%, transparent), transparent 70%),
    radial-gradient(55vw 55vw at 105% 108%, color-mix(in srgb, var(--amber) 18%, transparent), transparent 70%);
  background-attachment: fixed;
}

/*
 * Centred when it fits, scrollable when it does not. A grid with place-items:center cannot be
 * scrolled back to once its content is taller than the box — the overflow goes off both ends and
 * the top is unreachable — so this is a flex column with the card centred by its own auto margins,
 * which overflows downward and scrolls honestly. The code box makes the card tall enough to matter.
 */
.signin {
  display: flex; justify-content: center;
  min-height: 100dvh; overflow-y: auto;
  padding: 16px;
}
.signin .card {
  width: min(380px, 100%);
  margin: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
}
.signin h1 { margin: 10px 0 4px; font-size: 22px; }
.signin p { margin: 0 0 12px; font-size: 13.5px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 9px 0 5px; }
input {
  width: 100%; padding: 10px 13px;
  background: var(--raised2); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  font: inherit;
}
input:focus { outline: 2px solid var(--petal); outline-offset: 1px; }
button {
  font: inherit; cursor: pointer; border: 0;
  background: var(--accent); color: var(--on-accent);
  padding: 11px 16px; border-radius: 14px; font-weight: 600;
}
button:disabled { opacity: 0.55; cursor: default; }
#signin-button { width: 100%; margin-top: 14px; }
button.plain { background: none; color: var(--muted); padding: 6px 10px; font-weight: 500; }
button.plain:hover { color: var(--text); }

/* ── The app ────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; height: 100dvh; }

.chats { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.pane-head strong { font-size: 19px; }
.link-state { font-size: 20px; line-height: 1; color: var(--faint); }
.link-state.live { color: #5de2a8; }
.search { margin: 0 12px 10px; width: auto; border-radius: 16px; }

.chat-list { list-style: none; margin: 0; padding: 0 8px 20px; overflow-y: auto; flex: 1; }
.chat-list li {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 10px; border-radius: 14px; cursor: pointer;
}
.chat-list li:hover { background: var(--raised); }
.chat-list li[aria-current="true"] { background: var(--raised2); }
.chat-line { min-width: 0; flex: 1; }
.chat-line .top { display: flex; align-items: baseline; gap: 8px; }
.chat-line strong { font-size: 15px; font-weight: 600; }
.chat-line .when { margin-left: auto; font-size: 11px; color: var(--faint); white-space: nowrap; }
.chat-line .preview {
  font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge {
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}

/* A face, or initials on a colour taken from the name so each person keeps the same one. */
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: var(--raised3); background-size: cover; background-position: center;
}
.avatar.saved { background: var(--accent); color: var(--on-accent); }

/* ── The open conversation ──────────────────────────────────────────────── */
.room { display: flex; flex-direction: column; min-width: 0; }
.room > div { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.room-empty { display: grid; place-items: center; align-content: center; gap: 14px; }
.room-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.room-head .avatar { width: 40px; height: 40px; font-size: 14px; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who small { font-size: 12px; }
.back { display: none; font-size: 18px; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 3px;
  /* The app's own doodles, at a whisper, so the conversation has something behind it. */
  background-image: url("wallpaper.svg");
  background-size: 384px 384px;
  color: var(--text);
}
:root[data-mood="light"] .messages { opacity: 1; }
.bubble {
  max-width: min(560px, 76%); padding: 8px 12px;
  border-radius: 18px; background: var(--raised2);
  align-self: flex-start; word-wrap: break-word; white-space: pre-wrap;
}
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.bubble .stamp { font-size: 10.5px; opacity: 0.65; margin-left: 8px; float: right; margin-top: 4px; }
.bubble.note { align-self: center; background: none; color: var(--faint); font-size: 12px; }
.day { align-self: center; color: var(--muted); font-size: 11.5px; margin: 12px 0 6px; }

.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.composer input { border-radius: 22px; }

/* On a phone the two panes become one, and the chat slides over the list. */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .chats { border-right: 0; }
  .app[data-open="true"] .chats { display: none; }
  .app:not([data-open="true"]) .room { display: none; }
  .back { display: block; }
}

/* ── Being let in from a phone ──────────────────────────────────────────── */
.small { font-size: 12.5px; margin: 6px 0; }
button.ghost {
  width: 100%; margin-top: 8px;
  background: var(--raised2); color: var(--text); font-weight: 500;
}
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 12px 0 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* The six characters, spaced so they can be read off a screen and typed without doubt. */
.code {
  font: 700 23px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 3px; text-align: center;
  background: var(--raised2); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 10px; margin: 8px 0;
}

/* ── A call ─────────────────────────────────────────────────────────────── */
.call {
  position: fixed; inset: 0; z-index: 10;
  background: #09090c; color: #fff;
  display: flex; flex-direction: column;
}
.call-faces { flex: 1; position: relative; overflow: hidden; }
.call-faces .remote { width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-faces .local {
  position: absolute; top: 18px; right: 18px;
  width: 132px; height: 190px; object-fit: cover;
  border-radius: 16px; background: #1c1c24;
}
/* Who it is, in the middle, until a picture covers it. */
.call-who {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  pointer-events: none;
}
.call-who strong { font-size: 22px; }
.avatar.big { width: 108px; height: 108px; font-size: 34px; }

.call-keys { display: flex; justify-content: center; gap: 16px; padding: 22px 16px 34px; }
button.round {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  font-size: 13px; font-weight: 600;
}
button.round.off { background: #fff; color: #09090c; }
button.round.go { background: #5de2a8; color: #04170e; }
button.round.stop { background: var(--danger); color: #fff; }


/* ── Choosing how it looks ──────────────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: center; padding: 20px;
}
.sheet-card {
  width: min(360px, 100%);
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 28px; padding: 22px;
}
.sheet-card > strong { font-size: 19px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin: 18px 0 8px; }

.segmented { display: flex; gap: 3px; background: var(--raised2); border-radius: 16px; padding: 3px; margin-top: 14px; }
.segmented button {
  flex: 1; background: none; color: var(--muted);
  border-radius: 13px; padding: 9px 0; font-size: 13px; font-weight: 600;
}
.segmented button.on { background: var(--accent); color: var(--on-accent); }

.themes { display: flex; gap: 12px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; padding: 0; position: relative; }
.swatch.on::after {
  content: ""; position: absolute; inset: -4px;
  border: 2px solid var(--text); border-radius: 50%;
}

#look-sheet .ghost { margin-top: 20px; }
#google-slot { display: flex; justify-content: center; margin-top: 14px; }
