:root {
  --bg: #0b0f17;
  --card: #121c2e;
  --text: #e7eefc;
  --muted: rgba(231, 238, 252, 0.65);
  --border: rgba(231, 238, 252, 0.12);
  --accent: #7aa2ff;
  --danger: #ff6b6b;
  --shadow: 0 10px 22px rgba(0,0,0,0.25);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1400px 700px at 20% 0%, rgba(122,162,255,0.18), transparent 60%),
              radial-gradient(1200px 700px at 100% 30%, rgba(255,107,107,0.10), transparent 60%),
              var(--bg);
  color: var(--text);
}
a { color: inherit; }
.app-shell { min-height: 100%; display: flex; flex-direction: column; }
.main { flex: 1 1 auto; padding: 22px; max-width: 1200px; margin: 0 auto; width: 100%; }
.footer { padding: 14px 22px; border-top: 1px solid var(--border); color: var(--muted); text-align: center; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  background: rgba(11, 15, 23, 0.55);
  display: flex; align-items: center; justify-content: space-between;
}
.brand-link {
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.2px;
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
}
.brand-meta {
  font-weight: 650;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 24, 39, 0.55);
}
.brand-link:hover { text-decoration: underline; }
.pill {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(16, 24, 39, 0.80);
  color: var(--muted);
  font-size: 12px;
}
h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: -0.4px; }
h2 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.card {
  background: rgba(18, 28, 46, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 750; font-size: 16px; margin-bottom: 4px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.field { display: grid; gap: 8px; margin-bottom: 12px; }
.label { font-size: 12px; color: var(--muted); }
.input, .title-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(16, 24, 39, 0.95);
  color: var(--text);
  outline: none;
}
.input:focus, .title-input:focus {
  border-color: rgba(122, 162, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.14);
}
.btn {
  border: 1px solid var(--border);
  background: rgba(16, 24, 39, 0.95);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 90ms ease, border-color 120ms ease, background 120ms ease;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(231, 238, 252, 0.22); }
.btn:active { transform: translateY(0px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border-color: rgba(122, 162, 255, 0.55); background: rgba(122, 162, 255, 0.14); }
.btn.danger { border-color: rgba(255, 107, 107, 0.55); background: rgba(255, 107, 107, 0.12); }
.btn.full { width: 100%; justify-content: center; }
.loading { display: grid; place-items: center; height: 100vh; gap: 14px; }
.spinner { width: 34px; height: 34px; border-radius: 999px; border: 3px solid rgba(231, 238, 252, 0.20); border-top-color: rgba(122, 162, 255, 0.75); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.notepad-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; min-height: calc(100vh - 170px); }
.sidebar { background: rgba(18, 28, 46, 0.75); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.sidebar-top { margin-bottom: 10px; }
.page-list { list-style: none; padding: 0; margin: 10px 0 12px; display: grid; gap: 8px; overflow: auto; flex: 1 1 auto; }
.page { padding: 10px 10px; border: 1px solid var(--border); background: rgba(16, 24, 39, 0.72); border-radius: 12px; cursor: pointer; }
.page:hover { border-color: rgba(231, 238, 252, 0.22); }
.page.active { border-color: rgba(122, 162, 255, 0.65); background: rgba(122, 162, 255, 0.12); }
.page-title { font-weight: 650; font-size: 14px; }
.editor-area { background: rgba(18, 28, 46, 0.75); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; min-width: 0; }
.editor-header { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.title-input { font-size: 16px; font-weight: 700; }
.status { margin-left: auto; font-size: 12px; }
.rte { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; min-height: 0; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rte-toolbar .sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }
.rte-surface { flex: 1 1 auto; min-height: 420px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: rgba(16, 24, 39, 0.70); overflow: auto; outline: none; line-height: 1.5; }
.rte-surface:empty:before { content: attr(data-placeholder); color: rgba(231, 238, 252, 0.35); }
.rte-surface img { max-width: 100%; height: auto; border-radius: 10px; }

/* Page-door highlight = swapped foreground/background */
.page-door {
  background-color: var(--text);
  color: var(--bg);
  padding: 0 3px;
  border-radius: 4px;
  cursor: pointer;
}
.page-door:hover { filter: brightness(0.9); }

/* New page title line */
.page-title-line {
  text-align: center;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.2px;
  margin: 0 0 10px;
}
.page-back { cursor: pointer; }
.page-back:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .notepad-layout { grid-template-columns: 1fr; }
  .brand-meta { display: none; }
}
