:root {
  --bg: #0f1115;
  --card: #171a21;
  --text: #e8e8ea;
  --muted: #8a8f98;
  --accent: #4da3ff;
  --border: #262a33;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
}
.card h1 { margin-top: 0; font-size: 20px; }
.muted { color: var(--muted); font-size: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 15px;
}
button {
  margin-top: 16px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #06121f;
  font-weight: 600;
  cursor: pointer;
}
.error { color: var(--danger); font-size: 14px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; }
.topbar a { color: var(--muted); text-decoration: none; }
.topbar button {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
}
.nav { display: flex; gap: 14px; }
.nav a { color: var(--accent); font-size: 13px; text-decoration: none; }
.actions { display: flex; gap: 10px; align-items: center; }
.actions a { color: var(--muted); font-size: 13px; }
.stats-row { display: flex; gap: 10px; padding: 14px 18px; }
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat-value { display: block; font-size: 22px; font-weight: 700; }
.stat-label { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.search-bar { display: flex; gap: 8px; padding: 14px 18px; }
.search-bar input, .search-bar select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 14px;
}
.search-bar button {
  width: auto;
  margin: 0;
  padding: 10px 16px;
  font-size: 13px;
}
.name-row { display: flex; justify-content: space-between; }
.detail { padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.detail .card { padding: 18px; }
.detail h2 { font-size: 15px; margin: 0 0 10px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.plain-list a { color: var(--accent); text-decoration: none; }
#global-status-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #0a1f14;
  border-top: 1px solid #1f4a30;
  padding: 8px 18px;
  font-size: 12px;
  color: #b9f5cf;
  max-height: 30vh;
  overflow-y: auto;
}
.status-line { padding: 3px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-progress-wrap { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.status-progress-bar {
  width: 140px;
  height: 6px;
  border-radius: 3px;
  background: #133621;
  overflow: hidden;
}
.status-progress-fill {
  height: 100%;
  background: #35d47a;
  transition: width 0.4s ease;
}
.status-progress-num { color: #8fe3b3; font-size: 11px; white-space: nowrap; }
.status-line b { color: #eafff2; font-weight: 600; }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #35d47a;
  flex-shrink: 0;
  animation: status-pulse 1.4s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.portrait { padding: 14px 18px; display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.doc-card { padding: 22px; }
.doc-card h2 { margin: 0 0 12px; font-size: 18px; }
.doc-body { font-size: 14px; line-height: 1.65; }
.doc-body h1, .doc-body h2, .doc-body h3 { color: var(--text); margin: 18px 0 8px; }
.doc-body h1:first-child, .doc-body h2:first-child, .doc-body h3:first-child { margin-top: 0; }
.doc-body p { margin: 0 0 12px; }
.doc-body ul, .doc-body ol { margin: 0 0 12px; padding-left: 20px; }
.doc-body li { margin-bottom: 4px; }
.doc-body strong { color: var(--text); }
.doc-updated { margin-top: 14px; font-size: 12px; }
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.export-status {
  margin: 10px 18px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
.download-link { color: var(--accent); }
.dialogs { list-style: none; margin: 0; padding: 0; }
.dialogs li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.dialogs a {
  flex: 1;
  display: flex;
  justify-content: space-between;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.badge {
  background: var(--accent);
  color: #06121f;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}
.export-one,
.sync-one {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
}
.toggle-chat {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.toggle-chat.on {
  background: var(--accent);
  color: #06121f;
  border-color: var(--accent);
}
.messages { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.message {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  max-width: 70%;
  align-self: flex-start;
}
.message.out { align-self: flex-end; background: #16324a; }
.message .date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.message .text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.media-link { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 13px; text-decoration: none; }
#load-more {
  display: block;
  margin: 16px auto;
  width: auto;
  padding: 8px 16px;
}
