:root {
  --page-bg: #f5f1e8;
  --panel-bg: #fffdf8;
  --text: #2f2d29;
  --muted: #777166;
  --border: #ddd5c8;
  --accent: #7c6a52;
  --accent-dark: #62523e;
  --shadow: 0 8px 24px rgba(58,49,39,.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page-bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: rgba(245,241,232,.95);
  border-bottom: 1px solid rgba(221,213,200,.75);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 24px;
  font-weight: 750;
}

.brand h1 {
  margin: 0;
  font-size: clamp(18px,2vw,23px);
}

.creator {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.top-controls {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.search-input {
  width: min(390px,100%);
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  background: var(--panel-bg);
}

.layout-toggle {
  display: flex;
  gap: 4px;
}

.layout-button,
.view-button {
  border: 0;
  border-radius: 10px;
  padding: 9px 11px;
  background: transparent;
  color: var(--muted);
}

.layout-button.active,
.view-button.active {
  background: #e9e1d4;
  color: var(--text);
  font-weight: 650;
}

.view-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px 0;
}

.main-content {
  width: min(1250px,calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.composer {
  max-width: 820px;
  margin: 0 auto 28px;
  padding: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background-color .18s ease;
}

.note-title-input {
  width: 100%;
  margin-bottom: 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
}

.format-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 10px;
  padding: 7px;
  border: 1px solid rgba(120,110,98,.18);
  border-radius: 11px;
  background: rgba(255,255,255,.45);
}

.format-toolbar button,
.format-toolbar select {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 4px 7px;
  background: rgba(255,255,255,.72);
  color: var(--text);
}

.format-toolbar button:hover,
.format-toolbar select:hover {
  border-color: var(--border);
  background: white;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--border);
}

.text-colors {
  display: flex;
  align-items: center;
  gap: 4px;
}

.text-color-swatch {
  width: 22px;
  min-width: 22px;
  height: 22px !important;
  padding: 0 !important;
  border: 2px solid rgba(255,255,255,.8) !important;
  border-radius: 50% !important;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12);
}

.custom-color-label {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: white;
  font-weight: 700;
  overflow: hidden;
  cursor: pointer;
}

.custom-color-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.document-editor {
  min-height: 145px;
  max-height: 480px;
  overflow-y: auto;
  padding: 8px 3px 12px;
  outline: none;
  line-height: 1.55;
}

.document-editor:empty::before {
  content: attr(data-placeholder);
  color: #a39a8d;
  pointer-events: none;
}

.document-editor ul,
.document-editor ol,
.card-preview ul,
.card-preview ol {
  margin: 6px 0;
  padding-left: 27px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 26px;
  margin: 3px 0;
}

.check-toggle {
  flex: 0 0 auto;
  min-width: 21px;
  color: var(--accent-dark);
  font-size: 19px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}

.check-item.checked .check-text {
  opacity: .55;
  text-decoration: line-through;
}

.check-text {
  flex: 1;
  min-width: 20px;
  outline: none;
}

.composer-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(120,110,98,.15);
}

.color-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-swatch {
  width: 25px;
  height: 25px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
}

.color-swatch.selected {
  border-color: var(--text);
}

.save-status {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
}

.composer-actions {
  display: flex;
  gap: 7px;
}

.primary-button,
.secondary-button {
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 650;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.6);
  color: var(--text);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
}

.note-count {
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e9e1d4;
  color: var(--muted);
  font-size: 12px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(210px,1fr));
  align-items: start;
  gap: 12px;
}

.notes-grid.list-view {
  display: flex;
  flex-direction: column;
}

.notes-grid.list-view .note-card {
  width: 100%;
  min-height: auto;
}

.note-card {
  position: relative;
  min-height: 95px;
  max-height: 260px;
  overflow: hidden;
  padding: 13px;
  border: 1px solid rgba(120,110,98,.14);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(58,49,39,.05);
  cursor: grab;
  transition: transform .15s ease,box-shadow .15s ease;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(58,49,39,.08);
}

.note-card.dragging {
  opacity: .45;
}

.note-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.card-preview {
  position: relative;
  max-height: 145px;
  overflow: hidden;
  line-height: 1.4;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.card-preview::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  background: linear-gradient(transparent,rgba(255,255,255,.28));
  pointer-events: none;
}

.card-preview a {
  color: #0057ff;
  text-decoration: underline;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.card-actions button {
  border: 0;
  border-radius: 8px;
  padding: 5px 7px;
  background: rgba(255,255,255,.55);
  color: var(--text);
  font-size: 11px;
}

.pin-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width:720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 13px 15px;
  }

  .top-controls {
    width: 100%;
  }

  .search-input {
    flex: 1;
  }

  .main-content {
    width: calc(100% - 18px);
    padding-top: 14px;
  }

  .format-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .format-toolbar > * {
    flex: 0 0 auto;
  }

  .composer-footer {
    flex-wrap: wrap;
  }

  .save-status {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }

  .notes-grid {
    grid-template-columns: repeat(auto-fill,minmax(165px,1fr));
  }

  .notes-grid.list-view {
    display: flex;
  }
}

.control-select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-bg);
  color: var(--text);
  padding: 0 9px;
}

.date-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.note-card.selected {
  outline: 3px solid rgba(0, 87, 255, .55);
  outline-offset: 2px;
}

.note-card.selected::before {
  content: "✓";
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0057ff;
  color: white;
  font-size: 12px;
  font-weight: 800;
  z-index: 2;
}

.note-date {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.notes-grid.title-view {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.notes-grid.title-view .note-card {
  min-height: 0;
  max-height: none;
  padding: 9px 12px;
}

.notes-grid.title-view .card-preview,
.notes-grid.title-view .card-actions,
.notes-grid.title-view .note-date,
.notes-grid.title-view .pin-label {
  display: none;
}

.notes-grid.title-view .note-card h3 {
  margin: 0;
}

.drop-indicator {
  position: fixed;
  z-index: 9999;
  height: 4px;
  border-radius: 3px;
  background: #0057ff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.9);
  pointer-events: none;
}

.context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}

.context-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
}

.context-menu button:hover {
  background: #eee7dc;
}

.notes-section + .notes-section {
  margin-top: 26px;
}


/* RNC 0.3.1B */

.document-editor a,
.card-preview a {
  cursor: pointer;
}

.document-editor a:hover,
.card-preview a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.note-card[data-view="trash"] {
  cursor: default;
}

.format-toolbar #undoButton,
.format-toolbar #redoButton {
  font-size: 18px;
  line-height: 1;
}



/* RNC 0.3.2 Pop-Out Editor */

.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(45, 40, 34, .28);
  backdrop-filter: blur(2px);
}

