:root {
  --bg: #f4f5f8; --panel: #ffffff; --text: #1c2230; --muted: #6b7385; --border: #dfe3ea;
  --accent: #2f6fdf; --accent-text: #ffffff; --in: #ffffff; --out: #e3edff;
  --ok: #1e8a4c; --warn: #b26a00; --bad: #c62828; --hover: #eef2f8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --text: #e5e8ee; --muted: #9099aa; --border: #2c3340;
    --accent: #5b8ff0; --accent-text: #0d1117; --in: #1f2531; --out: #23324d;
    --ok: #4cc07f; --warn: #e5a24a; --bad: #ef6b6b; --hover: #242b37;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
h2 { font-size: 1.1rem; margin: 0; }

button, .btn {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: .55rem 1rem; font: inherit; cursor: pointer; text-decoration: none; display: inline-block;
}
button:disabled { opacity: .6; cursor: default; }
button.small, .btn.small { padding: .3rem .7rem; font-size: .85rem; margin: .3rem .4rem 0 0; }
.link-btn { background: none; color: var(--accent); padding: .2rem .4rem; }
input, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit;
}
label { display: block; margin: .7rem 0; font-size: .9rem; color: var(--muted); }
label input { margin-top: .25rem; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 1.6rem; }
.center { max-width: 400px; margin: 10vh auto; }
.center.wide { max-width: 620px; }
.card ul { padding-left: 1.2rem; }
.card li { margin: .4rem 0; }

.topbar { display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar a { color: var(--accent); }
.brand { font-weight: 700; }
.spacer { flex: 1; }

#view-main { display: flex; flex-direction: column; height: 100vh; }
.layout { flex: 1; display: grid; grid-template-columns: minmax(220px, 320px) 1fr; min-height: 0; }
#chat-list { border-right: 1px solid var(--border); overflow-y: auto; background: var(--panel); }
.chat-item { display: block; width: 100%; text-align: left; background: none; color: var(--text);
  border-radius: 0; border-bottom: 1px solid var(--border); padding: .6rem .9rem; }
.chat-item:hover, .chat-item.active { background: var(--hover); }
.chat-item .row { display: flex; justify-content: space-between; gap: .5rem; }
.chat-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .preview { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 .45rem; font-size: .75rem; }

.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: var(--panel); }
#messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.msg { max-width: min(680px, 85%); padding: .5rem .75rem; border-radius: 12px; background: var(--in);
  border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--out); }
.msg.service { align-self: center; color: var(--muted); font-size: .85rem; background: none; border: 0; }
.meta { display: flex; gap: .6rem; font-size: .78rem; color: var(--muted); margin-bottom: .15rem; }
.sender { font-weight: 600; }
.text { white-space: pre-wrap; }
.load-more { align-self: center; }

a.link { text-decoration: underline; }
a.link.v-clean { color: var(--accent); }
a.link.v-unknown { color: var(--warn); }
a.link.v-suspicious { color: var(--warn); font-weight: 600; }
a.link.v-malicious { color: var(--bad); font-weight: 600; text-decoration: line-through; }

