:root {
  --ink: #0a0a0a;
  --muted: #626262;
  --faint: #8f8f8f;
  --hairline: #d8d8d8;
  --hairline-soft: #ececec;
  --wash: #fafafa;
  --mark: #fff4c8;
  --mark-hot: #ffe583;
  --display: "Helvetica Neue", Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --col: 42rem;
  --rail: 15rem;
  --margin-col: 15rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.62;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* chrome                                                              */
/* ------------------------------------------------------------------ */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--hairline);
}

.masthead .home {
  text-decoration: none;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.2s, color 0.2s;
}
.masthead .home:hover { border-color: var(--ink); color: var(--ink); }

.masthead .crumbs {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.masthead .crumbs a { text-decoration: none; }
.masthead .crumbs a:hover { text-decoration: underline; }
.masthead .sep { color: var(--hairline); padding: 0 0.5rem; }

.masthead .who { color: var(--faint); }

/* ------------------------------------------------------------------ */
/* buttons, inputs                                                     */
/* ------------------------------------------------------------------ */

button, .btn {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.15s, color 0.15s;
}
button:hover, .btn:hover { border-color: var(--ink); color: var(--ink); }
button:disabled { opacity: 0.4; cursor: default; border-color: var(--hairline); color: var(--muted); }

button.plain {
  border: none;
  padding: 0.2rem 0;
}
button.solid {
  border-color: var(--ink);
  color: #fff;
  background: var(--ink);
}
button.solid:hover { opacity: 0.82; color: #fff; }

input[type="text"], input[type="email"], input[type="password"] {
  font-family: var(--display);
  font-weight: 300;
  font-size: 1rem;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  padding: 0.5rem 0;
  width: 100%;
  outline: none;
}
input:focus { border-bottom-color: var(--ink); }
input::placeholder { color: var(--faint); font-weight: 300; }

/* ------------------------------------------------------------------ */
/* sign in                                                             */
/* ------------------------------------------------------------------ */

.gate {
  max-width: 21rem;
  margin: 0 auto;
  padding: 6rem 2rem 4rem;
}
.gate h1 {
  font-size: 1.75rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin: 0.6rem 0 0.4rem;
}
.gate p.sub {
  color: var(--muted);
  margin: 0 0 2.5rem;
  font-size: 0.95rem;
}
.gate .field { margin-bottom: 1.5rem; }
.gate .field .label { display: block; margin-bottom: 0.25rem; }
.gate .actions { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 2rem; }
.gate button { width: 100%; padding: 0.7rem; }
.gate .rule {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 2rem 0;
}
.gate .rule::before, .gate .rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline-soft);
}
.gate .alt {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.gate .alt button { width: auto; border: none; padding: 0; text-transform: none; font-family: var(--display); font-size: 0.85rem; letter-spacing: 0; text-decoration: underline; }

.notice {
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.7rem 0.85rem;
  border-left: 2px solid var(--ink);
  background: var(--wash);
  margin: 1.5rem 0;
}
.notice.bad { border-left-color: #b3261e; }

/* ------------------------------------------------------------------ */
/* dashboard                                                           */
/* ------------------------------------------------------------------ */

.page { max-width: 52rem; margin: 0 auto; padding: 4.5rem 2rem 6rem; }
.page h1 {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.025em;
  margin: 0.75rem 0 3rem;
}

.class-list { border-top: 1px solid var(--hairline); }
.class-list a.row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--hairline-soft);
  text-decoration: none;
}
.class-list a.row:hover .name { text-decoration: underline; }
.class-list .name { font-size: 1.1rem; flex: 1; }
.class-list .meta { color: var(--faint); font-size: 0.8rem; }

.empty { color: var(--muted); padding: 2rem 0; font-size: 0.95rem; }

.new-class {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--hairline);
}
.new-class .fields {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.new-class .fields > div { flex: 1; min-width: 11rem; }

/* ------------------------------------------------------------------ */
/* class view: rail | note | margin                                    */
/* ------------------------------------------------------------------ */

.class-wrap {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) var(--margin-col);
  align-items: start;
  min-height: calc(100vh - 4.4rem);
}

/* Only earns its place on a phone, where the rail would otherwise bury the note. */
.rail-toggle { display: none; }

.rail {
  border-right: 1px solid var(--hairline);
  padding: 2rem 1.25rem 6rem;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.rail .section { margin-bottom: 1.75rem; }
.rail .section > .head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.rail .section > .head .title {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: none;
  background: none;
  padding: 2px 0;
  outline: none;
  min-width: 0;
}
.rail .section > .head .title:focus { color: var(--ink); }

.rail .add {
  opacity: 0;
  border: none;
  padding: 0 0.2rem;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--faint);
  letter-spacing: 0;
}
.rail .section:hover .add, .rail .add:focus { opacity: 1; }

.rail a.note-link {
  display: block;
  padding: 0.28rem 0 0.28rem 0.7rem;
  margin-left: -0.7rem;
  border-left: 2px solid transparent;
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail a.note-link:hover { color: var(--ink); }
.rail a.note-link.on { color: var(--ink); border-left-color: var(--ink); }

.rail .rail-foot {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline-soft);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}

/* note pane */
.note-pane { padding: 3.5rem 3rem 8rem; min-width: 0; }
.note-inner { max-width: var(--col); }

.note-title {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.2;
  border: none;
  background: none;
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0 0 0.5rem;
  font-family: var(--display);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--hairline-soft);
}
.note-meta .stamp { flex: 1; color: var(--faint); font-size: 0.78rem; font-family: var(--mono); letter-spacing: 0.06em; }