.editor-modal {
  position: fixed;
  z-index: 910;
  top: 50%;
  left: 50%;
  width: min(850px, calc(100vw - 34px));
  max-height: calc(100vh - 48px);
  margin: 0;
  transform: translate(-50%, -50%);
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(40, 34, 27, .28);
}

.new-note-button {
  white-space: nowrap;
}

body.editor-open {
  overflow: hidden;
}

.document-editor a,
.card-preview a {
  cursor: pointer;
}

@media (max-width: 720px) {
  .editor-modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 18px);
  }

  .top-controls {
    flex-wrap: wrap;
  }
}


/* RNC 0.3.2A */

.editor-modal {
  top: 18px;
  bottom: 18px;
  left: 50%;
  width: min(850px, calc(100vw - 34px));
  max-height: none;
  transform: translateX(-50%);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.document-editor {
  min-height: 180px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
}

.composer-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 0 -16px -16px;
  padding: 12px 16px 16px;
  background: inherit;
}

.format-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(255, 253, 248, .96);
}

.check-text {
  min-height: 1.45em;
  min-width: 40px;
  cursor: text;
}

@media (max-width: 720px) {
  .editor-modal {
    top: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .document-editor {
    max-height: 50vh;
  }
}

/* RNC 0.3.2A card movement */

.note-card {
  position: relative;
  cursor: default;
  user-select: text;
}

.drag-handle {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 4;

  display: grid;
  place-items: center;

  width: 26px;
  height: 26px;

  border: 1px solid rgba(120,110,98,.18);
  border-radius: 8px;

  background: rgba(255,255,255,.62);
  color: var(--muted);

  font-size: 17px;
  line-height: 1;

  cursor: grab;
  user-select: none;

  opacity: .35;
  transition: opacity .15s ease;
}

.note-card:hover .drag-handle,
.drag-handle:focus-visible {
  opacity: 1;
}

.drag-handle:active {
  cursor: grabbing;
}

.note-card.selected .drag-handle {
  right: 34px;
}

.drop-indicator {
  height: 5px;
  background: #0057ff;
  box-shadow:
    0 0 0 1px white,
    0 2px 7px rgba(0,87,255,.35);
}


/* RNC 0.3.2B */

.editor-modal {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  max-height: calc(100vh - 36px);
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.note-metadata {
  margin: -1px 0 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.document-editor {
  flex: 0 1 auto;
  min-height: 150px;
  max-height: min(58vh, 560px);
  overflow-y: auto;

  /*
    Comfortable breathing room after final line.
  */
  padding-bottom: 56px;
}

.composer-footer {
  position: static;
  flex: 0 0 auto;
  margin: 0 -16px -16px;
  padding: 12px 16px 16px;
  background: inherit;
}

.format-toolbar {
  position: static;
  flex: 0 0 auto;
}

.danger-button {
  border: 1px solid #b76054;
  border-radius: 10px;
  padding: 8px 14px;
  background: rgba(255,255,255,.55);
  color: #9b3d34;
  font-weight: 650;
}

.danger-button:hover {
  background: rgba(183,96,84,.12);
}

@media (max-width: 720px) {
  .editor-modal {
    top: 50%;
    bottom: auto;
    max-height: calc(100vh - 16px);
    transform: translate(-50%, -50%);
  }

  .document-editor {
    max-height: 55vh;
    padding-bottom: 48px;
  }
}


/* RNC 0.3.2C */

.document-editor {
  padding-top: 28px;
  padding-bottom: 28px;
}


/* RNC 0.3.3 */

/*
  Packed / masonry-style board.
  Pinned and All Notes are separate grids, so each
  section packs independently.
*/
.notes-grid.packed-view {
  display: block;
  column-width: 230px;
  column-gap: 14px;
}

.notes-grid.packed-view .note-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 14px;
  vertical-align: top;

  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

/*
  Packed is an automatic layout, so don't stretch cards.
*/
.notes-grid.packed-view .note-card {
  min-height: 0;
}

/*
  Horizontal gesture protection while editing.
  Vertical scrolling remains normal.
*/
html,
body {
  overscroll-behavior-x: none;
}

body.editor-open {
  overscroll-behavior: none;
}

.editor-backdrop,
.editor-modal,
.document-editor {
  overscroll-behavior-x: none;
}

.editor-modal,
.document-editor {
  touch-action: pan-y;
}

@media (max-width: 720px) {
  .notes-grid.packed-view {
    column-width: 165px;
    column-gap: 10px;
  }

  .notes-grid.packed-view .note-card {
    margin-bottom: 10px;
  }
}


/* RNC 0.3.3B — true packed masonry + scoped swipe */

/*
  Restore normal browser horizontal navigation when
  the note editor is not open.
*/
html,
body {
  overscroll-behavior-x: auto;
}

/*
  Packed uses measured CSS-grid row spans instead of
  multi-column layout.
*/
.notes-grid.packed-view {
  display: grid;
  grid-template-columns:
    repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: 8px;
  gap: 12px;
  align-items: start;

  column-width: unset;
  column-gap: unset;
}

.notes-grid.packed-view .note-card {
  display: block;
  width: 100%;
  margin: 0;

  break-inside: auto;
  -webkit-column-break-inside: auto;
  page-break-inside: auto;
}

@media (max-width: 720px) {
  .notes-grid.packed-view {
    grid-template-columns:
      repeat(auto-fill, minmax(165px, 1fr));
    grid-auto-rows: 8px;
    gap: 10px;
  }

  .notes-grid.packed-view .note-card {
    margin: 0;
  }
}

/* RNC 0.3.3C */

.notes-grid.packed-view {
  grid-auto-flow: dense;
}

/*
  Browser page navigation remains browser-native.
  RNC no longer globally suppresses horizontal page gestures.
*/
html,
body,
body.editor-open {
  overscroll-behavior-x: auto;
}


/* RNC 0.3.4A — durable note images */

.note-image {
  display: block;
  max-width: 100%;
  height: auto;

  margin: 12px 0;

  border-radius: 8px;

  cursor: pointer;
}

.document-editor .note-image {
  max-height: 65vh;
  object-fit: contain;
}

.note-image.image-selected {
  outline: 3px solid rgba(0, 87, 255, .65);
  outline-offset: 3px;
}

.card-preview .note-image {
  max-width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 6px;
}

/* =========================================================
   RNC 0.3.4B — Image sizing + full screen
   ========================================================= */

.note-image {
  width: 50%;
  max-width: 100%;
  height: auto;
}

.image-size-controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);

  z-index: 12000;

  display: flex;
  align-items: center;
  gap: 7px;

  padding: 8px 10px;

  background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 12px;

  box-shadow:
    0 8px 30px rgba(0, 0, 0, .18);
}

.image-size-controls.hidden {
  display: none;
}

.image-size-label {
  margin-right: 3px;

  font-size: 12px;
  opacity: .65;
}

.image-size-controls button {
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 8px;

  background: white;

  padding: 6px 9px;

  cursor: pointer;
}

.image-size-controls button.active {
  font-weight: 700;

  outline: 2px solid rgba(0, 87, 255, .38);
}

.image-fullscreen-viewer {
  position: fixed;
  inset: 0;

  z-index: 20000;

  display: flex;
  align-items: center;
  justify-content: center;
}

.image-fullscreen-viewer.hidden {
  display: none;
}

.image-fullscreen-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0, 0, 0, .88);
}

