/* the hidden attribute always wins over a class that sets display (.ghost, .setting, …) */
[hidden] { display: none !important; }
:root {
  --bg: #161718;
  --surface: #1e1f21;
  --surface-2: #26282b;
  --border: #33363a;
  --text: #e9eaec;
  --muted: #9a9ea5;
  --faint: #6c7077;
  --you: #8ab4ff;          /* becomes the signed-in user's own colour */
  --radius: .25rem;
  --sans: "Twemoji Country Flags", "Helvetica Neue", "Inter", Helvetica, Arial, sans-serif;
  --ja: "Twemoji Country Flags", "Helvetica Neue", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --zh: "Twemoji Country Flags", "Helvetica Neue", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* no background on html: body's then paints the whole canvas (overscroll included) from behind,
   under the water's negative z-index; with one here, body's own box would cover the water */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.55 var(--sans); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.ja { font-family: var(--ja); }
body.zh { font-family: var(--zh); }
/* Pinyin in a Latin font. Noto Sans SC (served by Google) has no ǎ, ǒ, ǚ..., so the browser built
   them from a plain vowel plus a mark from another font, and the tone marks sat off to the right. */
body.zh .name-text[data-reading]::after, body.zh .person-reading, .pinyin { font-family: "Inter", "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; border-radius: var(--radius); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  max-width: 860px; margin: 0 auto; padding: 9px 16px;
  border-bottom: 1px solid var(--border);
}
.mark { font-weight: 300; font-size: 20px; letter-spacing: .01em; text-decoration: none; }
.boards { display: flex; gap: 4px; }
.boards a {
  text-decoration: none; padding: 3px 8px; border-radius: 999px; line-height: 1; opacity: .45;
  transition: opacity .15s, background-color .15s;
}
.flag { font-size: 18px; display: inline-block; vertical-align: middle; }
.boards a[aria-current="page"] { background: var(--surface-2); opacity: 1; }
.boards a:hover:not([aria-current]) { opacity: .8; }
.me { margin-left: auto; display: flex; gap: 16px; align-items: baseline; font-size: 14px; }
.me button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); }
.me button:hover { color: var(--text); }
.me .who { color: var(--you); font-weight: 500; }

main { max-width: 860px; margin: 0 auto; padding: 0 16px 170px; outline: none; }

/* ---------- board index ---------- */
.board-head { padding: 44px 0 22px; }
.board-head h1 {
  margin: 0; font-weight: 200; font-size: clamp(44px, 8vw, 64px); line-height: 1.05; letter-spacing: -.02em;
}
.starter { margin: 22px 0 0; }
#start-err:empty { min-height: 0; margin: 0; }

