:root {
  --bg-1: #edf2f9;
  --bg-2: #dfe7f2;
  --ink: #eaf1ff;
  --toolbar: rgba(255, 255, 255, 0.5);
  --note-bg: #1f3f67;
  --note-border: #2d5688;
  --note-border-active: #5f90c8;
  --accent-primary: #ff5a2a;
  --accent-secondary: #ff8c00;
  --accent-line: rgba(255, 90, 42, 0.65);
  --accent-glow: rgba(255, 90, 42, 0.95);
  --accent-halo: rgba(255, 140, 0, 0.5);
  --control-bg: #133054;
  --control-border: #355f93;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #152233;
  overflow: hidden;
  touch-action: none;
}

#app {
  position: relative;
  background: radial-gradient(circle at 20% 20%, var(--bg-1), var(--bg-2) 72%);
}

.toolbar {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 8px);
  right: calc(var(--safe-right) + 8px);
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: var(--toolbar);
  border: 1px solid rgba(0, 0, 0, 0.1);
  max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 16px);
  overflow: visible;
}

.import-result-toast {
  position: fixed;
  top: calc(var(--safe-top) + 66px);
  left: calc(var(--safe-left) + 8px);
  right: calc(var(--safe-right) + 8px);
  z-index: 54;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(17, 56, 100, 0.96);
  color: #eaf1ff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.import-result-toast[hidden] {
  display: none !important;
}

.import-result-toast a {
  color: #ffd07a;
  text-decoration: underline;
  white-space: nowrap;
}

.import-result-toast button {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #eaf1ff;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}

.import-result-toast button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.toolbar-toggle {
  display: none;
}

.add-note-mobile {
  display: none;
}

.mobile-add-menu {
  display: none;
}

.add-note-menu summary {
  padding: 8px 10px;
  min-width: 38px;
  text-align: center;
}

.toolbar-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.toolbar button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.toolbar-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toolbar button.active {
  border-color: #ff5a2a;
  box-shadow: 0 0 0 2px rgba(255, 90, 42, 0.2);
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.menu:not([open]) .menu-panel {
  display: none;
}

.menu-panel button {
  width: 100%;
  text-align: left;
}

.menu-panel a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #21354f;
  text-decoration: none;
  background: #fff;
}

.menu-panel a:hover {
  background: #f3f7fc;
}

.menu-panel form {
  margin: 0;
}

#canvas-settings-modal {
  border: 0;
  border-radius: 12px;
  padding: 0;
  width: min(420px, calc(100vw - 24px));
}

#canvas-settings-modal::backdrop {
  background: rgba(14, 20, 30, 0.45);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: #fff;
}

.settings-form h2 {
  margin: 0 0 2px;
  font-size: 18px;
  color: #21354f;
}

.settings-form label {
  font-size: 13px;
  color: #21354f;
}

.settings-form input[type="text"],
.settings-form input[type="color"],
.settings-form select {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
}

.settings-inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #21354f;
}

.settings-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.settings-form input[type="color"] {
  height: 40px;
  padding: 4px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.settings-actions .danger {
  margin-right: auto;
  border-color: #a13434;
  color: #7d1d1d;
  background: #fff4f4;
}

.settings-actions .danger:hover {
  background: #ffe9e9;
}

.canvas-share-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.canvas-share-list {
  max-height: 160px;
  overflow: auto;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  background: #f8fbff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.canvas-share-empty {
  font-size: 12px;
  color: #4b637d;
  padding: 4px 2px;
}

.canvas-share-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #21354f;
  padding: 2px 2px;
}

.canvas-share-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.canvas-share-owner {
  font-size: 11px;
  color: #4b637d;
  margin-left: auto;
}

.canvas-share-add-row {
  display: flex;
  gap: 8px;
}

.canvas-share-add-row input[type="text"] {
  flex: 1;
}

.canvas-share-hint {
  margin: 0;
  font-size: 12px;
  color: #4b637d;
}

.settings-actions button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.login-card {
  width: min(360px, calc(100vw - 24px));
  margin: max(80px, 10vh) auto 0;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
}

.login-card h1 {
  margin: 0 0 8px;
  color: #21354f;
  font-size: 22px;
}

.login-card p {
  margin: 0 0 10px;
  color: #2c4360;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card label {
  font-size: 13px;
  color: #21354f;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 16px;
}

.login-card button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.login-error {
  margin: 0 0 10px;
  color: #8a1f1f;
  font-size: 13px;
}