.image-fullscreen-content {
  position: relative;

  z-index: 1;

  max-width: 96vw;
  max-height: 94vh;

  display: flex;
  align-items: center;
  justify-content: center;
}

.image-fullscreen-content img {
  max-width: 96vw;
  max-height: 94vh;

  width: auto;
  height: auto;

  object-fit: contain;

  border-radius: 6px;
}

.image-fullscreen-close {
  position: absolute;
  top: -42px;
  right: 0;

  width: 36px;
  height: 36px;

  border: 0;
  border-radius: 999px;

  font-size: 28px;
  line-height: 32px;

  cursor: pointer;
}

body.image-viewer-open {
  overflow: hidden;
}


/* Full-screen note editor */

.composer.note-fullscreen {
  position: fixed !important;

  inset: 18px !important;

  width: auto !important;
  max-width: none !important;

  height: calc(100vh - 36px) !important;
  max-height: none !important;

  margin: 0 !important;

  display: flex;
  flex-direction: column;

  z-index: 11000;
}

.composer.note-fullscreen .document-editor {
  flex: 1 1 auto;

  max-height: none !important;
  min-height: 0;

  overflow-y: auto;
}

body.note-fullscreen-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .composer.note-fullscreen {
    inset: 0 !important;

    height: 100vh !important;

    border-radius: 0 !important;
  }

  .image-size-controls {
    bottom: 10px;

    max-width: calc(100vw - 20px);

    overflow-x: auto;
  }

  .image-size-label {
    display: none;
  }
}

/* =========================================================
   RNC 0.3.4B UI correction
   Keep images inside editor + controls inside note
   ========================================================= */

.document-editor {
  overflow-x: hidden;
  box-sizing: border-box;
  max-width: 100%;
}

.document-editor .note-image {
  display: block;
  box-sizing: border-box;

  max-width: 100% !important;
  height: auto !important;

  margin-left: 0;
  margin-right: auto;
}

/*
  Image tools now belong to the open note instead of
  floating against the browser viewport.
*/
.image-size-controls {
  position: static;

  left: auto;
  bottom: auto;
  transform: none;

  width: 100%;
  box-sizing: border-box;

  margin: 10px 0 12px;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;

  gap: 7px;

  padding: 8px 10px;

  z-index: 5;
}

.image-size-controls.hidden {
  display: none;
}

.composer.note-fullscreen .image-size-controls {
  flex: 0 0 auto;
}

@media (max-width: 700px) {
  .image-size-controls {
    position: static;

    max-width: 100%;

    margin: 8px 0 10px;

    overflow-x: visible;
  }
}

/* RNC 0.3.4B — image framing refinement */

.document-editor .note-image {
  max-width: calc(100% - 24px) !important;

  margin-top: 12px;
  margin-bottom: 12px;
  margin-left: 12px;
  margin-right: 12px;
}

/* RNC 0.3.4B — correct note full-screen positioning */

.composer.note-fullscreen {
  top: 18px !important;
  right: 18px !important;
  bottom: 18px !important;
  left: 18px !important;

  transform: none !important;

  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
}

@media (max-width: 700px) {
  .composer.note-fullscreen {
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    transform: none !important;
  }
}

/* RNC 0.3.4B — keep footer actions compact when image tools are visible */

.composer-footer {
  align-items: center;
}

.composer-actions {
  flex: 0 0 auto;
  align-items: center;
}

.composer-actions button {
  flex: 0 0 auto !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;

  padding: 8px 14px !important;

  line-height: 1.2 !important;
  white-space: nowrap;
}

#fullscreenNoteButton {
  white-space: nowrap;
}

/* =========================================================
   RNC 0.3.5A — Tags / Labels
   ========================================================= */

.note-tags-editor {
  display: flex;
  align-items: center;
  gap: 9px;

  margin-top: 8px;
  margin-bottom: 10px;

  padding: 8px 10px;

  border: 1px solid rgba(120, 110, 98, .16);
  border-radius: 10px;

  background: rgba(255, 255, 255, .28);
}

.note-tags-editor label {
  flex: 0 0 auto;

  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

#noteTagsInput {
  flex: 1 1 auto;

  min-width: 0;

  border: 0;
  outline: 0;

  background: transparent;

  color: inherit;
  font: inherit;
  font-size: 13px;
}

#noteTagsInput::placeholder {
  color: var(--muted);
  opacity: .7;
}


/* Card tag pills */

.note-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;

  margin-top: 10px;
}

.note-tag-pill {
  display: inline-flex;
  align-items: center;

  max-width: 100%;

  padding: 3px 8px;

  border: 1px solid rgba(80, 72, 62, .14);
  border-radius: 999px;

  background: rgba(255, 255, 255, .48);

  color: rgba(55, 50, 44, .78);

  font-size: 11px;
  line-height: 1.25;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/*
  Title-only view stays title-oriented.
  Tag filtering will come in 0.3.5B.
*/
.notes-grid.title-view .note-tag-list {
  display: none;
}


@media (max-width: 700px) {
  .note-tags-editor {
    align-items: flex-start;
  }
}

/* RNC 0.3.5B — clickable tag filters */

button.note-tag-pill {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
}

button.note-tag-pill:hover {
  background: rgba(255, 255, 255, .78);
  border-color: rgba(80, 72, 62, .28);
}

button.note-tag-pill:active {
  transform: translateY(1px);
}

#tagFilterSelect {
  min-width: 110px;
}

/* =========================================================
   RNC 0.3.5C — Manage Tags
   ========================================================= */

.manage-tags-button {
  white-space: nowrap;
}

.manage-tags-modal {
  position: fixed;
  inset: 0;

  z-index: 21000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;
}

.manage-tags-modal.hidden {
  display: none;
}

.manage-tags-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(35, 31, 27, .55);
}

.manage-tags-panel {
  position: relative;
  z-index: 1;

  width: min(560px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 40px));

  overflow: hidden;

  display: flex;
  flex-direction: column;

  border: 1px solid rgba(100, 90, 78, .20);
  border-radius: 18px;

  background: #fffdf8;

  box-shadow:
    0 20px 60px rgba(0, 0, 0, .28);
}

