:root {
  font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #271c31;
  background: #f8f7f4;
  --paper: #fff;
  --ink: #271c31;
  --muted: #665d70;
  --line: #e8e3eb;
  --violet: #582f78;
  --violet-dark: #372047;
  --tint: #f1eaf7;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #8753ac;
  outline-offset: 3px;
}
.page-width { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header {
  background: #fcfbf9;
  border-bottom: 1px solid #ebe6ea;
}
.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.assembly-trigger { background: var(--tint); border-color: #e5d8ec; }
.quantity {
  display: grid;
  place-items: center;
  min-width: 21px;
  min-height: 21px;
  padding: 0 4px;
  border-radius: 5px;
  background: #e8d9f1;
  color: #4c2a64;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: .07em;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--violet-dark);
  color: white;
  font: 25px/1 "STIX Two Text", Georgia, serif;
  padding-bottom: 3px;
}
.account-button, .outline-button {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--violet-dark);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}
.account-button:hover, .outline-button:hover { border-color: #b6a1c6; background: #f8f3fc; }
.person-icon { position: relative; width: 15px; height: 16px; }
.person-icon::before, .person-icon::after {
  content: "";
  position: absolute;
  border: 1.45px solid currentColor;
}
.person-icon::before { width: 6px; height: 6px; top: 0; left: 4.5px; border-radius: 50%; }
.person-icon::after { inset: 8px 1px 0; border-radius: 6px 6px 2px 2px; }

.hero {
  position: relative;
  isolation: isolate;
  margin-top: 34px;
  min-height: 302px;
  padding: 52px 52px 54px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 20px;
  color: #fff;
  background: radial-gradient(ellipse at 78% 42%, #553370 0%, transparent 55%),
    linear-gradient(111deg, #301c43 12%, #251633 100%);
  box-shadow: 0 14px 29px -23px #331d48ab;
}
.hero-graph {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: -1;
  width: 56%;
  height: 100%;
  pointer-events: none;
  mask-image: linear-gradient(90deg, transparent, black 22%);
}
.hero-content { width: min(100%, 525px); }
.hero h1 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif CJK SC", "Microsoft YaHei", serif;
  font-size: clamp(39px, 5vw, 59px);
  font-weight: 750;
  letter-spacing: .035em;
  line-height: 1.16;
}
.hero p { margin: 17px 0 27px; color: #e5d9ee; font-size: 15px; line-height: 1.65; }
.search-form {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 6px 6px 18px;
  border: 1px solid #fff7;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  box-shadow: 0 8px 18px #1d0e2b38;
}
.search-form:focus-within { outline: 2px solid #cfabea; outline-offset: 3px; }
.search-icon {
  position: relative;
  display: block;
  flex: none;
  width: 14px;
  height: 14px;
  margin: 0 2px 3px 0;
  border: 2px solid #6f587f;
  border-radius: 50%;
}
.search-icon::after {
  position: absolute;
  content: "";
  bottom: -3.5px;
  right: -4.5px;
  width: 6px;
  height: 2px;
  background: #6f587f;
  transform: rotate(47deg);
  border-radius: 2px;
}
.search-form input {
  flex: 1;
  width: 0;
  height: 42px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}
.search-form input::placeholder { color: #6f6777; }
.search-form button, .primary-button {
  min-height: 42px;
  padding: 0 19px;
  background: var(--violet);
  border: 1px solid transparent;
  border-radius: 8px;
  color: white;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}
.search-form button:hover, .primary-button:hover { background: #462362; }

.courses { margin-top: 36px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading .course-toggle { margin: 0; }
.courses h2, .catalog h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: .025em;
}
.course-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.course-card {
  min-height: 84px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}
.course-card:hover, .course-card.selected { border-color: #a98abb; background: #fcf8ff; }
.course-symbol {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  flex: none;
  padding-bottom: 2px;
  border-radius: 9px;
  background: var(--tint);
  color: #653884;
  font: 27px/1 "STIX Two Text", Georgia, serif;
}
.course-card:nth-child(2) .course-symbol { background: #f8eaf0; color: #8b4865; }
.course-card:nth-child(3) .course-symbol { background: #e8eef6; color: #365675; }
.course-text { flex: 1; min-width: 0; }
.course-name { display: block; font-size: 15px; font-weight: 750; line-height: 1.4; }
.course-details, #result-count {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.course-arrow { color: #775a8b; font-size: 18px; }

.catalog { margin-top: 38px; scroll-margin-top: 22px; }
.catalog-heading, .catalog-title-group, .filters {
  display: flex;
  align-items: center;
}
.catalog-heading { justify-content: space-between; gap: 13px 20px; margin-bottom: 15px; }
.catalog-modes { display: flex; align-items: center; gap: 5px; margin-bottom: 12px; }
.mode-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.mode-button[aria-pressed="true"] { color: var(--violet); background: var(--tint); border-color: #e8dcec; }
.mode-button:hover { color: var(--violet); }
.catalog-modes .retained-shortcut { margin: 0 0 0 auto; }
.catalog-title-group { flex-wrap: wrap; gap: 7px 13px; }
.catalog h2:focus { outline: none; }
#result-count { margin: 2px 0 0; font-size: 13px; }
.filters { flex-wrap: wrap; gap: 10px; }
.difficulty-filters { margin-bottom: 12px; }
.random-trigger { margin-inline-start: auto; background: var(--tint); }
.random-trigger:disabled { cursor: default; opacity: .55; }
.filter {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
}
.filter span { padding-left: 12px; white-space: nowrap; pointer-events: none; }
.filter select {
  min-height: 40px;
  width: auto;
  max-width: 170px;
  padding: 0 30px 0 11px;
  appearance: none;
  background: none;
  color: var(--ink);
  border: 0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 650;
}
.filter::after {
  position: absolute;
  top: calc(50% - 5px);
  right: 12px;
  width: 7px;
  height: 7px;
  content: "";
  border-right: 1.5px solid #634e74;
  border-bottom: 1.5px solid #634e74;
  transform: rotate(45deg);
  pointer-events: none;
}
.paper-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}
.paper-list:empty { display: none; }
.paper-list li + li { border-top: 1px solid var(--line); }
.paper-row { display: flex; align-items: center; gap: 2px; padding-right: 13px; }
.paper-link {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 0;
  min-height: 77px;
  padding: 13px 18px;
  text-decoration: none;
}
.paper-list li:first-child .paper-link { border-top-left-radius: 12px; }
.paper-list li:last-child .paper-link { border-bottom-left-radius: 12px; }
.paper-link:hover, .paper-link:focus-visible { background: #fcf8ff; }
.paper-details { flex: none; min-height: 34px; white-space: nowrap; }
.file-mark {
  margin: 0 3px 0 1px;
  width: 35px;
  height: 41px;
  display: grid;
  place-items: start center;
  flex: none;
  padding-top: 20px;
  border: 1px solid #e7d9f1;
  border-radius: 7px;
  background: #f6effb;
  color: #684083;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .05em;
  position: relative;
}
.file-mark::before {
  content: "";
  position: absolute;
  width: 13px;
  height: 7px;
  top: 8px;
  left: calc(50% - 6.5px);
  border-top: 1px solid #9d78b5;
  border-bottom: 1px solid #9d78b5;
}
.paper-main { flex: 1; min-width: 0; }
.paper-name { display: block; font-size: 15px; font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.paper-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.paper-info .paper-course { color: #674681; font-weight: 650; }
.paper-info .paper-material {
  border-radius: 4px;
  padding: 1px 5px;
  background: #f4edf9;
  color: #684083;
}
.paper-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.paper-link:hover .paper-action { text-decoration: underline; }
.more-row { display: flex; justify-content: center; padding-top: 18px; }
.empty-state {
  padding: 40px 20px;
  border: 1px dashed #ccbbd6;
  border-radius: 13px;
  text-align: center;
  background: #fbf8fd;
  color: var(--muted);
  font-size: 14px;
}
.empty-state p { margin: 7px 0 14px; }
.empty-state p:first-child { margin-top: 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 38px;
  padding: 20px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.auth-dialog {
  width: min(440px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 26px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 22px 70px #22133045;
}
.auth-dialog::backdrop { background: #24152caf; }
.auth-heading { display: flex; justify-content: space-between; align-items: start; }
.auth-dialog h2 { margin: 15px 0 0; font-size: 23px; }
.auth-dialog p { margin: 8px 0 16px; color: var(--muted); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
.close-button:hover { background: var(--tint); color: var(--ink); }
.auth-field { margin-bottom: 13px; }
.auth-field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.auth-field input {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid #cdbed6;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
.auth-field input[aria-invalid="true"] { border-color: #ac3e57; }
.auth-dialog .auth-feedback:not(:empty) { padding: 9px 11px; border-radius: 7px; background: var(--tint); color: #583572; }
.auth-dialog .auth-feedback:empty { display: none; }
.auth-dialog .auth-feedback[data-kind="error"] { background: #faedf1; color: #8e2a43; }
.primary-button { width: 100%; }
.text-button {
  display: block;
  margin: 7px auto 0;
  padding: 8px 14px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--violet);
  font-size: 13px;
  font-weight: 700;
}
.text-button:hover { background: var(--tint); }

.workspace-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  max-height: min(850px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #faf8fb;
  color: var(--ink);
  box-shadow: 0 22px 70px #22133045;
  overflow: hidden;
}
.workspace-dialog[open] { display: flex; flex-direction: column; }
.workspace-dialog::backdrop { background: #24152c9e; }
.workspace-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 21px 22px 16px;
  background: white;
}
.workspace-heading h2 { margin: 0; font-size: clamp(18px, 3vw, 25px); line-height: 1.4; overflow-wrap: anywhere; }
.workspace-heading .close-button { flex: none; }
.workspace-meta { margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.workspace-heading h2 + .workspace-meta { margin-top: 5px; }
.workspace-actions {
  padding: 0 22px 15px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.workspace-actions a { text-decoration: none; }
.workspace-actions .outline-button, .question-actions .outline-button { min-height: 36px; padding-inline: 11px; }
.workspace-actions .primary-button, .comments-form .primary-button { width: auto; }
.workspace-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 22px 21px; }
.workspace-list-heading {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.paper-list.question-results { background: transparent; border: 0; }
.question-results li + li { border: 0; margin-top: 12px; }
.question-card {
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.workspace-body > .question-card + .question-card { margin-top: 12px; }
.question-heading { margin-bottom: 7px; }
.question-card h3 { margin: 0; color: var(--violet-dark); font-size: 16px; }
.retained-title { margin: 1px 0 0; font-weight: 700; }
.question-actions { margin-top: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.question-select[aria-pressed="true"] { color: var(--violet); background: var(--tint); border-color: #bda6ce; }
.inline-link { color: #633c81; font-size: 13px; text-underline-offset: 3px; }
.source-button { display: block; padding: 0; border: 0; background: transparent; text-align: left; text-decoration: underline; }
.question-content { font-size: 15px; line-height: 1.75; }
.question-content p { margin: 6px 0; }
.question-content ol, .question-content ul { margin-block: 6px; padding-inline-start: 2em; }
.question-math-display { max-width: 100%; overflow-x: auto; padding: 4px 1px; }
.question-math-display > .katex-display { min-width: max-content; margin: .55em 0; }
.question-math-inline .katex { font-size: 1.08em; }
.question-figure { margin: 10px 0; }
.question-figure img { display: block; max-width: 100%; max-height: 370px; object-fit: contain; }
.question-source-note, .question-render-note { color: var(--muted); font-size: 13px; }
.question-tex-fallback { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .87em; }
.question-table { border-collapse: collapse; max-width: 100%; }
.question-table th, .question-table td { padding: 3px 8px; border: 1px solid var(--line); }
.assembly-item .assembly-source { display: block; margin-top: 2px; }
.assembly-label, .comments-form label { font-size: 13px; font-weight: 700; }
.assembly-name, .comments-form textarea {
  min-width: 0;
  border: 1px solid #cdbed6;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
.assembly-name { min-height: 41px; flex: 1; padding: 0 10px; }
.workspace-actions button:disabled, .question-actions button:disabled { opacity: .45; cursor: default; }
.comments-dialog { width: min(670px, calc(100% - 32px)); }
.comments-dialog .workspace-heading { border-bottom: 1px solid var(--line); }
.comments-list { padding: 0; margin: 0 0 18px; list-style: none; }
.comment-entry {
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  overflow-wrap: anywhere;
}
.comment-entry + .comment-entry { margin-top: 8px; }
.comment-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; color: var(--muted); font-size: 12px; }
.comment-author { color: var(--violet-dark); font-weight: 700; }
.comment-text { margin: 5px 0 0; line-height: 1.6; font-size: 14px; }
.comment-empty { color: var(--muted); font-size: 14px; }
.comments-form textarea { display: block; width: 100%; padding: 10px; margin: 6px 0 9px; resize: vertical; font: inherit; }
.comments-form textarea:focus-visible { outline: 3px solid #8753ac; outline-offset: 2px; }
.comment-submit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; }
#comments-feedback { margin: 0; color: var(--muted); font-size: 13px; }

.workspace-dialog.random-dialog { width: min(440px, calc(100% - 18px)); }
.workspace-dialog.replace-dialog { width: min(740px, calc(100% - 18px)); }
.random-dialog .workspace-heading, .replace-dialog .workspace-heading, .markdown-dialog .workspace-heading { border-bottom: 1px solid var(--line); }
.assembly-tool-form { display: grid; gap: 13px; }
.assembly-tool-form label { display: grid; gap: 5px; min-width: 0; color: var(--violet-dark); font-size: 13px; font-weight: 700; }
.assembly-tool-form input, .assembly-tool-form select, .markdown-pane textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #cdbed6;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 400;
}
.assembly-tool-form input[type="number"] { width: min(155px, 100%); }
.assembly-tool-form select[size] { padding: 4px; }
.assembly-tool-form select[size] option { padding: 4px 6px; }
.assembly-tool-form :is(input, select):focus-visible, .markdown-pane textarea:focus-visible { outline: 3px solid #8753ac; outline-offset: 2px; }
.tool-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.tool-actions .primary-button { width: auto; }
.tool-actions .primary-button:disabled, .markdown-toolbar button:disabled { cursor: default; opacity: .5; }
.tool-actions .workspace-meta { margin: 0; }

.markdown-workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.markdown-pane { min-width: 0; }
.markdown-pane-title { display: block; margin: 0 0 6px; color: var(--violet-dark); font-size: 14px; font-weight: 700; }
.markdown-pane textarea, .markdown-preview { display: block; min-height: 270px; }
.markdown-pane textarea { resize: vertical; font: 13px/1.65 "IBM Plex Mono", Consolas, monospace; }
.markdown-preview, .comment-preview { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: white; overflow-wrap: anywhere; }
.markdown-preview { max-height: 460px; overflow: auto; }
.markdown-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 9px 0; }
.markdown-toolbar .outline-button { min-height: 34px; padding-inline: 10px; }
.markdown-toolbar .workspace-meta { margin: 0 0 0 3px; }
.comment-preview { margin: 0 0 10px; }
.comment-preview h3, .markdown-help { margin: 0; color: var(--muted); font-size: 13px; }
.comment-preview h3 { margin-bottom: 6px; }
.markdown-help summary { cursor: pointer; font-weight: 700; }
.markdown-help ul { margin: 6px 0 0; padding-inline-start: 1.4em; line-height: 1.65; }
.markdown-empty { margin: 0; color: var(--muted); font-size: 14px; }
.markdown-content { line-height: 1.65; overflow-wrap: anywhere; font-size: 14px; }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content :is(h1, h2, h3, h4, h5, h6) { font-size: 1.1em; line-height: 1.5; }
.markdown-content :is(p, ul, ol, blockquote, pre) { margin-block: .5em; }
.markdown-content :is(ul, ol) { padding-inline-start: 1.65em; }
.markdown-content a { color: var(--violet); }
.markdown-content blockquote { margin-inline: 0; padding-inline-start: .8em; border-inline-start: 3px solid #d7c3e5; color: var(--muted); }
.markdown-content :is(code, pre) { border-radius: 5px; background: #f4eff7; }
.markdown-content code { padding: .1em .25em; }
.markdown-content pre { padding: .6em .8em; overflow: auto; white-space: pre; }
.markdown-content pre code { padding: 0; }
.markdown-content table { display: block; max-width: 100%; overflow: auto; border-collapse: collapse; }
.markdown-content :is(td, th) { padding: .25em .55em; border: 1px solid var(--line); }

.difficulty-dialog.workspace-dialog {
  --rating-gold: #bc700d;
  --rating-muted: #d3c6d0;
  width: min(520px, calc(100% - 18px));
}
.difficulty-dialog .workspace-heading { border-bottom: 1px solid var(--line); }
.difficulty-dialog #difficulty-context { overflow-wrap: anywhere; }
.difficulty-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 14px;
  border: 1px solid #eee1d2;
  border-radius: 11px;
  background: #fffcf7;
  font-variant-numeric: tabular-nums;
}
#difficulty-average { color: var(--violet-dark); font-size: clamp(32px, 8vw, 45px); line-height: 1; }
.difficulty-max { color: var(--muted); font-size: 13px; }
.difficulty-summary-details { display: grid; gap: 3px; }
.difficulty-average-stars {
  position: relative;
  width: max-content;
  color: var(--rating-muted);
  font: 19px/1.1 "Segoe UI Symbol", sans-serif;
  letter-spacing: 2px;
  white-space: nowrap;
}
.difficulty-stars-fill {
  position: absolute;
  inset: 0 auto 0 0;
  overflow: hidden;
  color: var(--rating-gold);
}
#difficulty-count { margin: 0; color: var(--muted); font-size: 13px; }
.difficulty-distribution { display: grid; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; }
.difficulty-bucket {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.difficulty-track { display: block; height: 8px; overflow: hidden; border-radius: 4px; background: #f1e7dc; }
.difficulty-bar { display: block; height: 100%; border-radius: inherit; background: #d88b24; }
.difficulty-percent { text-align: right; }
.difficulty-gate, .difficulty-form { margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.difficulty-gate { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.difficulty-gate p, .difficulty-scale-hint, .difficulty-mine, #difficulty-feedback { margin: 0; color: var(--muted); font-size: 13px; }
.difficulty-fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.difficulty-fieldset legend { padding: 0; color: var(--violet-dark); font-size: 15px; font-weight: 700; }
.difficulty-scale-hint { margin-top: 4px; }
.difficulty-options { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin: 10px 0 12px; }
.difficulty-option { position: relative; display: block; min-width: 0; cursor: pointer; }
.difficulty-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.difficulty-choice {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 5px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  line-height: 1.15;
}
.difficulty-choice-star { color: #9d8797; font: 21px/1 "Segoe UI Symbol", sans-serif; }
.difficulty-choice-number { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.difficulty-option:hover .difficulty-choice { border-color: #c99b61; }
.difficulty-option.filled .difficulty-choice-star { color: var(--rating-gold); }
.difficulty-option input:checked + .difficulty-choice { border-color: #c28a43; background: #fdf1de; }
.difficulty-option input:checked + .difficulty-choice .difficulty-choice-number { color: var(--ink); font-weight: 700; }
.difficulty-option input:focus-visible + .difficulty-choice { outline: 3px solid #8753ac; outline-offset: 2px; }
.difficulty-submit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px; }
.difficulty-submit-row .primary-button { width: auto; }
.difficulty-submit-row .primary-button:disabled { opacity: .55; cursor: default; }
#difficulty-feedback:not(:empty) { margin-top: 8px; }
.difficulty-button .difficulty-button-icon { color: #a15d0a; font-size: 14px; line-height: 1; }

#print-sheet { display: none; }

@media print {
  @page { margin: 17mm; }
  :root { background: white; color: black; }
  body > :not(#print-sheet) { display: none !important; }
  body > #print-sheet { display: block; }
  #print-sheet h1 { margin: 0 0 12mm; border-bottom: 1px solid #bbb; padding-bottom: 4mm; font-size: 21pt; }
  #print-sheet h2 { break-after: avoid; margin: 0 0 2mm; font-size: 13pt; }
  .print-question { margin-bottom: 8mm; }
  .print-question .question-content { font-size: 11pt; }
  .print-source { color: #555; font-size: 9pt; margin: 2mm 0 0; }
  .question-figure { break-inside: avoid; }
}

@media (max-width: 900px) {
  .hero { padding-inline: 34px; }
  .hero-graph { width: 65%; opacity: .85; }
  .course-arrow { display: none; }
}

@media (max-width: 670px) {
  .page-width { width: calc(100% - 32px); }
  .header-inner { min-height: 60px; }
  .brand { gap: 8px; font-size: 15px; }
  .brand-mark { width: 33px; height: 33px; }
  .account-button { padding-inline: 10px; }
  .hero { min-height: 250px; margin-top: 19px; padding: 30px 19px; border-radius: 15px; }
  .hero h1 { font-size: clamp(30px, 9.4vw, 43px); }
  .hero p { margin: 12px 0 21px; font-size: 13px; }
  .hero-graph { width: 82%; opacity: .45; }
  .search-form { gap: 8px; padding-left: 12px; }
  .search-form input { font-size: 14px; }
  .search-form button { padding-inline: 12px; }
  .courses, .catalog { margin-top: 28px; }
  .courses h2, .catalog h2 { font-size: 20px; }
  .course-grid { grid-template-columns: 1fr; gap: 8px; }
  .course-card { min-height: 58px; padding: 8px 12px; }
  .course-symbol { width: 38px; height: 38px; font-size: 23px; }
  .course-arrow { display: block; }
  .catalog-heading { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; gap: 7px; }
  .filter { flex: 1 1 auto; }
  .filter select { max-width: none; flex: 1; min-width: 0; }
  .paper-row { padding-right: 8px; }
  .paper-link { gap: 10px; padding-inline: 11px; }
  .paper-name { font-size: 14px; }
  .paper-action { display: none; }
  .paper-details { padding-inline: 7px; font-size: 12px; }
  .workspace-dialog { width: calc(100% - 18px); max-height: calc(100dvh - 18px); }
  .workspace-heading { padding: 15px 13px 11px; }
  .workspace-actions { padding: 0 13px 12px; }
  .workspace-body { padding: 12px; }
  .question-card { padding: 12px; }
}

@media (max-width: 400px) {
  .header-inner { gap: 6px; }
  .header-actions { gap: 5px; }
  .account-button { gap: 5px; padding-inline: 7px; font-size: 12px; }
  .account-button .person-icon { display: none; }
  .brand { letter-spacing: 0; }
}

@media (max-width: 540px) {
  .header-inner { flex-wrap: wrap; padding-block: 8px; }
  .header-actions { max-width: 100%; flex-wrap: wrap; }
  .markdown-workspace { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .markdown-pane textarea, .markdown-preview { min-height: 135px; }
}

@media (max-width: 420px) {
  .random-trigger { width: 100%; }
}

@media (max-width: 350px) {
  .brand > span:last-child { display: none; }
  .assembly-actions .primary-button { width: 100%; }
}
