@font-face {
  font-family: "Efour Digital Pro";
  src: url("../fonts/EfourDigitalPro.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/SpaceGrotesk.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --primary: #3949d8;
  --accent: #5868f0;
  --accent-hover: #2636b8;
  --text: #202733;
  --muted: #6b7685;
  --secondary: #4a5568;
  --bg: #ffffff;
  --wash: #f4f7fc;
  --line: #d7e0ee;
  --font-brand: "Efour Digital Pro", "Space Grotesk", system-ui, sans-serif;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 {
  font-family: var(--font-head);
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
button, input, textarea, select { font: inherit; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--primary);
}
.brand img { height: 2.1rem; width: auto; }
.brand span {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
}
.brand em {
  font-style: normal;
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.topnav { display: flex; gap: 1.25rem; margin-left: 0.5rem; }
.topnav a {
  color: var(--secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.topnav a[aria-current="page"],
.topnav a:hover { color: var(--primary); }
.admin-link { color: var(--accent) !important; font-weight: 600; }
.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.who { font-size: 0.85rem; color: var(--muted); }
.text-btn {
  background: none;
  border: 0;
  color: var(--secondary);
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  font-size: 0.85rem;
}
.text-btn:hover { color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); color: #fff; }

.kicker {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.4rem;
}
.lead { color: var(--secondary); font-size: 1.1rem; max-width: none; }
.empty { color: var(--muted); }

.flashes { padding: 0.75rem 1.5rem 0; }
.flash { margin: 0 0 0.5rem; font-size: 0.9rem; }
.flash-error { color: #dc2626; }
.flash-ok { color: #059669; }
.field-error { color: #dc2626; font-size: 0.8rem; margin: 0.2rem 0 0; }

.login-body {
  background: #fff;
}
.login-body main {
  padding: 0;
  min-height: 100vh;
}
.login-body > .flashes {
  position: fixed;
  top: 1.2rem;
  right: clamp(1rem, 3vw, 2.2rem);
  width: min(28vw, 20rem);
  z-index: 8;
  padding: 0;
}
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 7fr 3fr;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.login h1 {
  font-size: clamp(2.4rem, 5.4vw, 4.1rem);
  margin: 0 0 1rem;
}
.login-copy {
  background: linear-gradient(158deg, #e4eaff 0%, #f4f7fc 48%, #edf2fb 100%);
  padding: 1.35rem clamp(1.4rem, 4vw, 3.4rem) 2.8rem;
  display: flex;
  flex-direction: column;
}
.login-title { align-self: flex-start; }
.login-title span { font-size: 1.45rem; }
.login-title-mobile { display: none; }
.login-copy-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 36rem;
  padding-top: 3.2rem;
}
.login-pane {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 5vh, 3.5rem) clamp(1.2rem, 3vw, 2.4rem);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
  max-width: 22rem;
}
.login-form h2 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.login-form input[type="text"],
.login-form input[type="email"],
.login-form input[type="password"] {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
  background: transparent;
  color: var(--text);
}
.login-form input:focus { outline: none; border-bottom-color: var(--text); }
.check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  color: var(--secondary) !important;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.2rem;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  font-weight: 600;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-hover); }

.dash, .library, .studio, .editor-page {
  max-width: none;
  margin: 0;
  padding: 0 0 2rem;
}
.dash-hero h1, .lib-hero h1, .studio h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0 0 1.5rem;
}
.resume {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  padding: 1.1rem 0 1.4rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.resume span {
  font-family: var(--font-head);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.resume strong { font-size: 1.25rem; color: var(--primary); font-family: var(--font-head); }
.resume i { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.resume:hover strong { color: var(--accent); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 2.5rem 0 1rem;
}
.section-head h2 { margin: 0; font-size: 1.25rem; }

.course-lines { list-style: none; margin: 0; padding: 0; }
.course-lines li { border-bottom: 1px solid var(--line); }
.course-lines a {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.35rem 1rem;
  padding: 1rem 0;
  color: inherit;
}
.course-lines em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--muted);
  align-self: center;
}
.course-lines strong {
  font-family: var(--font-head);
  color: var(--text);
  font-size: 1.05rem;
}
.course-lines .excerpt {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.9rem;
}
.course-lines a:hover strong { color: var(--primary); }
.track {
  grid-column: 2;
  height: 3px;
  background: var(--wash);
  border-radius: 99px;
  overflow: hidden;
}
.track span { display: block; height: 100%; background: var(--accent); }

.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 1.25rem 0 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.65rem;
}
.cat-tabs a {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.92rem;
  font-weight: 600;
  padding-bottom: 0.45rem;
}
.cat-tabs a[aria-current="page"] {
  color: var(--primary);
}

.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;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem 1.5rem;
  margin: 0 0 0.85rem;
}
.page-head h1 {
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  margin: 0;
}
.lib-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 15.5rem;
  min-width: 11rem;
  margin-top: 0.35rem;
  padding: 0.15rem 0 0.35rem;
  border-bottom: 1px solid var(--line);
}
.lib-search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
}
.lib-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  padding: 0.2rem 0;
}
.lib-search input:focus { outline: none; }
.lib-search:focus-within { border-bottom-color: var(--text); }
.lib-search:focus-within .lib-search-icon { color: var(--text); }
.lib-cat { margin-top: 2.5rem; }
.lib-cat h2 { font-size: 1.5rem; margin: 0 0 0.5rem; }
.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1.75rem;
  width: 100%;
}
.cat-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 8rem;
  padding: 1.15rem 1rem 1.2rem;
  color: inherit;
  background: #f6f7fb;
}
.cat-block strong {
  font-family: var(--font-head);
  font-size: 1.15rem;
  color: var(--text);
}
.cat-block span { color: var(--muted); font-size: 0.82rem; }
.cat-block em {
  font-style: normal;
  color: var(--secondary);
  font-size: 0.88rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cat-block:hover { background: #eef0f6; }
.cat-block:hover strong { color: var(--primary); }

.stat-grid,
.course-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.35rem;
  width: 100%;
}
.dash .lead { max-width: 38rem; margin: 0 0 0.2rem; }
.stat-block,
.course-block,
.resume-block {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1rem 1.2rem;
  color: inherit;
  background: #f6f7fb;
}
.stat-block strong {
  font-family: var(--font-head);
  font-size: 1.7rem;
  color: var(--primary);
  letter-spacing: -0.03em;
}
.stat-block span { color: var(--muted); font-size: 0.82rem; }
button.stat-block {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
button.stat-block:hover,
button.stat-block[aria-expanded="true"] { background: #eef0f6; }
button.stat-block[aria-expanded="true"] strong { color: var(--primary); }
.pilot .activity-lines,
.pilot .course-lines { margin-top: 0.35rem; }
.course-block { min-height: 9rem; }
.course-block:hover,
.resume-block:hover { background: #eef0f6; }
.course-block:hover strong,
.resume-block:hover strong { color: var(--primary); }
.course-block-cat {
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.course-block strong,
.resume-block strong {
  font-family: var(--font-head);
  font-size: 1.12rem;
  color: var(--text);
  padding-right: 1.4rem;
}
.course-block em,
.resume-block em {
  font-style: normal;
  color: var(--secondary);
  font-size: 0.88rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.course-block .track,
.resume-block .track {
  grid-column: auto;
  margin-top: auto;
}
.resume-block {
  margin-top: 1.6rem;
  min-height: 8.5rem;
  padding: 1.4rem 1.35rem 1.45rem;
}
.resume-block strong { font-size: 1.55rem; }
.student-grid { margin-top: 1rem; }
.student-grid .course-block { min-height: 0; }
.seen-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.course-block .seen-mark,
.resume-block .seen-mark {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}
.course-lines .seen-mark,
.course-nav .seen-mark {
  margin-left: 0.35rem;
  vertical-align: -0.15em;
}
.seen-mark.is-done { color: var(--accent); }
.cat-block-admin {
  position: relative;
  padding-right: 2.5rem;
}
.cat-block-admin:hover strong { color: var(--text); }
.cat-block-admin.is-editing,
.cat-block-admin.is-editing:hover { background: #eef0f6; }
.icon-btn {
  position: absolute;
  top: 0.7rem;
  right: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover,
.icon-btn[aria-expanded="true"] { color: var(--primary); }
.cat-block-edit:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.cat-block-edit label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.cat-block-edit input {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0;
  background: transparent;
  color: var(--text);
  font-size: 0.98rem;
  width: 100%;
}
.cat-block-edit input:focus {
  outline: none;
  border-bottom-color: var(--text);
}
.edit-actions { display: flex; gap: 0.75rem; align-items: center; }
.text-btn.danger { color: #b42318; }
.text-btn.danger:hover { color: #8b1a12; }

.article-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 0 0 0.85rem;
}
.article-head h1 { margin: 0; }
.article-head-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}
.article-head .lib-search { margin-top: 0; }
.article-head .btn { flex-shrink: 0; }

.account-create {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1.1rem;
  align-items: end;
  width: 100%;
  margin: 0 0 2.2rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
  overflow: visible;
}
.account-create > label,
.account-cats {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 0;
}
.account-create > label input,
.account-create > label select {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0;
  background: transparent;
  color: var(--text);
  width: 100%;
}
.account-create > label input:focus,
.account-create > label select:focus {
  outline: none;
  border-bottom-color: var(--text);
}
.account-create .btn { justify-self: start; }
.account-cats[hidden] { display: none; }
.account-cats .drop,
.account-cats .drop-toggle {
  width: 100%;
  max-width: none;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}
.person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.75rem 1.2rem;
  align-items: center;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 0;
  overflow: visible;
}
.person:has(.drop.is-open) { z-index: 8; }
.person-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.person-info strong {
  font-family: var(--font-head);
  font-size: 1.08rem;
  color: var(--text);
}
.person-info span {
  color: var(--muted);
  font-size: 0.86rem;
}

.drop { position: relative; z-index: 1; }
.drop.is-open { z-index: 20; }
.drop-toggle {
  min-width: 11rem;
  max-width: 16rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 1.4rem 0.5rem 0;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drop-toggle::after {
  content: "";
  position: absolute;
  right: 0.15rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}
.drop-toggle { position: relative; }
.drop-menu[hidden] { display: none !important; }
.drop-menu:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 0.4rem);
  z-index: 12;
  min-width: 16rem;
  max-width: min(22rem, 80vw);
  max-height: 18rem;
  overflow: auto;
  padding: 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(32, 39, 51, 0.1);
}
.person-access .drop-menu:not([hidden]) {
  left: auto;
  right: 0;
}
.drop-menu label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.4rem 0.45rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.drop-menu label:hover { background: #f6f7fb; }
.drop-menu input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--primary);
}
.drop-menu .btn { margin-top: 0.45rem; align-self: flex-start; }
.drop-menu .hint { margin: 0.35rem 0.45rem; }
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 1.75rem;
  align-items: center;
}
.pager a { color: var(--secondary); font-weight: 600; }
.pager a[aria-current="page"],
.pager a:hover { color: var(--primary); }

.reader-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 40;
  pointer-events: none;
}
.reader-body { background: #fff; }
.reader {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0.5rem 0 4rem;
}
.toc-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.2rem 0 0.4rem;
}
.toc-title {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.55rem;
  font-size: 0.98rem;
  line-height: 1.3;
}
.toc-actions { display: flex; gap: 1rem; margin: 0.9rem 0 0; }
.side-toc {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin-top: 1.75rem;
}
.side-toc .nav-label { margin-top: 0; }
.side-toc nav {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.side-toc nav a {
  color: var(--secondary);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.28rem 0.5rem;
  border-radius: 0.4rem;
}
.side-toc nav a:hover { color: var(--primary); background: var(--wash); }
.side-toc .lvl-1 { font-weight: 600; color: var(--text); }
.side-toc .lvl-3 { padding-left: 1.05rem; font-size: 0.8rem; }

.course-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  max-width: 68ch;
}
.course-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: inherit;
  min-width: 0;
}
.course-nav-next { text-align: right; justify-self: end; }
.course-nav span {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.course-nav strong {
  font-family: var(--font-head);
  font-size: 1.05rem;
  color: var(--text);
}
.course-nav a:hover strong { color: var(--primary); }

.article h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 0.8rem; }
.md { font-size: 1.05rem; color: var(--text); max-width: 68ch; }
.md h2 { margin-top: 2rem; }
.md h3 { margin-top: 1.4rem; color: var(--accent-hover); }
.md mark {
  background: #e8edff;
  color: var(--primary);
  padding: 0 0.15em;
}
.md del { color: var(--muted); }
.md a { text-decoration: underline; text-underline-offset: 3px; }
.md img { border-radius: 0.75rem; margin: 1rem 0; }
.md blockquote {
  margin: 1.2rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
  color: var(--secondary);
}
.md code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  background: var(--wash);
  padding: 0.1em 0.35em;
  border-radius: 0.3rem;
}
.md pre {
  background: var(--wash);
  padding: 1rem;
  overflow: auto;
  border-radius: 0.75rem;
}
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.4rem; text-align: left; }

