:root {
  --bg: #1e1f26;
  --bg2: #23242c;
  --bg3: #2b2d37;
  --bg4: #343744;
  --line: #3a3d4b;
  --text: #eceef4;
  --muted: #9a9fb2;
  --red: #ee3b46;
  --red2: #ff5560;
  --blue: #4a8cff;
  --ok: #3ecf8e;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: #7db0ff; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font: 0.9em ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.grow { flex: 1; }

/* pokéball */
.ball, .boot .ball {
  display: inline-block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #14151a;
  background: linear-gradient(#ee3b46 0 46%, #14151a 46% 54%, #f4f5f8 54%);
  position: relative;
  flex: none;
}
.ball::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  height: 28%;
  transform: translate(-50%, -50%);
  background: #f4f5f8;
  border: 3px solid #14151a;
  border-radius: 50%;
}
.boot { height: 100%; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot .ball { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* buttons & fields */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg4);
  font-weight: 600;
  transition: background 0.12s;
}
.btn:hover:not(:disabled) { background: #3f4252; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg3); }
.btn.wide { width: 100%; padding: 11px; }
.link { color: #7db0ff; text-decoration: underline; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; color: var(--muted); flex: none; }
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--bg4); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.send { color: var(--red2); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
input[type='text'], input[type='email'], input[type='password'], input[type='search'], select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
.err { color: #ff8b92; min-height: 1.2em; margin: 4px 0 10px; font-size: 14px; }
.only-mobile { display: none; }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--bg4); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px #0006; }
.toast.err { border-color: var(--red); }

/* auth */
.auth { height: 100%; display: grid; place-items: center; padding: 20px; overflow: auto; background: radial-gradient(900px 500px at 50% -10%, #3a1d27 0, transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px #0007; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 10px; }
.auth-card h1 { text-align: center; margin: 0 0 4px; font-size: 24px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.note { background: var(--bg3); padding: 8px 12px; border-radius: 8px; text-align: center; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0 14px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.google { display: flex; justify-content: center; min-height: 44px; }
.switch { text-align: center; margin: 18px 0 0; color: var(--muted); }
.fine { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* pick screen */
.pick { height: 100%; display: flex; flex-direction: column; padding: 18px 22px 0; gap: 14px; min-height: 0; }
.pick-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.pick-head h1 { margin: 0 0 2px; font-size: 24px; }
.pick-head p { margin: 0; color: var(--muted); }

/* dex */
.dex { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dex-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 12px; }
.dex-tools input.dex-search { flex: 1 1 220px; max-width: 320px; }
.dex-tools select { width: auto; flex: 0 1 180px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { accent-color: var(--red); }
.dex-count { margin-left: auto; color: var(--muted); font-size: 13px; }
.dex-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.dex-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  align-content: start;
  padding: 2px 6px 18px 2px;
}
.dex-grid .empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 40px 0; }
.dex-card {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 8px 4px 6px;
  background: var(--bg2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: center;
  content-visibility: auto;
  contain-intrinsic-size: 120px 130px;
}
.dex-card:hover { background: var(--bg3); }
.dex-card.on { border-color: var(--red); background: #33232b; }
.dex-card.mine::after { content: '★'; position: absolute; }
.dex-card { position: relative; }
.dex-card.mine::after { top: 4px; right: 7px; color: #ffcb3d; font-size: 13px; }
.dex-card img { image-rendering: pixelated; width: 72px; height: 72px; object-fit: contain; }
.dex-card .num { font-size: 11px; color: var(--muted); }
.dex-card .nm { font-size: 12px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.dex-detail { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; overflow-y: auto; margin-bottom: 14px; text-align: center; }
.dex-detail .art { width: 200px; height: 200px; object-fit: contain; filter: drop-shadow(0 8px 14px #0008); }
.dex-detail .dnum { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.dex-detail h3 { margin: 0 0 8px; font-size: 21px; }
.dex-detail h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.dex-detail .gen { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.types { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.type, .badge { padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; background: #777; text-shadow: 0 1px 1px #0005; }
.badge { background: #8a6bd1; }
.t-normal { background: #8f8f78; } .t-fire { background: #e8742c; } .t-water { background: #4a85e6; }
.t-electric { background: #d9a50f; } .t-grass { background: #4fa83d; } .t-ice { background: #55b7b0; }
.t-fighting { background: #b8352c; } .t-poison { background: #9440a2; } .t-ground { background: #c0974b; }
.t-flying { background: #7d93e8; } .t-psychic { background: #e8467a; } .t-bug { background: #8da016; }
.t-rock { background: #a28d3c; } .t-ghost { background: #655091; } .t-dragon { background: #5f36e8; }
.t-dark { background: #5b4a40; } .t-steel { background: #8a8aa4; } .t-fairy { background: #de7bb0; }
.evo-tree { overflow-x: auto; padding-bottom: 4px; display: flex; justify-content: center; }
.evo-branch { display: flex; align-items: center; gap: 4px; }
.evo-kids { display: grid; gap: 4px; }
.evo-arrow { color: var(--muted); }
.evo { display: grid; justify-items: center; width: 74px; padding: 4px 2px; border-radius: 8px; font-size: 11px; line-height: 1.15; }
.evo img { image-rendering: pixelated; }
.evo:hover { background: var(--bg3); }
.evo.on { background: #33232b; outline: 1px solid var(--red); }
.forms { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.form { border-radius: 8px; padding: 2px; }
.form img { image-rendering: pixelated; }
.form:hover { background: var(--bg3); }
.form.on { background: #33232b; outline: 1px solid var(--red); }
.choose { width: 100%; margin-top: 18px; padding: 11px; }
.dexwrap { height: 100%; display: flex; flex-direction: column; padding: 16px 20px 0; min-height: 0; }
.dex-head h2 { margin: 0; }
.dex-head p { margin: 2px 0 12px; color: var(--muted); }

/* shell */
.shell { height: 100%; display: grid; grid-template-columns: 68px 244px minmax(0, 1fr) 244px; }
.rail { background: #17181d; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; }
.rail-btn { width: 46px; height: 46px; border-radius: 14px; background: var(--bg3); display: grid; place-items: center; color: var(--muted); transition: border-radius 0.15s, background 0.15s; }
.rail-btn:hover, .rail-btn.on { border-radius: 14px; background: var(--bg4); color: var(--text); box-shadow: inset 3px 0 0 var(--red); }
.ver { font-size: 10px; color: #5e6275; }
.side { background: var(--bg2); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #00000040; }
.side-head { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid #00000050; }
.channels { flex: 1; overflow-y: auto; padding: 10px 8px; display: grid; align-content: start; gap: 2px; }
.label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 8px 4px; }
.ch { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; color: var(--muted); text-align: left; }
.ch:hover { background: var(--bg3); color: var(--text); }
.ch.on { background: var(--bg4); color: var(--text); }
.ch.unread { color: var(--text); font-weight: 700; }
.ch .hash { width: 18px; text-align: center; opacity: 0.8; }
.ch .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--red2); }
.userpanel { display: flex; align-items: center; gap: 4px; padding: 8px; background: #1b1c22; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; text-align: left; }
.me:hover { background: var(--bg3); }
.who { display: grid; min-width: 0; line-height: 1.2; }
.who b, .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); font-size: 12px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.members { background: var(--bg2); overflow-y: auto; padding: 10px 8px; border-left: 1px solid #00000040; align-content: start; display: grid; gap: 2px; }
.mem { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; text-align: left; min-width: 0; }
.mem:hover { background: var(--bg3); }
.mem.off { opacity: 0.5; }
.tag { margin-left: 6px; padding: 0 6px; font-size: 10px; border-radius: 4px; background: var(--red); color: #fff; vertical-align: middle; font-weight: 700; }
.tag.adm { background: var(--blue); }

/* avatars */
.ava { position: relative; display: inline-block; flex: none; border-radius: 50%; background: var(--bg4); overflow: visible; }
.ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.ava.sprite img { object-fit: contain; image-rendering: pixelated; padding: 8%; }
.ava .dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #6b6f80; border: 2px solid var(--bg2); }
.ava .dot.on { background: var(--ok); }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; flex: 1; position: relative; }
.chat-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid #00000050; flex: none; }
.chat-head .hash { color: var(--muted); }
.chat-head .topic { color: var(--muted); font-size: 13px; margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { background: #5a3a12; color: #ffd9a0; text-align: center; padding: 4px; font-size: 13px; }
.scroll { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.msgs { padding: 12px 0 8px; }
.welcome { padding: 30px 20px 10px; color: var(--muted); }
.welcome h3 { color: var(--text); margin: 10px 0 4px; font-size: 24px; }
.loadmore { display: block; margin: 8px auto; padding: 6px 14px; border-radius: 99px; background: var(--bg3); color: var(--muted); font-size: 13px; }
.loadmore:hover { color: var(--text); }
.day { display: flex; align-items: center; gap: 12px; margin: 14px 18px 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; padding: 2px 18px 2px 18px; margin-top: 12px; }
.msg.grouped { margin-top: 0; }
.msg:hover { background: #ffffff08; }
.msg.flash { background: #ee3b4630; }
.msg .replyline { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin: 0 0 2px 22px; color: var(--muted); font-size: 13px; cursor: pointer; min-width: 0; }
.msg .replyline span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .replyline b { color: #c8ccda; flex: none; }
.curve { width: 18px; height: 10px; border-left: 2px solid var(--line); border-top: 2px solid var(--line); border-radius: 6px 0 0 0; flex: none; margin-top: 6px; }
.ava-btn { height: 40px; border-radius: 50%; }
.gutter { font-size: 10px; color: transparent; text-align: right; padding-top: 4px; }
.msg:hover .gutter { color: var(--muted); }
.meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.meta .name { font-weight: 700; }
.meta .name:hover { text-decoration: underline; }
.meta .pk { font-size: 11px; color: var(--muted); background: var(--bg3); padding: 0 6px; border-radius: 99px; }
.meta time { font-size: 12px; color: var(--muted); }
.content { min-width: 0; }
.body { overflow-wrap: anywhere; white-space: pre-wrap; }
.body .embed { display: block; margin-top: 6px; width: fit-content; max-width: 100%; }
.body .embed img { display: block; max-width: min(100%, 420px); max-height: 320px; border-radius: 10px; background: var(--bg3); }
.edited { color: var(--muted); font-size: 11px; margin-left: 4px; }
.editbox small { color: var(--muted); }
textarea.edit { resize: vertical; min-height: 52px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { display: inline-flex; gap: 5px; align-items: center; padding: 1px 8px; border-radius: 8px; background: var(--bg3); border: 1px solid transparent; }
.react b { font-size: 12px; color: var(--muted); }
.react.mine { border-color: var(--blue); background: #243252; }
.react:hover { background: var(--bg4); }
.actions { position: absolute; right: 18px; top: -14px; display: none; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: 0 4px 14px #0005; }
.msg:hover .actions, .msg:focus-within .actions { display: flex; }
.actions button { width: 30px; height: 28px; display: grid; place-items: center; color: var(--muted); border-radius: 6px; }
.actions button:hover { background: var(--bg4); color: var(--text); }
.actions button.danger:hover { color: #ff8b92; }
.composer { flex: none; padding: 0 16px 6px; }
.composer .box { display: flex; align-items: flex-end; gap: 2px; background: var(--bg3); border-radius: 12px; padding: 4px 6px 4px 14px; }
.composer textarea { background: transparent; border: 0; resize: none; padding: 9px 4px; max-height: 180px; line-height: 1.4; }
.composer textarea:disabled { cursor: not-allowed; }
.replybar { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px; background: var(--bg4); border-radius: 10px 10px 0 0; color: var(--muted); font-size: 13px; margin-bottom: -4px; position: relative; z-index: 1; }
.typing { height: 20px; font-size: 12px; color: var(--muted); padding: 2px 4px; }

/* emoji popover */
.emoji-pop { position: fixed; z-index: 60; width: 232px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px; background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px #0008; }
.emoji-pop button { font-size: 22px; padding: 4px; border-radius: 8px; line-height: 1.2; }
.emoji-pop button:hover { background: var(--bg4); }

/* modal */
.overlay { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 70px #000a; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 10px 20px 20px; }
.settings h4 { margin: 0 0 4px; }
.set-ava { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.set-ava p { margin: 0 0 8px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.split { justify-content: space-between; margin-top: 8px; }
.set-poke { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg3); border-radius: 12px; margin-bottom: 8px; }
.set-poke > div { flex: 1; display: grid; }
.set-poke small, .profile small { color: var(--muted); }
.set-poke img { image-rendering: pixelated; }
.profile-top { display: flex; gap: 16px; align-items: center; }
.profile-top h3 { margin: 0; font-size: 22px; }
.profile-top p { margin: 2px 0; }
.status { color: var(--text); }
.profile-poke { display: flex; align-items: center; gap: 16px; margin-top: 18px; padding: 12px; background: var(--bg3); border-radius: 14px; }
.profile-poke > div { display: grid; gap: 4px; justify-items: start; }
.profile-poke .types { justify-content: flex-start; }
.scrim { display: none; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--bg4) transparent; }

/* responsive */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 68px 232px minmax(0, 1fr); }
  .members { position: fixed; right: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(100%); transition: transform 0.2s; }
  .shell.show-members .members { transform: none; }
  .only-mobile { display: inline-grid; }
  .scrim { position: fixed; inset: 0; background: #0008; z-index: 30; }
  .shell.show-members .scrim, .shell.show-nav .scrim { display: block; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: 60px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .side { position: fixed; left: 60px; top: 0; bottom: 0; width: 240px; z-index: 40; transform: translateX(-120%); transition: transform 0.2s; }
  .shell.show-nav .rail, .shell.show-nav .side { transform: none; }
  .dex-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 46%); }
  .dex-detail { margin-bottom: 8px; }
  .dex-detail .art { width: 130px; height: 130px; }
  .pick { padding: 12px 12px 0; }
  .dexwrap { padding: 12px 12px 0; }
  .msg { padding-left: 12px; padding-right: 12px; column-gap: 10px; }
  .actions { right: 8px; }
  .dex-count { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.keep { margin: 0 0 10px; }
