:root {
  --rail-width: 220px;
  --comments-width: 320px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; color: #1a1a1a; }

/* Three fixed columns by design for v1 (desktop-only — see the design spec's
   "out of scope" note on mobile). grid-template-columns is the only rule
   that needs a breakpoint added later; widths are kept as custom properties
   so that change stays a one-line edit. */
.layout {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr var(--comments-width);
  height: 100vh;
}

.hidden { display: none; }

.tabs { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid #ddd; background: #fafafa; }
.tabs-header { display: flex; justify-content: flex-end; padding: 8px; border-bottom: 1px solid #eee; }
.burger {
  background: none; border: 1px solid #ccc; border-radius: 6px; color: #333;
  font-size: 18px; line-height: 1; padding: 4px 8px; cursor: pointer;
}
.burger:hover { background: #f0f0f0; }
.tab-list { flex: 1; overflow-y: auto; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: grab; border-bottom: 1px solid #eee;
}
.tab.dragging { opacity: 0.5; }
.tab-label { flex: 1; }
.tab-label[contenteditable="true"] { outline: 1px dashed #999; padding: 2px; }

.tab-add {
  flex-shrink: 0;
  width: 28px; height: 28px;
  margin: 10px auto;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #ccc; border-radius: 50%; background: #fff;
  color: #555; font-size: 16px; line-height: 1; cursor: pointer;
}
.tab-add:hover { background: #f0f0f0; border-color: #999; }

.main { overflow-y: auto; padding: 24px 32px; }
.chunk { margin-bottom: 56px; max-width: 68ch; }
.chunk-edit { float: right; }
/* Bodies are inserted as raw markdown text, so preserve their paragraph breaks rather than
   letting HTML collapse the whole fragment into one run-on block. */
.chunk-body { white-space: pre-wrap; }

.comments { display: flex; flex-direction: column; border-left: 1px solid #ddd; background: #fafafa; }
.comment-list { flex: 1; overflow-y: auto; padding: 12px; }
.comment { margin-bottom: 10px; }
.comment .author { font-weight: 600; margin-right: 6px; }
.comment-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #ddd; }
.comment-form textarea { flex: 1; font: inherit; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }
.overlay-card { background: #fff; width: 80vw; height: 80vh; display: flex; flex-direction: column; padding: 16px; gap: 12px; }
.overlay-title { padding: 8px; font: inherit; font-size: 16px; border: 1px solid #ccc; }
.overlay-text { flex: 1; font-family: ui-monospace, monospace; font-size: 14px; }
.overlay-text:disabled { background: #f5f5f5; color: #999; }

.center-card { display: flex; align-items: center; justify-content: center; height: 100vh; }
.card { width: 320px; padding: 24px; border: 1px solid #ddd; border-radius: 8px; }
.card input, .card button { width: 100%; padding: 8px; margin-top: 8px; font: inherit; }
.msg { margin-top: 12px; min-height: 1.2em; }
.msg.ok { color: #0a7d2c; }
.msg.err { color: #c0392b; }

/* Hamburger drawer, shared by every page via nav.js. Fixed overlay so it works regardless
   of the host page's own layout (grid on index.html, plain flow on admin.html). */
.nav-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease; z-index: 90;
}
.nav-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.nav-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 280px; max-width: 86vw;
  background: #fff; border-left: 1px solid #ddd; box-shadow: -8px 0 24px rgba(0,0,0,0.15);
  transform: translateX(100%); transition: transform 0.18s ease; z-index: 91;
  display: flex; flex-direction: column;
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid #eee; }
.nav-drawer-title { font-weight: 600; }
.nav-drawer-close { margin-left: auto; background: none; border: 0; font-size: 18px; cursor: pointer; padding: 2px 6px; }
.nav-drawer-who { padding: 10px 16px; color: #666; font-size: 13px; border-bottom: 1px solid #eee; }
.nav-drawer-links { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid #eee; }
.nav-drawer-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: #1a1a1a; text-decoration: none; padding: 10px 16px; font: inherit; cursor: pointer;
}
.nav-drawer-item:hover { background: #f5f5f5; }
.nav-drawer-signout { color: #c0392b; margin-top: auto; border-top: 1px solid #eee; }

/* Admin page */
.admin-wrap { max-width: 640px; margin: 0 auto; padding: 32px 40px; }
.admin-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.admin-header h1 { flex: 1; font-size: 20px; margin: 0; }
.panel { border: 1px solid #ddd; border-radius: 8px; padding: 16px; margin-top: 16px; }
.add-user-form { display: flex; gap: 8px; }
.add-user-form input { flex: 1; padding: 8px; font: inherit; }
.add-user-form button, .user-row button { padding: 8px 12px; font: inherit; cursor: pointer; }
.user-list { display: flex; flex-direction: column; gap: 12px; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee; }
.user-row:last-child { border-bottom: 0; }
.user-row .email { font-weight: 600; }
.user-row .dates { color: #888; font-size: 12px; margin-top: 2px; }
.user-row .actions { display: flex; gap: 6px; }
.user-row .actions button.danger { color: #c0392b; }
.badge { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-right: 4px; background: #eee; color: #555; }
.badge.role-owner { background: #ded1f7; color: #4b2a8f; }
.badge.status-active { background: #d6f5df; color: #0a7d2c; }
.badge.status-disabled { background: #f7d7d7; color: #c0392b; }
