@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fonts/fraunces-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fonts/fraunces-latin-wght-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }

/* Each person has a colour. The whole look is those two colours meeting. */
:root {
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --mine: #f2b33d; --mine-ink: #2a1d00;
  --theirs: #ee6f9e; --theirs-ink: #33081a;
  --r-bubble: 22px; --r-tail: 7px;
  --pad: clamp(12px, 3.6vw, 20px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
[data-theme="dusk"]     { --bg: #1c1830; --bg-2: #241f3d; --surface: #2d2749; --raise: #3a335c; --text: #f3effc; --muted: #a59dc3; --line: #ffffff1a; --shade: #0b081a99; color-scheme: dark; }
[data-theme="lagoon"]   { --bg: #0e2a32; --bg-2: #123640; --surface: #1a444f; --raise: #235663; --text: #ebf7f5; --muted: #8fb7b6; --line: #ffffff1c; --shade: #03141999; color-scheme: dark; }
[data-theme="daylight"] { --bg: #f1eff7; --bg-2: #f8f7fc; --surface: #ffffff; --raise: #ffffff; --text: #211d33; --muted: #6f6a87; --line: #211d3318; --shade: #211d3355; color-scheme: light; }

.c-marigold { --c: #f2b33d; --c-ink: #2a1d00; }
.c-rose     { --c: #ee6f9e; --c-ink: #33081a; }
.c-sky      { --c: #62b0f5; --c-ink: #04213d; }
.c-mint     { --c: #4fd0a8; --c-ink: #02281c; }
.c-coral    { --c: #f47a5c; --c-ink: #340d02; }
.c-orchid   { --c: #c184ea; --c-ink: #250a3a; }
.c-lime     { --c: #b9d94a; --c-ink: #1f2a00; }
.c-teal     { --c: #3fc4cf; --c-ink: #022a2e; }
.c-peach    { --c: #f6a57a; --c-ink: #3a1602; }
.c-lilac    { --c: #a79cf2; --c-ink: #150f3d; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 400 16px/1.42 var(--body); overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button, textarea, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--mine); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; justify-content: center; position: relative; isolation: isolate; overflow: hidden; }
/* the two colours, glowing from opposite corners */
#app::before, #app::after { content: ""; position: absolute; z-index: -1; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(90px); opacity: .22; pointer-events: none; }
#app::before { background: var(--theirs); top: -42vmax; left: -30vmax; }
#app::after  { background: var(--mine); bottom: -46vmax; right: -30vmax; }
[data-theme="daylight"] #app::before, [data-theme="daylight"] #app::after { opacity: .3; }

.shell { width: 100%; max-width: 1180px; height: 100%; display: flex; min-width: 0; }
.pane { height: 100%; display: flex; flex-direction: column; min-width: 0; flex: 1; }
.shell[data-view="list"] .pane.chat, .shell[data-view="chat"] .pane.list { display: none; }

/* ---- chat list ---- */
.brand { display: flex; flex: none; }
.brand i { width: 26px; height: 26px; border-radius: 50%; background: var(--theirs); }
.brand i + i { background: var(--mine); margin-left: -9px; mix-blend-mode: screen; }
[data-theme="daylight"] .brand i + i { mix-blend-mode: multiply; }
.rows { flex: 1; overflow-y: auto; padding: 8px 8px calc(env(safe-area-inset-bottom) + 12px); scrollbar-width: thin; scrollbar-color: var(--line) transparent; display: flex; flex-direction: column; }
.chat-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 20px; }
.chat-row:hover, .chat-row.on { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.chat-row .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-row b { font: 540 18.5px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .mid span { color: var(--muted); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .mid span.typing { color: var(--mine); font-style: italic; font-family: var(--display); }
.chat-row.unread .mid span { color: var(--text); font-weight: 600; }
.chat-row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.chat-row time { font-size: 12px; color: var(--muted); }
.badge { font-style: normal; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--mine); color: var(--mine-ink); font-size: 12.5px; font-weight: 700; display: grid; place-items: center; }
.av { position: relative; width: 46px; height: 46px; flex: none; }
.av span { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; font: 600 19px/1 var(--display); background: var(--c); color: var(--c-ink); }
.av span.on::after { content: ""; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: #55e08b; border: 2.5px solid var(--bg); }
.av.pair span { inset: auto; width: 31px; height: 31px; font-size: 14px; border: 2px solid var(--bg); }
.av.pair span:first-child { left: 0; top: 0; }
.av.pair span:last-child { right: 0; bottom: 0; }

/* ---- top bar ---- */
.bar { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.bar .av { width: 40px; height: 40px; }
.bar .av span { font-size: 17px; }
.bar .av.pair span { width: 27px; height: 27px; font-size: 12.5px; }
.head { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; text-align: left; border-radius: 14px; }
.back { margin-left: -8px; }
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font: 560 21px/1.15 var(--display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who p { margin: 1px 0 0; font-size: 13px; color: var(--muted); min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who p.typing { color: var(--theirs); font-style: italic; font-family: var(--display); font-size: 14px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--line); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---- conversation ---- */
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px var(--pad) 6px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scroll > :first-child { margin-top: auto; }
.day { align-self: center; margin: 16px 0 10px; font: italic 400 14px/1 var(--display); color: var(--muted); }
.more { align-self: center; margin: 4px 0 8px; padding: 8px 14px; border-radius: 99px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
.empty { margin: auto; text-align: center; max-width: 30ch; color: var(--muted); }
.empty b { display: block; font: 500 26px/1.15 var(--display); color: var(--text); margin-bottom: 8px; }

.row { display: flex; flex-direction: column; max-width: min(78%, 520px); align-self: flex-start; align-items: flex-start; position: relative; }
.row.mine { align-self: flex-end; align-items: flex-end; }
.row.gap { margin-top: 9px; }
.bubble { padding: 9px 14px 10px; border-radius: var(--r-bubble); background: var(--surface); color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; user-select: text; -webkit-user-select: text; position: relative; }
.row.theirs .bubble { border: 1px solid color-mix(in srgb, var(--c) 38%, transparent); background: color-mix(in srgb, var(--c) 13%, var(--surface)); }
.from { font: 600 13px/1.2 var(--body); color: var(--c); margin: 0 0 3px 12px; }
[data-theme="daylight"] .from { color: color-mix(in srgb, var(--c) 62%, #000); }
.row.mine .bubble { background: var(--mine); color: var(--mine-ink); }
.row.theirs.tail .bubble { border-bottom-left-radius: var(--r-tail); }
.row.mine.tail .bubble { border-bottom-right-radius: var(--r-tail); }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble.big { font-size: 44px; line-height: 1.1; padding: 2px 4px; background: none !important; border: 0 !important; }
.bubble.gone { background: none !important; border: 1px dashed var(--line) !important; color: var(--muted) !important; font-style: italic; font-size: 14px; }
.bubble.photo { padding: 4px; overflow: hidden; }
.bubble.photo img { display: block; width: 100%; max-width: 360px; height: auto; border-radius: 18px; background: var(--line); cursor: zoom-in; }
.bubble.photo .cap { display: block; padding: 6px 10px 4px; }
.row.sending .bubble { opacity: .6; }
.row.failed .bubble { outline: 2px solid #ff6b6b; }
.meta { font-size: 11.5px; color: var(--muted); margin: 3px 6px 0; }
.meta.err { color: #ff8a8a; }
.react { margin: -8px 10px 0; padding: 2px 7px; border-radius: 99px; background: var(--raise); border: 1px solid var(--line); font-size: 15px; line-height: 1.3; position: relative; z-index: 1; box-shadow: 0 2px 8px var(--shade); }
.row.pop .bubble { animation: pop .28s var(--ease); }
@keyframes pop { from { transform: scale(.86) translateY(8px); opacity: 0; } }

/* ---- writing ---- */
.compose { display: flex; align-items: flex-end; gap: 8px; padding: 8px var(--pad) calc(env(safe-area-inset-bottom) + 10px); }
.field { flex: 1; min-width: 0; display: flex; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 3px 4px 3px 16px; }
.field textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; padding: 9px 0; max-height: 132px; line-height: 1.38; font-size: 16px; }
.field textarea::placeholder { color: var(--muted); }
.field .icon-btn { width: 38px; height: 38px; }
.send { width: 46px; height: 46px; border-radius: 50%; background: var(--mine); color: var(--mine-ink); display: grid; place-items: center; flex: none; transition: transform .15s var(--ease), opacity .15s; }
.send svg { width: 22px; height: 22px; }
.send:disabled { opacity: .35; cursor: default; }
.send:not(:disabled):active { transform: scale(.9); }
.draft { margin: 0 var(--pad); padding: 8px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.draft img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; }
.draft span { flex: 1; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); max-width: 86vw; padding: 10px 16px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line); box-shadow: 0 8px 30px var(--shade); font-size: 14.5px; animation: rise .22s var(--ease); }
.banner { margin: 6px var(--pad) 0; padding: 9px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--muted); text-align: center; }

/* ---- sheets ---- */
.veil { position: fixed; inset: 0; z-index: 20; background: var(--shade); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 18px var(--pad) calc(env(safe-area-inset-bottom) + 18px); animation: rise .26s var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 2px 0 14px; font: 520 24px/1.15 var(--display); }
.sheet h3 { margin: 22px 0 8px; font: 600 14px/1.2 var(--body); color: var(--muted); }
.sheet p { margin: 6px 0; color: var(--muted); font-size: 14.5px; }
.emojis { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 12px; }
.emojis button { flex: 1; aspect-ratio: 1; max-width: 62px; font-size: 28px; border-radius: 50%; background: var(--surface); }
.emojis button.on { background: var(--mine); }
.menu button { width: 100%; text-align: left; padding: 14px 4px; border-top: 1px solid var(--line); font-size: 16.5px; display: flex; justify-content: space-between; align-items: center; }
.menu button.danger { color: #ff7d7d; }
.menu button span { color: var(--muted); font-size: 14px; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.themes button { padding: 10px 8px 9px; border-radius: 16px; border: 2px solid var(--line); font-size: 14px; font-weight: 600; }
.themes button i { display: block; height: 34px; border-radius: 9px; margin-bottom: 7px; }
.themes button.on { border-color: var(--mine); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 44px; height: 44px; border-radius: 50%; background: var(--c); border: 3px solid var(--bg-2); outline: 2px solid transparent; }
.swatches button.on { outline-color: var(--text); }
.swatches button:disabled { opacity: .25; cursor: not-allowed; }
.sheet .btn { margin-top: 10px; }
.sheet label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.sheet input[type="text"] { width: 100%; padding: 13px 15px; border-radius: 15px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; outline: 0; }
.sheet input[type="text"]:focus { border-color: var(--mine); }
.sheet input.link { font-size: 13.5px; color: var(--muted); margin: 8px 0 4px; }
.sheet .err { color: #ff8a8a; min-height: 20px; }
.checks { display: flex; flex-direction: column; }
.checks label, .checks.plain div { display: flex; align-items: center; gap: 11px; padding: 11px 2px; margin: 0; font-size: 16.5px; font-weight: 400; border-top: 1px solid var(--line); cursor: pointer; }
.checks.plain div { cursor: default; }
.checks input { width: 21px; height: 21px; accent-color: var(--mine); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.person { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-top: 1px solid var(--line); font-size: 16px; }
.person .grow { flex: 1; min-width: 0; }
.mini { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.mini.danger { color: #ff7d7d; }
.people { margin-bottom: 8px; }
.btn { display: block; width: 100%; padding: 14px 18px; border-radius: 16px; background: var(--mine); color: var(--mine-ink); font-weight: 650; font-size: 16.5px; text-align: center; }
.btn.quiet { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }

/* ---- photo viewer ---- */
.viewer { position: fixed; inset: 0; z-index: 30; background: #000000ee; display: grid; place-items: center; animation: fade .18s; cursor: zoom-out; }
.viewer img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }

/* ---- signing in ---- */
.door { margin: auto; width: 100%; max-width: 400px; padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); }
.door .mark { display: flex; margin-bottom: 26px; }
.door .mark i { width: 54px; height: 54px; border-radius: 50%; background: var(--theirs); }
.door .mark i + i { background: var(--mine); margin-left: -18px; mix-blend-mode: screen; }
.door input[type="text"] { width: 100%; }
[data-theme="daylight"] .door .mark i + i { mix-blend-mode: multiply; }
.door h1 { margin: 0 0 8px; font: 520 40px/1.02 var(--display); letter-spacing: -.02em; }
.door p { margin: 0 0 22px; color: var(--muted); }
.door label { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.door input { width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; outline: 0; }
.door input:focus { border-color: var(--mine); }
.door .btn { margin-top: 22px; }
.door .err { color: #ff8a8a; font-size: 14.5px; margin: 12px 0 0; min-height: 20px; }

@media (min-width: 900px) {
  .shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 55%, transparent); }
  .shell[data-view] .pane.list { display: flex; flex: none; width: 340px; border-right: 1px solid var(--line); }
  .shell[data-view] .pane.chat { display: flex; }
  .back { display: none; }
  .veil { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
