:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2128;
  --border: #30363d; --text: #e6edf3; --muted: #8b949e;
  --accent: #1f6feb; --green: #3fb950; --red: #f85149; --yellow: #d29922;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 100%; max-width: 400px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.tabs { display: flex; gap: 6px; margin: 18px 0; }
.tab {
  flex: 1; padding: 8px; background: var(--panel2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; background: var(--panel2);
  color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; }
button.primary {
  background: var(--accent); color: #fff; border: none; padding: 10px 16px;
  border-radius: 6px; font-weight: 600; cursor: pointer; width: 100%; margin-top: 14px;
}
button.primary.small { width: auto; padding: 6px 12px; font-size: 12px; margin: 0; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
button.ghost.full { width: 100%; }
button.ghost:hover { background: var(--panel2); }
.error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* App layout */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.user-box { display: flex; gap: 10px; align-items: center; }
.layout {
  display: grid; grid-template-columns: 300px 1fr 260px;
  gap: 16px; padding: 16px; align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.panel h2, .panel h3 { margin: 0 0 12px; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

.content-box {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px; min-height: 420px; white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.7;
  overflow-y: auto;
}
.content-box.editable { background: #fff9e6; color: #111; }
.placeholder { color: var(--muted); text-align: center; padding: 80px 0; font-family: inherit; }

.history { max-height: 500px; overflow-y: auto; }
.history-item {
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.history-item:hover { background: var(--panel2); }
.history-item.active { background: var(--accent); color: #fff; }
.history-item .name { font-weight: 600; }
.history-item .preview {
  color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item.active .preview { color: rgba(255,255,255,0.75); }