.manage-tags-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  padding: 20px 22px 16px;

  border-bottom:
    1px solid rgba(120, 110, 98, .14);
}

.manage-tags-heading h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.manage-tags-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.manage-tags-close {
  flex: 0 0 auto;

  width: 34px;
  height: 34px;

  border: 1px solid rgba(80, 72, 62, .14);
  border-radius: 999px;

  background: rgba(255, 255, 255, .65);

  font-size: 24px;
  line-height: 28px;

  cursor: pointer;
}

.manage-tags-list {
  overflow-y: auto;

  padding: 10px 14px 16px;
}

.manage-tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  padding: 12px 8px;

  border-bottom:
    1px solid rgba(120, 110, 98, .11);
}

.manage-tag-row:last-child {
  border-bottom: 0;
}

.manage-tag-info {
  min-width: 0;

  display: flex;
  flex-direction: column;

  gap: 2px;
}

.manage-tag-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manage-tag-info span {
  color: var(--muted);
  font-size: 12px;
}

.manage-tag-actions {
  flex: 0 0 auto;

  display: flex;
  gap: 7px;
}

.manage-tag-actions button {
  padding: 7px 11px;

  border-radius: 9px;

  cursor: pointer;
}

.manage-tags-empty {
  padding: 30px 12px;

  text-align: center;

  color: var(--muted);
}

body.manage-tags-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .manage-tag-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .manage-tag-actions {
    width: 100%;
  }
}

/* =========================================================
   RNC 0.3.6A — Notebooks
   ========================================================= */

.note-notebook-editor {
  display: flex;
  align-items: center;
  gap: 9px;

  margin-top: 8px;
  margin-bottom: 8px;

  padding: 8px 10px;

  border: 1px solid rgba(120, 110, 98, .16);
  border-radius: 10px;

  background: rgba(255, 255, 255, .28);
}

.note-notebook-editor label {
  flex: 0 0 auto;

  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

#noteNotebookSelect {
  flex: 1 1 auto;
  min-width: 0;
}

#notebookFilterSelect {
  min-width: 120px;
}

@media (max-width: 700px) {
  .note-notebook-editor {
    align-items: flex-start;
  }
}

/* RNC 0.3.6A — notebook top-bar sizing polish */

#notebookFilterSelect {
  min-width: 180px;
  width: 180px;
  flex: 0 0 180px;
}

#newNotebookButton {
  width: auto !important;
  min-width: 118px;
  height: 38px;

  padding: 0 14px !important;

  white-space: nowrap;
  line-height: 1;
}

/* =========================================================
   RNC 0.3.6A — top control labels
   ========================================================= */

.top-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;

  min-width: 0;
}

.top-field-label {
  padding-left: 4px;

  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1;

  letter-spacing: .03em;
}

.top-field > select,
.top-field > input {
  margin: 0;
}

.top-field-search {
  flex: 1 1 220px;
}

.top-field-search .search-input {
  width: 100%;
}


/* Label the four layout choices as one View group */

.layout-toggle {
  position: relative;

  padding-top: 13px;
}

.layout-toggle::before {
  content: "View";

  position: absolute;
  top: 0;
  left: 4px;

  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1;

  letter-spacing: .03em;
}

/* RNC 0.3.6A — correct labeled Notebook field sizing */

.top-field #notebookFilterSelect {
  flex: 0 0 auto;
  width: 180px;
  min-width: 180px;
  height: 38px;
}


/* RNC 0.3.6A — top-bar grouping polish */

#newNotebookButton,
#manageTagsButton {
  margin-left: 8px;
  margin-right: 4px;
}


/* RNC 0.3.6A — proper top toolbar flex layout */

.top-controls .top-field {
  flex: 0 0 auto;
}

.top-controls .top-field-search {
  flex: 1 1 220px;
  min-width: 150px;
  max-width: 300px;
}

#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  flex: 0 0 auto;
}

#newNotebookButton,
#manageTagsButton {
  margin-left: 0;
  margin-right: 0;
}

.top-field #notebookFilterSelect {
  width: 180px;
  min-width: 180px;
  flex: none;
}

.top-field #tagFilterSelect {
  width: 135px;
  min-width: 135px;
  flex: none;
}

.top-field #sortSelect {
  width: 175px;
  min-width: 175px;
  flex: none;
}

.top-controls .layout-toggle {
  flex: 0 0 auto;
}

.top-controls {
  gap: 12px;
  min-width: 0;
}

/* RNC 0.3.6A — proper top toolbar flex layout */

.top-controls .top-field {
  flex: 0 0 auto;
}

.top-controls .top-field-search {
  flex: 1 1 220px;
  min-width: 150px;
  max-width: 300px;
}

#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  flex: 0 0 auto;
}

#newNotebookButton,
#manageTagsButton {
  margin-left: 0;
  margin-right: 0;
}

.top-field #notebookFilterSelect {
  width: 180px;
  min-width: 180px;
  flex: none;
}

.top-field #tagFilterSelect {
  width: 135px;
  min-width: 135px;
  flex: none;
}

.top-field #sortSelect {
  width: 175px;
  min-width: 175px;
  flex: none;
}

.top-controls .layout-toggle {
  flex: 0 0 auto;
}

.top-controls {
  gap: 12px;
  min-width: 0;
}

/* RNC 0.3.6A — two-row application header */

.topbar {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.top-controls {
  width: 100%;
  flex: none;

  justify-content: flex-start;
  align-items: flex-end;

  flex-wrap: wrap;

  gap: 12px 14px;
}

/* Keep the labeled controls together */
.top-controls .top-field {
  flex: 0 0 auto;
}

/* Search may grow when room is available */
.top-controls .top-field-search {
  flex: 1 1 220px;
  min-width: 190px;
  max-width: 360px;
}

/* Actions stay compact */
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  flex: 0 0 auto;
  align-self: flex-end;
}

/* Keep View together */
.top-controls .layout-toggle {
  flex: 0 0 auto;
  align-self: flex-end;
}

/* RNC 0.3.6A — compact labeled header */

/* Put branding and controls back on one row */
.topbar {
  flex-direction: row !important;
  align-items: center !important;
  gap: 22px !important;

  padding-top: 12px !important;
  padding-bottom: 12px !important;
}

/* Branding stays compact and does not get squeezed */
.brand {
  flex: 0 0 auto;
  min-width: 370px;
}

/* Controls remain on the same row */
.top-controls {
  flex: 1 1 auto;
  width: auto;

  display: flex;
  flex-wrap: nowrap;

  justify-content: flex-end;
  align-items: flex-end;

  gap: 10px;

  min-width: 0;
}

/* Small labels only */
.top-field-label {
  height: auto;
  margin: 0 0 3px 4px;

  font-size: 9px;
  line-height: 1;
}