.studio-links { display: flex; gap: 1.25rem; margin-bottom: 2rem; }
.studio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}
.soft-form, .user-perms {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0 0 1.5rem;
  border-bottom: 1px solid var(--line);
}
.soft-form label, .editor-meta label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.soft-form input, .soft-form select,
.editor-meta input, .editor-meta select, .inline-edit input, .inline-edit select {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0;
  background: transparent;
}
.hint { color: var(--muted); font-size: 0.9rem; }
.editor-meta .hint {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 0.2rem;
}
.edit-list { list-style: none; padding: 0; }
.inline-edit {
  display: grid;
  grid-template-columns: 10rem 1fr 10rem auto;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}
.perm-row, .auth-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.auth-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  background: #f6f7fb;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.auth-row input {
  accent-color: var(--primary);
}
.user-perms h2,
.user-perms h3 { font-size: 1.1rem; margin: 0; }
.user-perms small { font-weight: 400; color: var(--muted); }

.cat-create,
.cat-admin form {
  display: grid;
  grid-template-columns: minmax(12rem, 0.38fr) minmax(0, 1fr) auto;
  gap: 0.65rem 1.1rem;
  align-items: end;
  width: 100%;
}
.cat-create {
  margin: 0 0 2.2rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}
.cat-create label,
.cat-admin label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.cat-create input,
.cat-admin input {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0;
  background: transparent;
  color: var(--text);
  font-size: 1.02rem;
  width: 100%;
}
.cat-create input:focus,
.cat-admin input:focus {
  outline: none;
  border-bottom-color: var(--text);
}
.cat-admin {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}
.cat-admin li {
  padding: 1.15rem 0 1.2rem;
  border-bottom: 1px solid var(--line);
}
.cat-admin .pipe-line {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.editor {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.editor-meta { display: flex; flex-direction: column; gap: 0.8rem; position: sticky; top: 1.2rem; }
.editor-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.editor-main { min-width: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.toolbar button {
  border: 0;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
}
.toolbar button:hover { color: var(--primary); }
#md-input {
  width: 100%;
  min-height: 70vh;
  border: 0;
  padding: 0.4rem 0.8rem;
  resize: vertical;
  background: transparent;
  line-height: 1.55;
}
.preview {
  min-height: 70vh;
  padding-left: 0.5rem;
}
.emoji-pop {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.45rem 0.55rem;
  display: none;
  flex-wrap: wrap;
  gap: 0.15rem;
  max-width: min(28rem, calc(100vw - 2rem));
  box-shadow: 0 12px 40px rgba(32, 39, 51, 0.12);
}
.emoji-pop:not([hidden]) { display: flex; }
.emoji-pop button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.3rem;
  letter-spacing: 0;
}
.emoji-pop button:hover { transform: scale(1.15); }

.nav-toggle { display: none; }
.app-body {
  display: grid;
  grid-template-columns: 19rem minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1rem 1rem;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}
.sidebar:has(.side-toc) { overflow: hidden; }
.sidebar .brand { margin-bottom: 1.1rem; flex-shrink: 0; }
.sidebar > nav { flex-shrink: 0; }
.nav-label {
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1rem 0 0.35rem;
}
.sidebar nav a {
  display: block;
  color: var(--secondary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.38rem 0.5rem;
  border-radius: 0.4rem;
}
.sidebar nav a[aria-current="page"],
.sidebar nav a:hover {
  color: var(--primary);
  background: var(--wash);
}
.side-search { margin-top: 1.2rem; }
.side-search label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.side-search input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0;
  background: transparent;
}
.side-search input:focus { outline: none; border-bottom-color: var(--text); }
.sidebar-user {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar-user strong { font-family: var(--font-head); color: var(--primary); }
.sidebar-user span {
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}
.sidebar-foot {
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 0.35rem;
}
.pomo {
  padding: 0.75rem 0.35rem 0.85rem;
  border-top: 1px solid var(--line);
}
.pomo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.pomo-head .nav-label { margin: 0; }
.pomo-mins {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}
.pomo-mins input {
  width: 2.7rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: right;
  padding: 0.1rem 0;
  font-variant-numeric: tabular-nums;
}
.pomo-mins input:focus { outline: none; border-bottom-color: var(--text); }
.pomo-mins input:disabled { opacity: 0.55; }
.pomo-time {
  margin: 0.4rem 0 0.4rem;
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1;
}
.pomo.is-running .pomo-time { color: var(--text); }
.pomo.is-done .pomo-time { color: var(--primary); }
.pomo-bar {
  height: 3px;
  background: var(--wash);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.pomo-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
}
.pomo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.account {
  margin-top: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  position: relative;
  flex-shrink: 0;
}
.account-toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.45rem 0.35rem;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  cursor: pointer;
}
.account-toggle::after {
  content: "";
  display: inline-block;
  margin-left: 0.4rem;
  border: 4px solid transparent;
  border-top-color: var(--muted);
  transform: translateY(2px);
}
.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.4rem);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.4rem 0;
  box-shadow: 0 10px 30px rgba(32, 39, 51, 0.08);
  display: flex;
  flex-direction: column;
}
.account-menu[hidden] { display: none; }
.account-menu a,
.logout-hold {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.55rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.account-menu a:hover,
.logout-hold:hover { background: var(--wash); color: var(--text); }
.logout-form small {
  display: block;
  padding: 0 0.85rem 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
}
.logout-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--hold, 0%);
  background: rgba(57, 73, 216, 0.2);
  z-index: 0;
}
.logout-hold span:last-child { position: relative; z-index: 1; }
.logout-hold.is-holding {
  color: var(--primary);
  box-shadow: inset 0 0 0 1.5px var(--primary);
}
.logout-hold.is-holding .logout-fill {
  background: rgba(57, 73, 216, 0.32);
}
.logout-hold.is-holding::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--hold, 0%);
  background: var(--primary);
  z-index: 2;
}
.app-frame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  width: 100%;
  padding: 1.5rem 1.6rem 1.4rem;
}
.app-frame main {
  flex: 1;
  width: 100%;
}
.page-copy {
  margin: 2.2rem 0 0;
  text-align: right;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  width: 100%;
}
.login-body > .page-copy {
  position: fixed;
  right: clamp(1rem, 3vw, 2.2rem);
  bottom: 0.9rem;
  z-index: 6;
  width: auto;
  margin: 0;
}
.page {
  width: 100%;
  max-width: none;
  padding-bottom: 0.5rem;
}
.page > h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); margin: 0 0 0.85rem; }
.page > h2 { font-size: 1.25rem; margin: 2.2rem 0 0.9rem; }
.forms-stack { display: flex; flex-direction: column; gap: 1.5rem; }
.pipe-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0;
  color: var(--text);
  font-family: var(--font-head);
  font-size: 0.95rem;
  margin: 0 0 1.8rem;
}
.pipe-line i {
  display: inline-block;
  width: auto;
  height: auto;
  background: none;
  margin: 0 0.55rem;
  color: var(--muted);
  font-style: normal;
}
.pipe-line i::before { content: "·"; }
.muted { color: var(--muted); font-size: 0.85rem; }
.pipe-cats { list-style: none; margin: 0; padding: 0; }
.pipe-cats li { border-bottom: 1px solid var(--line); }
.pipe-cats a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 0;
  color: inherit;
}
.pipe-cats strong { font-family: var(--font-head); color: var(--text); }
.pipe-cats span { color: var(--muted); font-size: 0.86rem; }
.pipe-cats a:hover strong { color: var(--primary); }
.activity-lines { list-style: none; margin: 0; padding: 0; }
.activity-lines li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.activity-lines time { color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-line { color: var(--muted); padding: 1rem 0; }
.visit-card, .side-panel {
  position: relative;
  min-height: 28rem;
  padding: 2.2rem 1.4rem 1.6rem;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #f4f7fc 0%, #fff 55%);
}
.visit-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  min-height: calc(100vh - 5rem);
  position: sticky;
  top: 1rem;
}
.visit-card img { height: 4.2rem; width: auto; margin-bottom: 0.9rem; }
.visit-word {
  font-family: var(--font-brand);
  font-size: clamp(1.6rem, 2.4vw, 2.15rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
}
.visit-learn {
  font-family: var(--font-head);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0.35rem 0 1.4rem;
}
.visit-services {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.15rem;
  font-size: 0.78rem;
  color: var(--text);
  margin: 0 0 1.4rem;
}
.visit-services i {
  display: inline-block;
  width: 1px;
  height: 0.85em;
  background: var(--accent);
  margin: 0 0.45rem;
}
.visit-cta { width: 100%; max-width: 16rem; }
.visit-meta {
  list-style: none;
  padding: 1.2rem 0 0;
  margin: 1.2rem 0 0;
  border-top: 1px solid var(--line);
  width: 100%;
  color: var(--muted);
  font-size: 0.82rem;
}
.visit-arc {
  position: absolute;
  pointer-events: none;
  height: 55%;
  width: 3.4rem;
}
.visit-arc-l { left: -0.4rem; top: 0; }
.visit-arc-r { right: -0.6rem; bottom: 0; height: 45%; }
.side-panel { min-height: 0; position: sticky; top: 1rem; }
.side-panel h2 { margin: 0 0 0.8rem; font-size: 1.35rem; }

@media (max-width: 1400px) {
  .cat-grid,
  .stat-grid,
  .course-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .editor { grid-template-columns: 14rem minmax(0, 1fr); }
  .preview { display: none; }
  .cat-grid,
  .stat-grid,
  .course-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    z-index: 30;
    box-shadow: 12px 0 40px rgba(32, 39, 51, 0.12);
    transition: transform 0.2s ease;
  }
  .nav-open .sidebar { transform: none; }
  .nav-toggle {
    display: inline-flex;
    position: fixed;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 31;
    background: var(--primary);
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font-weight: 600;
  }
  .app-frame { padding: 3.2rem 1.1rem 1.2rem; }
  .dash-split, .reader, .editor, .studio-grid, .inline-edit, .course-lines a, .resume, .activity-lines li, .cat-create, .cat-admin form, .account-create, .person, .article-head, .course-nav {
    grid-template-columns: 1fr;
  }
  .drop-toggle { max-width: none; width: 100%; min-width: 0; }
  .drop-menu:not([hidden]),
  .person-access .drop-menu:not([hidden]) { left: 0; right: auto; }
  .article-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .article-head-actions,
  .page-head {
    width: 100%;
    flex-wrap: wrap;
  }
  .course-nav > span:empty { display: none; }
  .course-nav-next { text-align: left; justify-self: start; }
  .lib-search {
    margin-left: auto;
    flex: 0 1 15.5rem;
  }
  .visit-card { min-height: 22rem; position: static; }
  .preview { display: block; }
  .cat-grid,
  .stat-grid,
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .login {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }
  .login-copy { display: none !important; }
  .login-pane {
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: calc(1.25rem + env(safe-area-inset-top)) 1.35rem calc(1.5rem + env(safe-area-inset-bottom));
  }
  .login-title-mobile {
    display: inline-flex;
    flex-shrink: 0;
    margin: 0 0 2rem;
  }
  .login-form {
    max-width: none;
    width: 100%;
    margin-top: auto;
    margin-bottom: auto;
    gap: 1.05rem;
  }
  .login-form h2 { font-size: 1.55rem; }
  .login-form input[type="text"],
  .login-form input[type="email"],
  .login-form input[type="password"] {
    font-size: 1rem;
    padding: 0.75rem 0;
    width: 100%;
  }
  .login-form .btn,
  .login-form .btn-ghost {
    width: 100%;
    min-height: 2.85rem;
  }
  .login-body > .flashes {
    width: auto;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}
@media (max-width: 520px) {
  .cat-grid,
  .stat-grid,
  .course-grid { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .toc, .toc-toggle, .flashes, .reader-progress, .sidebar, .nav-toggle, .lib-search, .page-copy, .side-toc { display: none !important; }
  .app-body { display: block; }
  .reader { display: block; padding: 0; }
  .article { max-width: none; }
}
