@font-face {
  font-family: MathNoteFallback;
  src: local("Segoe UI");
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: "Segoe UI", MathNoteFallback, sans-serif;
  font-size: 14px;
  color: #28483f;
  background: #eef3f0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
}
button:hover {
  background: #e9f0ec;
}
button:active {
  background: #ddebe3;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #65b2a4;
  outline-offset: 3px;
}
button[aria-pressed="true"],
button[aria-current="page"] {
  color: #096b5e;
  background: #e1eee7;
}
.icon {
  width: 23px;
  height: 23px;
  flex: none;
}
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.app-header {
  height: 78px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 10px 25px;
  border-bottom: 1px solid #e0e8e2;
  background: #fff;
}
.brand {
  padding: 0;
  gap: 10px;
}
.brand > svg {
  width: 40px;
  height: 40px;
}
.brand strong {
  font-size: 19px;
  letter-spacing: -0.5px;
  text-align: left;
}
.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 2.3px;
  color: #879e93;
  margin-top: 1px;
}
.document-title {
  display: flex;
  flex-direction: column;
  min-width: 100px;
  flex: 1;
}
.document-title > button {
  justify-content: flex-start;
  padding: 0;
  min-height: 26px;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  text-align: left;
}
.save-state {
  font-size: 11px;
  color: #889e93;
  margin-top: 3px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-actions button {
  font-size: 13px;
}
.header-actions [data-action="save"] {
  background: #157b69;
  color: white;
  padding: 9px 16px;
}
.main-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fbfdfb;
  padding: 8px 23px;
  border-bottom: 1px solid #dbe5de;
  min-height: 58px;
  flex: none;
}
.history-tools,
.primary-tools,
.pinned-tools,
.ink-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}
.history-tools {
  padding-right: 9px;
  border-right: 1px solid #dbe5de;
}
.main-toolbar button {
  width: 40px;
  height: 40px;
  flex: none;
}
.main-toolbar button span {
  display: none;
}
.main-toolbar [data-action="tools"] {
  width: auto;
  background: #e6eee7;
  gap: 5px;
  padding: 6px 12px;
  margin-left: auto;
}
.main-toolbar [data-action="tools"] span {
  display: inline;
  font-size: 13px;
}
.ink-controls {
  gap: 10px;
  margin-left: 3px;
}
.ink-controls[hidden] {
  display: none;
}
.ink-controls input[type="color"] {
  padding: 0;
  width: 25px;
  height: 25px;
  border: 3px solid white;
  border-radius: 50%;
  outline: 1px solid #c8d9cf;
  overflow: hidden;
  cursor: pointer;
}
.ink-controls input[type="range"] {
  width: 65px;
  accent-color: #1b7a69;
  height: 18px;
}
.pinned-tools {
  padding-left: 12px;
  border-left: 1px solid #dbe5de;
}
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}
.section-rail {
  width: 190px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 25px 12px 16px;
  background: #f8faf7;
  border-right: 1px solid #dce5dc;
  gap: 4px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.8px;
  font-weight: 700;
  color: #7f9789;
  margin: 0 0 16px;
}
.section-rail > .eyebrow {
  padding: 0 12px;
}
.section-rail > button {
  justify-content: flex-start;
  min-height: 45px;
  padding: 8px 10px;
  text-align: left;
  font-weight: 500;
}
.section-rail > button > span:nth-child(2) {
  flex: 1;
}
.section-mark {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd9cc;
  border-radius: 6px;
  font-size: 10px;
  flex: none;
}
.section-rail small {
  font-size: 11px;
  color: #8ca293;
}
.section-rail > .add-section {
  justify-content: center;
  align-self: center;
  width: 38px;
  margin-top: 8px;
  border: 1px dashed #c7d8c9;
  min-height: 32px;
}
.add-section svg {
  width: 17px;
  height: 17px;
}
.rail-help {
  margin-top: auto;
  padding: 30px 9px 0;
  color: #91a699;
  font-size: 11px;
  line-height: 1.6;
}
.rail-help > button {
  display: block;
  text-align: left;
  padding: 0;
  min-height: 25px;
  color: #628775;
  font-size: 11px;
}
.paper-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #eaf0ec;
  scrollbar-gutter: stable;
  touch-action: pan-x pan-y;
}
.pages {
  display: flex;
  flex-direction: column;
  gap: 45px;
  align-items: center;
  padding: 38px 35px 80px;
  min-width: fit-content;
}
.page-frame {
  position: relative;
  flex: none;
  background: #fff;
  box-shadow: 0 3px 18px #244c3c0e;
}
.paper {
  height: 100%;
  width: 100%;
  display: block;
  overflow: hidden;
  touch-action: none;
}
#app:is([data-active-tool="pen"], [data-active-tool="marker"]) .paper {
  cursor: crosshair;
}
#app.writing-cursor-active .paper,
#app.writing-cursor-active .paper * {
  cursor: none;
}
.writing-contact-cursor {
  position: fixed;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}