/* Compact control heights */
.top-controls .control-select,
.top-controls .search-input,
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  height: 38px !important;
}

/* Compact field widths */
.top-field #notebookFilterSelect {
  width: 150px;
  min-width: 150px;
}

.top-controls .top-field-search {
  flex: 0 1 240px;
  min-width: 160px;
  max-width: 240px;
}

.top-field #tagFilterSelect {
  width: 120px;
  min-width: 120px;
}

.top-field #sortSelect {
  width: 155px;
  min-width: 155px;
}

/* Buttons line up with the field controls */
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  margin-top: 12px;
  padding-left: 13px !important;
  padding-right: 13px !important;
}

/* View remains compact */
.top-controls .layout-toggle {
  margin-top: 0;
  padding-top: 12px;
}

/* Only stack on genuinely smaller screens */
@media (max-width: 1150px) {
  .topbar {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .brand {
    min-width: 0;
  }

  .top-controls {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

/* RNC 0.3.6A — final compact header layout */

.topbar {
  display: grid !important;
  grid-template-columns: 330px minmax(0, 1fr);
  align-items: center !important;
  column-gap: 20px !important;

  padding: 10px 22px !important;
}

/* Branding owns its column */
.brand {
  min-width: 0 !important;
  width: 330px;
  overflow: hidden;
}

/* Controls stay entirely in their own column */
.top-controls {
  min-width: 0;
  width: 100%;

  display: flex;
  flex-wrap: nowrap;

  justify-content: flex-start;
  align-items: flex-end;

  gap: 10px;
}

/* Slightly tighter fields so the whole toolbar fits */
.top-field #notebookFilterSelect {
  width: 135px;
  min-width: 135px;
}

.top-controls .top-field-search {
  flex: 1 1 190px;
  min-width: 150px;
  max-width: 215px;
}

.top-field #tagFilterSelect {
  width: 105px;
  min-width: 105px;
}

.top-field #sortSelect {
  width: 140px;
  min-width: 140px;
}

/* Keep action buttons compact */
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Do not let the layout icons expand */
.top-controls .layout-toggle {
  flex: 0 0 auto;
}

/* Stack only when the screen genuinely needs it */
@media (max-width: 1250px) {
  .topbar {
    grid-template-columns: 1fr !important;
    row-gap: 10px;
  }

  .brand {
    width: auto;
  }

  .top-controls {
    flex-wrap: wrap;
  }
}

/* RNC 0.3.6A — lighter top toolbar typography */

.top-controls .control-select,
.top-controls .search-input,
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  font-size: 14px !important;
  font-weight: 500;
}

#newNoteButton {
  font-weight: 650;
}

.top-field-label,
.layout-toggle::before {
  font-size: 9px;
  font-weight: 650;
}

.top-controls .layout-button,
.top-controls .view-button {
  font-size: 14px;
}

/* RNC 0.3.6A — compact toolbar typography + smartphone layout */

/* Slightly smaller desktop toolbar text */
.top-controls .control-select,
.top-controls .search-input,
#newNoteButton,
#newNotebookButton,
#manageTagsButton {
  font-size: 12px !important;
}

#newNoteButton {
  font-weight: 650;
}

.top-field-label,
.layout-toggle::before {
  font-size: 8px !important;
}

.top-controls .layout-button,
.top-controls .view-button {
  font-size: 12px !important;
}


/* =========================================================
   Smartphone / narrow-screen toolbar
   ========================================================= */

@media (max-width: 700px) {
  .topbar {
    display: block !important;
    padding: 10px 12px !important;
  }

  .brand {
    width: auto !important;
    margin-bottom: 10px;
  }

  .top-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
    width: 100%;
  }

  /* New Note gets a full-width primary position */
  #newNoteButton {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0 !important;
  }

  /* Notebook and Search can span full width where useful */
  .top-field-search {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none !important;
  }

  .top-field-search .search-input {
    width: 100%;
  }

  .top-field #notebookFilterSelect,
  .top-field #tagFilterSelect,
  .top-field #sortSelect {
    width: 100% !important;
    min-width: 0 !important;
  }

  .top-field {
    width: 100%;
  }

  /* Action buttons fit their grid cells */
  #newNotebookButton,
  #manageTagsButton {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  /* View controls get their own full-width row */
  .layout-toggle {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
  }

  /* Keep controls finger-friendly even with smaller text */
  .top-controls .control-select,
  .top-controls .search-input,
  #newNoteButton,
  #newNotebookButton,
  #manageTagsButton {
    min-height: 40px;
  }
}

/* RNC 0.3.6A — compact brand block */

.brand {
  gap: 10px;
}

.brand-mark {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px;
  border-radius: 14px;
  font-size: 25px !important;
}

.brand h1 {
  font-size: 20px !important;
  line-height: 1.08;
}

.creator {
  font-size: 11px !important;
  margin-top: 2px;
}

/* Slightly narrower reserved branding column */
.topbar {
  grid-template-columns: 285px minmax(0, 1fr) !important;
}

/* =========================================================
   RNC 0.3.6B — Manage Notebooks
   ========================================================= */

.manage-notebooks-modal {
  position: fixed;
  inset: 0;

  z-index: 21000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;
}

.manage-notebooks-modal.hidden {
  display: none;
}

.manage-notebooks-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(35, 31, 27, .55);
}

.manage-notebooks-panel {
  position: relative;
  z-index: 1;

  width: min(560px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 40px));

  overflow: hidden;

  display: flex;
  flex-direction: column;

  border: 1px solid rgba(100, 90, 78, .20);
  border-radius: 18px;

  background: #fffdf8;

  box-shadow:
    0 20px 60px rgba(0, 0, 0, .28);
}

.manage-notebooks-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  padding: 20px 22px 16px;

  border-bottom:
    1px solid rgba(120, 110, 98, .14);
}

.manage-notebooks-heading h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.manage-notebooks-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.manage-notebooks-close {
  width: 34px;
  height: 34px;

  border: 1px solid rgba(80, 72, 62, .14);
  border-radius: 999px;

  background: rgba(255, 255, 255, .65);

  font-size: 24px;
  cursor: pointer;
}

.manage-notebooks-list {
  overflow-y: auto;
  padding: 10px 14px 16px;
}

.manage-notebook-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  padding: 12px 8px;

  border-bottom:
    1px solid rgba(120, 110, 98, .11);
}

.manage-notebook-row:last-child {
  border-bottom: 0;
}

.manage-notebook-info {
  min-width: 0;

  display: flex;
  flex-direction: column;

  gap: 2px;
}

.manage-notebook-info span {
  color: var(--muted);
  font-size: 12px;
}

