:root{color-scheme:light dark;font:14px system-ui,sans-serif}*{box-sizing:border-box}body{margin:0;background:Canvas;color:CanvasText}main{max-width:760px;margin:auto;padding:24px}section{margin:24px 0;padding:20px;border:1px solid #8886;border-radius:12px}label{display:inline-block;margin:6px}button,input,select,textarea{font:inherit}button{cursor:pointer;padding:6px 9px;border:1px solid #8886;border-radius:6px;background:Canvas;color:CanvasText}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid #6b8cff;outline-offset:2px}.editor{height:100vh;display:flex;flex-direction:column}header{display:flex;gap:5px;align-items:center;padding:9px;border-bottom:1px solid #8885}#status{margin:6px 10px;font-size:12px;color:GrayText}textarea{flex:1;width:100%;resize:none;border:0;outline:0;padding:14px;line-height:1.6;background:Canvas;color:CanvasText}article{padding:16px;overflow:auto;line-height:1.6}dialog{max-width:90vw;max-height:85vh;overflow:auto;border:1px solid #888;border-radius:10px}pre{white-space:pre-wrap;overflow-wrap:anywhere}
article pre,article table{max-width:100%;overflow:auto}article pre{padding:12px;background:#8882;border-radius:6px}article table{display:block;border-collapse:collapse}article th,article td{border:1px solid #8888;padding:6px}article blockquote{border-left:3px solid #888;padding-left:12px;margin-left:0}article img{max-width:100%}article a{color:#557be0}

[hidden] { display: none !important; }
button:disabled { cursor: default; }
#changes > span {
  display: block;
  padding-inline: 6px;
  tab-size: 4;
}
article pre { white-space: pre; overflow-wrap: normal; }
article { overflow-wrap: anywhere; }

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/SourceSerif4Variable-Roman.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/SourceSerif4Variable-Italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}

