.dashboard-view .service-cards:has(> a[href="/notes"]) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.service-view.notes-route {
  width: min(1600px, calc(100% - 36px));
  align-items: stretch;
  padding: 6px 0 16px;
}

.notes-route > .route-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}

.notes-app, .notes-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  gap: 12px;
}

.notes-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.notes-bar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
}

.notes-app button, .notes-list-link {
  padding: 7px 11px;
  border-radius: 12px;
  font-size: .85rem;
}

.notes-list-link { border: 1px solid #454545; }
.notes-list-link:hover { border-color: #888; }
.notes-app button:disabled { opacity: .4; }
.notes-list {
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #373737;
  border-radius: 18px;
  padding: 0 12px;
}
.notes-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}
.notes-row + .notes-row { border-top: 1px solid #373737; }
.notes-row strong, .notes-row .notes-title, .notes-list-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}
.notes-list-title small { display: block; padding-inline: 10px; }
.notes-storage-option { display: flex; align-items: center; gap: 8px; }
.notes-storage-option input { width: auto; }
.notes-row .notes-title { border-color: transparent; font-size: 1rem; }
.notes-row .notes-title:hover { border-color: #777; }
.notes-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  border: 1px solid #373737;
  border-radius: 18px;
  background-color: #242424;
  background-image: radial-gradient(#414141 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: default;
}
.notes-stage[data-tool="Hand"] { cursor: grab; }
.notes-stage[data-tool="Hand"]:active { cursor: grabbing; }
.notes-stage[data-tool="Text"] { cursor: text; }
.notes-stage[data-tool="Flag"] { cursor: text; }
.notes-stage[data-tool="Arrow"] { cursor: crosshair; }
.notes-stage[data-tool="Select"].notes-move-ready { cursor: move; }
.notes-stage.notes-pen-eraser { cursor: none; }
@media (any-hover: hover) {
  .notes-stage:is([data-tool="Pen"], [data-tool="Highlighter"], [data-tool="Eraser"]) { cursor: none; }
}
.notes-stage canvas, .notes-objects { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.notes-ring {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 1;
  pointer-events: none;
  border: 1px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #171717;
}
.notes-object {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  font-size: 18px;
  line-height: 1.37;
  color: #e7e7e7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.notes-object math { width: max-content; max-width: 100%; margin: 0; text-align: left; }
[data-text-size="medium"] { font-size: 36px; }
[data-text-size="large"] { font-size: 54px; }
.notes-measure { visibility: hidden; }
.notes-math-error { color: #ff9a9a; }
.notes-flag { display: flex; align-items: flex-start; gap: .35em; }
.notes-flag svg { display: block; width: 1.14em; height: 1.14em; margin-top: .08em; color: #a7c8ff; }
.notes-flag > :first-child { flex: 0 0 auto; }
.notes-flag > span:last-child { min-width: 0; }
.notes-inline-box { z-index: 2; width: max-content; }
.notes-inline-editor {
  display: block;
  padding: 0;
  min-height: 0;
  resize: none;
  user-select: text;
  touch-action: auto;
  cursor: text;
  border: 0;
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
  background: transparent;
  font: inherit;
  scrollbar-width: none;
}
.notes-inline-editor::-webkit-scrollbar { display: none; }
.notes-inline-editor:focus { outline: 1px dashed var(--accent); }
.notes-object-menu {
  position: absolute;
  z-index: 5;
  display: grid;
  min-width: 108px;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #515151;
  background: #1b1b1d;
  box-shadow: 0 4px 15px #0005;
}
.notes-object-menu button { text-align: left; border-color: transparent; padding: 5px 9px; border-radius: 7px; }
.notes-toolbar, .notes-ink-settings, .notes-zoom {
  position: absolute;
  z-index: 3;
  border: 1px solid #454545;
  border-radius: 15px;
  background: #1b1b1d;
  box-shadow: 0 4px 15px #0005;
  cursor: default;
}
.notes-toolbar, .notes-ink-settings { position: fixed; z-index: 10; color: var(--text); }
.notes-toolbar, .notes-zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}
.notes-toolbar { max-width: calc(100% - 8px); overflow: auto; scrollbar-width: none; }
.notes-toolbar.vertical {
  flex-direction: column;
  max-height: calc(100% - 8px);
  overflow: auto;
  scrollbar-width: none;
  touch-action: pan-y;
}
.notes-toolbar button, .notes-zoom button, .notes-ink-settings button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: clamp(23px, calc(9vw - 4px), 38px);
  height: 38px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}
.notes-toolbar button[aria-pressed="true"] {
  border-color: #589dff;
  background: #303b4c;
}
.notes-toolbar button:hover:enabled, .notes-zoom button:hover:enabled, .notes-ink-settings button:hover:enabled {
  border-color: #777;
}
.notes-toolbar button svg, .notes-zoom button svg, .notes-ink-settings button svg { width: 21px; height: 21px; }
.notes-ink-fill { fill: var(--ink-color); }
.notes-toolbar button.notes-grip { cursor: grab; touch-action: none; color: var(--muted); }
.notes-toolbar button.notes-grip:active { cursor: grabbing; }
.notes-toolbar-divider { width: 1px; height: 20px; background: #464646; flex: 0 0 auto; }
.notes-toolbar.vertical .notes-toolbar-divider { width: 20px; height: 1px; }
.notes-ink-settings {
  display: grid;
  gap: 10px;
  width: min(294px, calc(100% - 8px));
  padding: 10px;
}
.notes-width-setting, .notes-palette { display: flex; align-items: center; gap: 5px; }
.notes-width-setting input[type="range"] {
  flex: 1;
  min-width: 0;
  width: auto;
  min-height: 0;
  padding: 0;
  accent-color: #a4adbc;
}
.notes-width-setting output { color: var(--muted); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.notes-palette { flex-wrap: wrap; }
.notes-palette button, .notes-palette input[type="color"] { width: 24px; height: 24px; padding: 0; border-radius: 50%; }
.notes-palette button { background: var(--swatch); color: #171717; }
.notes-palette button[aria-pressed="true"] { border-color: #fff; }
.notes-palette button svg { width: 15px; height: 15px; }
.notes-palette input[type="color"] { min-height: 0; cursor: pointer; }
.notes-corner {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 3;
}
.notes-zoom {
  position: static;
  flex-direction: column;
  font-size: .7rem;
  font-variant-numeric: tabular-nums;
}
.notes-zoom button { width: 33px; height: 30px; }
.notes-zoom span { min-width: 33px; text-align: center; }
.notes-corner button.notes-writing-lock, .notes-header-actions button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  padding: 5px;
  border-radius: 10px;
}
.notes-corner button.notes-writing-lock { background: #1b1b1d; }
.notes-writing-lock[aria-pressed="true"] { color: #a7c8ff; border-color: #589dff; }
.notes-writing-lock svg, .notes-header-actions svg { width: 20px; height: 20px; }
.notes-header-actions button { border-color: transparent; }
.notes-flag-list { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.notes-flag-list button { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
#workspace-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
  margin-left: auto;
  text-align: right;
  font-size: .75rem;
  color: var(--muted);
}
#workspace-status span:empty, .notes-save-recovery:has(> [hidden]) { display: none; }
.notes-save-recovery button { font-size: .75rem; padding: 3px 7px; }

@media (max-width: 660px) {
  .dashboard-view .service-cards:has(> a[href="/notes"]) {
    --service-card-height: clamp(56px, 10vh, 90px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, var(--service-card-height));
    flex-basis: calc(2 * var(--service-card-height) + 12px);
  }
  .dashboard-view .service-cards > a[href="/notes"] { grid-column: 1 / -1; }
  .service-view.notes-route { width: calc(100% - 20px); padding-bottom: 8px; }
  .notes-app, .notes-editor { gap: 7px; }
  .notes-row button { padding: 7px 8px; }
}

@media (max-width: 390px) {
  .notes-toolbar { gap: 1px; }
}
