@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 100 900; font-stretch: 62% 125%; src: url(/fonts/archivo.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Archivo'; font-style: italic; font-weight: 100 900; font-stretch: 62% 125%; src: url(/fonts/archivo-italic.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Space Mono'; font-weight: 400; src: url(/fonts/spacemono-400.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Space Mono'; font-weight: 700; src: url(/fonts/spacemono-700.woff2) format('woff2'); font-display: swap; }
:root {
  --ink: #16141a; --lime: #cdf23a; --blue: #7dc5f2; --pink: #e6a5e6; --cream: #f4f1e9; --paper: #fefdf7; --grey: #66655e; --line: #d9d5c8; --red: #e85b5b;
  --sans: 'Archivo', 'Segoe UI', system-ui, sans-serif; --mono: 'Space Mono', ui-monospace, Consolas, monospace;
  --outline: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 2.1px 2.1px 0 var(--ink), -2.1px -2.1px 0 var(--ink), 2.1px -2.1px 0 var(--ink), -2.1px 2.1px 0 var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink: #f4f1e9; --cream: #16141a; --paper: #1d1b23; --grey: #a7a39a; --line: #332f3c; }
}
:root[data-theme="dark"] { --ink: #f4f1e9; --cream: #16141a; --paper: #1d1b23; --grey: #a7a39a; --line: #332f3c; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--cream); overflow-x: hidden; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
body.in-app { height: 100vh; overflow: hidden; }
body.in-app .ticker, body.in-app .nav, body.in-app footer { display: none; }
body.in-app main#app { flex: 1; min-height: 0; }
.dots { background-image: radial-gradient(circle, var(--line) 1.3px, transparent 1.6px); background-size: 24px 24px; }
a { color: inherit; text-decoration: none; }

.titlebar { height: 34px; background: var(--blue); color: var(--ink); display: flex; align-items: center; justify-content: space-between; padding: 0 0 0 14px; -webkit-app-region: drag; border-bottom: 2px solid var(--ink); }
.titlebar-label { font: 800 12px var(--sans); letter-spacing: .06em; }
.titlebar-btns { display: flex; height: 100%; -webkit-app-region: no-drag; }
.titlebar-btns button { width: 44px; height: 100%; border: none; background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.titlebar-btns button:hover { background: rgba(22,20,26,0.12); }
.titlebar-btns button#tb-close:hover { background: var(--red); color: var(--paper); }

.ticker { height: 30px; background: #181b13; color: var(--lime); overflow: hidden; white-space: nowrap; display: flex; align-items: center; font: 700 11.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.ticker-track { display: flex; animation: tick 32s linear infinite; }
.ticker-track span { padding: 0 16px; }
@keyframes tick { to { transform: translateX(-50%); } }

.nav { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: 0 auto; padding: 14px 24px; }
.logo { position: relative; display: inline-flex; align-items: center; font: italic 900 30px/1 var(--sans); font-stretch: 125%; color: var(--blue); letter-spacing: -.01em; text-shadow: var(--outline), 4px 4px 0 var(--ink); }
.logo-pill { font: 800 11px/20px var(--sans); color: var(--ink); background: var(--pink); border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; margin-left: 8px; letter-spacing: .06em; text-shadow: none; box-shadow: 2px 2px 0 var(--ink); vertical-align: middle; }
#nav-actions { display: flex; gap: 10px; align-items: center; }
#nav-actions span { font: 700 13px var(--sans); opacity: .7; margin-right: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--lime); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: 11px 22px;
  font: 800 14px/1.2 var(--sans); letter-spacing: .04em; cursor: pointer; box-shadow: 4px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.small { padding: 8px 16px; font-size: 12px; box-shadow: 3px 3px 0 var(--ink); }
.btn.blue { background: var(--blue); }
.btn.pink { background: var(--pink); }
.btn.ghost { background: var(--paper); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1100px; margin: 0 auto; padding: 0 24px 60px; min-height: calc(100vh - 140px); }
#app.full { max-width: none; padding: 0; min-height: 0; }

/* ---------- landing ---------- */
.hero { text-align: center; padding: 60px 0 40px; }
.hero .tag { display: inline-block; background: var(--ink); color: var(--lime); border-radius: 999px; padding: 7px 18px; font: 700 11px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; margin-bottom: 22px; }
.hero h1 { font: italic 900 clamp(38px, 7vw, 72px)/1.02 var(--sans); font-stretch: 125%; color: var(--blue); text-shadow: var(--outline), 6px 6px 0 var(--ink); margin: 0 0 20px; letter-spacing: -.01em; }
.hero p { max-width: 540px; margin: 0 auto 30px; font-size: 17px; color: var(--grey); }
.hero .cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.pill-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 36px 0; }
.pill { font: 800 13px var(--sans); padding: 10px 18px; border-radius: 999px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.pill.lime { background: var(--lime); } .pill.blue { background: var(--blue); } .pill.pink { background: var(--pink); } .pill.paper { background: var(--paper); }

/* ---------- auth forms ---------- */
.auth-card { max-width: 400px; margin: 40px auto; background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; padding: 28px; box-shadow: 6px 6px 0 var(--ink); }
.auth-card h2 { margin: 0 0 6px; font: italic 900 26px var(--sans); font-stretch: 125%; color: var(--blue); text-shadow: var(--outline), 3px 3px 0 var(--ink); }
.auth-card p.sub { color: var(--grey); font-size: 13px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; color: var(--grey); }
.field input { width: 100%; background: var(--cream); border: 2px solid var(--ink); border-radius: 12px; padding: 11px 14px; font: 500 14px var(--sans); color: var(--ink); }
.field input:focus { outline: none; border-color: var(--blue); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--grey); text-align: center; }
.err { background: #fde8e8; border: 2px solid var(--red); color: #8a2222; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.ok { background: #eafbe0; border: 2px solid #4a9b3e; color: #2c5c22; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }

/* ---------- app shell ---------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; gap: 20px; min-height: 70vh; }
.sidebar { background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; padding: 14px; height: fit-content; }
.sidebar .btn { width: 100%; margin-bottom: 12px; }
.conv-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.conv-item:hover { background: var(--cream); }
.conv-item.active { background: var(--lime); font-weight: 700; }
.conv-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv-item .x { opacity: .4; font-size: 11px; }
.conv-item .x:hover { opacity: 1; color: var(--red); }

.chat-pane { background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; display: flex; flex-direction: column; min-height: 70vh; }
.chat-pane .head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 2px solid var(--line); }
.chat-pane .head .title { font-weight: 800; font-size: 15px; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 78%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.55; border: 2px solid var(--ink); }
.msg.user { align-self: flex-end; background: var(--blue); }
.msg.assistant { align-self: flex-start; background: var(--cream); }
.msg.assistant :is(p) { margin: 0 0 8px; }
.msg.assistant :is(p):last-child { margin-bottom: 0; }
.msg.assistant code { background: var(--paper); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; }
.msg.assistant pre { background: var(--ink); color: var(--lime); padding: 12px; border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.msg-empty { opacity: .5; font-size: 14px; text-align: center; margin-top: 60px; }
.composer { display: flex; gap: 10px; padding: 16px; border-top: 2px solid var(--line); }
.composer input { flex: 1; background: var(--cream); border: 2px solid var(--ink); border-radius: 999px; padding: 12px 18px; font-size: 14px; }
.composer input:focus { outline: none; border-color: var(--blue); }

.share-bar { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.share-link { background: var(--cream); border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 10px; font-family: var(--mono); font-size: 11px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

footer { text-align: center; padding: 30px 0; }
.madeby { font: 700 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--grey); }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

/* ---------- Discord-style app shell ---------- */
.shell { display: grid; grid-template-columns: 72px 240px 1fr; height: 100%; background: var(--cream); }
.rail { background: var(--ink); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 10px; overflow-y: auto; }
.rail-icon { width: 46px; height: 46px; border-radius: 50%; background: var(--paper); color: var(--ink); display: flex; align-items: center; justify-content: center; font: 800 16px var(--sans); cursor: pointer; border: 2px solid transparent; transition: border-radius .15s, border-color .15s; flex-shrink: 0; }
.rail-icon:hover { border-radius: 16px; border-color: var(--lime); }
.rail-icon.active { border-radius: 16px; background: var(--lime); }
.rail-icon.home { background: var(--blue); }
.rail-icon.add, .rail-icon.settings { background: transparent; color: var(--lime); border: 2px dashed var(--lime); font-size: 20px; }
.rail-sep { width: 32px; height: 2px; background: var(--grey); opacity: .3; border-radius: 1px; }

.sidebar2 { background: var(--paper); border-right: 2px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-head { padding: 16px 14px 10px; font: 800 15px var(--sans); display: flex; justify-content: space-between; align-items: center; }
.invite-btn { font: 700 10px var(--mono); background: var(--cream); border: 1.5px solid var(--line); border-radius: 6px; padding: 3px 8px; cursor: pointer; }
.chan-group { padding: 14px 14px 4px; font: 700 10px var(--mono); letter-spacing: .1em; color: var(--grey); text-transform: uppercase; }
.chan-item { padding: 8px 14px; margin: 1px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; opacity: .8; }
.chan-item:hover { background: var(--cream); opacity: 1; }
.chan-item.active { background: var(--blue); opacity: 1; }
.chan-item.voice { opacity: .9; }
.dm-list { flex: 0 0 auto; padding: 0 6px; }
.dm-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.dm-item:hover { background: var(--cream); }
.dm-item.active { background: var(--blue); }
.dm-item.pending { cursor: default; opacity: .8; }
.dm-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-item .meta { font-size: 11px; color: var(--grey); }
.dm-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); opacity: .4; margin-left: auto; }
.dm-item .dot.online { background: #4a9b3e; opacity: 1; box-shadow: 0 0 6px #4a9b3e; }
.member-list { margin-top: auto; border-top: 2px solid var(--line); padding-top: 6px; max-height: 40vh; overflow-y: auto; }

.avatar { border-radius: 50%; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink); flex-shrink: 0; }

.main-pane { display: flex; flex-direction: column; min-width: 0; }
.main-pane { min-height: 0; }
.main-pane .chat-pane { border: none; border-radius: 0; min-height: 0; height: 100%; }
.chan-msg { display: flex; gap: 12px; padding: 4px 0; }
.chan-msg-head { display: flex; gap: 8px; align-items: baseline; }
.chan-msg-head b { font-size: 14px; }
.chan-msg-head .time { font-size: 10px; color: var(--grey); font-family: var(--mono); }
.chan-msg .md p { margin: 2px 0; }

.game-panel { background: var(--cream); border-top: 2px solid var(--line); padding: 16px; text-align: center; }
.game-grid { display: grid; gap: 4px; max-width: 280px; margin: 10px auto 0; }
.game-grid.connect4 { max-width: 360px; }
.game-cell { aspect-ratio: 1; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }
.game-cell:hover { background: var(--lime); }

.watch-box { background: #000; border-top: 2px solid var(--line); }

.call-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--cream); border-radius: 999px; padding: 10px 18px; display: flex; align-items: center; gap: 12px; font: 700 13px var(--sans); box-shadow: 0 6px 20px rgba(0,0,0,0.3); z-index: 60; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,8,16,0.55); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-backdrop.open { display: flex; }
.chat-modal { background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; width: 100%; max-width: 480px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.chat-modal .head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 2px solid var(--line); }
.chat-modal .head .t { font-weight: 800; font-size: 16px; }
.chat-modal .head .close { cursor: pointer; opacity: .6; background: none; border: none; color: var(--ink); font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body input, .modal-body select { width: 100%; background: var(--cream); border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; font: 500 14px var(--sans); color: var(--ink); }
.modal-body .field { margin-bottom: 12px; }
.modal-body .btn { width: 100%; margin-top: 6px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 56px 1fr; }
  .sidebar2 { position: fixed; left: 56px; top: 0; bottom: 0; width: 240px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
}