.threads { margin: 0; padding: 6px 0 0; }
.thread-card {
  display: block; text-decoration: none; padding: 12px 0 10px;
}
.thread-card:hover .op-text { color: #fff; }
.op-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.op-text { font-size: 20px; font-weight: 300; line-height: 1.4; margin: 4px 0 8px; max-width: 36em; }
.count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.recent { margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--border); list-style: none; color: var(--muted); }
.recent li { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .name { font-size: 14px; }
.thread-card .typing-mini { color: var(--faint); font-size: 13px; margin-top: 6px; min-height: 1.3em; }

/* ---------- names, time ---------- */
.name { font-weight: 500; }
.pid { color: var(--faint); font-size: 12px; }
.when { color: var(--faint); font-size: 13px; }

/* ---------- thread ---------- */
/* back to the board: a chevron that hangs in the left margin on wide screens, and sits inline on narrow ones */
.back {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; color: var(--muted); transition: color .15s, background-color .15s;
}
.back:hover { color: var(--text); background: var(--surface-2); }
.missing { padding-top: 22px; }
.missing .back { margin-left: -8px; }
.posts { list-style: none; margin: 0; padding: 0; }
.post { padding: 9px 0; scroll-margin-top: 64px; }
/* typing in a thread on a phone: the posts settle at the bottom, just above the composer (app.js composing()) */
html.composing #view { display: flex; flex-direction: column; justify-content: flex-end; box-sizing: border-box; }
/* your post while it's on its way: there at once, a little dim until the server has it */
.post > .head, .post > .body { transition: opacity .3s ease; }
.post.pending > .head, .post.pending > .body { opacity: .55; }
.post .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 14px; position: relative; }
.post .head .back { align-self: center; margin: -7px -6px -7px -8px; }
.post .body { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 40em; }
.post:first-child { padding: 24px 0 18px; }
.post:first-child .body { font-size: 26px; font-weight: 200; line-height: 1.35; letter-spacing: -.01em; margin-top: 6px; }
.body .gt { color: #9be15d; }

/* a post arrives: it slides in, and its number briefly takes the poster's colour */
.post.arrive { animation: arrive .45s cubic-bezier(.2, .8, .2, 1) both; }
.thread-card.arrive { animation: arrive .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- bottom dock: typing + composer ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to bottom, rgba(22, 23, 24, 0), var(--bg) 22px);
  padding: 22px 16px calc(14px + env(safe-area-inset-bottom));
}
/* iOS Safari draws the page under its translucent bottom bar, below where fixed things end: carry the
   dock's shade down there too, so posts don't show through a bare strip */