.manage-notebook-actions {
  display: flex;
  gap: 7px;
}

.manage-notebook-actions button {
  padding: 7px 11px;
  border-radius: 9px;
  cursor: pointer;
}

.manage-notebooks-empty {
  padding: 30px 12px;

  text-align: center;
  color: var(--muted);
}

body.manage-notebooks-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .manage-notebook-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .manage-notebook-actions {
    width: 100%;
  }
}

/* 0.3.6C - Manage Tags / Notebook ordering */

.manage-tags-create {
  display: flex;
  justify-content: flex-start;
  margin: 12px 0 14px;
}

.manage-tags-create button {
  white-space: nowrap;
}

.manage-notebook-actions .move-button {
  min-width: 34px;
  padding-left: 8px;
  padding-right: 8px;
}

.manage-notebook-actions .move-button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* 0.3.7A - Note reminders */

.note-reminder-editor {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.note-reminder-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-reminder-field label {
  font-size: 12px;
}

.note-reminder-field input {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
}

.note-reminder {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.78;
}

.note-reminder.overdue {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .note-reminder-editor {
    align-items: stretch;
  }

  .note-reminder-field {
    flex: 1 1 140px;
  }

  .note-reminder-field input,
  #clearReminderButton {
    min-height: 40px;
  }
}

/* 0.3.7C - Reminder notifications */

.notification-button {
  white-space: nowrap;
  min-height: 40px;
}

.notification-button:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 700px) {
  .notification-button {
    width: 100%;
  }
}

/* 0.3.7C - compact notification control */

.notification-button {
  width: auto;
  min-width: 0;
  min-height: 40px;
  padding-left: 14px;
  padding-right: 14px;
}

/* 0.3.7C - In-app due reminder popup */

.rnc-reminder-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.22);
}

.rnc-reminder-popup-panel {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 18px;
  background: #f7f1e5;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.22);
}

.rnc-reminder-popup-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.62;
}

.rnc-reminder-popup-panel h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.rnc-reminder-popup-due {
  margin-bottom: 20px;
  font-size: 14px;
  opacity: 0.72;
}

.rnc-reminder-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 700px) {
  .rnc-reminder-popup {
    align-items: flex-end;
    padding: 12px;
  }

  .rnc-reminder-popup-panel {
    border-radius: 18px;
  }

  .rnc-reminder-popup-actions button {
    min-height: 44px;
  }
}

/* 0.3.8A - Note icons */

.note-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-title-row .note-title-input {
  flex: 1;
  min-width: 0;
}

.note-icon-select {
  width: 58px;
  min-width: 58px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  text-align: center;
}

.note-title-icon {
  display: inline-block;
  margin-right: 7px;
  font-size: 0.95em;
  line-height: 1;
}

@media (max-width: 700px) {
  .note-icon-select {
    width: 54px;
    min-width: 54px;
  }
}

/* 0.3.8A - compact icon selector */

.note-icon-select {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  padding-left: 6px;
  padding-right: 4px;
}

/* 0.3.8A - streamlined note editor */

.note-meta-strip {
  display: grid;
  grid-template-columns:
    minmax(190px, 0.9fr)
    minmax(220px, 1.2fr)
    minmax(300px, 1.1fr);
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.note-meta-item {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.note-meta-item label,
.note-meta-label {
  display: block;
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.66;
}

.note-notebook-editor,
.note-tags-editor,
.note-reminder-editor {
  display: block;
}

.note-notebook-editor select,
.note-tags-editor input {
  width: 100%;
  min-height: 36px;
  box-sizing: border-box;
  margin: 0;
}

.note-reminder-controls {
  display: grid;
  grid-template-columns:
    minmax(130px, 1fr)
    minmax(105px, 0.8fr)
    auto;
  gap: 6px;
  align-items: center;
}

.note-reminder-controls input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  box-sizing: border-box;
  padding: 5px 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
}

.compact-reminder-clear {
  min-height: 36px;
  padding: 6px 10px;
  white-space: nowrap;
}

.document-editor {
  flex: 1 1 auto;
}

.composer-footer {
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.composer-footer .color-picker {
  flex-shrink: 0;
}

.composer-footer .date-toggle {
  white-space: nowrap;
}

.composer-actions {
  margin-left: auto;
}

@media (max-width: 950px) {
  .note-meta-strip {
    grid-template-columns:
      minmax(180px, 1fr)
      minmax(220px, 1.3fr);
  }

  .note-reminder-editor {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .note-meta-strip {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .note-reminder-editor {
    grid-column: auto;
  }

  .note-reminder-controls {
    grid-template-columns: 1fr 1fr;
  }

  .compact-reminder-clear {
    grid-column: 1 / -1;
  }

  .composer-footer {
    flex-wrap: wrap;
  }

  .composer-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

/* 0.3.8A - streamlined editor polish */

/* Make Tags clearly editable without turning it back into a heavy box */
.note-tags-editor input {
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.34);
  outline: none;
}

.note-tags-editor input:focus {
  border-color: rgba(0, 0, 0, 0.28);
  background: rgba(255, 255, 255, 0.55);
}

/* Give the reminder time enough room for AM / PM */
.note-reminder-controls {
  grid-template-columns:
    minmax(150px, 1.05fr)
    minmax(130px, 0.9fr)
    auto;
}

#noteReminderTime {
  min-width: 130px;
}

/* Keep save state visible but secondary */
.save-status {
  max-width: 92px;
  font-size: 11px;
  line-height: 1.15;
  opacity: 0.62;
}

/* Preserve compact footer rhythm */
.composer-footer {
  align-items: center;
}

@media (max-width: 700px) {
  .note-reminder-controls {
    grid-template-columns: 1fr 1fr;
  }

  #noteReminderTime {
    min-width: 0;
  }

  .save-status {
    max-width: none;
    font-size: 10px;
  }
}

/* 0.3.8A - footer overflow fix */

.composer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.composer-footer .color-picker,
.composer-footer .date-toggle,
.composer-footer .save-status {
  flex-shrink: 0;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  justify-content: flex-end;
}

@media (max-width: 1050px) {
  .composer-actions {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 700px) {
  .composer-actions {
    justify-content: stretch;
  }

  .composer-actions button {
    flex: 1 1 auto;
  }
}

/* 0.3.8A - final metadata fit polish */

.note-reminder-editor {
  min-width: 0;
}

.note-reminder-controls {
  width: 100%;
  min-width: 0;
  grid-template-columns:
    minmax(145px, 1fr)
    minmax(120px, 0.8fr)
    auto;
}

#noteReminderDate,
#noteReminderTime {
  min-width: 0;
}

.compact-reminder-clear {
  min-width: 58px;
  padding-left: 9px;
  padding-right: 9px;
}

/* Keep save/open status from consuming footer space */
.save-status {
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 0.3.8A - compact lower editor controls */

.note-meta-strip {
  gap: 8px;
}

.note-meta-item label,
.note-meta-label {
  font-size: 10px;
  margin-bottom: 3px;
}

.note-notebook-editor select,
.note-tags-editor input,
.note-reminder-controls input {
  min-height: 32px;
  height: 32px;
  font-size: 13px;
  padding: 3px 8px;
}

.note-reminder-controls {
  grid-template-columns:
    minmax(130px, 1fr)
    minmax(110px, 0.8fr)
    auto;
  gap: 5px;
}

.compact-reminder-clear {
  min-height: 32px;
  height: 32px;
  min-width: 50px;
  padding: 3px 8px;
  font-size: 12px;
}

.composer-footer {
  gap: 8px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.composer-footer .date-toggle {
  font-size: 12px;
}

.save-status {
  font-size: 9px;
  max-width: 62px;
}

.composer-actions {
  gap: 6px;
}

.composer-actions button {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 13px;
}

.color-picker {
  gap: 5px;
}

@media (max-width: 700px) {
  .note-notebook-editor select,
  .note-tags-editor input,
  .note-reminder-controls input,
  .compact-reminder-clear {
    min-height: 36px;
    height: 36px;
  }

  .composer-actions button {
    min-height: 38px;
  }
}

/* 0.3.8C - Notebook colors */

.manage-notebook-info {
  position: relative;
}

.notebook-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  min-width: 10px;
  margin-right: 7px;
  border-radius: 50%;
  vertical-align: middle;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.14);
}

/* 0.3.8C - active notebook color identity */

#viewHeading.notebook-accent-heading {
  padding-left: 10px;
  border-left:
    4px solid
    var(--notebook-accent);
}

/* 0.3.9A - Freeform canvas */

.notes-grid.freeform-view {
  position: relative;
  display: block;
  min-height: 820px;
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(
      circle,
      rgba(90, 78, 62, 0.10) 1px,
      transparent 1px
    );
  background-size: 24px 24px;
}

.notes-grid.freeform-view .note-card {
  position: absolute;
  width: 230px;
  min-height: 95px;
  max-height: 260px;
  margin: 0;
}

.notes-grid.freeform-view .drag-handle {
  cursor: move;
}

@media (max-width: 700px) {
  .notes-grid.freeform-view {
    min-height: 680px;
  }

  .notes-grid.freeform-view .note-card {
    width: min(220px, calc(100% - 16px));
  }
}

/* 0.3.9B - Expandable Freeform workspace */

.notes-grid.freeform-view {
  position: relative;
  display: block;
  width: 100%;
  height: 720px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(120, 110, 98, 0.12);
  border-radius: 14px;
  background:
    radial-gradient(
      circle,
      rgba(90, 78, 62, 0.10) 1px,
      transparent 1px
    );
  background-size: 24px 24px;
}

/*
  Invisible normal-flow spacer creates the
  scrollable canvas underneath absolute cards.
*/
.notes-grid.freeform-view::after {
  content: "";
  display: block;
  width:
    var(
      --freeform-canvas-width,
      1600px
    );
  height:
    var(
      --freeform-canvas-height,
      1100px
    );
  pointer-events: none;
}

.notes-grid.freeform-view .note-card {
  z-index: 1;
}

@media (max-width: 700px) {
  .notes-grid.freeform-view {
    height: 620px;
  }

  .notes-grid.freeform-view::after {
    width:
      var(
        --freeform-canvas-width,
        1200px
      );
    height:
      var(
        --freeform-canvas-height,
        900px
      );
  }
}

/* 0.3.9C1 - Freeform zoom */

.freeform-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 3px;
}