/* The host page blurs the webpage behind this translucent layer. */
.editor {
  --note-font: "Source Serif 4", Georgia, serif;
  --note-size: 14px;
  --ink: light-dark(#222120, #f1f1f1);
  --muted: light-dark(#3d3a36, #d0d0d0);
  --line: light-dark(#38332b38, #ffffff39);
  --chip: light-dark(#fffaf326, #14141435);
  --paper: light-dark(#fbf8ef, #292929);
  --footer-surface: var(--paper);
  --footer-light-opacity: 100%;
  --footer-dark-opacity: 100%;
  --accent: light-dark(#38322a, #ececec);
  --selected: light-dark(#d4c9b9a8, #5b5b5bb3);
  color: var(--ink);
  background: var(--paper);
  font-size: var(--note-size);
  overflow: hidden;
}

.embedded-note {
  background: transparent;
}

.embedded-note .editor {
  --footer-light-opacity: 7%;
  --footer-dark-opacity: 36%;
  --footer-surface: light-dark(
    color-mix(in srgb, #fffdf6 var(--footer-light-opacity), transparent),
    color-mix(in srgb, #242424 var(--footer-dark-opacity), transparent)
  );
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.editor .note-surface {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.embedded-note .editor .note-surface {
  background: linear-gradient(
    145deg,
    light-dark(#fffefb1a, #36363666),
    var(--footer-surface) 76%
  );
}

.embedded-note .editor {
  position: fixed;
  left: var(--panel-left);
  right: var(--panel-right);
  top: var(--panel-top);
  bottom: var(--panel-bottom);
  width: min(var(--panel-width), 100vw);
  height: calc(100vh * 2 / 3);
  border-radius: 5px;
}

.embedded-note:not(.panel-positioned) .editor {
  visibility: hidden;
}

.editor .note-toolbar {
  flex: 0 0 auto;
  gap: 8px;
  padding: 12px 12px 9px 16px;
  border: 0;
}

.editor :is(#space, #spaceName) {
  flex: 1 1 0;
  min-width: 0;
  margin-right: auto;
  padding: 5px 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  background: transparent;
  border-color: transparent;
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: -.035em;
}

.editor #spaceName {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.editor .toolbar-actions {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--chip);
}

.editor .toolbar-actions svg {
  display: block;
  width: 17px;
  height: 17px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor button {
  color: var(--ink);
  background: var(--chip);
  border-color: var(--line);
  border-radius: 3px;
}

.editor button:not(:disabled):hover,
.editor #preview[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--selected);
  color: var(--accent);
}

.editor button:disabled {
  opacity: .55;
}

.editor .toolbar-actions button {
  width: clamp(26px, calc(min(var(--panel-width, 100vw), 100vw) * .09), 32px);
  height: 31px;
  padding: 0;
  border-color: transparent;
  background: transparent;
}

.editor .note-footer {
  flex: 0 0 auto;
  padding: 7px 17px 9px;
  background: var(--footer-surface);
}

.editor .status-line,
.editor #fallback {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.editor .note-footer:has(#status[data-state="alert"]) {
  --footer-color: light-dark(
    color-mix(in srgb, #ec5865 var(--footer-light-opacity), transparent),
    color-mix(in srgb, #ad243a var(--footer-dark-opacity), transparent)
  );
}

.editor .note-footer:has(#status[data-state="success"]) {
  --footer-color: light-dark(
    color-mix(in srgb, #4cbd6e var(--footer-light-opacity), transparent),
    color-mix(in srgb, #087436 var(--footer-dark-opacity), transparent)
  );
}

.editor .note-footer:has(#status:is([data-state="alert"], [data-state="success"])) {
  background: linear-gradient(to right, var(--footer-color) 0 65%, var(--footer-surface) 95%);
}

.editor #status[data-state="alert"] {
  color: light-dark(#691d24, #ffe0e0);
}

.editor #status[data-state="success"] {
  color: light-dark(#20492b, #d8f4dd);
}

.editor .note-footer:has(#status[data-state="alert"]) #connectFolder {
  color: light-dark(#691d24, #ffe0e0);
  border-color: light-dark(#691d2440, #ffffff59);
  background: #ffffff12;
}

.editor #fallback {
  padding: 0 16px 8px;
}

.editor :is(#text, #noteInput, #render) {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0 12px 8px;
  padding: 13px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: var(--chip);
  font: 400 var(--note-size)/1.65 var(--note-font);
  font-optical-sizing: auto;
  caret-color: var(--accent);
  scrollbar-color: var(--line) transparent;
}

.editor #text::placeholder {
  color: var(--muted);
  opacity: 1;
}

.editor #text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.embedded-note .editor :is(#text, #noteInput, #render) {
  background: transparent;
}

.editor #noteInput {
  padding: 0;
}

.editor #noteInput .cm-editor {
  height: 100%;
  background: transparent;
}

.editor #noteInput .cm-focused {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.editor #noteInput .cm-scroller {
  font: inherit;
}

.editor #noteInput .cm-content {
  padding-block: 13px 18px;
  caret-color: var(--accent);
}

.editor #noteInput .cm-line {
  padding-inline: 6px 14px;
}

.editor #noteInput .cm-gutters {
  background: transparent;
  color: var(--muted);
  border: 0;
}

.editor #noteInput .cm-foldGutter {
  padding-left: 5px;
}

.editor #noteInput :is(.cm-foldGutter .cm-gutterElement, .cm-foldPlaceholder) {
  cursor: pointer;
}

.editor #noteInput .cm-placeholder {
  color: var(--muted);
}

.editor #render {
  padding-inline-start: 36px;
}

.editor article .foldable-heading {
  position: relative;
}

.editor article .foldable-heading:has(> .heading-toggle:enabled) {
  cursor: pointer;
}

.editor article .heading-toggle {
  position: absolute;
  inset-inline-start: calc(-33px + var(--heading-tier, 0) * 3px);
  inset-block-start: 0;
  width: 16px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--note-size);
  line-height: 1;
}

.editor article .heading-toggle::before {
  content: "";
  width: 5px;
  height: 5px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.editor article .heading-toggle[aria-expanded="true"]::before {
  transform: rotate(135deg);
}

.editor :where(pre, code) {
  font-size: var(--note-size);
}

.editor article :is(h1, h2, h3, h4, h5, h6) {
  margin-block: 1.1em .45em;
  font-family: var(--note-font);
  font-weight: 650;
  line-height: 1.3;
}

.editor article h1 { font-size: 1.7em; }
.editor article h2 { font-size: 1.45em; --heading-tier: 1; }
.editor article h3 { font-size: 1.27em; --heading-tier: 2; }
.editor article h4 { font-size: 1.15em; --heading-tier: 3; }
.editor article h5 { font-size: 1.07em; --heading-tier: 4; }
.editor article h6 { font-size: 1em; --heading-tier: 5; }

.editor article > :first-child {
  margin-top: 0;
}

.editor article a {
  color: var(--accent);
  text-underline-offset: .18em;
}

.editor article ul,
.editor article ol {
  padding-inline-start: 1.4em;
}

.editor article li + li {
  margin-top: .2em;
}

.editor article blockquote {
  padding: .15em 0 .15em .8em;
  border-color: var(--accent);
  color: var(--muted);
}

.editor article blockquote p {
  margin-block: .25em;
}

.editor article :not(pre) > code,
.editor article pre,
.editor article th {
  background: var(--selected);
}

.editor article :not(pre) > code {
  border-radius: 5px;
  padding: .1em .3em;
}

.editor article th,
.editor article td {
  border-color: var(--line);
}

.editor .material-dialog {
  --ink: #1d1d1d;
  --muted: #494949;
  --paper: #e9e9e9;
  --accent: #555;
  --line: #767676;
  --dialog-field: #fafafa;
  color-scheme: only light;
  position: fixed;
  inset: 0;
  width: min(var(--dialog-width, 360px), calc(100% - 32px));
  max-width: none;
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 12px 32px #6665;
  font: 14px/1.45 Roboto, system-ui, sans-serif;
}

.editor .material-dialog[open] {
  display: flex;
  flex-direction: column;
}

.editor .material-dialog::backdrop {
  background: #00000052;
}

.editor .dialog-wide {
  --dialog-width: 680px;
}

.editor #historyDialog {
  height: 80vh;
}

.editor #historyDialog .dialog-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.editor #historyReview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.editor #historyReview:focus-visible {
  outline: 2px solid var(--accent);
}

.editor .dialog-heading {
  flex: none;
  margin: 0;
  padding: 24px 24px 12px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 500;
}

.editor .dialog-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px 24px 12px;
}

