:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --accent: #3d9cf0;
  --accent2: #2dd4a8;
  --danger: #f07178;
  --warn: #e6c07b;
  --ok: #2dd4a8;
  --border: #2a3548;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { padding: 16px; max-width: 720px; margin: 0 auto; }
h1 { font-size: 1.35rem; margin: 0 0 4px; font-weight: 700; }
.sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 16px; line-height: 1.4; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a26;
  color: var(--text);
  font-size: 1rem;
}
input[type="file"] { padding: 8px; }
button, .btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button.secondary { background: #2a3548; color: var(--text); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.device-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--accent2);
}
.meta-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
  word-break: break-all;
}
.sas {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 12px;
  font-family: ui-monospace, monospace;
  color: var(--warn);
}
.progress-wrap {
  height: 10px;
  background: #121a26;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.15s ease;
}
.status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 8px;
}
.trusted li, .peer-list li {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.trusted ul, .peer-list { margin: 0; padding: 0; }
.peer-list .peer-info { min-width: 0; flex: 1; }
.peer-list .peer-info strong { display: block; color: var(--text); }
.lang { float: right; font-size: 0.8rem; }
.lang button { padding: 4px 8px; font-size: 0.75rem; background: #2a3548; }
.hidden { display: none !important; }
a.download {
  color: var(--accent2);
  font-weight: 600;
  word-break: break-all;
  display: inline-block;
  margin-top: 6px;
}
.security-box {
  border-left: 3px solid var(--accent2);
  padding-left: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}
.code {
  font-family: ui-monospace, monospace;
  background: #121a26;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}
.chat {
  background: #121a26;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 220px;
  overflow-y: auto;
  padding: 10px;
  margin-top: 10px;
  font-size: 0.9rem;
}
.chat .msg {
  margin-bottom: 8px;
  line-height: 1.35;
  word-break: break-word;
}
.chat .msg.me { color: var(--accent2); }
.chat .msg.them { color: var(--text); }
.chat .msg.sys { color: var(--muted); font-size: 0.8rem; }
.chat .msg .who { font-weight: 600; margin-right: 6px; }

textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a26;
  color: var(--text);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
.qr-wrap {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  min-height: 0;
}
.qr-wrap:empty { display: none; padding: 0; }
.qr-wrap img, .qr-wrap canvas { max-width: 220px; height: auto; }