.freeform-zoom-controls.hidden {
  display: none;
}

.freeform-zoom-controls button {
  min-width: 28px;
  height: 28px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1;
}

#freeformZoomResetButton {
  min-width: 44px;
}

.notes-grid.freeform-view .note-card {
  transform:
    scale(
      var(--freeform-zoom, 1)
    );
  transform-origin: top left;
}

/* Preserve the zoom while hovering a Freeform card */
.notes-grid.freeform-view .note-card:hover {
  transform:
    scale(
      var(--freeform-zoom, 1)
    );
}

@media (max-width: 700px) {
  .freeform-zoom-controls button {
    min-width: 30px;
    height: 30px;
  }
}

/* 0.3.9C2 - Freeform pan */

.notes-grid.freeform-view {
  cursor: grab;
  touch-action: none;
}

.notes-grid.freeform-view.freeform-panning {
  cursor: grabbing;
  user-select: none;
}

.notes-grid.freeform-view .note-card {
  cursor: default;
}

.notes-grid.freeform-view .drag-handle {
  cursor: move;
}

/* 0.3.9C2 - Freeform drag repair */

.notes-grid.freeform-view .drag-handle {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.notes-grid.freeform-view .note-card {
  -webkit-user-drag: none;
}

/* 0.3.9C3 - Freeform Home / Fit */

#freeformHomeButton {
  min-width: 30px;
}

#freeformFitButton {
  min-width: 34px;
  font-size: 10px;
}

/* 0.3.9D1 - Pinning is not a Freeform concept */

.notes-grid.freeform-view .pin-action {
  display: none;
}

/* 0.3.9D2 - Floating Freeform toolbar */

.freeform-board-shell {
  position: relative;
}

.freeform-board-shell .freeform-zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 25;

  display: inline-flex;
  align-items: center;
  gap: 3px;

  margin: 0;
  padding: 5px;

  background:
    rgba(250, 247, 240, 0.94);

  border:
    1px solid
    rgba(120, 110, 98, 0.18);

  border-radius: 10px;

  box-shadow:
    0 4px 14px
    rgba(60, 52, 43, 0.10);

  backdrop-filter:
    blur(8px);

  -webkit-backdrop-filter:
    blur(8px);
}

.freeform-board-shell
.freeform-zoom-controls.hidden {
  display: none;
}

.freeform-board-shell
.freeform-zoom-controls button {
  min-width: 28px;
  height: 28px;
  padding: 2px 6px;
}

.freeform-board-shell
#freeformZoomResetButton {
  min-width: 44px;
}

.freeform-board-shell
#freeformFitButton {
  min-width: 34px;
}

@media (max-width: 700px) {
  .freeform-board-shell
  .freeform-zoom-controls {
    top: 8px;
    right: 8px;
    padding: 4px;
  }
}

/* 0.3.9D2A - Freeform toolbar above canvas */

/*
  Keep the Freeform canvas as one complete visible box.
  The toolbar sits above it instead of floating over it.
*/
.freeform-board-shell {
  position: relative;
}