.admin-card {
  width: min(760px, calc(100vw - 24px));
  margin: max(32px, 5vh) auto 0;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-header h1 {
  margin: 0;
  color: #21354f;
  font-size: 22px;
}

.admin-back {
  color: #21354f;
  text-decoration: none;
  font-size: 14px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 14px;
}

.admin-create-form label {
  font-size: 13px;
  color: #21354f;
}

.admin-create-form input[type="text"],
.admin-create-form input[type="password"] {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
}

.admin-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.admin-create-form button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  overflow: hidden;
}

.users-table th,
.users-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: left;
}

.admin-password-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-password-form input[type="password"] {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  width: 140px;
}

.admin-password-form button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 6px 8px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.users-table tr:last-child td {
  border-bottom: 0;
}

.admin-success {
  margin: 0 0 10px;
  color: #0d5a2b;
  font-size: 13px;
}

.toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar select {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  min-width: 160px;
}

.sync-status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  user-select: none;
}

.user-menu summary {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.user-menu .menu-panel {
  left: auto;
  right: 0;
  min-width: 150px;
}

.user-menu-form button {
  width: 100%;
  text-align: left;
}

.sync-status.synced {
  color: #0d5a2b;
  background: #ddf7e7;
  border-color: #8ad7a8;
}

.sync-status.offline {
  color: #7a1e1e;
  background: #fbe4e4;
  border-color: #e6a6a6;
}

@media (max-width: 980px) {
  .toolbar {
    gap: 6px;
    padding: 7px;
  }

  .toolbar button,
  .menu summary,
  .toolbar select {
    padding: 7px 9px;
    font-size: 16px;
  }

  .toolbar select {
    min-width: 120px;
  }
}

@media (max-width: 720px) {
  .toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-toggle {
    display: inline-flex;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: #fff;
    color: #21354f;
    padding: 8px 12px;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
  }

  .add-note-mobile {
    display: inline-flex;
    margin-left: auto;
  }

  .mobile-add-menu {
    display: inline-flex;
  }

  .mobile-add-menu summary {
    padding: 8px 10px;
    min-width: 38px;
    text-align: center;
  }

  .mobile-add-menu .menu-panel {
    left: auto;
    right: 0;
    max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 16px);
  }

  .toolbar-content {
    display: none;
    margin-top: 4px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }

  .toolbar.toolbar-open .toolbar-content {
    display: flex;
  }

  .toolbar-content button,
  .toolbar-content select,
  .toolbar-content .menu summary,
  .toolbar-content .menu,
  .toolbar-content .toolbar-right {
    width: 100%;
  }

  .toolbar-content .menu-panel {
    position: static;
    margin-top: 6px;
    box-shadow: none;
  }

  .toolbar-right {
    margin-left: 0;
    justify-content: space-between;
  }

  .import-result-toast {
    top: calc(var(--safe-top) + 52px);
    flex-wrap: wrap;
  }
}

.note-style-toolbar {
  position: absolute;
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.note-style-toolbar[hidden] {
  display: none !important;
}

.note-style-toolbar label {
  font-size: 12px;
  color: #21354f;
}

.note-style-toolbar input[type="color"] {
  width: 32px;
  height: 26px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  background: #fff;
  padding: 0;
  cursor: pointer;
}

#note-attach-btn,
#note-lock-btn,
#image-download-btn,
#note-detach-btn {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  color: #21354f;
  padding: 5px 9px;
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.note.locked {
  cursor: grab;
  border-color: #4f6f95;
}

#note-attach-btn.active {
  border-color: #ff5a2a;
  box-shadow: 0 0 0 2px rgba(255, 90, 42, 0.18);
}

#note-detach-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-color: var(--bg-1);
  background-repeat: repeat;
  background-position: var(--pattern-offset-x, 0px) var(--pattern-offset-y, 0px);
  background-size: var(--pattern-size, 32px) var(--pattern-size, 32px);
}

#viewport[data-pattern="none"] {
  background-image: none;
}

#viewport[data-pattern="dots"] {
  background-image: radial-gradient(circle, rgba(32, 65, 112, 0.22) 1.2px, transparent 1.3px);
}

#viewport[data-pattern="grid"] {
  background-image:
    linear-gradient(90deg, rgba(32, 65, 112, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(32, 65, 112, 0.16) 1px, transparent 1px);
  background-size:
    var(--pattern-size, 32px) var(--pattern-size, 32px),
    var(--pattern-size, 32px) var(--pattern-size, 32px);
  background-position:
    var(--pattern-offset-x, 0px) var(--pattern-offset-y, 0px),
    var(--pattern-offset-x, 0px) var(--pattern-offset-y, 0px);
}

