:root {
  --bg: #0f1419;
  --card: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9bb0;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --ok: #22c55e;
  --err: #ef4444;
  --bubble: #243044;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a5f 0%, var(--bg) 55%);
  color: var(--text);
}
.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}
h1 { margin: 0 0 8px; font-size: 1.75rem; font-weight: 700; }
.sub { margin: 0 0 28px; color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.hidden { display: none !important; }
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type="password"], input[type="text"], textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1218;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
textarea {
  resize: vertical;
  min-height: 44px;
  line-height: 1.45;
}

/* ---- Chat card ---- */
.chat-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  margin-bottom: 16px;
}
.chat-head {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.chat-refresh {
  margin: 0 !important;
  width: auto !important;
  padding: 6px 12px !important;
}
.chat-stream {
  flex: 1;
  max-height: min(52vh, 420px);
  min-height: 180px;
  overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.chat-empty {
  text-align: center;
  padding: 28px 8px;
  font-size: 0.9rem;
}
.chat-bubble {
  background: var(--bubble);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 12px;
  margin-bottom: 10px;
  max-width: 100%;
}
.chat-bubble:last-child { margin-bottom: 0; }
.msg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
}
.msg-nick { font-weight: 600; color: var(--text); }
.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.45;
  margin-bottom: 8px;
}
.chat-bubble .btn-copy-msg {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  font-size: 0.75rem;
  margin: 0;
  width: auto;
  border-radius: 6px;
}
.chat-bubble .btn-copy-msg:hover { border-color: var(--accent); }

.chat-compose {
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
  background: #15202b;
}
.chat-err {
  color: var(--err);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.nick-fold {
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.nick-fold summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-bottom: 6px;
}
.nick-fold summary::-webkit-details-marker { display: none; }
.nick-fold summary::before {
  content: "▸ ";
  color: var(--muted);
}
.nick-fold[open] summary::before { content: "▾ "; }
.nick-fold input { margin-top: 2px; }
.compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.compose-row textarea {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
}
.compose-row #btnSendMsg {
  flex-shrink: 0;
  min-width: 72px;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 1rem;
}
.compose-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  min-height: 1.2em;
}
.compose-hint { opacity: 0.75; }

.drop {
  text-align: center;
  padding: 40px 20px;
  cursor: pointer;
  border-style: dashed;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.drag {
  border-color: var(--accent);
  background: #1e2a3d;
}
.drop-title { margin: 0 0 8px; font-size: 1.1rem; }
.drop-hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.bar {
  height: 8px;
  background: #0d1218;
  border-radius: 999px;
  overflow: hidden;
}
#barFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width .1s linear;
}
.status { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }
.ok { color: var(--ok); font-weight: 600; margin: 0 0 12px; }
.link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.link-row input { flex: 1; }
button {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--accent2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 14px;
  width: 100%;
}
button.ghost:hover { border-color: var(--accent); }
.meta { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
a#openLink {
  color: var(--accent);
  font-size: 0.9rem;
}
.err {
  color: var(--err);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.file-item:last-child { border-bottom: none; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.file-meta .small, .small { font-size: 0.8rem; }
.muted { color: var(--muted); }
a.dl {
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
a.dl:hover { background: var(--accent2); }
.list-card { margin-top: 8px; }

@media (max-width: 420px) {
  .wrap { padding: 28px 14px 48px; }
  .compose-hint { display: none; }
  .chat-stream { max-height: 46vh; min-height: 160px; }
}