.writing-contact-cursor img {
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  pointer-events: none;
  will-change: transform;
}
.paper-bg {
  pointer-events: all;
}
.page-number {
  position: absolute;
  top: -23px;
  font-size: 10px;
  letter-spacing: 0.6px;
  color: #789685;
}
.object {
  cursor: inherit;
}
.selection-box {
  fill: #14816b08;
  stroke: #218976;
  stroke-dasharray: 5 4;
  stroke-width: 1;
}
.selection-layer {
  pointer-events: none;
}
.selection-layer [data-resize] {
  pointer-events: all;
  cursor: nwse-resize;
}
.instrument [data-instrument] {
  cursor: grab;
}
.instrument [data-instrument="rotate"] {
  cursor: crosshair;
}
.instrument [data-instrument="resize"] {
  cursor: ew-resize;
}
.add-page {
  background: #f6faf6;
  border: 1px solid #c4d7c7;
  color: #3f7b61;
  font-size: 13px;
  padding: 8px 20px;
}
.add-page .icon {
  width: 17px;
  height: 17px;
}
.statusbar {
  min-height: 35px;
  flex: none;
  border-top: 1px solid #dbe5dd;
  background: #f9fbf8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  font-size: 11px;
  gap: 15px;
}
.tool-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7b9486;
}
.statusbar > div {
  display: flex;
  align-items: center;
  gap: 0;
  flex: none;
}
.statusbar button {
  font-size: 11px;
  min-height: 30px;
  padding: 4px 7px;
}
.status-separator {
  height: 13px;
  border-left: 1px solid #cfddd2;
  margin: 0 8px;
}
.license-status {
  color: #41846b;
}
.reference-pane {
  width: 30%;
  min-width: 230px;
  background: #f7faf7;
  border-left: 1px solid #ccded1;
  display: flex;
  flex-direction: column;
  resize: horizontal;
  overflow: auto;
}
.reference-pane > div:first-child {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}
.reference-scroll {
  overflow: auto;
  flex: 1;
}
.reference-scroll > svg {
  width: 100%;
  background: white;
  display: block;
}
.reference-scroll .object {
  pointer-events: none;
}
dialog {
  border: 1px solid #d3e1d6;
  background: #fff;
  color: #28483f;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 22px 80px #183d2d26;
  width: min(740px, calc(100vw - 32px));
  max-height: calc(100vh - 36px);
  overflow: hidden;
}
dialog::backdrop {
  background: #20392d58;
  backdrop-filter: blur(3px);
}
dialog > form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 38px);
  margin: 0;
}
dialog header {
  padding: 25px 28px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid #e6ece6;
  flex: none;
}
dialog header .eyebrow {
  font-size: 9px;
  margin-bottom: 7px;
}
h2 {
  font-size: 24px;
  letter-spacing: -0.6px;
  margin: 0;
  font-weight: 650;
}
dialog header button {
  margin: -3px -10px 0 10px;
  color: #7c9686;
}
.dialog-body {
  padding: 20px 28px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
dialog footer {
  padding: 14px 28px;
  background: #f8faf7;
  border-top: 1px solid #e1e9e0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex: none;
}
.primary {
  background: #157b69;
  color: white;
  padding: 9px 20px;
}
.primary:hover {
  background: #0c6d5b;
}
.intro {
  color: #6f897b;
  line-height: 1.7;
  margin: 0 0 19px;
  font-size: 13px;
}
.form-error {
  font-size: 12px;
  color: #aa4e3e;
  margin: 0 28px 8px;
  flex: none;
  white-space: pre-wrap;
}
.form-error:empty {
  display: none;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 17px;
  min-width: 0;
}
.field > span {
  font-size: 12px;
  font-weight: 600;
  color: #61806c;
}
input:not([type="range"]):not([type="color"]),
textarea,
select {
  border: 1px solid #ccdacd;
  border-radius: 8px;
  background: #fff;
  color: #28483f;
  padding: 10px 12px;
  min-height: 40px;
  width: 100%;
  min-width: 0;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input[type="number"] {
  font-variant-numeric: tabular-nums;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.graph-preview,
.space-preview {
  width: 100%;
  height: auto;
  max-height: 330px;
  display: block;
  border: 1px solid #e1eae2;
  border-radius: 9px;
  background: #fbfdfb;
  margin: 12px 0;
}
.formula-preview {
  padding: 22px;
  min-height: 100px;
  text-align: center;
  background: #f6faf6;
  border-radius: 10px;
  overflow: auto;
  font-size: 25px;
}
.formula-content {
  line-height: normal;
  padding: 2px;
  box-sizing: border-box;
}
.formula-content .katex-display {
  margin: 0;
  text-align: left;
}
.formula-content .katex-display > .katex {
  text-align: left;
}
.formula-measure {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  left: 0;
  top: 0;
  width: max-content;
}
.template-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}
.template-row button {
  border: 1px solid #d4e2d5;
  background: #f8fbf7;
  font-size: 12px;
}
.catalog-dialog {
  width: min(880px, calc(100vw - 32px));
  height: min(740px, calc(100vh - 36px));
}
.catalog-dialog > form {
  height: 100%;
}
.catalog-dialog .dialog-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.catalog-dialog .intro,
.catalog-dialog .catalog-search {
  flex: none;
}
.catalog-dialog .catalog {
  flex: 1;
  min-height: 0;
  height: auto;
}
.catalog-search {
  margin-bottom: 17px;
}
.catalog {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 20px;
  height: min(400px, 50vh);
}
.catalog nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-right: 1px solid #e0e9e0;
  padding-right: 14px;
  overflow: auto;
}
.catalog nav > button {
  justify-content: space-between;
  text-align: left;
  font-size: 12px;
  padding: 10px 12px;
  flex: none;
}
.catalog nav small {
  opacity: 0.5;
}
.catalog-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
  align-content: start;
  padding-right: 4px;
}
.catalog-results > button {
  justify-content: flex-start;
  text-align: left;
  padding: 12px 10px;
  min-height: 75px;
  border: 1px solid #e5ece4;
  background: #fbfdf9;
}
.catalog-results > button:hover {
  background: #edf5ed;
  border-color: #b5d4bd;
}
.catalog-results > button > svg {
  width: 54px;
  height: 42px;
  flex: none;
}
.catalog-results > button span {
  font-size: 12px;
  font-weight: 600;
}
.catalog-results small {
  display: block;
  font-size: 10px;
  color: #89a18e;
  font-weight: 400;
  margin-top: 6px;
}
.tool-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tool-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eaf0e7;
  padding: 5px 0;
}
.tool-row > button:first-child {
  justify-content: flex-start;
  text-align: left;
  flex: 1;
  gap: 16px;
}
.tool-row small {
  display: block;
  font-size: 11px;
  color: #829b8b;
  margin-top: 4px;
}
.tool-row strong {
  font-weight: 600;
}
.tool-row > button:last-child {
  font-size: 11px;
  border: 1px solid #dce6da;
  min-width: 76px;
}
.tool-row .icon {
  color: #4c8c71;
}
.instrument-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.instrument-choices > button {
  border: 1px solid #d4e3d4;
  justify-content: flex-start;
  padding: 17px;
  gap: 18px;
}
.instrument-choices strong {
  font-size: 13px;
  font-weight: 500;
}
.library-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}
.library-actions > button {
  border: 1px solid #d8e5d7;
}
.library-list > button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  gap: 18px;
  padding: 17px 12px;
  border-bottom: 1px solid #e4ece2;
  border-radius: 0;
}
.library-list > button > span:nth-child(2) {
  flex: 1;
}
.library-list small {
  display: block;
  font-size: 10px;
  color: #89a18d;
  margin-top: 6px;
}
.note-symbol {
  padding: 10px;
  border: 1px solid #d1e1d0;
  border-radius: 9px;
  color: #388260;
  background: #f1f7ed;
}
.empty-state {
  padding: 50px 20px;
  text-align: center;
  color: #8da18e;
  font-size: 13px;
}
.page-manager > div,
.pinned-order > div {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e7eee3;
  gap: 8px;
  padding: 4px;
}
.page-manager > div > button:first-child,
.pinned-order > div > span {
  flex: 1;
  justify-content: flex-start;
}
.page-manager > div > button {
  font-size: 12px;
}
.option-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option-list button {
  justify-content: flex-start;
  padding: 15px;
  border: 1px solid #e0e9dd;
  font-size: 13px;
}
.option-list .icon {
  color: #568f6f;
}
.search-results button {
  display: block;
  text-align: left;
  width: 100%;
  border-bottom: 1px solid #e3ecdf;
  padding: 12px;
}
.search-results small {
  display: block;
  color: #889e8b;
  margin-top: 8px;
}
.guide section {
  margin-bottom: 25px;
}
.guide h3 {
  font-size: 15px;
  margin: 0 0 12px;
  color: #2b6f51;
}
.guide p {
  color: #6e8977;
  line-height: 1.8;
  font-size: 13px;
}
.guide dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  font-size: 12px;
}
.guide dd {
  margin: 0;
  color: #6e8977;
}
kbd {
  background: #eff4eb;
  border: 1px solid #dbe6d4;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 11px;
}
.license-message {
  padding: 18px 20px;
  background: #edf5e8;
  border-left: 3px solid #9dc29f;
  border-radius: 8px;
  color: #4b7954;
  line-height: 1.6;
}
.solid-list fieldset {
  border: 1px solid #dce7d8;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 17px;
}
.solid-list legend {
  font-size: 11px;
  color: #7a987c;
  padding: 0 8px;
}
.solid-volume {
  display: block;
  font-size: 12px;
  color: #478458;
  margin-top: 8px;
}
progress {
  width: 100%;
  accent-color: #328761;
}
details {
  margin: 10px 0 20px;
}
summary {
  cursor: pointer;
  color: #5e8769;
  padding: 10px 0;
  font-size: 12px;
}
#toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translate(-50%, 15px);
  background: #234c3c;
  color: white;
  border-radius: 10px;
  box-shadow: 0 10px 35px #1d3d2b20;
  max-width: min(650px, 90vw);
  padding: 14px 20px;
  font-size: 13px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
  z-index: 10;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 1100px) {
  .section-rail {
    width: 150px;
  }
  .main-toolbar {
    gap: 8px;
    padding: 7px 16px;
  }
  .pinned-tools {
    gap: 0;
    padding-left: 6px;
  }
  .main-toolbar button {
    width: 35px;
  }
  .app-header {
    gap: 20px;
    padding: 10px 18px;
  }
  .header-actions {
    gap: 4px;
  }
  .ink-controls {
    gap: 6px;
  }
  .ink-controls input[type="range"] {
    width: 48px;
  }
  .statusbar {
    padding: 0 12px;
  }
  .reference-pane {
    min-width: 210px;
  }
}
@media (max-width: 900px) {
  .section-rail {
    width: 126px;
    padding: 20px 7px;
  }
  .section-rail > button {
    font-size: 12px;
    padding: 7px;
  }
  .section-rail .section-mark {
    display: none;
  }
  .rail-help {
    padding: 20px 5px 0;
    font-size: 10px;
  }
  .main-toolbar {
    gap: 5px;
    padding: 7px 12px;
  }
  .main-toolbar button {
    width: 33px;
    padding: 6px;
  }
  .ink-controls input[type="range"] {
    width: 35px;
  }
  .pinned-tools {
    max-width: 155px;
    overflow-x: auto;
  }
  .app-header {
    gap: 16px;
  }
  .brand strong {
    font-size: 16px;
  }
  .brand > svg {
    width: 34px;
    height: 34px;
  }
  .header-actions button span {
    display: none;
  }
  .header-actions [data-action="save"] {
    padding: 8px 12px;
  }
  .pages {
    padding: 35px 25px 70px;
  }
  .reference-pane {
    min-width: 190px;
  }
  .catalog {
    grid-template-columns: 140px 1fr;
    gap: 10px;
  }
  .catalog-results > button {
    padding: 9px 7px;
  }
  .catalog-results > button > svg {
    width: 42px;
  }
  .dialog-body {
    padding: 18px 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
@media print {
  body.printing {
    background: transparent;
  }
  html,
  body,
  #app {
    height: auto;
    overflow: visible;
    background: white;
  }
  .app-header,
  .main-toolbar,
  .section-rail,
  .statusbar,
  .add-page,
  .page-number,
  .reference-pane,
  .instrument-layer,
  .selection-layer,
  #dialogs,
  #toast {
    display: none !important;
  }
  .workspace,
  .paper-scroll,
  .pages {
    display: block;
    overflow: visible;
    padding: 0;
    min-width: 0;
    background: white;
  }
  .page-frame {
    width: 100% !important;
    height: auto !important;
    box-shadow: none;
    margin: 0;
    break-after: page;
    page-break-after: always;
  }
  .paper {
    width: 100%;
    height: auto;
    display: block;
  }
  @page {
    size: A4;
    margin: 10mm;
  }
}
.print-pages {
  display: none;
}
html.printing,
body.printing {
  background: transparent !important;
}
@media print {
  body.printing #app {
    display: none !important;
  }
  body.printing .print-pages {
    display: block;
  }
  .print-sheet {
    break-after: page;
    page-break-after: always;
    display: block;
    margin: 0;
    padding: 0;
    width: 100%;
  }
  .print-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .print-sheet > svg {
    width: 100%;
    height: 100%;
    display: block;
  }
}
[hidden] {
  display: none !important;
}
/* Recovery follows the existing document dialogs; notebook content stays primary. */
.recovery-list {
  display: grid;
  gap: 0;
  margin: 20px 0;
}
.recovery-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line, #dce4df);
}
.recovery-row > div {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.recovery-row p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted, #657873);
}
.recovery-row button {
  flex: none;
  min-height: 40px;
}
.recovery-row .danger {
  color: #a3473d;
}
@media (max-width: 640px) {
  .recovery-row {
    flex-wrap: wrap;
  }
  .recovery-row > div {
    flex-basis: 100%;
  }
}
