:root {
  --brand: #002eff;
  --brand-2: #4f9dff;
  --brand-ink: #ffffff;
  --brand-soft: rgba(0, 46, 255, 0.1);
  --bg: #ffffff;
  --surface: #f2f5fa;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #e11d48;
  --snap: #f43f5e;
  --fire: #f97316;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Dark theme: follows the system unless the user picked Light or Dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #4d6bff;
    --brand-soft: rgba(77, 107, 255, 0.2);
    --bg: #0b1120;
    --surface: #162033;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #243049;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #4d6bff;
  --brand-soft: rgba(77, 107, 255, 0.2);
  --bg: #0b1120;
  --surface: #162033;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #243049;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* iPhones, iPads and Macs use Apple's emojis; everyone else gets the Android
   ones (css/emoji.css, switched on in js/theme.js). */
:root {
  --font-text: "Inter Display", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Text style (Settings → Text style): regular text with semibold headings… */
  --w-text: 400;
  --w-heading: 600;
}
/* …or semibold text with bold headings. */
:root[data-text="semibold"] { --w-text: 600; --w-heading: 700; }
/* The emoji font goes first so its colour emojis win over plain ones some text
   fonts have; it only covers emoji characters, so letters and numbers are unchanged. */
:root.android-emoji { --font-text: "KoolKat Emoji", "Inter Display", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html, body { height: 100%; margin: 0; }
body {
  font: var(--w-text) 16px/1.4 var(--font-text);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; }
h1, h2, h3 { margin: 0; }
h1, h2, h3, h4, strong, b, th { font-weight: var(--w-heading); }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.center { align-items: center; justify-content: center; }
.dark { background: #000; color: #fff; }
.muted { color: var(--muted); }
.dark .muted { color: rgba(255, 255, 255, 0.7); }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }
.fineprint { font-size: 13px; color: var(--muted); margin: 8px 0; }

.logo-big { width: 96px; height: 96px; border-radius: 22%; box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 35%, transparent); }
.logo, .brand img, .empty-logo, .dialog-brand img { border-radius: 22%; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: var(--w-heading);
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn { white-space: nowrap; }
.btn.wide { width: 100%; padding: 12px; margin-top: 8px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn.text { font-weight: var(--w-heading); font-size: 18px; }
.icon-btn.plain { background: transparent; color: var(--text); }

/* ---------- auth ---------- */
.auth {
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(79, 157, 255, 0.22), transparent 50%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-card h1 { font-size: 34px; letter-spacing: -0.5px; margin-top: 8px; }
.auth-card form { text-align: left; margin-top: 16px; }
.auth-card label { display: block; font-size: 14px; font-weight: var(--w-heading); margin: 12px 0 0; }
.auth-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.auth-card input:focus { outline: 2px solid var(--brand); border-color: transparent; }

.tabs {
  display: flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  margin-top: 20px;
}
.tabs.inset { margin: 0 16px 8px; }
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 999px;
  font-weight: var(--w-heading);
  color: var(--muted);
}
.tab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }

/* ---------- camera ---------- */
.camera { background: #000; color: #fff; }
.camera video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera video.mirrored { transform: scaleX(-1); }
.camera-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  gap: 12px;
}

.overlay-top, .overlay-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 2;
}
.overlay-top { top: 0; padding-top: calc(12px + var(--safe-top)); }
.overlay-bottom { bottom: 0; padding-bottom: calc(24px + var(--safe-bottom)); }
.overlay-bottom.end { justify-content: flex-end; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--w-heading);
  font-size: 20px;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.brand img { width: 32px; height: 32px; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); }
.logo { width: 26px; height: 26px; flex: none; }
.panel-header h2 { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.empty-logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; opacity: 0.9; }
.dialog-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 13px;
  font-weight: var(--w-heading);
  color: var(--muted);
}
.dialog-brand img { width: 18px; height: 18px; }
.theme-picker { margin-top: 16px; }
.theme-picker .tabs { margin-top: 6px; }

.shutter {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 6px solid #fff;
  background: rgba(255, 255, 255, 0.15);
  transition: transform 0.1s;
}
.shutter:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.45); }
.nav-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  display: grid;
  place-items: center;
}
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--snap);
  color: #fff;
  font-size: 12px;
  font-weight: var(--w-heading);
  line-height: 20px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: var(--w-heading);
  font-size: 15px;
  flex: none;
  text-transform: uppercase;
}
.avatar.large { width: 72px; height: 72px; font-size: 30px; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-edit { position: relative; border: none; background: none; padding: 0; border-radius: 50%; }
.avatar-edit-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}
.link-btn { border: none; background: none; color: var(--brand); font-size: 13px; padding: 4px; }

/* ---------- photo stage (preview + viewer) ---------- */
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.frame { position: relative; }
.frame img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.caption-bar {
  position: absolute;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  text-align: center;
  font-size: 18px;
  padding: 8px 12px;
  overflow-wrap: anywhere;
}
.caption-bar { white-space: pre-wrap; line-height: 1.3; }
/* Long captions wrap onto more lines instead of running off the photo. */
.caption-bar textarea {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  font: inherit;
  font-size: 18px;
  line-height: 1.3;
  resize: none;
  overflow: hidden;
  outline: none;
}
.caption-bar textarea::placeholder { color: rgba(255, 255, 255, 0.6); }
/* The viewer's hint has its own background so it never mixes with a caption,
   moves to the top when the caption is low down, and fades after a moment. */
.viewer-hint {
  left: 16px;
  right: 16px;
  width: fit-content;
  margin: 0 auto;
  bottom: calc(24px + var(--safe-bottom));
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  text-shadow: none;
  transition: opacity 0.6s;
  z-index: 3;
}
.viewer-hint.top { bottom: auto; top: calc(76px + var(--safe-top)); }
.viewer-hint.faded { opacity: 0; }
.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(96px + var(--safe-bottom));
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 4px #000;
  margin: 0;
  pointer-events: none;
}
.viewer-top { justify-content: space-between; background: linear-gradient(rgba(0, 0, 0, 0.5), transparent); }
.viewer-top > div { display: flex; flex-direction: column; }

/* ---------- panels ---------- */
.panel { overflow-y: auto; padding-bottom: calc(24px + var(--safe-bottom)); }
.panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(8px + var(--safe-top)) 8px 8px;
  background: var(--bg);
  text-align: center;
}
.panel-header h2 { font-size: 20px; }
.lock-note { margin: 0 16px 8px; font-size: 13px; color: var(--muted); }
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 20px 16px 6px;
}
.search { padding: 4px 16px 8px; }
.search input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.search input:focus { outline: 2px solid var(--brand); border-color: transparent; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
button.item:active, label.item:active { background: var(--surface); }
label.item:has(input:checked) { background: var(--brand-soft); }
label.item { cursor: pointer; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: var(--w-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.item-actions { display: flex; gap: 6px; }
.item input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 32px 24px; margin: 0; }

.snap-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid var(--snap);
  flex: none;
}
.snap-icon.new { background: var(--snap); }
.snap-icon.sent { border-radius: 0; border: 0; width: 0; height: 0;
  border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 13px solid var(--snap); }
.snap-icon.sent.opened { border-left-color: var(--muted); }
.item-sub.new { color: var(--snap); font-weight: var(--w-heading); }

.load-more { display: flex; justify-content: center; padding: 16px; }
.streak { font-weight: var(--w-heading); color: var(--fire); white-space: nowrap; }
.streak.expiring::after { content: " ⌛"; }
.streak-line { font-size: 18px; font-weight: var(--w-heading); margin: 8px 0; }

.send-bar {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--brand);
  color: #fff;
}
.send-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--w-heading); }
.send-bar .btn { background: #fff; color: var(--brand); border-color: #fff; }

/* ---------- dialogs ---------- */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 24px;
  width: min(92vw, 380px);
  background: var(--bg);
  color: var(--text);
  text-align: center;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin-top: 8px; }
dialog .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.fingerprint {
  display: block;
  font: 600 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  border-radius: 10px;
  padding: 10px;
  word-spacing: 4px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: rgba(20, 18, 30, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 40; /* above the call screen */
  text-align: center;
}
.toast.error { background: var(--danger); }
.boot-error { max-width: 420px; padding: 24px 16px; text-align: center; }
.boot-error .fineprint { overflow-wrap: anywhere; }
.camera-info { margin-top: 12px; text-align: left; font-size: 13px; color: var(--muted); }
.camera-info summary { cursor: pointer; }
.camera-info pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  background: var(--surface);
  border-radius: 10px;
  padding: 8px;
  user-select: text;
}
#screen-send { padding-bottom: 0; }
.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.notify-text { display: flex; flex-direction: column; }
.notify-text .fineprint { margin: 2px 0 0; }
.notify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  font-size: 14px;
  font-weight: var(--w-heading);
}
.notify-banner .icon-btn { width: 32px; height: 32px; }
.notify-banner svg { width: 18px; height: 18px; }