/* Override the previous floating placement */
.freeform-board-shell .freeform-zoom-controls {
  position: static;

  display: flex;
  width: max-content;

  margin:
    0
    0
    10px
    auto;

  padding: 5px;

  background:
    rgba(250, 247, 240, 0.94);

  border:
    1px solid
    rgba(120, 110, 98, 0.18);

  border-radius: 10px;

  box-shadow:
    0 3px 10px
    rgba(60, 52, 43, 0.08);

  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/*
  Restore/guarantee the complete Freeform canvas outline,
  including the bottom edge.
*/
.freeform-board-shell
.notes-grid.freeform-view {
  box-sizing: border-box;

  border:
    1px solid
    rgba(120, 110, 98, 0.12);

  border-radius: 14px;
}

/* Keep hidden behavior intact outside Freeform */
.freeform-board-shell
.freeform-zoom-controls.hidden {
  display: none;
}

@media (max-width: 700px) {
  .freeform-board-shell
  .freeform-zoom-controls {
    margin-bottom: 8px;
  }
}

/* 0.3.9D2B - Keep complete Freeform canvas visible */

.notes-grid.freeform-view {
  height:
    calc(
      100dvh - 355px
    );

  min-height: 420px;
  max-height: 720px;
}

@media (max-width: 700px) {
  .notes-grid.freeform-view {
    height:
      calc(
        100dvh - 320px
      );

    min-height: 360px;
    max-height: 620px;
  }
}

/* 0.3.9E - Freeform marquee selection */

.notes-grid.freeform-view
.freeform-marquee {
  position: absolute;
  z-index: 20;

  pointer-events: none;

  border:
    1.5px solid
    rgba(0, 87, 255, 0.72);

  border-radius: 5px;

  background:
    rgba(0, 87, 255, 0.09);

  box-shadow:
    inset 0 0 0 1px
    rgba(255, 255, 255, 0.35);
}

.notes-grid.freeform-view
.freeform-marquee-active {
  cursor: crosshair;
}

/* 0.3.9E1 - Pull Freeform workspace upward */

#allNotesSection:has(#notesGrid.freeform-view) {
  margin-top: -58px;
}

@media (max-width: 700px) {
  #allNotesSection:has(#notesGrid.freeform-view) {
    margin-top: -28px;
  }
}

/* 0.3.9E2 - Align Freeform heading and toolbar */

#allNotesSection:has(#notesGrid.freeform-view) {
  position: relative;
}

/*
  Let the toolbar position relative to the complete
  Notes section instead of relative to the canvas shell.
*/
#allNotesSection:has(#notesGrid.freeform-view)
.freeform-board-shell {
  position: static;
}

/*
  Reserve enough space on the right so the heading
  and toolbar never collide.
*/
#allNotesSection:has(#notesGrid.freeform-view)
.section-heading {
  min-height: 38px;
  margin-bottom: 10px;
  padding-right: 245px;
}

/*
  Put the Freeform controls on the same visual row
  as the Notes heading.
*/
#allNotesSection:has(#notesGrid.freeform-view)
.freeform-zoom-controls {
  position: absolute;
  top: 0;
  right: 0;

  margin: 0;
}

/* Restore normal shell positioning outside Freeform */
#allNotesSection:not(:has(#notesGrid.freeform-view))
.freeform-board-shell {
  position: relative;
}

@media (max-width: 700px) {
  #allNotesSection:has(#notesGrid.freeform-view)
  .section-heading {
    padding-right: 0;
    margin-bottom: 8px;
  }

  #allNotesSection:has(#notesGrid.freeform-view)
  .freeform-board-shell {
    position: relative;
  }

  #allNotesSection:has(#notesGrid.freeform-view)
  .freeform-zoom-controls {
    position: static;
    margin:
      0
      0
      8px
      auto;
  }
}

/* 0.3.9E3 - Responsive Freeform height */

/*
  JavaScript now calculates the actual available
  browser height. Do not cap the desktop canvas
  at the old fixed 720px value.
*/
.notes-grid.freeform-view {
  max-height: none;
}

@media (max-width: 700px) {
  .notes-grid.freeform-view {
    max-height: none;
  }
}

/* 0.3.10A - Freeform card resizing */

.freeform-resize-handle {
  display: none;
}

.notes-grid.freeform-view .note-card {
  max-height: none;
}

.notes-grid.freeform-view
.freeform-resize-handle {
  position: absolute;

  right: 3px;
  bottom: 3px;

  z-index: 8;

  display: block;

  width: 18px;
  height: 18px;

  padding: 0;
  border: 0;

  background: transparent;

  cursor: nwse-resize;

  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.notes-grid.freeform-view
.freeform-resize-handle::after {
  content: "";

  position: absolute;

  right: 2px;
  bottom: 2px;

  width: 9px;
  height: 9px;

  border-right:
    2px solid
    rgba(90, 78, 62, 0.48);

  border-bottom:
    2px solid
    rgba(90, 78, 62, 0.48);
}

.notes-grid.freeform-view
.note-card:hover
.freeform-resize-handle::after,
.notes-grid.freeform-view
.note-card.freeform-resizing
.freeform-resize-handle::after {
  border-color:
    rgba(70, 60, 48, 0.8);
}

.notes-grid.freeform-view
.note-card.freeform-resizing {
  user-select: none;
}

/* 0.3.10B - Freeform Arrange */

.freeform-arrange-wrap {
  position: relative;
  display: inline-flex;
}

.freeform-arrange-menu {
  position: absolute;

  top: calc(100% + 6px);
  right: 0;

  z-index: 40;

  min-width: 130px;
  padding: 5px;

  border:
    1px solid
    rgba(120, 110, 98, 0.20);

  border-radius: 9px;

  background:
    rgba(250, 247, 240, 0.98);

  box-shadow:
    0 8px 22px
    rgba(60, 52, 43, 0.14);
}

.freeform-arrange-menu.hidden {
  display: none;
}

.freeform-arrange-menu button {
  display: block;

  width: 100%;
  min-width: 0;
  height: auto;

  padding: 7px 9px;

  border: 0;
  border-radius: 6px;

  background: transparent;

  text-align: left;
  white-space: nowrap;
}

.freeform-arrange-menu button:hover {
  background:
    rgba(120, 110, 98, 0.10);
}

/* 0.3.10C - Grid density: Spread Out */

.notes-grid.grid-spread-view {
  grid-template-columns:
    repeat(
      auto-fill,
      minmax(285px, 1fr)
    );

  column-gap: 24px;
  row-gap: 24px;
}

@media (max-width: 700px) {
  .notes-grid.grid-spread-view {
    grid-template-columns:
      repeat(
        auto-fill,
        minmax(205px, 1fr)
      );

    column-gap: 16px;
    row-gap: 18px;
  }
}
