:root {
  color-scheme: light dark;
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #17212b;
  --muted: #667585;
  --line: #dbe2ea;
  --accent: #2b8be6;
  --accent-ink: #ffffff;
  --hint: #fff6e0;
  --hint-line: #f1d48a;
  --btn: #e9eff5;
  --btn-ink: #17212b;
  --success: #2a9d4b;
  --primary: #2b8be6;
  --danger: #df3f45;
  --code: #f2f4f7;
  --spoiler: #9aa6b2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "PingFang TC", "Noto Sans SC", "Noto Sans TC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621;
    --card: #17212b;
    --ink: #e8eef3;
    --muted: #8a9aab;
    --line: #253342;
    --accent: #3f9ce8;
    --hint: #2b2614;
    --hint-line: #6b5a22;
    --btn: #22303e;
    --btn-ink: #e8eef3;
    --success: #34a853;
    --primary: #3f9ce8;
    --danger: #e5484d;
    --code: #1f2b37;
    --spoiler: #5b6a79;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; padding-bottom: 168px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; flex: none; }
.brand div { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 16px; line-height: 1.2; }
.brand small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 6px; }
.tool {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; min-height: 36px; white-space: nowrap;
}
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.who { position: relative; }
#who { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  display: flex; flex-direction: column; min-width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu button { text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; }
.menu button:hover, .menu button:focus-visible { background: var(--btn); }