#viewport.panning {
  cursor: grabbing;
}

#links-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#links-overlay line {
  stroke: var(--accent-line);
  stroke-width: 4;
}

#links-overlay line.attach-preview-line {
  stroke: var(--accent-primary);
  stroke-width: 3;
  stroke-dasharray: 10 6;
  stroke-linecap: round;
}

#world {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
  z-index: 1;
}

.note {
  position: absolute;
  width: 260px;
  height: 180px;
  border: 1px solid var(--note-border);
  border-radius: 6px;
  background: var(--note-color, var(--note-bg));
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

.image-object {
  position: absolute;
  border: 1px solid var(--note-border);
  border-radius: 6px;
  background: #0e223b;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.image-object img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.file-object {
  position: absolute;
  border: 1px solid var(--note-border);
  border-radius: 8px;
  background: #102844;
  color: #eaf1ff;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  overflow: hidden;
}

.file-icon {
  width: 38px;
  height: 46px;
  border: 1px solid #7a97bb;
  border-radius: 5px;
  background: #1f426d;
  color: #dfeaff;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.file-icon::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-top: 1px solid #7a97bb;
  border-right: 1px solid #7a97bb;
  background: #2f5788;
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.file-icon.pdf {
  border-color: #c47a7a;
  background: #6b2a2a;
  color: #ffe9e9;
}

.file-icon.pdf::before {
  border-top-color: #c47a7a;
  border-right-color: #c47a7a;
  background: #8a3b3b;
}

.file-name {
  width: 100%;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-open {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #eaf1ff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
}

.file-open:hover {
  background: rgba(255, 255, 255, 0.18);
}

.canvas-object.selected {
  border-color: var(--accent-primary);
  box-shadow:
    0 0 0 3px var(--accent-glow),
    0 0 0 7px var(--accent-halo),
    0 10px 22px rgba(0, 0, 0, 0.28);
}

.note.editing {
  border-color: var(--note-border-active);
}

.note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 8px 8px 6px;
}

.note-title,
.note-title-view,
.note-collapsed-label {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--ink);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 13px;
  line-height: 1.2;
}

.note-title {
  outline: none;
}

.note-title::placeholder {
  color: rgba(234, 241, 255, 0.62);
}

.note-collapsed-label {
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-title-view {
  display: none;
  border: 0;
  background: transparent;
  color: var(--note-text-color, var(--ink));
  padding-left: 2px;
  padding-right: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
  line-height: 1.25;
}

.note:not(.editing):not(.collapsed) .note-title {
  display: none;
}

.note:not(.editing):not(.collapsed) .note-title-view:not([hidden]) {
  display: block;
}

.note-controls {
  display: none;
  align-items: center;
  gap: 6px;
}

.note.selected .note-controls,
.note.editing .note-controls {
  display: flex;
}

.note-mode,
.note-toggle,
.note-info {
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  border-radius: 4px;
  padding: 2px 6px;
}

.note-toggle,
.note-info {
  cursor: pointer;
}

.note-info {
  width: 22px;
  min-width: 22px;
  text-align: center;
  padding: 2px 0;
  font-weight: 700;
  line-height: 1;
}

.note-content {
  width: 100%;
  height: calc(100% - 40px);
  border: 0;
  background: transparent;
  resize: none;
  padding: 8px 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  outline: none;
  font-size: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--note-text-color, var(--ink));
  cursor: inherit;
}

.note-preview {
  display: none;
  width: 100%;
  height: calc(100% - 40px);
  padding: 8px 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  color: var(--note-text-color, var(--ink));
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.4;
}

.note-preview h1,
.note-preview h2,
.note-preview h3,
.note-preview p {
  margin: 0 0 8px;
}

.note-preview ul {
  margin: 0 0 8px 18px;
  padding: 0;
}

.note-preview code {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
}

.note-preview pre {
  margin: 0 0 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  overflow: auto;
}

.note.mode-markdown:not(.editing) .note-preview {
  display: block;
}

.note.mode-markdown:not(.editing) .note-content {
  display: none;
}

.note-url-view {
  display: none;
  width: 100%;
  height: calc(100% - 40px);
  padding: 18px 14px 14px;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
}

.note-url-view a {
  display: inline-block;
  max-width: 100%;
  color: #cfe4ff;
  text-decoration: underline;
  word-break: break-all;
  font-size: 15px;
  line-height: 1.35;
}

.note-url-empty {
  color: rgba(234, 241, 255, 0.7);
  font-size: 13px;
}

.note-todo-view {
  display: none;
  width: 100%;
  height: calc(100% - 40px);
  padding: 10px 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.note-log-view {
  display: none;
  width: 100%;
  height: calc(100% - 40px);
  padding: 8px 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.log-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.log-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-active-kind {
  font-size: 13px;
  color: var(--note-text-color, var(--ink));
  opacity: 0.92;
}

.log-change-type {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--note-text-color, var(--ink));
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.log-type-picker {
  display: flex;
  gap: 6px;
}

.log-type-picker[hidden] {
  display: none;
}

.log-type-picker button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--note-text-color, var(--ink));
  border-radius: 999px;
  padding: 4px 9px;
  font: inherit;
  font-size: 12px;
  text-transform: lowercase;
  cursor: pointer;
}

.log-type-picker button.active {
  background: rgba(255, 255, 255, 0.2);
}

.log-entry-host {
  display: block;
}

.log-row {
  display: flex;
  gap: 6px;
}

.log-row button,
.log-event-btn {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--note-text-color, var(--ink));
  border-radius: 6px;
  padding: 6px 9px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.log-event-btn {
  width: 100%;
  text-align: left;
}

.log-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.12);
  color: var(--note-text-color, var(--ink));
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.log-list[hidden] {
  display: none;
}