.prose { font-size: 1.0625rem; }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3 {
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2.25rem 0 0.75rem;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.05rem; }
.prose p { margin: 0 0 1.15rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
.prose li { margin-bottom: 0.3rem; }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--wash);
  border: 1px solid var(--hairline-soft);
  border-radius: 3px;
  padding: 0.05em 0.3em;
}
.prose pre {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--wash);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 0 0 1.25rem;
}
.prose pre code { background: none; border: none; padding: 0; font-size: inherit; }
.prose blockquote {
  margin: 0 0 1.15rem;
  padding-left: 1rem;
  border-left: 2px solid var(--hairline);
  color: var(--muted);
}
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.25rem; font-size: 0.95rem; }
.prose th, .prose td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--hairline-soft); }
.prose th { font-weight: 400; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.prose img { max-width: 100%; }
.prose hr { border: none; border-top: 1px solid var(--hairline); margin: 2rem 0; }
.prose a { color: inherit; text-decoration-color: var(--hairline); text-underline-offset: 2px; }

/* maths */
.prose .math-block {
  margin: 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}
.prose .katex { font-size: 1.04em; }
.prose .katex-display { margin: 0; }
.prose .math-inline .katex { font-size: 1.02em; }
/* KaTeX failed to load: show the source, quietly marked as such */
.prose .math-block:not(:has(.katex)),
.prose .math-inline:not(:has(.katex)) {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--muted);
}

.editor {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--ink);
  width: 100%;
  min-height: 24rem;
  border: none;
  border-left: 1px solid var(--hairline-soft);
  padding: 0 0 0 1rem;
  margin-left: -1rem;
  outline: none;
  resize: none;
  background: none;
  tab-size: 2;
}
.editor:focus { border-left-color: var(--ink); }

/* annotations */
.anno {
  background: var(--mark);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  cursor: default;
}
.anno.hot { background: var(--mark-hot); }

.pop {
  position: absolute;
  z-index: 40;
  max-width: 20rem;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 0.7rem 0.85rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.pop .who { display: block; margin-bottom: 0.2rem; }
.pop .thread + .thread { margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--hairline-soft); }

.sel-btn {
  position: absolute;
  z-index: 50;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.sel-btn:hover { color: #fff; opacity: 0.85; }

/* margin column */
.margin-col {
  padding: 3.5rem 2rem 8rem 0;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
.margin-col .label { display: block; margin-bottom: 1rem; }

.cmt {
  border-left: 2px solid var(--hairline);
  padding: 0 0 0 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: default;
}
.cmt:hover, .cmt.hot { border-left-color: var(--ink); }
.cmt .quote {
  display: block;
  color: var(--faint);
  font-style: italic;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmt .who { display: block; color: var(--muted); font-size: 0.75rem; font-family: var(--mono); letter-spacing: 0.06em; margin-top: 0.25rem; }
.cmt .kill { opacity: 0; border: none; padding: 0; font-size: 0.65rem; letter-spacing: 0.1em; }
.cmt:hover .kill { opacity: 1; }
.cmt.orphan { border-left-style: dashed; }

.cmt-form textarea {
  font-family: var(--display);
  font-weight: 300;
  font-size: 0.85rem;
  line-height: 1.5;
  width: 100%;
  min-height: 4.5rem;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  outline: none;
  resize: vertical;
  background: none;
  color: var(--ink);
}
.cmt-form textarea:focus { border-color: var(--ink); }
.cmt-form .quote { display: block; color: var(--faint); font-style: italic; font-size: 0.8rem; margin-bottom: 0.4rem; }
.cmt-form { margin-bottom: 1.5rem; }
.cmt-form .row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* members / invite panel */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6rem 2rem;
  overflow-y: auto;
}
.panel .sheet {
  width: 100%;
  max-width: 30rem;
  border: 1px solid var(--ink);
  border-radius: 5px;
  background: #fff;
  padding: 2rem;
}
.panel h2 { font-weight: 300; font-size: 1.3rem; letter-spacing: -0.02em; margin: 0.5rem 0 1.5rem; }
.panel .link-box {
  font-family: var(--mono);
  font-size: 0.75rem;
  word-break: break-all;
  background: var(--wash);
  border: 1px solid var(--hairline-soft);
  border-radius: 4px;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.75rem;
}
.panel .member-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 0.9rem;
}
.panel .member-row .email { color: var(--faint); font-size: 0.8rem; }
.panel .close { margin-top: 1.75rem; }

/* ------------------------------------------------------------------ */
/* small screens                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 62rem) {
  .class-wrap { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .margin-col {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    padding: 0 3rem 5rem;
    border-top: 1px solid var(--hairline-soft);
    padding-top: 2rem;
  }
  .note-pane { padding: 3rem 3rem 3rem; }
}

@media (max-width: 44rem) {
  .class-wrap { display: block; }
  .rail {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    padding: 0.5rem 1.5rem 1.5rem;
  }
  .rail-toggle {
    display: block;
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--hairline);
    border-radius: 0;
    text-align: left;
    padding: 0.85rem 1.5rem;
  }
  .rail-shut .rail { display: none; }
  .rail-shut .rail-toggle { border-bottom-color: var(--hairline); }

  .note-pane { padding: 2rem 1.5rem 3rem; }
  .margin-col { padding: 2rem 1.5rem 4rem; }
  .masthead { padding: 1.25rem 1.5rem; flex-wrap: wrap; gap: 0.6rem 1rem; }
  .masthead .crumbs { order: 3; flex-basis: 100%; }
  .masthead .who { display: none; }
  .page { padding: 3rem 1.5rem 5rem; }
}
