:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f4f4f5;
  --border: #e8e8e8;
  --text: #1c1c1e;
  --text-muted: #767676;
  --text-faint: #a3a3a3;
  --accent: #ff6161;
  --accent-hover: #ff4d4d;
  --accent-soft: #fff0f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }

/* Sidebar */
.pnav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.18s ease;
  z-index: 40;
  overflow: hidden;
}
.pnav-collapsed { width: var(--sidebar-w-collapsed); }
.pnav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.pnav-brand {
  font-weight: 700; font-size: 16px; color: var(--text);
  white-space: nowrap;
}
.pnav-collapsed .pnav-brand { opacity: 0; }
.pnav-toggle {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 13px; padding: 6px;
  border-radius: var(--radius-sm); flex-shrink: 0;
}
.pnav-toggle:hover { background: var(--surface-hover); }
.pnav-links { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.pnav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: 14px;
  white-space: nowrap;
}
.pnav-link:hover { background: var(--surface-hover); color: var(--text); }
.pnav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pnav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.pnav-collapsed .pnav-label { opacity: 0; }

.pmain { margin-left: var(--sidebar-w); transition: margin-left 0.18s ease; min-height: 100vh; }
body:has(.pnav-collapsed) .pmain { margin-left: var(--sidebar-w-collapsed); }

/* Top bar: search + filters */
.ptop {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 24px 32px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.psearch { flex: 1; min-width: 220px; }
.psearch input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; font-family: var(--font);
  background: var(--bg); color: var(--text);
}
.psearch input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.pfilters { display: flex; gap: 8px; flex-wrap: wrap; }
.pfilters select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 13px; font-family: var(--font); background: var(--surface); color: var(--text-muted);
}

/* Card grid */
.pgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; padding: 24px 32px;
}
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; text-decoration: none; color: inherit; display: flex; flex-direction: column;
  gap: 8px; transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.pcard:hover { box-shadow: var(--shadow-md); border-color: #d8d8d8; }
.pcard-code { font-size: 11px; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; }
.pcard-title { font-size: 16px; font-weight: 700; margin: 0; }
.pcard-desc { font-size: 13px; color: var(--text-muted); flex: 1; }
.pcard-meta { font-size: 12px; color: var(--text-faint); }
.pbadge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; width: fit-content;
}
.pbadge-live { background: #e8f8ee; color: #1a8a4a; }
.pbadge-pending { background: #f2f2f2; color: var(--text-faint); }
.ptags { display: flex; gap: 6px; flex-wrap: wrap; }
.ptag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* Buttons */
.pbtn {
  background: var(--accent); color: #fff; border: none; padding: 9px 16px;
  border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.pbtn:hover { background: var(--accent-hover); }
.pbtn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.pbtn-ghost:hover { background: var(--surface-hover); }

/* Hero */
.phero { padding: 40px 32px 8px; }
.phero .eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-faint);
  letter-spacing: 0.06em; margin-bottom: 10px;
}
.phero h1 { font-size: clamp(24px, 3vw, 34px); line-height: 1.3; margin: 0 0 12px; max-width: 640px; }
.phero p { max-width: 560px; color: var(--text-muted); font-size: 14px; margin: 0 0 4px; }

/* Modal (auth) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(28,28,30,0.4);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); max-width: 380px; width: 100%; padding: 28px 26px 24px;
  box-shadow: var(--shadow-md);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none; cursor: pointer;
  font-size: 15px; color: var(--text-faint); line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-card h2 { font-size: 18px; margin: 0 0 4px; }
.modal-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 20px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 8px 0; text-align: center; font-size: 13px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); background: var(--bg);
  font-family: var(--font); font-size: 14px; color: var(--text); border-radius: var(--radius-sm);
}
.field input:focus { outline: none; border-color: var(--accent); }
.auth-submit {
  width: 100%; padding: 10px 0; margin-top: 6px; border: none; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }
.auth-message { margin-top: 14px; font-size: 12px; min-height: 14px; }
.auth-message.error { color: #c0392b; }
.auth-message.success { color: #1a8a4a; }
.auth-field-hide { display: none; }
#userEmailTag { font-size: 12px; color: var(--text-muted); margin-right: 4px; }
.pfooter {
  padding: 24px 32px; border-top: 1px solid var(--border); display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-faint);
}
.pfooter a { color: var(--text-muted); text-decoration: none; }
.pfooter a:hover { color: var(--text); }

/* Admin page bits */
.padmin { padding: 32px; max-width: 640px; }
.padmin h1 { font-size: 20px; margin: 0 0 20px; }
.prow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-bottom: 8px; background: var(--surface);
}
.prow button { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 13px; }
.prow button:hover { color: #c0392b; }
.paddform { display: flex; gap: 8px; margin-top: 20px; }
.paddform input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font); font-size: 14px;
}
.pnote { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* Sidebar collapse fix */
.pnav-collapsed .pnav-head { justify-content: center; padding: 18px 8px; }
.pnav-collapsed .pnav-brand { display: none; }
.pnav-collapsed .pnav-label { display: none; }
.pnav-collapsed .pnav-link { justify-content: center; padding: 9px 0; }

.pcount { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.pcard-type { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }

.pnav-disabled { color: var(--text-faint); cursor: default; }
.pnav-disabled em { font-style: normal; font-size: 10px; background: var(--bg); padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.qtimer { font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 6px 14px; border-radius: 999px; }
.qnote { font-size: 13px; color: var(--text-muted); background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-md); padding: 12px 14px; margin: 16px 0; }
.qitem { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; }
.qitem-num { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-bottom: 8px; }
.qitem input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px; font-family: var(--font); }
.qitem input:focus { outline: none; border-color: var(--accent); }
.qsubmitbar { position: sticky; bottom: 0; background: var(--bg); padding: 16px 0; border-top: 1px solid var(--border); margin-top: 8px; }