.log-item {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--note-text-color, var(--ink));
  font-size: 12px;
}

.log-item-latest {
  margin-top: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.log-history-toggle {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--note-text-color, var(--ink));
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  align-self: flex-start;
}

.log-ts {
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-kind {
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 11px;
  text-transform: lowercase;
}

.log-value {
  white-space: pre-wrap;
  word-break: break-word;
}

.log-empty {
  color: rgba(234, 241, 255, 0.7);
  font-size: 12px;
}

.todo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  margin: 0 0 6px;
  color: var(--note-text-color, var(--ink));
  font-size: 15px;
  line-height: 1.3;
}

.todo-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #8db2e4;
  flex: 0 0 auto;
}

.todo-label {
  white-space: pre-wrap;
  word-break: break-word;
}

.todo-empty {
  color: rgba(234, 241, 255, 0.7);
  font-size: 13px;
}

.note.mode-url:not(.editing) .note-url-view {
  display: flex;
}

.note.mode-url:not(.editing) .note-content {
  display: none;
}

.note.mode-todo:not(.editing) .note-todo-view {
  display: block;
}

.note.mode-todo:not(.editing) .note-content {
  display: none;
}

.note.mode-log:not(.editing) .note-log-view {
  display: block;
}

.note.mode-log:not(.editing) .note-content {
  display: none;
}

.note.mode-code .note-content {
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  line-height: 1.45;
}

.note.editing .note-content {
  cursor: text;
  user-select: text;
}

.note.collapsed {
  height: 40px !important;
}

.note.collapsed .note-title {
  display: none;
}

.note.collapsed .note-title-view {
  display: none;
}

.note.collapsed .note-collapsed-label {
  display: block;
}

.note.collapsed .note-content,
.note.collapsed .note-preview,
.note.collapsed .note-url-view,
.note.collapsed .note-todo-view,
.note.collapsed .note-log-view,
.note.collapsed .resize-handle {
  display: none;
}

.note.collapsed .note-mode {
  display: none;
}

.resize-handle {
  position: absolute;
  z-index: 4;
  background: transparent;
}

.handle-n,
.handle-s {
  left: 14px;
  right: 14px;
  height: 14px;
}

.handle-e,
.handle-w {
  top: 14px;
  bottom: 14px;
  width: 14px;
}

.handle-n {
  top: -7px;
  cursor: ns-resize;
}

.handle-s {
  bottom: -7px;
  cursor: ns-resize;
}

.handle-e {
  right: -7px;
  cursor: ew-resize;
}

.handle-w {
  left: -7px;
  cursor: ew-resize;
}

.handle-ne,
.handle-nw,
.handle-se,
.handle-sw {
  width: 20px;
  height: 20px;
}

.handle-ne {
  top: -10px;
  right: -10px;
  cursor: nesw-resize;
}

.handle-nw {
  top: -10px;
  left: -10px;
  cursor: nwse-resize;
}

.handle-se {
  bottom: -10px;
  right: -10px;
  cursor: nwse-resize;
}

.handle-sw {
  bottom: -10px;
  left: -10px;
  cursor: nesw-resize;
}
  z-index: 60;
