/* Wide desktop workspace with a mobile-first reading layer. Loaded after site.css. */
:root {
  --workspace-bg: #f2f4f7;
  --workspace-surface: #ffffff;
  --workspace-divider: #e4e7eb;
  --mobile-gutter: 14px;
}

html {
  min-width: 0;
  scroll-padding-top: calc(72px + env(safe-area-inset-top, 0px));
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--workspace-bg);
}

.main {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  background:
    radial-gradient(circle at 92% 3%, rgba(49, 95, 85, .055), transparent 30rem),
    var(--workspace-bg);
}

.note {
  width: 100%;
  max-width: 1800px;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 34px clamp(28px, 4.4vw, 88px) 72px;
  border: 0;
  border-radius: 0;
  background: var(--workspace-surface);
  box-shadow: none;
}

.note-header {
  max-width: 1280px;
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-color: var(--workspace-divider);
}

.breadcrumbs {
  overflow-wrap: anywhere;
}

.note h1 {
  max-width: none;
  overflow-wrap: anywhere;
  hyphens: auto;
  font-size: clamp(32px, 3.1vw, 48px);
  line-height: 1.08;
  text-wrap: pretty;
}

.note-content {
  width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

.note-content > p,
.note-content > ul,
.note-content > ol,
.note-content > blockquote,
.note-content > h2,
.note-content > h3,
.note-content > h4 {
  max-width: 88ch;
}

.note-content > h2,
.note-content > h3,
.note-content > h4 {
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.note-content span.math-display {
  display: block;
}

.note-content li .math-display {
  margin-top: .8em;
  margin-bottom: .8em;
}

.note-content > pre,
.note-content > table,
.note-content > .mermaid-card,
.note-content > .functionplot-card,
.note-content > .math-display,
.note-content > figure,
.note-content > img,
.note-content > video,
.note-content > iframe {
  margin-right: 0;
  margin-left: 0;
}

.note-content pre,
.note-content table,
.math-display,
.mermaid-card {
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.note-content table {
  display: table;
  width: min(100%, 1240px);
  max-width: 100%;
  margin: 1.6em 0;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 13.5px;
}

.note-content th,
.note-content td {
  min-width: 0;
  padding: 10px 13px;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

.note-content th:first-child,
.note-content td:first-child {
  width: 28%;
  min-width: 180px;
}

.note-content pre,
.mermaid-card,
.functionplot-card {
  max-width: 1320px;
}

.functionplot-card {
  min-width: 0;
}

.functionplot-title {
  max-width: 100%;
  overflow-wrap: anywhere;
  hyphens: auto;
  line-height: 1.35;
  text-wrap: pretty;
}

.functionplot-canvas {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  touch-action: pan-y;
}

.functionplot-canvas svg {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.mermaid-card {
  min-width: 0;
}

.mermaid-card .mermaid {
  min-width: min(420px, 100%);
}

@media (min-width: 2100px) {
  .note {
    max-width: 1960px;
  }
}

@media (max-width: 900px) {
  body.menu-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .menu-button {
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    width: 46px;
    height: 46px;
  }

  .sidebar {
    height: 100vh;
    height: 100dvh;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-right: calc(18px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(18px + env(safe-area-inset-left, 0px));
  }

  .close-button {
    width: 44px;
    height: 44px;
  }

  .nav-folder summary,
  .nav-note a,
  .search-clear {
    min-height: 44px;
  }

  .nav-note a {
    display: flex;
    align-items: center;
  }

  .main {
    padding: calc(64px + env(safe-area-inset-top, 0px)) 0 0;
  }

  .note {
    min-height: calc(100vh - 64px);
    min-height: calc(100dvh - 64px - env(safe-area-inset-top, 0px));
    padding: 24px 18px calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .note-header {
    margin-bottom: 22px;
    padding-bottom: 17px;
  }

  .breadcrumbs {
    font-size: 10.5px;
    line-height: 1.45;
  }

  .note h1 {
    font-size: clamp(27px, 7.8vw, 36px);
    line-height: 1.12;
  }

  .note-content {
    font-size: 16px;
    line-height: 1.68;
  }

  .note-content h2 {
    margin-top: 1.9em;
    font-size: clamp(21px, 6vw, 25px);
  }

  .note-content h3 {
    margin-top: 1.65em;
    font-size: clamp(18px, 5vw, 21px);
  }

  .note-content pre {
    max-width: 100%;
    padding: 14px;
    font-size: 12.5px;
  }

  .note-content table {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: separate;
    border-spacing: 0;
    scrollbar-width: thin;
  }

  .note-content th,
  .note-content td {
    min-width: 132px;
    padding: 9px 10px;
  }

  .note-content th:first-child,
  .note-content td:first-child {
    width: auto;
    min-width: 145px;
  }

  .math-display {
    max-width: 100%;
    padding-bottom: .55em;
    text-align: left;
    scrollbar-width: thin;
  }

  .functionplot-card,
  .mermaid-card {
    width: 100%;
    margin: 1.45em 0;
    padding: 12px;
    border-radius: 11px;
  }

  .functionplot-title {
    margin-bottom: 8px;
    font-size: 12.5px;
  }

  .functionplot-canvas {
    min-height: 0;
  }

  .mermaid-card {
    overflow-x: auto;
  }

  .note-content > :last-child {
    margin-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 520px) {
  :root {
    --mobile-gutter: 14px;
  }

  .main {
    padding-right: 0;
    padding-left: 0;
  }

  .note {
    padding-right: max(var(--mobile-gutter), env(safe-area-inset-right, 0px));
    padding-left: max(var(--mobile-gutter), env(safe-area-inset-left, 0px));
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .note h1 {
    font-size: clamp(26px, 8.2vw, 33px);
  }

  .functionplot-card,
  .mermaid-card {
    padding: 10px;
  }
}

@media (max-width: 360px) {
  :root {
    --mobile-gutter: 12px;
  }

  .note h1 {
    font-size: 25px;
  }

  .note-content {
    font-size: 15.5px;
  }

  .functionplot-card,
  .mermaid-card {
    margin-right: 0;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .functionplot-canvas {
    scroll-behavior: auto;
  }
}