.file { margin-top: .4rem; padding: .5rem .6rem; border: 1px dashed var(--border); border-radius: 10px; }
.file-info { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.fname { font-weight: 600; overflow-wrap: anywhere; }
.status-line { margin-top: .3rem; font-weight: 600; }
.s-clean, .s-sent { color: var(--ok); }
.s-suspicious, .s-warn, .s-expired { color: var(--warn); }
.s-blocked, .s-malicious, .s-error, .s-too_large, .s-dlp_blocked { color: var(--bad); }
.reason { font-size: .85rem; color: var(--muted); }
.preview-img { display: block; max-width: 100%; max-height: 360px; margin-top: .4rem; border-radius: 8px; }
.engines { margin-top: .3rem; font-size: .8rem; color: var(--muted); }
.engines ul { margin: .2rem 0; padding-left: 1.1rem; }
.engines .v-malicious, .engines .v-blocked { color: var(--bad); }
.engines .v-suspicious, .engines .v-error { color: var(--warn); }
#outbox { padding: 0 1rem; }
#outbox .file { background: var(--panel); margin-bottom: .4rem; }

#composer { display: flex; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--border); background: var(--panel); align-items: flex-end; }
#composer textarea { resize: vertical; min-height: 2.6rem; max-height: 10rem; }
.attach { margin: 0; font-size: 1.4rem; cursor: pointer; color: var(--text); padding: .3rem; }
.attach input { display: none; }

/* /go gate pages */
body.gate { display: flex; align-items: flex-start; justify-content: center; }
.gate-card { max-width: 620px; margin: 10vh 16px; }
.gate-card .url { font-family: Consolas, monospace; overflow-wrap: anywhere; background: var(--bg); padding: .5rem; border-radius: 6px; }
.gate-card .bad { color: var(--bad); }
.gate-card .warn { color: var(--warn); }

/* admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; }
.tile .num { font-size: 1.6rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: .6rem; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar.bad { background: var(--bad); }
.bar.warn { background: var(--warn); }
.daybars { display: flex; align-items: flex-end; gap: 4px; height: 140px; border-bottom: 1px solid var(--border); }
.daybars .day { flex: 1; display: flex; flex-direction: column-reverse; min-width: 6px; }
.daybars .seg-clean { background: var(--ok); }
.daybars .seg-suspicious, .daybars .seg-unknown { background: var(--warn); }
.daybars .seg-bad { background: var(--bad); }
.legend span { margin-right: 1rem; font-size: .85rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 35vh 1fr; }
  #chat-list { border-right: 0; border-bottom: 1px solid var(--border); }
}
.gap-top { margin-top: 1rem; }
.qr { display: block; width: 220px; height: 220px; margin: .6rem auto; background: #fff; padding: 6px; border-radius: 8px; }
code { font-family: Consolas, monospace; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.inline-form input { width: auto; flex: 1; min-width: 180px; }
select { padding: .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.secret-box { border: 1px solid var(--warn); border-radius: 10px; padding: .4rem 1rem; margin-bottom: 1rem; }
.secret-box code { font-size: 1.1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .2rem; align-items: center; }
.section-title { margin: 1.5rem 0 .5rem; }

/* isolated browser */
#view-desk { display: flex; flex-direction: column; height: 100vh; }
.desk-layout { flex: 1; display: flex; min-height: 0; }
.desk-stage { flex: 1; position: relative; background: #000; min-width: 0; }
#desk-frame { width: 100%; height: 100%; border: 0; display: block; }
.desk-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 2rem; text-align: center; color: #c9d1d9; }
.desk-files { width: 320px; overflow-y: auto; padding: .8rem 1rem; background: var(--panel); border-left: 1px solid var(--border); }
.desk-files h3 { font-size: 1rem; margin: .8rem 0 .3rem; }
.small-text { font-size: .85rem; margin: .2rem 0 .6rem; }
@media (max-width: 720px) { .desk-files { width: 100%; } .desk-layout { flex-direction: column; } }

/* emoji, reactions, stickers, avatars */
body, input, textarea, button { font-family: "Segoe UI", system-ui, sans-serif, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji"; }
.chat-item { display: flex; gap: .6rem; align-items: center; }
.chat-text { min-width: 0; flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.reactions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.reaction { background: var(--hover); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  padding: .05rem .5rem; font-size: .85rem; line-height: 1.5; }
.reaction.mine { border-color: var(--accent); background: var(--out); }
.reaction.add { opacity: 0; transition: opacity .15s; }
.msg:hover .reaction.add, .reaction.add:focus { opacity: .8; }
.reaction-picker { display: flex; gap: .2rem; flex-wrap: wrap; }
.sticker { margin-top: .3rem; }
.sticker-emoji { font-size: 2.6rem; line-height: 1; }
.sticker-img { display: block; max-width: 160px; max-height: 160px; }
#composer { position: relative; }
.emoji-btn { background: none; font-size: 1.4rem; padding: .2rem .3rem; color: var(--text); }
.emoji-panel { position: absolute; bottom: 100%; left: 3rem; width: min(340px, 90vw); max-height: 220px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .4rem;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: .15rem; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.emoji-panel.hidden { display: none; }
.emoji { background: none; font-size: 1.35rem; padding: .15rem; border-radius: 6px; color: var(--text); }
.emoji:hover { background: var(--hover); }