.editor .dialog-body > p {
  margin: 0 0 12px;
  color: var(--muted);
}

.editor .dialog-body > p:empty {
  margin: 0;
}

.editor .dialog-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 24px 24px;
}

.editor .material-dialog button {
  min-height: 40px;
  padding: 0 12px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-weight: 600;
}

.editor .material-dialog button:not(:disabled):hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: var(--line);
}

.editor .material-dialog .dialog-primary {
  padding-inline: 18px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.editor .material-dialog .dialog-primary:not(:disabled):hover {
  color: #fff;
  background: color-mix(in srgb, #fff 8%, var(--accent));
  border-color: var(--accent);
}

.editor .material-dialog button:disabled {
  opacity: 1;
  color: color-mix(in srgb, var(--ink) 38%, transparent);
  border-color: color-mix(in srgb, var(--ink) 12%, transparent);
}

.editor .material-dialog .dialog-primary:disabled {
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  border-color: transparent;
}

.editor .material-dialog :is(button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.editor .menu-actions {
  display: grid;
  gap: 2px;
}

.editor .menu-actions button {
  min-height: 44px;
  border-radius: 12px;
  text-align: start;
  color: var(--ink);
}

.editor #revisions {
  --revision-row-height: 40px;
  --revision-gap: 4px;
  display: grid;
  flex: none;
  gap: var(--revision-gap);
  grid-auto-rows: var(--revision-row-height);
  max-block-size: min(65%, calc(5 * var(--revision-row-height) + 4 * var(--revision-gap) + 8px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
}

.editor #revisions button {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: start;
}

.editor #revisions button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.editor #revisions:empty {
  display: none;
}

.editor .dialog-field {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 500;
}

.editor .dialog-field :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--dialog-field);
}

.editor .dialog-field textarea {
  font-family: ui-monospace, monospace;
}

.editor .dialog-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 0 12px;
}

.editor .cloud-actions {
  padding: 0;
}

.editor .dialog-back {
  margin-inline-end: auto;
}

.editor .material-dialog :is(#changes, #old) {
  margin: 4px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--dialog-field);
}

.editor .material-dialog #changes:empty {
  display: none;
}

.editor #changes .added { background: color-mix(in srgb, #24a060 23%, var(--dialog-field)); }
.editor #changes .removed { background: #f9dedc; }
.editor #changes .hunk { background: #f2f2f2; }

.editor #historyReview > details {
  margin-block-start: 4px;
}

.editor #historyReview summary {
  width: fit-content;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
}

.editor #historyReview summary:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

@media (max-height: 430px) {
  .editor .dialog-heading { padding-block: 14px 8px; }
  .editor .dialog-actions { padding-bottom: 10px; }
  .editor .cloud-actions { padding: 0; }
}

@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  .embedded-note .editor {
    --footer-light-opacity: 100%;
    --footer-dark-opacity: 100%;
    --footer-surface: Canvas;
  }

  .embedded-note .editor .note-surface {
    background: Canvas;
  }
}


.editor #connectFolder {
  margin-top: 5px;
  font-size: 11px;
}