.dock::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 40vh; background: var(--bg); pointer-events: none; }
html.has-water .dock::after { background: none; }
.dock-inner { max-width: 860px; margin: 0 auto; position: relative; }
/* posts arrived below while you were reading further up */
.newposts {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%);
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text);
  padding: 5px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35); animation: arrive .3s cubic-bezier(.2, .8, .2, 1) both;
}
.newposts:hover { background: var(--border); }
.newposts[hidden] { display: none; }
.typing { min-height: 1.5em; font-size: 13px; color: var(--muted); padding: 0 2px 6px; }
.typing .name { font-size: 13px; }
.dots { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .3; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: .375rem;
  transition: border-color .15s, box-shadow .15s;
}
/* focus: one soft glow in your colour, not a coloured border plus a ring */
.composer:focus-within { box-shadow: 0 0 0 1px color-mix(in srgb, var(--you) 35%, transparent), 0 0 18px color-mix(in srgb, var(--you) 22%, transparent); }
textarea {
  flex: 1; min-height: 40px; max-height: 40vh; resize: none; border: 0; background: transparent;
  padding: 8px 8px; outline: none; display: block; width: 100%; line-height: 1.5;
}
textarea::placeholder { color: var(--faint); }
.send, .solid {
  border: 1px solid transparent; border-radius: var(--radius); padding: 7px 16px;
  background: var(--you); color: #111; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.send:disabled { background: var(--surface-2); color: var(--faint); cursor: default; }
.send:not(:disabled):hover, .solid:hover { filter: brightness(1.08); }
.ghost {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 16px; background: transparent; cursor: pointer;
}
.ghost:hover { background: var(--surface-2); }
a.ghost { color: inherit; text-decoration: none; display: inline-block; }
.note { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 14px; pointer-events: none; }
.err { color: #ff8f8f; min-height: 1.2em; margin: 6px 2px 0; font-size: 14px; }

.signin {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: .375rem; padding: 12px 14px;
}
.signin p { margin: 0; flex: 1 1 260px; color: var(--muted); }
/* over the water: the same frosted glass as the composer */
html.has-water .signin {
  background: rgba(30, 31, 33, .26);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border-color: rgba(255, 255, 255, .09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 10px 30px rgba(0, 0, 0, .28);
}
html.has-water .signin p { color: #c3c8cf; }
/* Google's button is an iframe with a light page inside; on a dark-scheme page the browser paints an
   opaque white backdrop behind it (the white frame). Matching schemes keeps the iframe transparent. */
.gbtn { color-scheme: light; }

.empty { padding: 40px 0; color: var(--muted); font-weight: 300; font-size: 20px; }

/* ---------- profile dialog ---------- */
dialog {
  border: 1px solid var(--border); border-radius: .5rem; background: var(--surface); color: var(--text);
  padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 1rem 3rem rgba(0, 0, 0, .5);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 6px; font-weight: 300; font-size: 26px; }
.quiet { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field input {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: 8px 12px; color: var(--text); font-size: 16px;
  width: 100%; min-width: 0;
}
.field input:focus { outline: none; border-color: var(--you); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--you) 22%, transparent); }
.swatches { border: 0; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px 6px; }
.swatches legend { font-size: 14px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatches span { display: block; width: 100%; height: 18px; border-radius: 999px; }   /* pills: full width, half the height of circles */
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatches input:focus-visible + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--you); }
.row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 22px; }

@media (max-width: 560px) {
  .top { gap: 14px; }
  .op-text { font-size: 18px; }
  .post:first-child .body { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .post.arrive, .thread-card.arrive, .dots i, .post .en { animation: none; }
}


/* proportional kana only in short UI text; post bodies stay full-width (easier to read, and to learn from) */
body.ja .name, body.ja .me, body.ja .send, body.ja .signin p, body.ja .back { font-feature-settings: "palt"; }

/* ---------- names: profile links, hover furigana, @username on collisions ---------- */
a.name { text-decoration: none; }
a.name:hover .name-text { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.name-text { position: relative; }
.name-text[data-reading]::after {
  content: attr(data-reading); position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translate(-50%, 2px);
  white-space: nowrap; font-size: 11px; font-weight: 400; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1px 6px; pointer-events: none;
  opacity: 0; transition: opacity .12s, transform .12s; z-index: 2;
}
.name:hover .name-text[data-reading]::after, .name:focus-visible .name-text[data-reading]::after { opacity: 1; transform: translate(-50%, 0); }
.op-tag {
  font-size: 11px; font-weight: 500; line-height: 1; padding: 2px 5px; border-radius: var(--radius);
  color: var(--muted); border: 1px solid var(--border); align-self: center;
}
.handle { color: var(--faint); font-weight: 400; font-size: .9em; }
body.ja .post .name, body.ja .op-line .name, body.zh .post .name, body.zh .op-line .name { font-size: 15px; }

/* ---------- profile ---------- */
.person { padding: 26px 0 20px; position: relative; }
.person > .back { margin: 0 0 6px -8px; }
.person:has(.person-reading) { --name-top: 25px; }
@media (min-width: 960px) {
  .post .head .back { position: absolute; left: -44px; top: 50%; transform: translateY(-50%); margin: 0; }
  .person > .back { position: absolute; left: -44px; top: calc(41px + var(--name-top, 0px)); margin: 0; }
  .missing .back { position: absolute; margin: 0 0 0 -44px; }
}
.person-reading { color: var(--muted); font-size: 15px; margin-bottom: 2px; }
.person-name { margin: 0; font-weight: 200; font-size: clamp(40px, 7vw, 56px); line-height: 1.1; letter-spacing: -.01em; }
.person-meta { margin-top: 8px; display: flex; gap: 12px; align-items: baseline; }
.history { list-style: none; margin: 0; padding: 0; }
.history a { display: block; text-decoration: none; padding: 9px 0; }
.history a:hover .body { color: #fff; }
.history-op { color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .body { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 40em; }

/* ---------- onboarding / settings ---------- */
dialog .field { margin-top: 14px; }
dialog .field:first-of-type { margin-top: 0; }
.prefix-input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.prefix-input:focus-within { border-color: var(--you); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--you) 22%, transparent); }
.prefix { color: var(--faint); padding-left: 12px; }
.prefix-input input { border: 0; background: transparent; padding-left: 2px; flex: 1; }
.prefix-input input:focus { box-shadow: none; }
.hint { color: var(--faint); font-size: 12px; font-weight: 400; }
.hint[data-ok="1"] { color: #3ddc97; }
.hint[data-ok="0"] { color: #ff8f8f; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .two .field { margin-top: 14px; }   /* beats :first-of-type above, which also matched the first field of each pair */
.field .flag { font-size: 15px; line-height: 1; }
/* every label line the same height, flag or not, so paired fields line up */
.field > span:first-child:not(.prefix-input) { display: flex; align-items: center; gap: .35em; min-height: 20px; line-height: 20px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; gap: 0; } }

/* ---------- water background (public/water.js), opt-in for now: ?bg=water / ?bg=plain ---------- */
/* main takes focus on navigation (for screen readers); it shouldn't draw a focus ring when it does */
main:focus-visible { outline: none; }
/* 100lvh: the largest viewport, so on iOS the sky also fills the strip under Safari's bottom bar */
.water { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .8s ease; }
.water.ready { opacity: 1; }
/* the dock fades into the water instead of ending in a solid band */
/* the dock is only a faint shade behind the typing line; the composer's own glass does the rest */
html.has-water .dock { background: linear-gradient(to bottom, rgba(22, 23, 24, 0), rgba(22, 23, 24, .38) 30px); }
/* on the board index the dock only holds a card (sign in / finish setting up): no band behind it,
   so the bottom of the page is as open as the top */
html.has-water .dock:not(.in-thread) { background: none; }
/* in a thread, while someone is typing, a band rises behind the typing line: it blurs and dims the
   posts scrolling under it so the line stays readable, its top edge faded rather than cut. When
   nobody is typing it sinks away and only the glass composer is left. */
html.has-water .dock.in-thread { padding-top: 34px; background: none; }
html.has-water .dock.in-thread::before {
  content: ""; position: absolute; inset: 0 0 -40vh 0; z-index: -1; pointer-events: none;   /* on down under iOS's bottom bar */
  background: linear-gradient(to bottom, rgba(22, 23, 24, .35), rgba(22, 23, 24, .72) 40px);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30px); mask-image: linear-gradient(to bottom, transparent, #000 30px);
  opacity: 0; transform: translateY(18px);
  transition: opacity .35s ease, transform .45s cubic-bezier(.2, .8, .2, 1);
}
html.has-water .dock.in-thread.typing-on::before { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { html.has-water .dock.in-thread::before { transform: none; transition: opacity .2s; } }
html.has-water .top { border-bottom-color: rgba(255, 255, 255, .08); }
/* over the water, the composer is frosted glass instead of an opaque grey slab: it blurs what's
   behind it, keeps a dark tint for contrast, and a hairline rim plus a faint top highlight read as
   the edge of a pane. Plain background: unchanged (there's nothing to blur). */
html.has-water .composer {
  background: rgba(30, 31, 33, .26);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  transition: background-color .2s, border-color .2s, box-shadow .2s;
  border-color: rgba(255, 255, 255, .09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 10px 30px rgba(0, 0, 0, .28);
}
/* typing: a little darker, so your own words keep their contrast */
html.has-water .composer:focus-within {
  background: rgba(22, 23, 24, .42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 10px 30px rgba(0, 0, 0, .28),
    0 0 0 1px color-mix(in srgb, var(--you) 35%, transparent), 0 0 18px color-mix(in srgb, var(--you) 22%, transparent);
}
html.has-water .send:disabled { background: rgba(255, 255, 255, .07); }
/* ---------- top bar: one line on a phone ---------- */
.top { flex-wrap: nowrap; }
.me { min-width: 0; }
.me .who { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32vw; }
.gear {
  background: none; border: 0; padding: 4px; margin: -4px -4px -4px 0; cursor: pointer; color: var(--muted);
  display: inline-flex; border-radius: 50%; transition: color .15s, transform .4s cubic-bezier(.2, .8, .2, 1);
}
.gear:hover { color: var(--text); transform: rotate(45deg); }
@media (max-width: 560px) { .top { gap: 12px; } .boards a { padding: 3px 6px; } .me { gap: 12px; } }

/* ---------- settings: a switch row, sign out at the left of the buttons ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.setting label { display: grid; gap: 2px; cursor: pointer; }
.setting .setting-text { display: grid; gap: 2px; }
.setting-name { font-size: 15px; color: var(--text); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 40px; height: 24px; margin: 0; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform .2s cubic-bezier(.2, .8, .2, 1), background-color .2s;
}
.switch:checked { background: color-mix(in srgb, var(--you) 45%, var(--surface-2)); }
.switch:checked::after { transform: translateX(16px); background: var(--text); }
.grow { flex: 1; }
.link-quiet { background: none; border: 0; padding: 7px 0; color: var(--muted); cursor: pointer; }
.link-quiet:hover { color: #ff8f8f; }
#kiokun-on { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; flex-shrink: 0; }

/* ---------- tap a word (Japanese and Chinese boards, public/lookup.js) ---------- */
.lookup-on .post .body { cursor: pointer; }
/* a post's English, under it after a tap (app.js toggleEnglish) */
.lookup-on .post:not(.pending) { cursor: pointer; }
.post .en {
  margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--border); max-width: 40em;
  font: 400 15px/1.5 var(--sans); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere;
  animation: arrive .2s cubic-bezier(.2, .8, .2, 1) both;
}
.post .en.loading { color: var(--faint); }
.post .en.failed { color: var(--faint); font-style: italic; }
.post:first-child .en { font-size: 17px; margin-top: 10px; }
::highlight(lookup) { background-color: color-mix(in srgb, var(--you) 30%, transparent); color: #fff; }
.lookup {
  position: absolute; z-index: 30; padding: 12px 14px 10px; border-radius: .5rem;
  background: rgba(30, 31, 33, .92); border: 1px solid var(--border); color: var(--text);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45); font-size: 14px; line-height: 1.45;
  animation: arrive .2s cubic-bezier(.2, .8, .2, 1) both;
}
.lookup { overflow-y: auto; overscroll-behavior: contain; }
.lookup .lk-head { font-size: 20px; font-weight: 400; line-height: 1.3; }
.lookup .lk-star { font-size: 10px; color: var(--muted); vertical-align: super; margin-left: 1px; }
.lookup .lk-reason { font-size: 12px; color: var(--muted); margin-top: 1px; }
.lookup .lk-info { color: var(--faint); }
.lookup .lk-plain { list-style: none; padding-left: 0; }
.lookup .lk-reading { font-size: 14px; color: var(--muted); margin-left: 6px; }
.lookup .lk-pinyin { font-family: "Inter", "Helvetica Neue", Arial, sans-serif; }   /* tone marks sit right */
.lookup .lk-alt { font-size: 15px; color: var(--faint); margin-left: 6px; }
.lookup .lk-pos { font-size: 11px; color: var(--faint); text-transform: lowercase; }
.lookup ol { margin: 4px 0 8px; padding-left: 18px; }
.lookup li { margin: 2px 0; }
.lookup .lk-word + .lk-word { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.lookup .lk-readings { color: var(--muted); margin-top: 2px; }
.lookup .lk-none { margin: 6px 0 2px; color: var(--muted); }
.lookup .lk-foot { display: flex; justify-content: flex-end; align-items: baseline; gap: 10px; }
.lookup .lk-saved { font-size: 13px; color: var(--muted); }
.lookup .lk-more { display: block; text-align: right; font-size: 13px; color: var(--muted); text-decoration: none; }
.lookup .lk-more:hover { color: var(--text); }

/* ---------- kiokun entry pane (public/pane.js) ---------- */
.kpane {
  position: fixed; z-index: 40; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45); font-size: 14px;
  right: 0; bottom: 0; left: 0; height: 62vh; border-radius: .5rem .5rem 0 0; border-bottom: 0;
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.kpane.open { transform: none; }
.kp-bar { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 8px 6px 14px; touch-action: none; border-bottom: 1px solid var(--border); }
.kp-grab { position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); }
.kp-title { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-close { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 24px; line-height: 1; width: 40px; height: 40px; border-radius: var(--radius); }
.kp-close:hover { color: var(--text); background: var(--surface-2); }
.kp-close:focus-visible { outline: 2px solid var(--you); outline-offset: -2px; }
.kp-body { position: relative; flex: 1; min-height: 0; }
.kp-body iframe { width: 100%; height: 100%; border: 0; background: var(--bg); color-scheme: dark; }
.kpane.dragging iframe { pointer-events: none; }
.kp-fallback { position: absolute; inset: 0; margin: 0; padding: 24px 16px; text-align: center; background: var(--surface); color: var(--muted); }
.kp-fallback[hidden] { display: none; }
.kp-fallback a { display: block; margin-top: 10px; color: var(--you); }
@media (min-width: 960px) {
  .kpane {
    top: 46px; left: auto; width: min(440px, 42vw); height: auto; border-radius: 0; border-bottom: 1px solid var(--border); border-right: 0;
    transform: translateX(100%);
  }
  .kpane.open { transform: none; }
  .kp-grab { display: none; }
  .kp-bar { padding-top: 6px; touch-action: auto; }
}
@media (prefers-reduced-motion: reduce) { .kpane { transition: none; } }

/* ---------- friends and messages (public/inbox.js) ---------- */
.inbox-btn { position: relative; }
.inbox-btn:hover { transform: none; }
.inbox-btn[aria-expanded="true"] { color: var(--text); }
.inbox-btn .dot { position: absolute; top: 2px; right: 1px; width: 8px; height: 8px; border-radius: 50%; background: #ff5a5f; box-shadow: 0 0 0 2px var(--bg); }
.inbox {
  position: fixed; z-index: 45; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font-size: 15px;
}
html.has-water .inbox { background: rgba(22, 23, 24, .86); -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%); }
html.inbox-open { overflow: hidden; }   /* a phone: the panel is the page while it's open */
@media (min-width: 720px) {
  .inbox { top: 47px; left: auto; width: 380px; border-left: 1px solid var(--border); border-top: 1px solid var(--border); box-shadow: -12px 0 32px rgba(0, 0, 0, .35); }
  html.inbox-open { overflow: visible; }
}
.ib-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--border); flex: none; }
.inbox.in-chat .ib-tabs { display: none; }
.ib-tabs [role=tab] { background: none; border: 0; cursor: pointer; color: var(--muted); font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.ib-tabs [role=tab]:hover { color: var(--text); }
.ib-tabs [role=tab][aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.ib-n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: #ff5a5f; color: #fff; font-size: 11.5px; line-height: 18px; text-align: center; }
.ib-close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 24px; line-height: 1; width: 38px; height: 38px; border-radius: var(--radius); }
.ib-close:hover { color: var(--text); background: var(--surface-2); }
.ib-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.ib-empty { color: var(--muted); padding: 28px 18px; margin: 0; line-height: 1.5; }

.ib-av { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #121314; font-weight: 600; font-size: 15px; }
.ib-mid { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.ib-mid .handle { color: var(--faint); font-size: 12.5px; }
.ib-name { text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-name:hover { text-decoration: underline; }

.ib-convs, .ib-people { list-style: none; margin: 0; padding: 0; }
.ib-conv { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: none; border: 0; border-bottom: 1px solid rgba(255, 255, 255, .05); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ib-conv:hover { background: rgba(255, 255, 255, .04); }
.ib-who { font-weight: 500; }
.ib-last { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-conv.unread .ib-last { color: var(--text); }
.ib-when { color: var(--faint); font-size: 12px; align-self: flex-start; margin-top: 3px; white-space: nowrap; }
.ib-conv.unread .ib-when::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--you); margin-left: 6px; vertical-align: 1px; }

.ib-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ib-chathead { display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 6px; border-bottom: 1px solid var(--border); flex: none; }
.ib-person { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.ib-person .ib-av { width: 30px; height: 30px; font-size: 13px; }
.ib-back { background: none; border: 0; cursor: pointer; color: var(--you); font-size: 30px; line-height: 1; width: 38px; height: 38px; border-radius: var(--radius); }
.ib-back:hover { background: var(--surface-2); }
.ib-msgs { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.ib-day { align-self: center; color: var(--faint); font-size: 12px; margin: 10px 0 4px; }
.ib-b { max-width: 78%; padding: 7px 12px; border-radius: 18px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.ib-b.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.ib-b.mine { align-self: flex-end; background: #3a6fd8; color: #fff; border-bottom-right-radius: 6px; }
.ib-b.pending { opacity: .6; }
.ib-hi { text-align: center; }
.ib-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex: none; }
.ib-compose textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; padding: 7px 14px; outline: none; }
.ib-compose textarea:focus { border-color: color-mix(in srgb, var(--you) 60%, var(--border)); }
.ib-compose .send { width: 36px; height: 36px; padding: 0; border-radius: 50%; flex: none; font-size: 17px; background: #3a6fd8; color: #fff; }
.ib-err:empty { display: none; }
.ib-err { margin: 0 14px 10px; }

.ib-dir { display: flex; flex-direction: column; }
.ib-search { margin: 12px 14px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; padding: 8px 12px; outline: none; }
.ib-search:focus { border-color: color-mix(in srgb, var(--you) 60%, var(--border)); }
.ib-sect { color: var(--faint); font-size: 12.5px; font-weight: 400; margin: 0; padding: 16px 14px 4px; }
.ib-person-row { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.ib-btn { flex: none; font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; white-space: nowrap; }
.ib-btn.add { background: var(--text); color: #121314; border-color: var(--text); }
.ib-btn.addback { background: var(--you); color: #0b1424; border-color: var(--you); }
.ib-btn.wait { color: var(--faint); }
.ib-btn.friends { color: var(--muted); border-color: transparent; }
.ib-btn:disabled { opacity: .5; cursor: default; }
.inbox button:focus-visible, .inbox a:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; }
.ib-compose .send:disabled { background: var(--surface-2); color: var(--faint); }

/* ---------- panes beside the board, not over it (a computer) ----------
   Messages sit on the right, under their button; the kiokun entry on the left. Each open pane
   takes its width from the page, so the board and its composer move into the space between and
   you can read, look words up and chat at once. Too narrow for both beside the text: the kiokun
   pane goes back over the board (the messages keep their side). Phones: unchanged. */
:root { --pane-l: 0px; --pane-r: 0px; --kp-w: min(440px, 42vw); --ib-w: 380px; }
@media (min-width: 960px) {
  .kpane { left: 0; right: auto; width: var(--kp-w); border-left: 0; border-right: 1px solid var(--border); box-shadow: 12px 0 32px rgba(0, 0, 0, .35); transform: translateX(-100%); }
  .kpane.open { transform: none; }
  html.kpane-open { --pane-l: var(--kp-w); }
  html.inbox-open { --pane-r: var(--ib-w); }
  .inbox { width: var(--ib-w); }
  body { padding-left: var(--pane-l); padding-right: var(--pane-r); transition: padding .22s cubic-bezier(.2, .8, .2, 1); }
  .dock { left: var(--pane-l); right: var(--pane-r); transition: left .22s cubic-bezier(.2, .8, .2, 1), right .22s cubic-bezier(.2, .8, .2, 1); }
}
@media (min-width: 960px) and (max-width: 1239px) { html.kpane-open.inbox-open { --pane-l: 0px; } }
@media (prefers-reduced-motion: reduce) { body, .dock { transition: none !important; } }
