/* Ticker 网页样式。设计语言见 design/DESIGN.md：柿 / 墨 / 藤黄三色，叶形（对角两大两小圆角），节拍格壁纸；浅色 / 深色两套变量 */
:root {
  --bg: #fff; --bg2: #f6f2ec; --hover: #f2ece4; --sel: #ffe9dd; --text: #1d1a26; --sub: #6b6475; --line: #e8e1d8;
  --accent: #c8410f; --on-accent: #fff; --brand: #ff6a2c; --amber: #ffc94d; --online: #23a47a;
  --danger: #c21f5b; --tick: #c8410f; --hl: rgba(255, 201, 77, .4);
  --in: #fff; --out: #ffe3d3; --out-text: #1d1a26; --meta: #716a7a; --out-meta: #9a4a24; --out-acc: #a3390c;
  --pill: rgba(29, 26, 38, .62); --menu: rgba(255, 255, 255, .95); --shadow: 0 1px 2px rgba(42, 35, 64, .12);
  --wall: /* 节拍格：/ 是「嘀」、\ 是「嗒」留下的拍子痕迹，右上角一团柿色暖光 */
    radial-gradient(120% 70% at 100% 0, rgba(255, 106, 44, .12), transparent 60%),
    repeating-linear-gradient(45deg, rgba(42, 35, 64, .05) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(-45deg, rgba(42, 35, 64, .05) 0 1px, transparent 1px 24px), #f3ece2;
  color-scheme: light;
}
.dark {
  --bg: #1c1a23; --bg2: #15131b; --hover: #282531; --sel: #2b2733; --text: #f2eee8; --sub: #a9a2b0; --line: #2e2a37;
  --accent: #ff8a57; --on-accent: #1d1a26; --brand: #ff7a3d; --danger: #ff7096; --tick: #ff8a57; --hl: rgba(255, 201, 77, .22);
  --in: #24212d; --out: #8e3517; --out-text: #fff; --meta: #9c95a4; --out-meta: #ffd9c4; --out-acc: #ffd9c4;
  --pill: rgba(0, 0, 0, .45); --menu: rgba(28, 26, 35, .95); --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --wall:
    radial-gradient(120% 70% at 100% 0, rgba(255, 106, 44, .09), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 24px), #131118;
  color-scheme: dark;
}
html { font-size: 15px; }
html[data-fs=s] { font-size: 13.5px; }
html[data-fs=l] { font-size: 17.5px; }
* { box-sizing: border-box; scrollbar-width: thin; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 1rem/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text); background: var(--bg); overflow: hidden; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
.dark input, .dark textarea, .dark select { border-color: #3a3644; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.ic { display: inline-grid; width: 24px; height: 24px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: currentColor; }
.ib {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px 5px 14px 5px; padding: 0;
  background: none; color: var(--sub); display: grid; place-items: center; cursor: pointer;
}
.ib:hover { background: var(--hover); }
.ib.act { color: var(--accent); }
.btn {
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 12px 4px 12px 4px; cursor: pointer;
  background: var(--hover); color: var(--accent); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.wide { width: 100%; }
.hint { color: var(--sub); font-size: .88em; margin: 4px 0 8px; }
.none { color: var(--sub); text-align: center; padding: 24px 12px; margin: 0; }

/* 登录 */
#login { height: 100vh; height: 100dvh; overflow: auto; display: grid; place-items: center; padding: 16px; background: var(--wall); }
.card {
  width: min(380px, 100%); background: var(--bg); border-radius: 24px; padding: 32px 28px 20px;
  box-shadow: 0 6px 28px rgba(42, 35, 64, .1); display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.logo { width: 96px; height: 96px; margin: 0 auto; }
.card h1 { margin: 0; font-size: 1.7em; letter-spacing: .02em; }
.tag { margin: -8px 0 4px; font-size: .85em; letter-spacing: .1em; color: var(--sub); } /* 标语，紧贴在标题下 */
.tabs { display: flex; background: var(--bg2); border-radius: 12px 4px 12px 4px; padding: 3px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 10px 3px 10px 3px; background: none; color: var(--sub); cursor: pointer; }
.tabs .on { background: var(--bg); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.err { color: var(--danger); min-height: 1.3em; margin: 0; font-size: .9em; }
.srv { color: var(--sub); font-size: .82em; margin-top: 6px; word-break: break-all; }

/* 布局 */
#app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; height: 100dvh; }
#side { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: var(--bg); }
#side .bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px 8px 8px; }
#q { border-radius: 16px 5px 16px 5px; background: var(--bg2); border: 2px solid transparent; padding: 8px 16px; }
#q:focus { border-color: var(--accent); background: var(--bg); }
#list { flex: 1; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
#main { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--wall); }
#main:not(.open) > :not(#empty) { display: none !important; }
#main.open > #empty { display: none; }
#empty { flex: 1; display: grid; place-items: center; }
#empty span, .day span { background: var(--pill); color: #fff; padding: 3px 12px; border-radius: 10px 3px 10px 3px; font-size: .9em; }
@media (max-width: 899px) {
  #app { grid-template-columns: 1fr; }
  body.chat #side, body:not(.chat) #main { display: none; }
  #side { border-right: 0; }
}
@media (min-width: 900px) { .back { display: none !important; } }

/* 列表行 */
.row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin: 0 6px;
  border-radius: 14px 4px 14px 4px; cursor: pointer; min-height: 60px;
}
.row:hover { background: var(--hover); }
.row.sel { background: var(--sel); }
.mid { flex: 1; min-width: 0; }
.l1, .l2 { display: flex; align-items: center; gap: 4px; min-height: 22px; }
.l1 b { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
time { color: var(--sub); font-size: .8em; flex: none; }
.l2 span { flex: 1; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l2 em { font-style: normal; color: var(--text); }
.tick { width: 18px; height: 18px; color: var(--tick); }
.badge { /* 未读角标：柿色底配墨字，叶形 */
  font-style: normal; background: var(--brand); color: #1d1a26; border-radius: 9px 3px 9px 3px; min-width: 22px; height: 22px;
  padding: 0 7px; font-size: .78em; font-weight: 700; display: grid; place-items: center; flex: none;
}
.typing, small.on, span.on { color: var(--accent) !important; }
.sec { padding: 12px 18px 6px; color: var(--sub); font-size: .88em; font-weight: 600; }
.av { /* 叶形头像，纯色 */
  --c: #4d5a86; flex: none; position: relative; width: 54px; height: 54px; border-radius: 42% 16%;
  background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 1.35em;
}
.av.sm { width: 42px; height: 42px; font-size: 1.05em; }
.av.xl { width: 112px; height: 112px; font-size: 2.8em; }
.av.xl .ic { width: 52px; height: 52px; }
.av.on::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--bg);
}

/* 会话头与横条 */
#head {
  display: flex; align-items: center; gap: 6px; height: 56px; flex: none; padding: 0 8px;
  background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.who { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; padding-left: 4px; }
.who > div { min-width: 0; }
.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; color: var(--sub); font-size: .85em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px; flex: none;
  background: var(--bg); border-bottom: 1px solid var(--line); font-size: .9em; color: var(--sub);
}
.strip > .ic { color: var(--accent); width: 20px; height: 20px; }
.pin { /* 置顶条：左上角斜角色块，不用左侧竖条 */
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; padding: 3px 8px 3px 12px; border-radius: 10px 3px 10px 3px;
  background: linear-gradient(135deg, var(--accent) 0 8px, transparent 8px), color-mix(in srgb, var(--accent) 6%, transparent);
}
.pin .ic { color: var(--accent); width: 20px; height: 20px; }
.pin > div { min-width: 0; }
.pin b { display: block; color: var(--accent); font-size: .92em; }
.pin span { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 消息区 */
.mwrap { position: relative; flex: 1; min-height: 0; }
#msgs { position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; }
#inner { margin-top: auto; width: 100%; max-width: 760px; align-self: center; padding: 8px 12px 6px; }
.day { position: sticky; top: 6px; z-index: 1; text-align: center; margin: 8px 0; pointer-events: none; }
.msg { display: flex; padding: 2px 0; border-radius: 10px; transition: background .4s; }
.msg.own { justify-content: flex-end; }
.msg.hl { background: var(--hl); }
.bub { /* 嘀嗒气泡：对方的尖角在右上、左下（斜线 /），自己的在左上、右下（斜线 \），不加尾巴 */
  --ra: var(--accent); --r: 18px 4px 18px 4px; position: relative; display: flow-root; max-width: min(480px, 86%); min-width: 64px;
  padding: 6px 10px 6px; border-radius: var(--r); background: var(--in); color: var(--text);
  box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.own .bub { --ra: var(--out-acc); --r: 4px 18px 4px 18px; background: var(--out); color: var(--out-text); }
.own .bub a { color: inherit; }
.dark .own .bub a { text-decoration: underline; }
.txt { white-space: pre-wrap; }
.name { color: var(--c); font-weight: 600; font-size: .9em; margin-bottom: 1px; }
.dark .name { color: color-mix(in srgb, var(--c) 45%, #fff); }
.fwd { color: var(--ra); font-size: .86em; margin-bottom: 2px; }
.quote { /* 引用块：左上角斜角色块 */
  --c: #4d5a86; border-radius: 10px 3px 10px 3px; padding: 2px 8px 2px 12px; margin: 2px 0 4px; cursor: pointer; font-size: .9em; min-width: 0;
  background: linear-gradient(135deg, var(--c) 0 8px, transparent 8px), color-mix(in srgb, var(--c) 12%, transparent);
}
.own .quote { --c: var(--out-acc) !important; }
.quote b { display: block; color: color-mix(in srgb, var(--c) 85%, #1d1a26); }
.dark .quote b { color: color-mix(in srgb, var(--c) 45%, #fff); }
.quote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.meta {
  float: right; position: relative; top: .45em; margin: -.2em -2px 0 .8em; display: inline-flex; align-items: center; gap: 2px;
  font-size: .74em; color: var(--meta); white-space: nowrap; user-select: none; line-height: 1.6;
}
.own .meta { color: var(--out-meta); }
.meta .tick { width: 16px; height: 16px; color: inherit; }
.img { display: block; max-width: 320px; max-height: 360px; min-width: 60px; min-height: 40px; border-radius: 12px 3px 12px 3px; margin: 2px -4px 4px; cursor: zoom-in; background: var(--hover); }
.own .img { border-radius: 3px 12px 3px 12px; }
.imgl { display: block; }
.bub.media { padding: 0; background: none; box-shadow: none; }
.bub.media .img { margin: 0; border-radius: var(--r); }
.bub.media .name, .bub.media .fwd, .bub.media .quote { background: var(--in); padding: 2px 8px; border-radius: 10px 3px 10px 3px; margin-bottom: 4px; }
.bub.media > .meta { position: absolute; right: 8px; bottom: 8px; top: auto; margin: 0; padding: 0 7px; border-radius: 9px 3px 9px 3px; background: rgba(29, 26, 38, .55); color: #fff; }
.file { display: flex; align-items: center; gap: 10px; color: inherit !important; text-decoration: none !important; padding: 4px 0; min-width: 200px; }
.fi { width: 46px; height: 46px; border-radius: 16px 5px 16px 5px; background: var(--ra); color: var(--bg); display: grid; place-items: center; flex: none; }
.own .fi { color: var(--out); }
.file b { display: block; font-weight: 600; word-break: break-all; }
.file small { color: var(--meta); }
.own .file small { color: var(--out-meta); }
.tr { margin-top: 4px; padding-top: 4px; border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent); }
.tr small { display: block; font-size: .78em; color: var(--ra); }
.trt { font-style: italic; opacity: .78; white-space: pre-wrap; }
.reacts { margin-top: 4px; }
.re { /* 回应：叶形胶囊；自己点过的用藤黄 */
  display: inline-block; border: 0; border-radius: 12px 3px 12px 3px; padding: 2px 9px; margin: 2px 4px 0 0; cursor: pointer;
  background: color-mix(in srgb, var(--ra) 12%, transparent); color: inherit; font-size: .88em; font-weight: 600;
}
.re.mine { background: var(--amber); color: #1d1a26; }
#down {
  position: absolute; right: 18px; bottom: 14px; width: 48px; height: 48px; border: 0; border-radius: 18px 6px 18px 6px;
  background: var(--bg); color: var(--sub); box-shadow: 0 1px 6px rgba(0, 0, 0, .2); cursor: pointer; display: grid; place-items: center; z-index: 2;
}
#down .badge { position: absolute; top: -8px; right: -4px; }

/* 输入区 */
#compose { flex: none; width: 100%; max-width: 760px; align-self: center; padding: 4px 12px calc(10px + env(safe-area-inset-bottom)); }
#bars { display: flex; flex-direction: column; }
.cbar {
  display: flex; align-items: center; gap: 10px; background: var(--bg); padding: 4px 4px 4px 10px;
  border-radius: 20px 6px 0 0; border-bottom: 1px solid var(--line); color: var(--accent);
}
.cbar + .cbar { border-radius: 0; }
.cbar > div {
  flex: 1; min-width: 0; padding: 2px 8px 2px 12px; font-size: .9em; border-radius: 10px 3px 10px 3px;
  background: linear-gradient(135deg, var(--accent) 0 8px, transparent 8px), color-mix(in srgb, var(--accent) 6%, transparent);
}
.cbar b { display: block; }
.cbar span { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow { display: flex; align-items: flex-end; gap: 2px; background: var(--bg); border-radius: 20px 6px 20px 6px; padding: 4px; box-shadow: var(--shadow); }
#bars:not(:empty) + .crow { border-radius: 0 0 20px 6px; }
#text { border: 0; resize: none; padding: 11px 6px; max-height: 180px; background: none; line-height: 1.4; }
#send { width: 40px; height: 40px; margin: 2px; background: var(--accent); color: var(--on-accent); }
#send:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
#joinbar { display: flex; justify-content: center; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); flex: none; }
#joinbar .btn { width: min(736px, 100%); background: var(--bg); box-shadow: var(--shadow); }

/* 信息面板：宽屏右侧抽屉，窄屏全屏 */
#info {
  position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; z-index: 5; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -4px 0 16px rgba(0, 0, 0, .08); padding-bottom: env(safe-area-inset-bottom);
}
@media (max-width: 899px) { #info { width: 100%; border: 0; } }
@media (min-width: 1100px) { #main.side { padding-right: 380px; } #main.side #info { box-shadow: none; } }
#info header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 8px; background: var(--bg); }
#info header b { flex: 1; font-size: 1.15em; }
.hero { text-align: center; padding: 4px 16px 14px; }
.hero .av { margin: 0 auto; }
.hero h2 { margin: 12px 0 2px; font-size: 1.3em; overflow-wrap: anywhere; }
.hero small { color: var(--sub); }
.field { padding: 8px 22px; }
.field div { white-space: pre-wrap; overflow-wrap: anywhere; }
.field small { color: var(--sub); }
.row.act { color: var(--accent); min-height: 48px; font-weight: 500; }
.row.act .ib { color: inherit; width: 42px; height: 42px; }
.row.danger { color: var(--danger); }
.role { color: var(--accent); font-size: .8em; }
.kick { border: 0; background: none; color: var(--danger); cursor: pointer; min-height: 44px; margin: -11px 0; padding: 0 8px; }
.pad { padding: 12px 16px; }

/* 弹出菜单、弹窗、提示 */
#pop {
  position: fixed; z-index: 50; min-width: min(220px, calc(100vw - 16px)); padding: 6px 0; border-radius: 18px 6px 18px 6px;
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; /* 窄屏也完整留在视口内 */
  background: var(--menu); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
}
.pi { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 44px; padding: 0 18px; border: 0; background: none; cursor: pointer; text-align: left; }
.pi:hover { background: var(--hover); }
.pi .ic { color: var(--sub); width: 22px; height: 22px; }
.pi.danger, .pi.danger .ic { color: var(--danger); }
.emo { display: flex; flex-wrap: wrap; justify-content: center; padding: 0 6px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.emo button { flex: 1 0 36px; max-width: 48px; min-width: 36px; height: 44px; border: 0; border-radius: 50%; background: none; font-size: 1.45em; cursor: pointer; transition: transform .1s; }
.emo button:hover { transform: scale(1.2); }
.emo button.mine { background: var(--hl); }
.mehead { display: flex; align-items: center; gap: 12px; padding: 6px 16px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.mehead b, .mehead small { display: block; }
.mehead small { color: var(--sub); }
#modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .42); }
.dlg {
  width: min(440px, 100%); max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); border-radius: 24px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.dlg header { display: flex; align-items: center; padding: 8px 8px 4px 22px; }
.dlg header b { flex: 1; font-size: 1.15em; }
.dlg .body { flex: 1; overflow-y: auto; padding: 4px 22px 10px; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 16px 16px; }
.fl { display: block; margin: 10px 0; }
.fl > span { display: block; font-size: .85em; color: var(--sub); margin-bottom: 4px; }
.plist { margin: 8px -16px 0; }
.plist .row { min-height: 52px; }
.chk { display: flex; align-items: center; gap: 12px; padding: 6px 16px; min-height: 52px; cursor: pointer; border-radius: 14px 4px 14px 4px; }
.chk:hover { background: var(--hover); }
.chk input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.chk span { flex: 1; }
.chk small { color: var(--sub); }
#toast {
  position: fixed; left: 50%; top: 16px; z-index: 60; transform: translate(-50%, -12px); opacity: 0; visibility: hidden; max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 12px 4px 12px 4px; background: rgba(29, 26, 38, .88); color: #fff; transition: .25s; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
@media (pointer: coarse) {
  .bub { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .emo button { min-width: 44px; }
}
@media (max-width: 899px) {
  .dlg { align-self: end; border-radius: 24px 24px 0 0; margin: 0 -16px -16px; width: 100vw; padding-bottom: env(safe-area-inset-bottom); }
  .bub { max-width: 88%; }
  .img { max-width: min(320px, 68vw); }
}