/* ---------- KoolKat Unlimited ---------- */
.kool-badge { height: 0.95em; width: auto; margin-left: 5px; vertical-align: -0.1em; }
.flair-line { margin: 2px 0 8px; color: var(--flair, var(--brand)); font-weight: var(--w-heading); font-style: italic; overflow-wrap: anywhere; }
dialog { max-height: 90dvh; overflow-y: auto; }
.storage-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(225, 29, 72, 0.12);
  color: var(--danger);
  font-size: 14px;
  font-weight: var(--w-heading);
  text-align: left;
}
.plan-card {
  margin: 16px 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-head { display: flex; flex-direction: column; }
.plan-head strong { display: flex; align-items: center; font-size: 17px; }
.plan-head .fineprint { margin: 2px 0 0; }
.storage .fineprint { margin: 4px 0 0; display: block; }
.storage-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.storage-bar span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; }
.storage-bar span.full { background: var(--danger); }
.perks { list-style: none; margin: 0; padding: 0; font-size: 14px; display: grid; gap: 4px; }
.plan-card .btn.wide { margin-top: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input, .admin-form input, .social-field input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.inline-form input:focus, .admin-form input:focus, .social-field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.admin-form { padding: 0 16px; }
.admin-form label { display: block; font-size: 14px; font-weight: var(--w-heading); margin: 10px 0 0; }
.admin-form label .fineprint { display: block; font-weight: var(--w-text); margin: 2px 0 0; }
.admin-form input { display: block; width: 100%; margin-top: 6px; background: var(--surface); }
.admin-form .row { display: flex; gap: 8px; margin-top: 12px; }
.admin-form .row.wrap { flex-wrap: wrap; }
.admin-form .btn.wide { margin-top: 14px; }
.code-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
#btn-request-open { white-space: normal; line-height: 1.25; }

/* ---------- home bar, favorites ---------- */
.nav-group { display: flex; gap: 10px; }
.viewer-actions { display: flex; gap: 8px; }
#btn-snap-favorite .star-full { display: none; color: #facc15; }
#btn-snap-favorite[aria-pressed="true"] .star-full { display: block; }
#btn-snap-favorite[aria-pressed="true"] .star-empty { display: none; }
.fav-star { color: #eab308; font-size: 18px; flex: none; }

/* ---------- chats ---------- */
.chat-actions { display: flex; gap: 8px; padding: 4px 16px 8px; }
.chat-actions .btn { flex: 1; }
.group-avatar { background: linear-gradient(135deg, var(--brand-2), var(--brand)); font-size: 16px; }
.unread-dot {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: var(--w-heading);
  line-height: 22px;
  text-align: center;
  flex: none;
}
.item-sub.unread { color: var(--text); font-weight: var(--w-heading); }
dialog .row.wrap { flex-wrap: wrap; }

.chat-screen { background: var(--bg); }
.chat-screen .panel-header { border-bottom: 1px solid var(--border); flex: none; grid-template-columns: auto 1fr auto; }
.chat-title { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.chat-title h2 { font-size: 18px; display: flex; align-items: center; max-width: 100%; }
.chat-title .fineprint { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.messages { flex: 1; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; }
.load-older { align-self: center; margin-bottom: 8px; }
.message-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.message { display: flex; flex-direction: column; align-items: flex-start; max-width: 80%; }
.message.mine { align-self: flex-end; align-items: flex-end; }
.message .sender { font-size: 12px; color: var(--muted); margin: 6px 10px 2px; display: flex; align-items: center; }
.bubble {
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.mine .bubble { background: var(--brand); color: #fff; }
.message .time { font-size: 11px; color: var(--muted); margin: 2px 10px 0; }
.message.failed .bubble { opacity: 0.6; font-style: italic; }
.composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.composer input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.composer .btn { padding: 10px 14px; }

/* ---------- free Unlimited requests ---------- */
.upsell-note { margin: 0 0 6px; }
#request-form { display: grid; gap: 6px; }
#request-form .fineprint { margin: 0; }
textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.request-status { margin: 0; font-size: 14px; font-weight: var(--w-heading); color: var(--brand); }
.request-msg { font-style: italic; overflow-wrap: anywhere; }

/* ---------- news ---------- */
.top-actions { display: flex; gap: 8px; }
.top-actions .icon-btn { position: relative; }
.news-compose { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.news-compose textarea { margin-top: 6px; background: var(--surface); }
.section-title.flush { margin: 12px 0 0; }
.admin-form label.check { display: flex; align-items: center; gap: 8px; font-weight: var(--w-text); }
.admin-form label.check input { width: auto; margin: 0; flex: none; }
.news-list { list-style: none; margin: 0; padding: 8px 16px; display: grid; gap: 12px; }
.news-post { background: var(--surface); border-radius: 14px; padding: 14px; }
.news-post h3 { font-size: 17px; margin: 0 0 4px; overflow-wrap: anywhere; }
.news-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.news-body { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.news-code { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-code code {
  font: 700 15px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px dashed var(--brand);
  border-radius: 8px;
  padding: 6px 10px;
  letter-spacing: 0.05em;
}
.news-post .btn.danger { margin-top: 10px; }

/* ---------- installed app ---------- */
.app-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(calc(100vw - 24px), 460px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: var(--w-heading);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
.update-bar { bottom: calc(16px + var(--safe-bottom)); background: var(--brand); color: #fff; }
.update-bar .btn { background: #fff; color: var(--brand); border-color: #fff; }
.offline-bar { top: calc(64px + var(--safe-top)); background: #1f2937; color: #fff; justify-content: center; text-align: center; }
/* Installed app (standalone): leave room for the status bar. */
@media (display-mode: standalone) {
  .toast { bottom: calc(130px + var(--safe-bottom)); }
}

/* ---------- Unlimited personalisation ---------- */
.bff-heart { height: 1em; width: auto; vertical-align: -0.12em; margin-left: 4px; flex: none; }
.item > .bff-heart { height: 20px; margin: 0; }
.bff-title { display: flex; align-items: center; gap: 4px; }
.extras-title { margin: 6px 0 4px; font-weight: var(--w-heading); color: var(--text); }
.icon-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.icon-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--bg);
  font-size: 12px;
  font-weight: var(--w-heading);
}
.icon-choice img, .icon-plus {
  width: 48px;
  height: 48px;
  border-radius: 22%;
  object-fit: cover;
}
.icon-plus { display: grid; place-items: center; background: var(--border); font-size: 24px; color: var(--muted); }
.icon-choice[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
#icon-note { margin: 6px 0 0; }
#btn-icon-upload { margin-top: 8px; }
.badge-editor { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-preview { display: grid; place-items: center; width: 48px; height: 40px; border-radius: 10px; background: var(--bg); }
.badge-preview img { max-width: 40px; max-height: 32px; }
#btn-friend-bff[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }

/* ---------- KatCam ---------- */
.katcam-inset {
  position: absolute;
  top: calc(72px + var(--safe-top));
  left: 16px;
  width: 30%;
  max-width: 180px;
  aspect-ratio: 3 / 4;
  border: 3px solid #fff;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 1;
}
.camera .katcam-inset video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.katcam-later {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: var(--w-heading);
  line-height: 1.6;
}
.katcam-status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(120px + var(--safe-bottom));
  margin: 0;
  text-align: center;
  font-weight: var(--w-heading);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  z-index: 2;
}
#btn-katcam[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* ---------- adding friends: QR & Nearby ---------- */
.add-ways { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 8px; }
.add-ways .btn { flex: 1 1 auto; }
.qr-box { display: grid; place-items: center; margin: 8px 0; }
.qr-box canvas { width: min(70vw, 296px); height: auto; aspect-ratio: 1; border-radius: 16px; background: #fff; }
#btn-profile-qr { margin: 0 0 10px; }
.scan-screen .brand { font-size: 16px; }
.scan-frame {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(64vw, 280px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 1;
}
.scan-status {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(45% + min(32vw, 140px) + 20px);
  margin: 0;
  text-align: center;
  font-weight: var(--w-heading);
  z-index: 2;
}
.scan-actions { justify-content: center; }
.nearby-note { margin: 0 16px 8px; color: var(--muted); font-size: 14px; }
.nearby-status { margin: 0 16px 8px; font-weight: var(--w-heading); }

/* ---------- Activity Bubbles ---------- */
.activity-bubble {
  display: inline-block;
  max-width: 100%;
  margin: 2px 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--text);
  font-weight: var(--w-heading);
  overflow-wrap: anywhere;
}
.activity-bubble.small { margin: 2px 0 0; padding: 1px 8px; font-size: 12px; }
.chat-title .activity-bubble { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-editor { display: flex; flex-direction: column; gap: 6px; }
.activity-editor .fineprint { margin: 0; }
.emoji-row { display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-chip {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--bg);
  font-size: 20px;
}
.emoji-chip[aria-checked="true"] { border-color: var(--brand); }
.emoji-input { width: 56px; flex: none; text-align: center; }
.activity-editor select { flex: 1; min-width: 0; }

/* ---------- chat themes ---------- */
.theme-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--bg);
  font-size: 12px;
  font-weight: var(--w-heading);
}
.swatch[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
.swatch-fill {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center;
  color: var(--muted);
  font-size: 20px;
}
#swatch-color { background: var(--chat-custom-bg, linear-gradient(135deg, #f43f5e, #f59e0b, #10b981, #3b82f6, #a855f7)); }
#swatch-image { background-image: var(--chat-image, none); }
.bubble-row { align-items: center; margin-top: 8px; }
.bubble-row label { flex: 1; margin: 0; }
input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; }
.chat-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.chat-preview .bubble { max-width: 80%; font-size: 14px; }
.chat-preview .bubble.mine { align-self: flex-end; background: var(--bubble-mine, var(--brand)); color: var(--bubble-mine-text, var(--brand-ink)); }
.chat-preview .bubble.theirs { align-self: flex-start; }
.message.mine .bubble { background: var(--bubble-mine, var(--brand)); color: var(--bubble-mine-text, var(--brand-ink)); }

.bg-default { background: var(--bg); }
.bg-midnight, .messages[data-bg="midnight"], .chat-preview[data-bg="midnight"] { background: linear-gradient(160deg, #0f172a, #1e1b4b 60%, #312e81); }
.bg-sunset, .messages[data-bg="sunset"], .chat-preview[data-bg="sunset"] { background: linear-gradient(160deg, #fb7185, #f59e0b); }
.bg-ocean, .messages[data-bg="ocean"], .chat-preview[data-bg="ocean"] { background: linear-gradient(160deg, #0ea5e9, #1e3a8a); }
.bg-forest, .messages[data-bg="forest"], .chat-preview[data-bg="forest"] { background: linear-gradient(160deg, #166534, #4d7c0f); }
.bg-candy, .messages[data-bg="candy"], .chat-preview[data-bg="candy"] { background: linear-gradient(160deg, #f9a8d4, #c4b5fd 55%, #93c5fd); }
.messages[data-bg="color"], .chat-preview[data-bg="color"] { background: var(--chat-custom-bg); }
.messages[data-bg="image"], .chat-preview[data-bg="image"] { background: var(--chat-image) center / cover no-repeat, #000; }
/* Times, names and the "older" button stay readable on any background. */
.messages[data-bg]:not([data-bg="default"]) .time,
.messages[data-bg]:not([data-bg="default"]) .sender {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.messages[data-bg]:not([data-bg="default"]) .message:not(.mine) .bubble,
.chat-preview[data-bg]:not([data-bg="default"]) .bubble.theirs { background: rgba(255, 255, 255, 0.92); color: #0f172a; }

/* ---------- Kat Map ---------- */
.katmap-screen { background: var(--bg); }
.katmap-screen .panel-header { flex: none; }
.katmap { flex: 1; min-height: 0; background: var(--surface); z-index: 0; }
.katmap-locked { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; text-align: center; }
.katmap-sheet {
  flex: none;
  max-height: 40%;
  overflow-y: auto;
  padding: 12px 0 calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.katmap-sheet .tabs { margin: 0 16px; }
#katmap-status { margin: 8px 16px 0; }
.katmap-list { margin-top: 4px; }
.kat-pin { background: none; border: none; }
.kat-pin .pin-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--brand);
  color: #fff;
  font-weight: var(--w-heading);
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.kat-pin.me .pin-avatar { background: #10b981; }
.kat-pin .pin-name {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 12px;
  font-weight: var(--w-heading);
}
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- Calls and FaceTime ---------- */
.chat-actions { display: flex; align-items: center; justify-content: flex-end; min-width: 44px; }
.call-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(48px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 30%, #1e3a8a, #0b1120 70%);
  color: #fff;
  text-align: center;
}
.call-screen > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-screen > .call-local {
  inset: auto 16px auto auto;
  top: calc(16px + var(--safe-top));
  width: 28vw;
  max-width: 160px;
  height: auto;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  z-index: 2;
}
.call-screen video.mirrored { transform: scaleX(-1); }
/* FaceTime before it connects: your own camera fills the screen. */
.call-screen[data-kind="video"]:not(.has-video) > .call-local {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  border: none;
  border-radius: 0;
  z-index: 0;
}
.call-info { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.call-screen.has-video .call-info { text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
.call-screen.has-video .call-avatar, .call-screen.has-video .call-lock { display: none; }
.call-kind { font-size: 14px; font-weight: var(--w-heading); opacity: 0.85; }
.call-avatar { width: 112px; height: 112px; font-size: 48px; margin: 12px 0 4px; }
.call-info h2 { margin: 0; font-size: 28px; }
.call-status { margin: 0; font-size: 17px; opacity: 0.9; font-variant-numeric: tabular-nums; }
.call-lock, .call-peer-camera-off { margin: 4px 0 0; font-size: 13px; opacity: 0.75; }
.call-controls { position: relative; z-index: 1; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.call-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  color: #fff;
  font-size: 13px;
  font-weight: var(--w-heading);
}
.call-btn svg {
  box-sizing: content-box;
  width: 28px;
  height: 28px;
  padding: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  fill: currentColor;
}
.call-btn[aria-pressed="true"] svg { background: #fff; fill: #0b1120; }
.call-btn.accept svg { background: #22c55e; }
.call-btn.decline svg { background: #ef4444; transform: rotate(135deg); }
#call-incoming-controls { gap: 72px; }
body.in-call { overflow: hidden; }

/* ---------- text style picker ---------- */
.text-styles .tab { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2; padding-top: 6px; padding-bottom: 6px; }
.text-styles .tab span { font-size: 13px; }
/* Each choice previews itself. */
.text-style-regular .text-style-text { font-weight: 400; }
.text-style-regular .text-style-headings { font-weight: 600; }
.text-style-semibold .text-style-text { font-weight: 600; }
.text-style-semibold .text-style-headings { font-weight: 700; }

/* ---------- News photos and videos ---------- */
.news-media {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin: 10px 0 4px;
  border-radius: 12px;
  object-fit: contain;
  background: #000;
}
img.news-media { background: var(--surface); }
.news-attach { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 4px 0 8px; }
.news-attach .fineprint { margin: 0; }
.news-media-preview { width: 100%; }
.news-media-preview .news-media { max-height: 240px; margin-top: 4px; }
.upload-progress { height: 6px; margin: 8px 0; border-radius: 999px; background: var(--surface); overflow: hidden; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }

/* ---------- News: style switch ---------- */
.news-modes, .favorites-tabs { margin: 4px 16px 8px; flex: none; }
.avatar.small { width: 24px; height: 24px; font-size: 11px; }
.author-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: var(--w-heading);
}
.author-link .kool-badge { height: 14px; }
.admin-tag { margin: 0 0 6px; font-size: 13px; font-weight: var(--w-heading); color: var(--brand); }

/* ---------- News: Formal (a newspaper article) ---------- */
.news-formal { gap: 0; padding: 0 20px 24px; }
.news-formal .article {
  background: none;
  border-radius: 0;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  font-family: Georgia, "Times New Roman", Times, serif;
}
.news-formal .article:first-child { border-top: 3px double var(--text); }
.article-kicker {
  margin: 0 0 6px;
  font-family: var(--font-text);
  font-size: 11px;
  font-weight: var(--w-heading);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.news-formal .article-headline {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.article-byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--muted);
}
.article-byline .byline-author { color: var(--text); }
.article-date { white-space: nowrap; }
.news-formal .news-media { border-radius: 0; margin: 4px 0 14px; max-height: 60vh; }
.article-body p {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.article-body.drop-cap p:first-child::first-letter {
  float: left;
  font-size: 3.1em;
  line-height: 0.9;
  padding: 4px 6px 0 0;
  font-weight: 700;
}
.article-actions { clear: both; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-family: var(--font-text); }
.article-actions .btn.danger { margin-top: 0; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.reaction[aria-pressed="true"] { border-color: var(--brand); }

/* ---------- News: TikTok (full-screen feed) ---------- */
#screen-news.news-tiktok { background: #000; color: #fff; overflow: hidden; padding-bottom: 0; }
#screen-news.news-tiktok .panel-header { background: #000; color: #fff; }
#screen-news.news-tiktok .panel-header .icon-btn.plain { color: #fff; }
#screen-news.news-tiktok .news-modes { background: rgba(255, 255, 255, 0.12); }
#screen-news.news-tiktok .news-modes .tab { color: rgba(255, 255, 255, 0.75); }
#screen-news.news-tiktok .news-modes .tab.active { background: #fff; color: #000; }
#screen-news.news-tiktok #news-empty { display: none; }
.tiktok-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.tiktok-feed::-webkit-scrollbar { display: none; }
.tt-post {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #000;
}
.tt-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
img.tt-media { object-fit: contain; background: #111; }
.tt-plain { background: radial-gradient(circle at 30% 20%, var(--brand-2), var(--brand) 45%, #0b1120 100%); }
.tt-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.1) 45%, transparent 60%);
}
.tt-info {
  position: absolute;
  left: 16px;
  right: 84px;
  bottom: calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.tt-author { font-size: 16px; color: #fff; }
.tt-author .avatar { border: 2px solid #fff; width: 32px; height: 32px; font-size: 14px; }
.tt-text { max-height: 4.6em; overflow: hidden; }
.tt-title { margin: 0; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.tt-body { margin: 4px 0 0; font-size: 15px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.tt-post.expanded .tt-text { max-height: 45vh; overflow-y: auto; }
.tt-post.expanded .tt-shade { background: rgba(0, 0, 0, 0.6); }
.tt-more { border: none; background: none; padding: 0; color: #fff; font: inherit; font-weight: var(--w-heading); opacity: 0.9; }
.tt-date { font-size: 12px; opacity: 0.75; }
.tt-info .news-code code { color: var(--text); text-shadow: none; }
.tt-rail {
  position: absolute;
  right: 10px;
  bottom: calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.tt-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: var(--w-heading);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.tt-action .reaction-icon { font-size: 34px; line-height: 1; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5)); }
.tt-empty { height: 100%; display: grid; place-items: center; padding: 24px; text-align: center; opacity: 0.8; }

/* ---------- birthdays ---------- */
.birthday-pop { margin-left: 4px; font-size: 0.95em; }
.name-marks { display: inline-flex; align-items: center; }
.birthday-hero { font-size: 56px; line-height: 1; margin-bottom: 6px; }
.birthday-why { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.birthday-why strong { color: var(--text); }
.birthday-pick { display: flex; gap: 10px; justify-content: center; }
.birthday-pick label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); text-align: left; }
.birthday-pick select {
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}
#btn-profile-birthday { margin: 0 0 10px; }

/* ---------- News polls ---------- */
.poll { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; font-family: var(--font-text); }
.poll-question { margin: 0; font-weight: var(--w-heading); }
.poll-option {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  overflow: hidden;
}
.poll-option > span { position: relative; z-index: 1; }
/* After voting: each choice fills to its share of the votes. */
.poll.voted .poll-option::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--brand-soft);
  transition: width 0.4s;
}
.poll-option.mine { border-color: var(--brand); font-weight: var(--w-heading); }
.poll-pct { font-variant-numeric: tabular-nums; font-weight: var(--w-heading); }
.poll-total { margin: 0; font-size: 12px; color: var(--muted); }
.tt-info .poll { width: 100%; margin: 4px 0; text-shadow: none; }
.tt-info .poll-option { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.35); color: #fff; padding: 8px 12px; }
.tt-info .poll.voted .poll-option::before { background: rgba(255, 255, 255, 0.3); }
.tt-info .poll-option.mine { border-color: #fff; }
.tt-info .poll-total { color: rgba(255, 255, 255, 0.8); }
.poll-editor { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 4px 0 8px; }
#news-poll-fields { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.poll-option-inputs { display: grid; gap: 6px; }
#news-poll-note { margin: 0; }

/* ---------- comments (a sheet from the bottom) ---------- */
dialog.sheet {
  text-align: left;
  width: 100%;
  max-width: 560px;
  height: min(80vh, 640px);
  margin: auto auto 0;
  padding: 0;
  border-radius: 20px 20px 0 0;
  display: none;
  flex-direction: column;
}
dialog.sheet[open] { display: flex; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 17px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-list { list-style: none; margin: 0; padding: 8px 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
#comments-empty { flex: 1; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-avatar { border: none; background: none; padding: 0; }
.comment-main { min-width: 0; flex: 1; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-time { font-size: 12px; color: var(--muted); }
.comment-body { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-delete { padding: 2px 0; color: var(--danger); }
.comment-composer { align-items: flex-end; }
.comment-composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* ---------- verified badge and social links ---------- */
.verified-badge { height: 0.95em; width: 0.95em; margin-left: 5px; vertical-align: -0.12em; border-radius: 50%; }
.author-link .verified-badge { height: 14px; width: 14px; }
.section-title .verified-badge { margin: 0 4px 0 0; }
.name-marks .verified-badge + .kool-badge { margin-left: 3px; }
.social-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 8px 0 10px; }
.social-link { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; transition: transform 0.15s; }
.social-link:active { transform: scale(0.92); }
.social-link img { width: 100%; height: 100%; border-radius: 50%; }
.socials-dialog form { text-align: left; }
.social-field { display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; margin: 10px 0; }
.social-field img { grid-row: 1 / 3; width: 28px; height: 28px; border-radius: 50%; }
.social-field span { font-size: 0.85em; opacity: 0.75; }
.social-field input { width: 100%; }

/* ---------- tab bar (Home, Reels, Camera, Klicks, Chats) ---------- */
:root { --tabbar-h: 58px; }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.tabbar[hidden] { display: none; }
.tabbar.dark { background: #000; border-top-color: #1f1f1f; }
.tab-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  padding: 6px 0;
}
.tab-btn svg { width: 25px; height: 25px; fill: currentColor; }
.tab-btn.active { color: var(--text); font-weight: var(--w-heading); }
.tabbar.dark .tab-btn { color: rgba(255, 255, 255, 0.6); }
.tabbar.dark .tab-btn.active { color: #fff; }
.tab-btn .badge { top: 0; right: calc(50% - 26px); }
.tab-camera-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: var(--brand-ink);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 35%, transparent);
}
.tab-camera-icon svg { width: 22px; height: 22px; }
.has-tabbar .tabbed.panel,
.has-tabbar .home-feed { padding-bottom: calc(var(--tabbar-h) + 16px + var(--safe-bottom)); }
.has-tabbar .toast { bottom: calc(var(--tabbar-h) + 16px + var(--safe-bottom)); }
.tabbed .tab-hidden-back { visibility: hidden; }

/* The camera is just the camera now. */
.overlay-bottom.camera-bottom { justify-content: center; }

/* ---------- Home ---------- */
.home-screen { background: var(--bg); }
.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(6px + var(--safe-top)) 8px 2px 14px;
}
.home-brand { display: inline-flex; align-items: center; gap: 7px; font-size: 21px; font-weight: 700; letter-spacing: -0.5px; }
.home-brand .logo { width: 28px; height: 28px; }
.home-actions { display: flex; align-items: center; }
.home-actions .icon-btn { position: relative; width: 42px; height: 42px; }
.home-actions .icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.home-actions .badge { top: 2px; right: 2px; }
.home-actions .avatar { width: 30px; height: 30px; font-size: 14px; }
.chips {
  display: flex;
  gap: 8px;
  padding: 8px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 0;
  border-radius: 8px;
  padding: 7px 13px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: var(--w-heading);
}
.chip.active { background: var(--text); color: var(--bg); }
.home-feed { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.home-empty { margin: 8px 14px 16px; color: var(--muted); font-size: 14px; }
.home-klicks {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 28px);
  margin: 4px 14px 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--text);
  font: inherit;
  font-weight: var(--w-heading);
  text-align: left;
}
.home-klicks[hidden] { display: none; }
.home-klicks-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--snap); flex: none; }
.home-klicks-go { margin-left: auto; color: var(--brand); }
.shelf { margin-bottom: 14px; }
.shelf-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 14px 10px;
  font-size: 18px;
  font-weight: 700;
}
.shelf-title .clapper { width: 22px; height: 22px; fill: var(--snap); }
.shelf-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 14px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-reel {
  flex: none;
  width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  scroll-snap-align: start;
}
.shelf-reel-poster {
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}
.shelf-reel-poster img, .shelf-reel-poster video,
.reel-thumb img, .reel-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.shelf-reel-caption {
  font-size: 14px;
  font-weight: var(--w-heading);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shelf-reel-meta { font-size: 12px; color: var(--muted); }
.friends-row { gap: 14px; }
.home-friend {
  flex: none;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--text);
  font: inherit;
}
.home-friend-ring { padding: 2px; border-radius: 50%; border: 2px solid var(--border); }
.home-friend-ring.streak { border-color: var(--fire); }
.home-friend-ring.add .avatar { background: var(--surface); color: var(--text); font-size: 26px; }
.home-friend-ring .avatar { width: 56px; height: 56px; font-size: 22px; }
.home-friend-name { font-size: 12px; max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-friend-streak { font-size: 11px; color: var(--fire); margin-top: -3px; }
.home-news .shelf-title { margin-top: 10px; }
.home-card { margin-bottom: 18px; }
.home-card-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  background: #111;
  overflow: hidden;
}
.home-card-thumb > img, .home-card-thumb > video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
@media (min-width: 600px) {
  .home-card { margin: 0 14px 22px; }
  .home-card-thumb { border-radius: 14px; }
}
.home-card-title-art {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--brand) 0%, #6a3dff 55%, var(--snap) 120%);
  color: #fff;
  text-align: left;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.home-card-title-art img { width: 34px; height: 34px; border-radius: 22%; }
.home-card-title-art span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.home-card-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
}
.home-card-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: var(--w-heading);
}
.home-card-info { display: flex; gap: 12px; padding: 10px 14px 0; }
.home-card-avatar { border: 0; padding: 0; background: none; flex: none; height: 36px; }
.home-card-avatar img.avatar { width: 36px; height: 36px; border-radius: 50%; }
.home-card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.home-card-headline {
  font-size: 16px;
  font-weight: var(--w-heading);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-card-meta { font-size: 13px; color: var(--muted); }

/* ---------- KoolKat Reels ---------- */
.reels-screen { background: #000; color: #fff; }
.has-tabbar .reels-screen { bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
.reels-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 10px 8px 14px;
  pointer-events: none;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}
.reels-top > * { pointer-events: auto; }
.reels-top h2 { display: flex; align-items: center; gap: 8px; margin: 0 auto 0 0; font-size: 19px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.clapper { width: 24px; height: 24px; fill: currentColor; flex: none; }
.reels-top .clapper { fill: #fff; }
.reels-top .icon-btn svg { width: 26px; height: 26px; fill: #fff; }
.reels-feed {
  flex: 1;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.reels-feed::-webkit-scrollbar { display: none; }
.reel {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}
.reel-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.reel-video { width: 100%; height: 100%; object-fit: cover; background: #000; }
@media (min-aspect-ratio: 3/4) { .reel-video { object-fit: contain; } }
.reel-paused {
  position: absolute;
  font-size: 64px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.reel-burst {
  position: absolute;
  font-size: 110px;
  color: var(--snap);
  pointer-events: none;
  animation: reel-burst 0.8s ease-out forwards;
}
@keyframes reel-burst {
  0% { transform: scale(0.3); opacity: 0; }
  25% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1) translateY(-40px); opacity: 0; }
}
.reel-rail {
  position: absolute;
  right: 8px;
  bottom: 20px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.reel-author-pic { border: 2px solid #fff; border-radius: 50%; padding: 0; background: none; margin-bottom: 4px; }
.reel-author-pic .avatar { width: 46px; height: 46px; font-size: 20px; display: grid; }
.reel-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 22px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  padding: 0;
}
.reel-icon { font-size: 30px; line-height: 1; }
.reel-like .reel-icon { font-size: 36px; }
.reel-like.on .reel-icon { color: var(--snap); }
.reel-count { font-size: 13px; font-weight: var(--w-heading); }
.reel-info {
  position: absolute;
  left: 0;
  right: 72px;
  bottom: 0;
  z-index: 2;
  padding: 40px 14px 18px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.reel-author {
  display: inline-flex;
  align-items: center;
  border: 0;
  padding: 0;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.reel-time { font-weight: 400; opacity: 0.8; font-size: 14px; }
.reel-caption {
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.reel-caption.open { -webkit-line-clamp: unset; display: block; }
.reels-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}
.reels-empty[hidden] { display: none; }
.reels-empty .clapper { width: 64px; height: 64px; fill: var(--snap); margin-bottom: 8px; }
.reels-empty .fineprint { color: rgba(255, 255, 255, 0.6); }
.reel-new-dialog video { display: block; width: 100%; max-height: 46vh; border-radius: 12px; background: #000; margin: 8px 0 10px; }
.reel-new-dialog form { text-align: left; }
.reel-new-dialog textarea { width: 100%; }

/* ---------- profile pages ---------- */
.user-page { background: var(--bg); }
.up-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(6px + var(--safe-top)) 8px 4px;
  background: var(--bg);
}
.up-top .icon-btn svg { width: 26px; height: 26px; fill: currentColor; }
.up-title {
  margin: 0;
  text-align: center;
  font-size: clamp(26px, 9vw, 40px);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.up-title .name-marks, .up-title .verified-badge, .up-title .kool-badge { vertical-align: middle; }
.up-title .verified-badge { height: 0.6em; width: 0.6em; }
.up-title .kool-badge { height: 0.6em; }
.up-head { display: flex; flex-direction: column; align-items: center; padding: 6px 16px 0; text-align: center; }
.avatar.xlarge { width: 104px; height: 104px; font-size: 44px; }
.up-username { margin: 10px 0 2px; font-size: 18px; font-weight: var(--w-heading); }
.up-head .flair-line, .up-head .activity-bubble, .up-head .admin-tag { margin: 4px 0; }
.up-stats { display: flex; justify-content: center; margin: 12px 0 14px; }
.up-stats > div { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 0 10px; }
.up-stats > div + div { border-left: 1px solid var(--border); }
.up-stats strong { font-size: 20px; font-weight: 700; }
.up-stats span { font-size: 14px; color: var(--muted); }
.up-actions { display: flex; gap: 8px; width: 100%; max-width: 420px; justify-content: center; }
.up-btn { flex: 1; border-radius: 8px; padding: 11px 10px; font-size: 16px; border: 0; background: var(--surface); }
.up-btn.primary { background: var(--brand); color: var(--brand-ink); }
.up-btn.snap { background: var(--snap); }
.up-btn-more { flex: 0 0 48px; font-size: 18px; }
.up-more { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.up-more[hidden] { display: none; }
.up-head .social-row { margin-top: 14px; }
.up-head #up-joined { margin: 6px 0 4px; }
.up-tabs { display: flex; justify-content: center; border-bottom: 1px solid var(--border); margin-top: 8px; }
.up-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  font-weight: var(--w-heading);
  border-bottom: 2px solid var(--text);
  margin-bottom: -1px;
}
.up-tab .clapper { width: 18px; height: 18px; }
.reel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.reel-grid[hidden] { display: none; }
.home-feed .reel-grid { padding: 0 14px; gap: 6px; }
.home-feed .reel-thumb { border-radius: 10px; }
.reel-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  border: 0;
  padding: 0;
  background: #111;
  overflow: hidden;
}
.reel-thumb-views {
  position: absolute;
  left: 6px;
  bottom: 5px;
  color: #fff;
  font-size: 13px;
  font-weight: var(--w-heading);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
#up-empty { text-align: center; margin: 24px 16px; }
.reel-heart { width: 38px; height: 38px; fill: #fff; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5)); transition: transform 0.15s; }
.reel-like.on .reel-heart { fill: var(--snap); }
.reel-like:active .reel-heart { transform: scale(0.85); }
.shelf-reel { width: 132px; }

/* ---------- accent colour (Unlimited) ---------- */
.accent-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 8px; }
.accent-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  background: var(--swatch);
  padding: 0;
}
.accent-swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.accent-row { display: flex; align-items: center; gap: 8px; }
.accent-row input[type="color"] { width: 44px; height: 36px; flex: none; }
.accent-row input.accent-hex {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}
.accent-row input.accent-hex:focus { outline: 2px solid var(--brand); border-color: transparent; }

/* Flair in someone's accent colour stays readable on the dark theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .flair-line { color: color-mix(in srgb, var(--flair, var(--brand)) 75%, #fff); }
}
:root[data-theme="dark"] .flair-line { color: color-mix(in srgb, var(--flair, var(--brand)) 75%, #fff); }

/* ---------- KoolKat Music (like Spotify) ---------- */
.note-icon { width: 22px; height: 22px; fill: currentColor; flex: none; }
.shelf-title .note-icon { fill: var(--brand); }
.music-screen { background: #121212; color: #fff; }
.music-top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(6px + var(--safe-top)) 6px 4px;
}
.music-top h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 0 4px; font-size: 22px; font-weight: 800; grid-column: 1 / 3; }
#btn-music-back:not([hidden]) + h2 { grid-column: 2; }
.music-top .icon-btn { color: #fff; }
.music-top .icon-btn svg { width: 26px; height: 26px; fill: currentColor; }
.music-top .note-icon { width: 26px; height: 26px; fill: var(--brand-2); }
.music-body { flex: 1; overflow-y: auto; padding: 0 14px calc(24px + var(--safe-bottom)); overscroll-behavior: contain; }
.has-tabbar .music-body { padding-bottom: calc(var(--tabbar-h) + 16px + var(--safe-bottom)); }
.music-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 14px;
  padding: 0 12px;
  border-radius: 8px;
  background: #fff;
  color: #121212;
}
.music-search svg { width: 22px; height: 22px; fill: #121212; flex: none; }
.music-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 12px 0; font: inherit; font-weight: var(--w-heading); color: #121212; outline: none; }
.liked-songs {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #2a2a2a;
  color: #fff;
  font: inherit;
  text-align: left;
}
.liked-songs-art {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand), #c4b5fd);
  font-size: 24px;
}
.liked-songs-text { display: flex; flex-direction: column; }
.liked-songs-text span { font-size: 13px; color: #b3b3b3; }
.music-heading { margin: 22px 0 10px; font-size: 20px; font-weight: 800; }
.music-heading[hidden], .music-row[hidden] { display: none; }
.music-row, #home-music { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.music-row::-webkit-scrollbar { display: none; }
.song-card {
  flex: none;
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.song-card-cover { width: 140px; height: 140px; border-radius: 6px; }
.song-card-title { font-size: 14px; font-weight: var(--w-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-card-sub { font-size: 13px; color: #b3b3b3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-screen .song-card-sub, .user-page .song-card-sub { color: var(--muted); }
.song-cover {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: rgba(255, 255, 255, 0.9);
  flex: none;
}
.song-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.song-cover .note-icon { width: 40%; height: 40%; }
.song-list { list-style: none; margin: 0; padding: 0; }
.song-list[hidden] { display: none; }
.home-screen .song-list, .user-page .song-list { padding: 0 14px; }
.song-row { display: flex; align-items: center; gap: 8px; }
.song-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.song-thumb { width: 50px; height: 50px; border-radius: 4px; }
.song-text { display: flex; flex-direction: column; min-width: 0; }
.song-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row.playing .song-title { color: var(--brand-2); font-weight: var(--w-heading); }
.song-sub { display: flex; align-items: center; gap: 4px; font-size: 13px; color: #b3b3b3; white-space: nowrap; overflow: hidden; }
.home-screen .song-sub, .user-page .song-sub { color: var(--muted); }
.song-tag { padding: 0 4px; border-radius: 2px; background: #b3b3b3; color: #121212; font-size: 10px; font-weight: 700; }
.song-like, .mini-btn, .player-like {
  border: 0;
  background: none;
  color: #b3b3b3;
  font-size: 22px;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
}
.home-screen .song-like, .user-page .song-like { color: var(--muted); }
.song-like.on, .mini-btn.on, .player-like.on { color: var(--brand-2) !important; }
.home-screen .song-row.playing .song-title, .user-page .song-row.playing .song-title, .home-screen .song-like.on, .user-page .song-like.on { color: var(--brand) !important; }
.music-empty { color: #b3b3b3; text-align: center; margin: 24px 0; }
.music-empty[hidden] { display: none; }

/* Mini player: stays while you use the rest of KoolKat. */
.mini-player {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  padding: 0 4px 0 8px;
  border-radius: 8px;
  background: #2b2b2b;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.mini-player[hidden] { display: none; }
.has-tabbar .mini-player { bottom: calc(var(--tabbar-h) + 6px + var(--safe-bottom)); }
.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; padding: 0; background: none; color: inherit; font: inherit; text-align: left; }
.mini-cover { width: 40px; height: 40px; border-radius: 4px; }
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-text strong, .mini-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-text strong { font-size: 14px; }
.mini-text span { font-size: 13px; color: #b3b3b3; }
.mini-btn { color: #fff; }
.mini-btn svg, .player-ctl svg { width: 26px; height: 26px; fill: currentColor; }
.icon-pause { display: none; }
.is-playing .icon-pause { display: block; }
.is-playing .icon-play { display: none; }
.mini-progress { position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; background: rgba(255, 255, 255, 0.25); }
.mini-progress span { display: block; height: 100%; width: 0; background: #fff; }
.has-mini .home-feed, .has-mini .tabbed.panel, .has-mini .music-body { padding-bottom: calc(var(--tabbar-h) + 84px + var(--safe-bottom)); }
.has-mini .user-page { padding-bottom: calc(80px + var(--safe-bottom)); }

/* Now Playing */
dialog.player-dialog {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 55%, #121212) 0%, #121212 70%);
  color: #fff;
}
.player {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(6px + var(--safe-top)) 22px calc(20px + var(--safe-bottom));
}
.player-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.player-top .icon-btn { color: #fff; font-size: 20px; }
.player-top .icon-btn svg { width: 30px; height: 30px; fill: currentColor; }
.player-from { display: flex; flex-direction: column; align-items: center; text-align: center; font-size: 12px; min-width: 0; }
.player-from span { text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.player-from strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.player-switch { display: flex; align-self: center; gap: 4px; margin-top: 10px; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); }
.player-switch[hidden] { display: none; }
.player-switch button { border: 0; border-radius: 999px; padding: 6px 14px; background: none; color: #fff; font: inherit; font-size: 13px; font-weight: var(--w-heading); }
.player-switch button.active { background: #fff; color: #121212; }
.player-art { flex: 1; display: grid; place-items: center; min-height: 0; padding: 18px 0; }
.player-cover { width: min(100%, 46vh); aspect-ratio: 1; border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.player-cover[hidden] { display: none; }
#player-video { width: 100%; max-height: 46vh; border-radius: 8px; background: #000; }
.player-info { display: flex; align-items: center; gap: 10px; }
.player-names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.player-names strong { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { align-self: flex-start; border: 0; padding: 0; background: none; color: #b3b3b3; font: inherit; font-size: 16px; display: inline-flex; align-items: center; }
.player-like { font-size: 30px; color: #fff; }
#player-seek { width: 100%; margin: 16px 0 2px; accent-color: #fff; }
.player-times { display: flex; justify-content: space-between; font-size: 12px; color: #b3b3b3; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 30px; margin: 10px 0 14px; }
.player-ctl { display: grid; place-items: center; border: 0; background: none; color: #fff; width: 52px; height: 52px; padding: 0; }
.player-ctl svg { width: 34px; height: 34px; }
.player-ctl.big { width: 68px; height: 68px; border-radius: 50%; background: #fff; color: #121212; }
.player-ctl.big svg { width: 34px; height: 34px; }
.player-extra { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.player-extra .btn { background: rgba(255, 255, 255, 0.12); border-color: transparent; color: #fff; }
.player-extra .fineprint { color: #b3b3b3; }

/* Posting a song */
.song-new-dialog form { text-align: left; }
.song-new-top { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0 12px; }
.song-new-cover { width: 110px; height: 110px; border-radius: 8px; border: 0; padding: 0; font: inherit; font-size: 13px; font-weight: var(--w-heading); color: #fff; text-align: center; line-height: 1.3; }
.song-new-fields { flex: 1; min-width: 0; }
.song-new-fields label { display: block; font-size: 14px; font-weight: var(--w-heading); margin-bottom: 8px; }
.song-new-fields input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.song-file { margin: 4px 0 10px; overflow-wrap: anywhere; }
.up-tab { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: var(--w-heading); }
.up-tab.active { color: var(--text); border-bottom-color: var(--text); }
.up-tab .note-icon { width: 18px; height: 18px; }

.song-heart { width: 24px; height: 24px; fill: currentColor; display: block; margin: auto; }
.player-like .song-heart { width: 32px; height: 32px; }
.liked-songs-art { color: #fff; }
.player-names { text-align: left; align-items: flex-start; }

/* Explicit (E) */
.explicit-tag {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #b3b3b3;
  color: #121212;
  font-size: 10px;
  font-weight: 800;
  font-style: normal;
  flex: none;
  vertical-align: middle;
}
.home-screen .explicit-tag, .user-page .explicit-tag, .song-new-dialog .explicit-tag { background: var(--muted); color: var(--bg); }
.player-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-title > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-title .explicit-tag { width: 20px; height: 20px; font-size: 12px; }
.explicit-toggle { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; font-weight: var(--w-heading); }

/* ---------- KoolKat Playables ---------- */
.pad-icon { width: 24px; height: 24px; fill: currentColor; flex: none; }
.shelf-title .pad-icon { fill: #8a2be2; }
.panel-header .pad-icon { fill: #8a2be2; }
.playables-row { gap: 12px; }
.playable-card {
  flex: none;
  width: 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  font: inherit;
  text-align: left;
  scroll-snap-align: start;
}
.playable-card img { width: 100%; aspect-ratio: 1; object-fit: contain; margin-bottom: 6px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)); }
.kart-card { background: linear-gradient(160deg, #4aa3ff, #1aa33a); }
.wordle-card { background: linear-gradient(160deg, #1f4fff, #0b1d6b); }
.playable-name { font-size: 17px; font-weight: 800; }
.playable-sub { font-size: 13px; opacity: 0.9; line-height: 1.3; }
.playable-best { font-size: 13px; font-weight: var(--w-heading); margin-top: 6px; }
.playable-best:empty { display: none; }
.wordle-art { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 100%; aspect-ratio: 1; align-content: center; margin-bottom: 6px; }
.wordle-art b { display: grid; place-items: center; aspect-ratio: 1; border-radius: 4px; font-size: 20px; font-weight: 800; color: #fff; }
.wordle-art .c { background: #2f6bff; }
.wordle-art .p { background: #14246e; }
.wordle-art .a { background: #6b7280; }
.playables-intro { margin: 0 16px 12px; color: var(--muted); }
.playables-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }
.playable-card.big { width: auto; padding: 14px; }
@media (max-width: 360px) { .playables-grid { grid-template-columns: 1fr; } }

/* Kat Wordle */
.wordle-screen { background: var(--bg); overflow-y: auto; }
.kw-legend { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 6px; margin: 0 12px 8px; font-size: 12px; color: var(--muted); }
.kw-chip { padding: 2px 6px; border-radius: 4px; color: #fff; font-weight: 700; }
.kw-board { display: grid; gap: 6px; justify-content: center; margin: 4px auto 10px; }
.kw-row { display: grid; grid-template-columns: repeat(5, min(15vw, 58px)); gap: 6px; }
.kw-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: min(8vw, 30px);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  user-select: none;
}
.kw-tile.filled { border-color: var(--muted); animation: kw-pop 0.1s; }
.kw-tile.flip { animation: kw-flip 0.36s ease-in-out; }
.kw-tile.correct, .kw-key.correct, .kw-chip.correct { background: #2f6bff; border-color: #2f6bff; color: #fff; }
.kw-tile.present, .kw-key.present, .kw-chip.present { background: #14246e; border-color: #14246e; color: #fff; }
.kw-tile.absent, .kw-key.absent, .kw-chip.absent { background: #6b7280; border-color: #6b7280; color: #fff; }
@keyframes kw-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes kw-pop { 50% { transform: scale(1.08); } }
.kw-shake { animation: kw-shake 0.35s; }
@keyframes kw-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.kw-message {
  position: absolute;
  top: calc(80px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  white-space: nowrap;
}
.kw-keyboard { display: flex; flex-direction: column; gap: 7px; padding: 0 6px calc(12px + var(--safe-bottom)); margin-top: auto; }
.kw-keys { display: flex; justify-content: center; gap: 5px; }
.kw-key {
  flex: 1;
  max-width: 44px;
  height: 56px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0;
}
.kw-key.kw-wide { max-width: 66px; flex: 1.5; font-size: 12px; }
.kw-result { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.45); }
.kw-result[hidden] { display: none; }
.kw-result-card { width: min(100%, 380px); padding: 20px; border-radius: 18px; background: var(--bg); text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
.kw-result-title { margin: 0 0 4px; font-size: 22px; }
.kw-result-word { margin: 0 0 12px; color: var(--muted); font-weight: var(--w-heading); }
.kw-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.kw-stat { display: flex; flex-direction: column; }
.kw-stat strong { font-size: 24px; }
.kw-stat span { font-size: 11px; color: var(--muted); }
.kw-dist { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 14px; text-align: left; }
.kw-dist-row { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.kw-dist-n { width: 12px; }
.kw-dist-bar { padding: 1px 6px; border-radius: 3px; background: #6b7280; color: #fff; text-align: right; }
.kw-dist-bar.now { background: #2f6bff; }

/* Kat Kart */
.kart-screen { background: #000; color: #fff; }
.kart-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#kart-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.kart-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 10px 0;
  pointer-events: none;
}
.kart-hud > * { pointer-events: auto; }
.kart-stats { display: flex; flex-direction: column; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, 0.6); font-weight: 800; }
.kart-place { font-size: 40px; line-height: 1; font-style: italic; color: #fff; -webkit-text-stroke: 1.5px #000; }
.kart-place[data-place="1"] { color: #ffd21a; }
.kart-place[data-place="2"] { color: #d9dde3; }
.kart-place[data-place="3"] { color: #e3954d; }
.kart-lap, .kart-time { font-size: 16px; }
.kart-time { font-variant-numeric: tabular-nums; }
.kart-minimap { margin-left: auto; width: 110px; height: 110px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); }
.kart-board {
  position: absolute;
  left: 8px;
  top: calc(120px + var(--safe-top));
  margin: 0;
  padding: 6px 8px;
  list-style: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.kart-board li { display: flex; align-items: center; gap: 5px; line-height: 1.5; }
.kart-board li.me { color: #ffd21a; }
.kk-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #000; flex: none; }
.kart-countdown, .kart-finish {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 96px;
  font-weight: 900;
  font-style: italic;
  color: #fff;
  -webkit-text-stroke: 3px #000;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.kart-countdown[hidden], .kart-finish[hidden] { display: none; }
.kart-countdown.go { color: #ffd21a; }
.kart-finish { font-size: 64px; color: #ffd21a; }
.kart-steer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 34px;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.kart-podium {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  background: linear-gradient(180deg, #4aa3ff 0%, #bfe3ff 45%, #3da447 45%, #2d8a37 100%);
}
.kart-podium[hidden] { display: none; }
.podium-title { margin: 0 0 10px; font-size: 30px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px #000; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 6px; width: 100%; max-width: 380px; margin-top: 10px; }
.podium-spot { flex: 1; display: flex; flex-direction: column; align-items: center; }
.podium-kart { width: 92%; max-width: 120px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.35)); }
.podium-spot.p1 .podium-kart { animation: podium-bounce 0.9s ease-in-out infinite; }
@keyframes podium-bounce { 50% { transform: translateY(-8px); } }
.podium-name { font-weight: 800; font-size: 14px; color: #fff; text-shadow: 0 1px 3px #000; margin: 2px 0 4px; }
.podium-spot.me .podium-name { color: #ffd21a; }
.podium-step {
  width: 100%;
  display: grid;
  place-items: start center;
  padding-top: 6px;
  border-radius: 8px 8px 0 0;
  border: 3px solid #000;
  border-bottom: 0;
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 1px #000;
}
.p1 .podium-step { height: 120px; background: linear-gradient(#ffe066, #e6b800); }
.p2 .podium-step { height: 88px; background: linear-gradient(#eef1f5, #b8bec8); }
.p3 .podium-step { height: 64px; background: linear-gradient(#f0b27a, #c97b3a); }
.podium-list { width: 100%; max-width: 380px; margin: 0 0 14px; padding: 10px 14px; list-style: none; border-radius: 0 0 12px 12px; background: rgba(0, 0, 0, 0.55); color: #fff; font-weight: 700; }
.podium-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.podium-list li.me { color: #ffd21a; }
.podium-list-place { width: 34px; }
.podium-list-name { flex: 1; }
.podium-list-time { font-variant-numeric: tabular-nums; }
.kart-podium .btn:not(.primary) { background: #fff; color: #0f172a; }

.kw-hints { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 0 12px 8px; }
.kw-hint-list { display: contents; }
.kw-hint { padding: 5px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--text); font-size: 13px; font-weight: var(--w-heading); }

/* Kat Kart menu and lobby */
.kart-menu { text-align: center; }
.kart-menu-art { width: 120px; height: 120px; }
.kart-menu h2 { margin: 0 0 10px; }
.kart-menu-or { margin: 16px 0 4px; font-weight: 800; }
.kart-join { margin-top: 8px; }
.kart-join input { text-transform: uppercase; letter-spacing: 0.2em; text-align: center; font-weight: 800; }
.kart-code-big { margin: 0 0 6px; font-size: 44px; font-weight: 900; letter-spacing: 0.25em; }
.kart-lobby-players { list-style: none; margin: 14px 0 8px; padding: 0; text-align: left; }
.kart-lobby-players li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-weight: var(--w-heading); }
.kart-lobby-players .kk-dot { width: 14px; height: 14px; }
.podium-level { margin: 0 0 4px; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff; font-weight: 700; text-align: center; }
.podium-level[hidden] { display: none; }
.kart-board li.gone { opacity: 0.5; text-decoration: line-through; }

.kart-now-playing {
  position: absolute;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.4s, transform 0.4s;
}
.kart-now-playing.show { opacity: 1; transform: translate(-50%, 0); }
.kart-now-playing[hidden] { display: none; }
.kart-np-icon { font-size: 18px; color: #ffd21a; }

/* ---------- keyboard and controller ---------- */
/* A clear ring around whatever's selected when you use a keyboard or controller. */
.kb-nav :focus,
:focus-visible {
  outline: 3px solid var(--brand-2);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 35%, transparent);
}
.kb-nav .kw-key:focus, .kb-nav .chip:focus, .kb-nav .tab-btn:focus { outline-offset: 0; }

/* ---------- KoolKat on a PC ---------- */
/* Wide screens show KoolKat in a phone-sized column in the middle (Kat Kart
   uses the whole window). */
@media (min-width: 760px) {
  body { background: var(--surface); }
  .screen:not(.kart-screen):not(#screen-loading):not(#screen-auth),
  .tabbar {
    left: calc(50% - 280px);
    right: calc(50% - 280px);
  }
  .screen:not(.kart-screen):not(#screen-loading):not(#screen-auth) { background-color: var(--bg); box-shadow: 0 0 0 1px var(--border), 0 10px 50px rgba(0, 0, 0, 0.12); }
  .screen.camera, .screen.dark, .reels-screen { background-color: #000; }
  .music-screen { background-color: #121212; }
  .mini-player { left: calc(50% - 272px); right: calc(50% - 272px); }
  .tabbar { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
/* Kat Kart on a PC: a bigger minimap and leaderboard; no touch arrows. */
@media (min-width: 760px) {
  .kart-minimap { width: 170px; height: 170px; }
  .kart-board { font-size: 15px; top: calc(130px + var(--safe-top)); }
  .kart-place { font-size: 52px; }
  .kart-lap, .kart-time { font-size: 19px; }
}
@media (hover: hover) and (pointer: fine) {
  .kart-steer { display: none; }
}

/* KoolKat's "Are you sure?" box */
.confirm-dialog { max-width: 360px; text-align: center; }
.confirm-dialog p { margin: 4px 0 16px; font-size: 17px; font-weight: var(--w-heading); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Kat Kart power-ups */
.kart-item {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 4px solid #000;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.kart-item[hidden] { display: none; }
.kart-item img { width: 56px; height: 56px; image-rendering: pixelated; }
.kart-item.rolling img { animation: kart-roll 0.18s steps(2) infinite; }
@keyframes kart-roll { 50% { transform: translateY(-3px); } }
.kart-item-key { position: absolute; bottom: -20px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
@media (hover: none) { .kart-item-key { display: none; } }
.kart-alert {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}
.kart-alert[hidden] { display: none; }
.kart-alert img { width: 32px; height: 32px; image-rendering: pixelated; }

/* ---------- KatEscape ---------- */
img.pixel { image-rendering: pixelated; }
.escape-card { background: linear-gradient(160deg, #ff9e6d, #7a4c6e); }
.escape-card img { object-fit: contain; padding: 10%; }
.escape-screen { background: #000; color: #fff; }
.escape-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#escape-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.escape-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 10px; padding: calc(10px + var(--safe-top)) 10px 0; pointer-events: none; }
.escape-hud > * { pointer-events: auto; }
.escape-scores { display: flex; flex-direction: column; margin-left: auto; align-items: flex-end; font-weight: 900; text-shadow: 0 2px 0 #000; }
.escape-scores strong { font-size: 30px; font-variant-numeric: tabular-nums; -webkit-text-stroke: 1px #000; }
.escape-bolts { display: inline-flex; align-items: center; gap: 4px; font-size: 18px; }
.escape-bolts img { width: 24px; height: 24px; image-rendering: pixelated; }
.escape-boost { position: absolute; top: calc(90px + var(--safe-top)); right: 10px; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 10px; background: rgba(0,0,0,0.5); }
.escape-boost[hidden] { display: none; }
.escape-boost img { width: 32px; height: 32px; image-rendering: pixelated; }
.escape-boost-bar { width: 70px; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.3); overflow: hidden; }
.escape-boost-bar span { display: block; height: 100%; background: #ffd400; }
.escape-hint, .escape-over {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(88%, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
  font-size: 14px;
}
.escape-hint { pointer-events: none; }
.escape-hint[hidden], .escape-over[hidden] { display: none; }
.escape-hint img, .escape-over img { width: 64px; height: auto; image-rendering: pixelated; }
.escape-hint strong { font-size: 24px; }
.escape-over { background: rgba(0, 0, 0, 0.85); }
.escape-over h2 { margin: 4px 0 0; font-size: 24px; }
.escape-final { margin: 0; font-size: 34px; font-weight: 900; color: #ffd400; }
.escape-over .fineprint { color: rgba(255,255,255,0.8); }
.escape-over .btn:not(.primary) { background: #fff; color: #0f172a; }
@media (min-width: 760px) { .escape-screen { left: 0 !important; right: 0 !important; } }

.kart-song-pick { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 10px; font-weight: var(--w-heading); flex-wrap: wrap; }
.kart-song-pick select { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.kart-song-pick select:disabled { opacity: 0.75; }

.escape-song-pick { pointer-events: auto; margin-top: 6px; color: #fff; }
.escape-song-pick select { background: #fff; color: #0f172a; }

/* KatEscape multiplayer */
.escape-stage .kart-alert { white-space: normal; width: max-content; max-width: 86%; text-align: center; justify-content: center; }
.escape-item { bottom: calc(28px + var(--safe-bottom)); }
.escape-chase { position: absolute; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; padding: 4px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.55); font-weight: 900; text-shadow: 0 1px 0 #000; font-variant-numeric: tabular-nums; }
.escape-chase[hidden] { display: none; }
.escape-chase.close .escape-chase-gap { color: #ff6b6b; }
.escape-spectate { position: absolute; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.72); white-space: nowrap; max-width: calc(100% - 20px); }
.escape-spectate[hidden] { display: none; }
.escape-spectate > span { display: flex; flex-direction: column; align-items: center; overflow: hidden; text-overflow: ellipsis; }
.escape-spectate .fineprint { color: rgba(255, 255, 255, 0.75); }
.escape-spectate .btn:not(.primary) { background: #fff; color: #0f172a; }
.escape-results { list-style: none; width: 100%; margin: 4px 0; padding: 0; text-align: left; max-height: 40vh; overflow: auto; }
.escape-results[hidden] { display: none; }
.escape-results li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; font-weight: 700; }
.escape-results li.me { background: rgba(255, 212, 0, 0.2); }
.escape-results .place { width: 2.2em; font-weight: 900; color: #ffd400; }
.escape-results .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.escape-results .pts { font-variant-numeric: tabular-nums; }
.escape-over .row[hidden] { display: none; }
.escape-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.escape-mode { display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.escape-mode span { font-size: 12px; color: var(--muted); }
.escape-mode[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
.escape-mode:disabled { cursor: default; opacity: 1; }
.escape-mode:disabled:not([aria-checked="true"]) { opacity: 0.55; }
.escape-role { margin-left: auto; font-size: 13px; }

/* Circle Chaos */
.circles-card { background: linear-gradient(160deg, #ff5a5a, #ffd400 30%, #37c84a 55%, #2f6bff 78%, #9d00ff); }
.circles-card img { object-fit: contain; padding: 10%; image-rendering: pixelated; }
.circles-screen { background: #14102a; color: #fff; overflow-y: auto; padding-bottom: calc(16px + var(--safe-bottom)); }
@media (min-width: 760px) { .circles-screen { left: 0 !important; right: 0 !important; } }
.circles-screen .pixel, .cc-rules .pixel, .cc-team-pick .pixel, #dialog-circles .pixel { image-rendering: pixelated; }
.cc-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-top)) 12px 6px; }
.cc-turn { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.cc-turn strong { font-size: 18px; font-weight: 900; }
.cc-turn .fineprint { color: rgba(255, 255, 255, 0.75); }
.cc-dir { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.12); font-size: 22px; font-weight: 900; }
.cc-dir.flipped { transform: scaleX(-1); }
.cc-teams { list-style: none; margin: 4px 0; padding: 0 10px; display: grid; grid-template-columns: repeat(var(--cc-cols, 5), minmax(0, 1fr)); gap: 6px; }
.cc-team { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 8px; border: 3px solid transparent; border-radius: 12px; background: rgba(255, 255, 255, 0.08); text-align: center; min-width: 0; }
.cc-team img { width: 40px; height: auto; image-rendering: pixelated; }
.cc-team .cc-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 800; }
.cc-team .cc-count { display: inline-flex; align-items: center; gap: 3px; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.cc-team .cc-count img { width: 16px; }
.cc-team .cc-left { font-size: 11px; color: rgba(255, 255, 255, 0.7); }
.cc-team.turn { border-color: var(--cc-team); background: color-mix(in srgb, var(--cc-team) 22%, transparent); animation: cc-pulse 1s ease-in-out infinite; }
.cc-team.me .cc-name::after { content: ' · you'; color: #ffd400; }
.cc-team.gone { opacity: 0.4; }
.cc-team.bump .cc-count { animation: cc-bump 0.5s; }
.cc-team.hit .cc-count { animation: cc-hit 0.6s; }
@keyframes cc-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--cc-team) 35%, transparent); } }
@keyframes cc-bump { 40% { transform: scale(1.4); color: #8dff6a; } }
@keyframes cc-hit { 25%, 75% { transform: translateX(-3px); color: #ff6b6b; } 50% { transform: translateX(3px); color: #ff6b6b; } }
.cc-table { position: relative; margin: 6px 10px; border: 4px solid #000; border-radius: 14px; overflow: hidden; }
#cc-canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.cc-deck-count { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.6); font-weight: 800; font-size: 13px; }
.cc-reveal { display: flex; align-items: center; gap: 10px; margin: 6px 12px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); }
.cc-reveal[hidden] { display: none; }
.cc-reveal img { width: 48px; height: 48px; flex: none; image-rendering: pixelated; animation: cc-pop 0.4s; }
.cc-reveal p { margin: 0; font-weight: 700; line-height: 1.35; }
@keyframes cc-pop { from { transform: scale(0.3) rotate(-30deg); } }
.cc-actions { margin: 6px 12px; text-align: center; }
.cc-wait { margin: 6px 0 0; color: rgba(255, 255, 255, 0.75); }
.cc-wait:empty { display: none; }
.cc-picks[hidden] { display: none; }
.cc-picks p { margin: 0 0 6px; font-weight: 800; }
/* Your colour and the three rainbow circles, side by side. */
.cc-pick-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cc-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 8px 4px; border: 3px solid var(--cc-team, #f7c948); border-radius: 14px; background: #fff; color: #0f172a; font: inherit; font-weight: 800; cursor: pointer; }
.cc-pick img { width: 40px; height: 40px; image-rendering: pixelated; }
.cc-pick-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cc-pick-count { font-size: 12px; color: #475569; }
.cc-pick:not(:disabled):hover, .cc-pick:focus-visible { transform: translateY(-2px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.cc-pick:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 360px) {
  .cc-pick img { width: 30px; height: 30px; }
  .cc-pick-name { font-size: 11px; }
}
.cc-targets[hidden] { display: none; }
.cc-targets p { margin: 0 0 6px; font-weight: 800; }
.cc-target-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cc-target { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border: 3px solid var(--cc-team); border-radius: 999px; background: #fff; color: #0f172a; font: inherit; font-weight: 800; cursor: pointer; }
.cc-target img { width: 28px; image-rendering: pixelated; }
.cc-log { list-style: none; margin: 8px 12px 0; padding: 0; font-size: 13px; color: rgba(255, 255, 255, 0.8); }
.cc-log li { padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.cc-log li:first-child { color: #fff; }
.cc-results { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; background: rgba(10, 8, 25, 0.92); text-align: center; }
.cc-results[hidden] { display: none; }
.cc-results h2 { margin: 0; font-size: 26px; }
.cc-results-list { list-style: none; width: min(100%, 360px); margin: 0; padding: 0; }
.cc-results-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; font-weight: 800; text-align: left; }
.cc-results-list li.me { background: rgba(255, 212, 0, 0.18); }
.cc-results-list .place { width: 2.4em; color: #ffd400; font-weight: 900; }
.cc-results-list img { width: 32px; image-rendering: pixelated; }
.cc-results-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-results .btn:not(.primary) { background: #fff; color: #0f172a; }
.cc-rules { list-style: none; margin: 6px 0; padding: 0; text-align: left; font-size: 14px; }
.cc-rules li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.cc-rules img { width: 28px; flex: none; }
.cc-team-pick { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.cc-team-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 3px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 11px; font-weight: 800; cursor: pointer; min-width: 0; flex: 1; }
.cc-team-btn img { width: 32px; }
.cc-team-btn[aria-checked="true"] { border-color: var(--cc-team); background: color-mix(in srgb, var(--cc-team) 18%, var(--surface)); }
.cc-team-btn:disabled:not([aria-checked="true"]) { opacity: 0.35; cursor: default; }
#cc-lobby-players img.cc-mini { width: 22px; image-rendering: pixelated; }
.cc-pts { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.cc-results-list img.cc-mini-circle { width: 18px; }
.cc-bots { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 10px; font-weight: 800; }
.cc-bot-btn { width: 44px; height: 40px; border: 3px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-weight: 900; cursor: pointer; }
.cc-bot-btn[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }

/* Bolts ⚡ */
.bolts-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 16px 12px; padding: 10px 14px; border-radius: 14px; background: linear-gradient(135deg, #1b1446, #2f2380); color: #fff; }
.bolts-bar .fineprint { color: rgba(255, 255, 255, 0.8); }
.bolts-balance { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.bolts-balance strong { font-size: 22px; color: #ffd400; font-variant-numeric: tabular-nums; }
.bolts-balance img { width: 26px; height: 26px; }

/* Kat Invaders */
.invaders-card { background: linear-gradient(160deg, #3a2a8f, #120c2b); }
.invaders-card img { object-fit: contain; padding: 8%; image-rendering: pixelated; }
.invaders-screen { background: #000; color: #fff; }
@media (min-width: 760px) { .invaders-screen { left: 0 !important; right: 0 !important; } }
.ki-stage { position: relative; flex: 1; display: grid; place-items: center; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #120c2b; }
#ki-canvas { height: 100%; max-width: 100%; aspect-ratio: 180 / 320; object-fit: contain; image-rendering: pixelated; }
.ki-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 10px; padding: calc(10px + var(--safe-top)) 10px 0; pointer-events: none; }
.ki-hud > * { pointer-events: auto; }
.ki-time { margin: 6px auto 0; padding: 2px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.5); font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; }
.ki-stats { display: flex; flex-direction: column; align-items: flex-end; font-weight: 900; text-shadow: 0 2px 0 #000; }
.ki-stats strong { font-size: 28px; font-variant-numeric: tabular-nums; -webkit-text-stroke: 1px #000; }
.ki-stats span { font-size: 13px; letter-spacing: 1px; }
.ki-board { position: absolute; left: 10px; top: calc(64px + var(--safe-top)); list-style: none; margin: 0; padding: 6px 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.5); font-size: 12px; font-weight: 700; pointer-events: none; }
.ki-board[hidden] { display: none; }
.ki-board li { display: flex; align-items: center; gap: 5px; }
.ki-board li.me { color: #ffd400; }
.ki-board li.out { opacity: 0.45; }
.ki-board img { width: 18px; image-rendering: pixelated; }
.ki-board strong { margin-left: auto; padding-left: 8px; font-variant-numeric: tabular-nums; }
.ki-stage .kart-alert { white-space: normal; width: max-content; max-width: 86%; text-align: center; }
.ki-difficulty { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 8px; }
.ki-diff { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border: 3px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-weight: 800; cursor: pointer; }
.ki-diff span { font-size: 12px; font-weight: 600; color: var(--muted); }
.ki-diff[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
.ki-diff:disabled:not([aria-checked="true"]) { opacity: 0.5; cursor: default; }
#dialog-invaders .pixel { image-rendering: pixelated; }
.escape-results li img.ki-mini { width: 22px; image-rendering: pixelated; }
.cc-table .kart-now-playing { bottom: 8px; }

/* Bolt Shop */
.bolts-bar .shop-open { margin-left: auto; background: #ffd400; color: #1b1446; font-weight: 900; }
.bolt-badge { height: 0.95em; width: auto; margin-left: 4px; vertical-align: -0.1em; image-rendering: pixelated; }
.author-link .bolt-badge { height: 14px; }
.up-title .bolt-badge { height: 0.6em; vertical-align: middle; }
.shop-dialog { width: min(94vw, 460px); }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shop-head h2 { margin: 0; }
.shop-head .bolts-balance strong { color: var(--text); }
.shop-section { margin: 14px 0 8px; font-size: 16px; }
.shop-section .fineprint { font-weight: 500; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 3px solid var(--border); border-radius: 14px; background: var(--surface); text-align: center; }
.shop-item.owned { border-color: var(--shop-color, var(--brand)); }
.shop-item img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
.shop-item strong { font-size: 14px; }
.shop-item .fineprint { margin: 0; }
.shop-item .btn { width: 100%; }
.shop-list { display: grid; gap: 8px; }
.shop-list .shop-item { flex-direction: row; text-align: left; }
.shop-list .shop-item > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.shop-list .shop-item .btn { width: auto; }
.cc-team-pick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.cc-team-btn.locked { opacity: 0.7; border-style: dashed; }
.cc-team-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-size: 10px; }

/* Gems 💎 */
.gems-balance strong { color: #4fd6ff !important; }
.shop-wallet { display: inline-flex; gap: 12px; }
.shop-swap { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); }
.shop-swap-amount { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.shop-swap-amount input { width: 7em; }
.shop-swap .row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Bolt Shop / Gem Shop tabs */
.shop-tabs, .feedback-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.shop-tab, .feedback-tab { padding: 10px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-weight: 800; cursor: pointer; }
.shop-tab[aria-selected="true"], .feedback-tab[aria-selected="true"] { border-color: var(--brand); background: var(--brand-soft); }
.feedback-tab[hidden] { display: none; }
.feedback-tabs:has(.feedback-tab[hidden]) { grid-template-columns: 1fr; }
.gem-badge { image-rendering: pixelated; }

/* Suggestions & Bug reports */
.feedback-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.feedback-dialog { width: min(94vw, 480px); }
.feedback-dialog h2 { margin: 0 0 4px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-weight: 700; font-size: 14px; }
.field input, .field select, .field textarea { font: inherit; font-weight: 400; }
.field textarea { resize: vertical; min-height: 80px; }
#screen-feedback .feedback-tabs, #screen-feedback .feedback-filters, #screen-feedback .feedback-note { margin-left: 16px; margin-right: 16px; }
.feedback-open { margin: 0 16px 12px; width: calc(100% - 32px); }
.feedback-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.feedback-filters[hidden] { display: none; }
.feedback-filters input { grid-column: 1 / -1; }
.feedback-filters input, .feedback-filters select { font: inherit; min-width: 0; }
.feedback-list { margin: 0; }
.feedback-item { display: flex; align-items: flex-start; gap: 10px; }
.feedback-item.done { opacity: 0.85; }
.feedback-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.feedback-body strong { overflow-wrap: anywhere; }
.feedback-does { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: 14px; }
.feedback-chip { align-self: flex-start; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 800; }
.feedback-item .btn { flex: none; }

/* Circle Chaos on small phones: teams wrap into rows (names stay readable), smaller header. */
@media (max-width: 420px) {
  .cc-teams { grid-template-columns: repeat(min(var(--cc-cols, 5), 3), minmax(0, 1fr)); }
  .cc-team { padding: 6px 4px; }
  .cc-team > img { width: 32px; }
  .cc-team .cc-count { font-size: 17px; }
  .cc-team .cc-left { font-size: 10px; }
  .cc-turn strong { font-size: 16px; }
  .cc-top { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .cc-team-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cc-actions, .cc-reveal, .cc-log { margin-left: 8px; margin-right: 8px; }
  .cc-table { margin: 6px 8px; }
}
/* The name, count and turns stack under the cat. */
.cc-team-text { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
/* Nothing on the Circle Chaos screen gets squashed: it scrolls instead (the table used to shrink flat on small phones). */
.circles-screen > * { flex-shrink: 0; }
/* The Deck counter sits in the top corner, out of the pile's way. */
.cc-deck-count { top: 6px; bottom: auto; }
#screen-feedback .feedback-list { margin: 0 16px 16px; padding: 0; list-style: none; }
.feedback-list .feedback-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.feedback-dialog .feedback-list { text-align: left; padding: 0; list-style: none; }
.feedback-replies { list-style: none; margin: 6px 0 0; padding: 0 0 0 10px; border-left: 3px solid var(--brand-soft); display: grid; gap: 6px; }
.feedback-replies li { display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.feedback-reply-by { font-weight: 700; }
.feedback-reply-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-reply-form { display: flex; gap: 6px; align-items: flex-end; margin-top: 6px; }
.feedback-reply-input { flex: 1; min-width: 0; font: inherit; resize: vertical; }
/* Multi-touch games: holding a finger still shouldn't open the phone's long-press menu. */
.kart-stage, .escape-stage, .ki-stage { -webkit-touch-callout: none; }

/* ---------- Kat Survival ---------- */
.survival-card { background: linear-gradient(160deg, #2f6b34, #0e2412); }
.survival-card img { object-fit: contain; padding: 6%; image-rendering: pixelated; }
.survival-screen { background: #0e2412; color: #fff; }
@media (min-width: 760px) { .survival-screen { left: 0 !important; right: 0 !important; } }
.ks-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: #1d4d22; }
#ks-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.ks-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 8px; padding: calc(8px + var(--safe-top)) 8px 0; pointer-events: none; }
.ks-hud > * { pointer-events: auto; }
.ks-status { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; pointer-events: none; }
.ks-clock { padding: 3px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.55); font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ks-clock.night { background: rgba(20, 24, 70, 0.8); }
.ks-bars { display: flex; gap: 6px; width: min(100%, 260px); }
.ks-bar { --fill: 100%; flex: 1; position: relative; padding: 2px 8px; border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, 0.55); font-size: 13px; font-weight: 800; white-space: nowrap; }
.ks-bar::before { content: ""; position: absolute; inset: 0; width: var(--fill); background: var(--bar); opacity: 0.75; transition: width 0.2s; }
.ks-bar > * { position: relative; }
.ks-bar { isolation: isolate; }
.ks-bar::before { z-index: -1; }
.ks-bar.hp { --bar: #d7263d; }
.ks-bar.hunger { --bar: #c77a2b; }
#ks-minimap { width: 76px; height: 76px; border: 2px solid rgba(0, 0, 0, 0.6); border-radius: 8px; image-rendering: pixelated; }
.ks-cold { position: absolute; top: calc(78px + var(--safe-top)); left: 50%; transform: translateX(-50%); padding: 6px 12px; border-radius: 12px; background: rgba(60, 130, 220, 0.9); font-weight: 900; white-space: nowrap; pointer-events: none; animation: ks-pulse 1s ease-in-out infinite alternate; }
.ks-cold[hidden] { display: none; }
@keyframes ks-pulse { to { opacity: 0.6; } }
.ks-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding: 0 8px calc(8px + var(--safe-bottom, 0px)); pointer-events: none; }
.ks-inv { display: flex; gap: 6px; align-self: flex-start; padding: 4px 8px; border-radius: 12px; background: rgba(0, 0, 0, 0.55); font-weight: 900; pointer-events: none; }
.ks-inv span { display: inline-flex; align-items: center; gap: 2px; }
.ks-inv img { width: 22px; height: 22px; image-rendering: pixelated; }
.ks-actions { display: grid; grid-template-columns: repeat(2, 64px) 84px; grid-template-rows: 64px 64px; gap: 6px; pointer-events: auto; }
.ks-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; border: 2px solid rgba(0, 0, 0, 0.6); border-radius: 14px; background: rgba(255, 255, 255, 0.85); color: #0f172a; font: inherit; font-size: 11px; font-weight: 800; cursor: pointer; touch-action: none; }
.ks-btn img { width: 30px; height: 30px; image-rendering: pixelated; }
.ks-btn:disabled { opacity: 0.45; }
.ks-btn:active:not(:disabled) { transform: scale(0.94); }
.ks-swing { grid-column: 3; grid-row: 1 / span 2; border-radius: 50%; align-self: center; height: 84px; background: #ffd23f; }
.ks-swing img { width: 40px; height: 40px; }
.ks-stage .kart-alert { white-space: normal; width: max-content; max-width: 86%; text-align: center; }
.ks-rules { margin: 0 0 8px; padding-left: 0; list-style: none; font-size: 13px; text-align: left; }
.ks-rules li { margin: 4px 0; }
#dialog-survival .pixel, #screen-survival .pixel { image-rendering: pixelated; }
/* Out of the way of the buttons and your Kat. */
.ks-stage .kart-now-playing { top: calc(112px + var(--safe-top)); bottom: auto; }
.ks-stage .kart-alert { top: calc(150px + var(--safe-top)); }
.ks-ready { pointer-events: auto; padding: 4px 12px; border: 2px solid rgba(0, 0, 0, 0.5); border-radius: 999px; background: rgba(20, 24, 70, 0.85); color: #fff; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.ks-ready.on { background: #2f8f46; }
.ks-ready[hidden] { display: none; }

/* ---------- KoolKat Books ---------- */
.books-body, .book-body { width: 100%; box-sizing: border-box; padding: 0 16px; max-width: 760px; margin: 0 auto; }
.books-search { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; padding: 8px 12px; border-radius: 12px; background: var(--surface); }
.books-search svg { width: 20px; height: 20px; fill: var(--muted); flex-shrink: 0; }
.books-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; outline: none; }
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px 12px; }
.book-card { display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.book-card-title { font-weight: 800; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.book-card-author { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.book-card-author span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-card-meta { font-size: 12px; color: var(--muted); }
.book-cover { --book-hue: 210; position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 4px 10px 10px 4px; background: var(--surface); box-shadow: inset 6px 0 0 rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.18); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover.plain { background: linear-gradient(160deg, hsl(var(--book-hue) 70% 55%), hsl(calc(var(--book-hue) + 40) 70% 35%)); }
.book-cover-title { padding: 12px; color: #fff; font-weight: 900; font-size: 16px; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); overflow-wrap: anywhere; }
.book-cover-audio { position: absolute; right: 6px; bottom: 6px; padding: 2px 5px; border-radius: 8px; background: rgba(0, 0, 0, 0.6); font-size: 13px; }
.book-cover.small { width: 72px; flex-shrink: 0; }
.book-cover.small .book-cover-title { font-size: 10px; padding: 4px; }
#btn-books-more { display: block; margin: 16px auto; }
#btn-book-new.locked { opacity: 0.5; }
.book-info { display: flex; gap: 12px; margin: 4px 0 12px; }
.book-info-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.book-info-text strong { font-size: 18px; }
.book-info-text .author-link { display: inline-flex; align-items: center; gap: 6px; }
.book-description { margin: 0; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.book-audio-box { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.book-audio-box[hidden] { display: none; }
.book-audio-head { margin: 0 0 6px; font-weight: 800; }
.book-audio-box audio { width: 100%; }
.book-page { min-height: 46vh; max-height: 62vh; overflow-y: auto; padding: 20px 18px; border-radius: 6px 14px 14px 6px; background: #fffaf0; color: #2b2118; box-shadow: inset 8px 0 0 rgba(120, 90, 50, 0.12), 0 6px 18px rgba(0, 0, 0, 0.15); touch-action: pan-y; }
.book-page-image { display: block; max-width: 100%; max-height: 40vh; margin: 0 auto 14px; border-radius: 8px; object-fit: contain; }
.book-page.picture-only .book-page-image { max-height: 56vh; margin-bottom: 0; }
.book-page-text { font-family: Georgia, 'Times New Roman', serif; font-size: 18px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.book-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0; font-weight: 800; }
.book-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.book-actions[hidden] { display: none; }
#btn-book-like.on { color: #e5172f; }
.book-progress { position: relative; }
.book-progress::before { content: ""; position: absolute; inset: 0; width: var(--done, 0%); background: var(--brand); transition: width 0.2s; }
.book-progress[hidden] { display: none; }
.book-edit-dialog form { display: flex; flex-direction: column; gap: 8px; }
.book-edit-dialog { width: min(560px, calc(100vw - 24px)); }
.book-edit-top { display: flex; gap: 12px; }
.book-edit-cover { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.book-cover-pick { display: grid; place-items: center; width: 90px; aspect-ratio: 2 / 3; overflow: hidden; padding: 0; border: 2px dashed var(--border); border-radius: 4px 10px 10px 4px; background: var(--surface); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.book-cover-pick img { width: 100%; height: 100%; object-fit: cover; }
.book-edit-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.book-edit-fields label { display: flex; flex-direction: column; gap: 3px; font-weight: 700; font-size: 14px; }
.book-edit-fields input, .book-edit-fields textarea, .book-page-edit textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
.book-pages-edit { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.book-page-edit { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; background: var(--surface); }
.book-page-edit-head { display: flex; align-items: center; gap: 4px; }
.book-page-edit-head .spacer { flex: 1; }
.icon-mini { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.icon-mini:disabled { opacity: 0.35; cursor: default; }
.book-page-edit-pic { display: flex; align-items: center; gap: 10px; }
.book-page-pic { display: grid; place-items: center; min-width: 120px; height: 72px; overflow: hidden; padding: 0 8px; border: 2px dashed var(--border); border-radius: 10px; background: var(--bg); color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.book-page-pic img { height: 100%; max-width: 160px; object-fit: cover; }

/* Kat Kart on a phone turned sideways: a smaller HUD so the road (and the steering buttons) can be seen. */
@media (orientation: landscape) and (max-height: 520px) {
  .kart-hud { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); padding-top: 6px; }
  .kart-place { font-size: 28px; }
  .kart-lap, .kart-time { font-size: 13px; }
  .kart-minimap { width: 80px; height: 80px; }
  .kart-board { top: 84px; left: max(8px, env(safe-area-inset-left)); padding: 4px 6px; font-size: 10.5px; }
  .kart-board li { line-height: 1.3; }
  .kart-steer { bottom: 10px; padding: 0 max(24px, env(safe-area-inset-left)) 0 max(24px, env(safe-area-inset-right)); }
  .kart-item { bottom: 10px; width: 62px; height: 62px; }
  .kart-item img { width: 44px; height: 44px; }
  .kart-countdown { font-size: 72px; }
  .kart-menu-art { width: 64px; height: 64px; }
  .kart-now-playing { bottom: 82px; }
}
.kart-hud-buttons { display: flex; flex-direction: column; gap: 6px; }
#btn-kart-rotate.on { background: #ffd21a; color: #000; }
.kart-landscape-pick { font-size: 14px; }
.kart-landscape-pick input { width: 18px; height: 18px; }
@media (orientation: landscape) and (max-height: 520px) {
  .kart-hud-buttons { flex-direction: row; }
  .kart-hud-buttons .icon-btn { width: 36px; height: 36px; }
}
/* The Playables' 🔊 / 🔇 music button (only while a song's on). */
.music-mute { font-size: 18px; line-height: 1; }
.music-mute[hidden] { display: none; }
.music-mute.muted { opacity: 0.75; }
/* Longer pick names ("Random Rainbow") go onto two lines. */
.cc-pick-name { white-space: normal; text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.kart-tilt-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; margin: -4px 0 10px; font-size: 14px; font-weight: 700; }
.kart-tilt-options[hidden] { display: none; }
.kart-tilt-options label { display: inline-flex; align-items: center; gap: 6px; }
.kart-tilt-sens input { width: 120px; }

/* ---------- My Singing Katz ---------- */
.msk-card { background: linear-gradient(160deg, #62b6ff, #5cbf4a); }
.msk-card img { object-fit: contain; padding: 6%; }
.msk-screen { background: #155e9e; color: #fff; display: flex; flex-direction: column; }
@media (min-width: 760px) { .msk-screen { left: 0 !important; right: 0 !important; } }
.msk-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 10px 6px; background: rgba(0, 0, 0, 0.25); }
.msk-top h2 { flex: 1; margin: 0; font-size: 18px; text-align: center; }
.msk-top .fineprint { color: rgba(255, 255, 255, 0.8); font-weight: 700; }
.msk-stage { position: relative; flex: 1; min-height: 0; }
#msk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.msk-status { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.6); font-weight: 800; }
.msk-status[hidden] { display: none; }
.msk-controls { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 10px calc(10px + var(--safe-bottom, 0px)); background: rgba(0, 0, 0, 0.25); }
.msk-toggles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 440px); }
.msk-toggle { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 3px solid #ffd23f; border-radius: 14px; background: #fff; color: #0f172a; font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; }
.msk-toggle img { height: 44px; object-fit: contain; }
.msk-toggle.asleep { border-color: #94a3b8; opacity: 0.6; }
.msk-state { position: absolute; top: 2px; right: 6px; font-size: 14px; }
.msk-hint { margin: 0; color: rgba(255, 255, 255, 0.8); }
#btn-msk-pause { background: #fff; color: #0f172a; }

/* KoolKat Music albums */
.album-head { display: flex; gap: 14px; align-items: flex-end; margin: 4px 0 16px; }
.album-head[hidden] { display: none; }
.album-head-cover { width: 132px; height: 132px; flex-shrink: 0; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); overflow: hidden; }
.album-head-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-head-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.album-head-text h3 { margin: 0; font-size: 24px; font-weight: 900; line-height: 1.1; overflow-wrap: anywhere; }
.album-head-text .fineprint { color: rgba(255, 255, 255, 0.7); }
.album-artist { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-weight: 800; }
.album-play { margin-top: 4px; }
#music-search-albums-heading[hidden], #music-search-albums[hidden], #music-albums-heading[hidden], #music-albums[hidden] { display: none; }
.kart-ds { margin: 0 0 6px; }
.kart-ds-head { margin: 0 0 4px; font-weight: 800; font-size: 14px; }
.kart-ds-head .fineprint { font-weight: 600; }