.login, .app { max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.intro { padding: 24px; }
.intro h1 { margin: 0 0 12px; font-size: 22px; }
.steps { padding-left: 22px; margin: 12px 0; }
.steps li { margin: 6px 0; }
.muted { color: var(--muted); }
.status:empty { display: none; }
.status { padding: 10px 12px; border-radius: 10px; background: var(--btn); }
.status.bad { background: rgba(223, 63, 69, .12); color: var(--danger); }
.widget { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

.note { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.screen { padding: 0; overflow: hidden; }
.message { padding: 16px 18px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.text a { color: var(--accent); }
.text code { background: var(--code); padding: 1px 5px; border-radius: 5px; }
.text pre { background: var(--code); padding: 10px 12px; border-radius: 10px; overflow-x: auto; white-space: pre; }
.text blockquote { margin: 6px 0; padding: 2px 10px; border-left: 3px solid var(--accent); background: var(--btn); border-radius: 0 8px 8px 0; }
.text .spoiler { background: var(--spoiler); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s; }
.text .spoiler.open { background: transparent; color: inherit; }
.text .command { color: var(--accent); cursor: pointer; }
.text .command:hover { text-decoration: underline; }
.media { display: grid; gap: 4px; background: #000; }
.media img, .media video { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.media audio { width: 100%; background: var(--card); }
.doc { display: inline-flex; align-items: center; gap: 8px; margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; background: var(--btn); color: var(--ink); text-decoration: none; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }

.keyboard { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 14px; }
.row { display: flex; gap: 6px; }
.button {
  flex: 1 1 0; min-width: 0; min-height: 42px; padding: 8px 10px;
  border: 0; border-radius: 10px; background: var(--btn); color: var(--btn-ink);
  font-weight: 500; overflow-wrap: anywhere; position: relative;
  transition: filter .12s, transform .06s;
}
.button:hover { filter: brightness(.96); }
.button:active { transform: scale(.985); }
.button:disabled { opacity: .55; cursor: progress; }
.button.success { background: var(--success); color: #fff; }
.button.primary { background: var(--primary); color: #fff; }
.button.danger { background: var(--danger); color: #fff; }
.button .corner { position: absolute; right: 6px; top: 4px; font-size: 11px; opacity: .8; }
.painting .button { outline: 2px dashed rgba(127, 127, 127, .55); outline-offset: 2px; }
.painting .button.chosen { outline: 2px solid var(--accent); }

.hint { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--hint); border: 1px solid var(--hint-line); }
.hint .message { padding: 0; }
.hint .keyboard { padding: 10px 0 0; }
.others { margin-top: 22px; }
.others h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; letter-spacing: .02em; }
.other { margin-bottom: 10px; position: relative; }
.other .tag { display: block; padding: 0 18px 12px; color: var(--muted); font-size: 12px; }
.other .dismiss { position: absolute; right: 8px; top: 8px; z-index: 2; border: 0; background: rgba(0, 0, 0, .35); color: #fff; width: 28px; height: 28px; border-radius: 50%; }

.paint-bar { margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--accent); }
.paint-bar p { margin: 0 0 8px; }
.paint-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.paint-list { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.paint-list .item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.paint-list .item span.label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paint-list .key { color: var(--muted); }
.key { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 8px 16px; }
.danger-link { border: 0; background: none; color: var(--danger); padding: 4px 0; }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px max(16px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
}
.composer > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.awaiting { margin-bottom: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(43, 139, 230, .12); color: var(--accent); font-size: 13px; }
.attached { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.attached #attached-name { font-weight: 600; overflow-wrap: anywhere; }
.as-file { color: var(--muted); }
.format { display: flex; gap: 4px; margin-bottom: 6px; overflow-x: auto; }
.format button { flex: none; min-width: 34px; height: 30px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 0 8px; }
.compose-row { display: flex; align-items: flex-end; gap: 8px; position: relative; }
.round { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: inline-grid; place-items: center; font-weight: 700; }
.round.attach { cursor: pointer; }
.round.send { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.editor {
  flex: 1; min-width: 0; min-height: 42px; max-height: 38vh; overflow-y: auto;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  white-space: pre-wrap; overflow-wrap: anywhere; outline: none;
}
.editor:focus { border-color: var(--accent); }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.awaiting:not([hidden]) ~ .compose-row .editor { border-color: var(--accent); }
.editor .tg-spoiler { background: var(--spoiler); border-radius: 3px; }
.editor code { background: var(--code); border-radius: 4px; padding: 0 3px; }
.editor blockquote { margin: 2px 0; padding-left: 8px; border-left: 3px solid var(--accent); }
.editor a { color: var(--accent); }
.commands { left: 0; right: auto; top: auto; bottom: calc(100% + 8px); max-height: 50vh; overflow-y: auto; min-width: 240px; }
.commands button { display: flex; gap: 10px; }
.commands b { color: var(--accent); min-width: 72px; }

.toast {
  position: fixed; left: 50%; bottom: 190px; transform: translateX(-50%); z-index: 40;
  max-width: min(520px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: rgba(23, 33, 43, .92); color: #fff; box-shadow: var(--shadow); white-space: pre-wrap;
}
.alert { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0, 0, 0, .35); padding: 16px; }
.alert-box { background: var(--card); border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }
.alert-box p { white-space: pre-wrap; margin: 0 0 16px; }
.alert-box button { float: right; }
.palette {
  position: fixed; z-index: 45; width: 248px; padding: 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.palette p { margin: 0 0 8px; font-weight: 600; overflow-wrap: anywhere; }
.swatches { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.swatches button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 7px 8px; border-radius: 8px; text-align: left; }
.swatches button:hover, .swatches button.current { background: var(--btn); }
.dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 1px solid var(--line); flex: none; }
.dot-success { background: var(--success); }
.dot-primary { background: var(--primary); }
.dot-danger { background: var(--danger); }
.dot-none { background: var(--btn); }
.dot-default { background: conic-gradient(var(--success) 0 50%, var(--btn) 0); }
.busy .button, .busy .round.send { cursor: progress; }

@media (max-width: 560px) {
  body { padding-bottom: 184px; }
  .bar { padding: 8px 12px; }
  .tool { padding: 6px 10px; }
  #paint-toggle span[data-t] { display: none; }
  .login, .app { padding: 12px; }
  .message { padding: 14px; }
  .keyboard { padding: 0 10px 12px; }
  .button { padding: 8px 6px; font-size: 14px; }
}
