:root {
  --bg: #f8f8f6;
  --ink: #151515;
  --line: #d9d9d4;
  --card: #ffffff;
  --muted: #7a7a72;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: ui-rounded, "SF Pro Rounded", "SF Rounded", -apple-system,
    BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
}

#canvas {
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  background-color: #fcfcfa;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
}

#canvas.draw-active {
  cursor: crosshair;
}

#canvas.is-pan-ready {
  cursor: grab;
}

#canvas.is-panning {
  cursor: grabbing;
}

#world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.note {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--note-shadow, 0 6px 18px rgba(0, 0, 0, 0.07));
  overflow: hidden;
  padding: 10px;
  font-size: var(--note-font-size, 14px);
}

.note:focus {
  outline: none;
}

.note.is-text-active {
  border-color: #8c8c8c;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
}

.note.is-selected:not(.is-text-active) {
  border-color: #a9b6d6;
  box-shadow:
    0 0 0 2px rgba(103, 152, 255, 0.48),
    0 6px 18px rgba(0, 0, 0, 0.07);
}

.note.is-selection-preview:not(.is-selected):not(.is-text-active) {
  border-color: #b5c3e6;
  box-shadow:
    0 0 0 2px rgba(87, 136, 234, 0.34),
    0 6px 18px rgba(0, 0, 0, 0.07);
}

.card-content {
  min-height: 14px;
  display: grid;
  gap: 2px;
  align-content: start;
}

.block {
  border-radius: 6px;
}

.block.text {
  min-height: 18px;
  outline: none;
  padding: 2px 4px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.block.todo {
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: 1px 3px;
}

.block.todo input[type="checkbox"] {
  width: 1.15em;
  height: 1.15em;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #1e73da;
}

.block.todo .todo-text {
  flex: 1;
  min-height: 1.2em;
  outline: none;
  line-height: 1.25;
  font-size: 0.98em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.block.todo .todo-text * {
  font-size: inherit !important;
}

.block.todo .todo-text:empty::before {
  content: "To-do";
  color: #a6a69f;
}

.block.todo.done .todo-text {
  text-decoration: line-through;
  text-decoration-thickness: 0.06em;
  text-decoration-color: #9a9a94;
  color: #9a9a94;
}

.block.todo.done .todo-text a {
  color: inherit;
  text-decoration-color: #9a9a94;
}

.block a {
  color: #5f5f5f;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.08em;
}

.block a:hover {
  cursor: pointer;
}

.slash-menu {
  position: fixed;
  z-index: 9999;
  display: grid;
  gap: 2px;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.slash-menu button {
  border: 0;
  text-align: left;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.slash-menu button:hover {
  background: #f2f2ef;
}

.drawing-preview {
  position: absolute;
  border: 1px dashed #222;
  background: rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.drawing-preview.selection {
  border-color: #2f6df6;
  background: rgba(47, 109, 246, 0.14);
  z-index: 2147483647;
}

.canvas-switcher-trigger {
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 10000;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(17, 24, 39, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  color: #3a3f46;
  cursor: pointer;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 4px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.canvas-switcher-trigger span {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  justify-self: center;
  align-self: center;
  background: rgba(58, 63, 70, 0.72);
}

.canvas-switcher-trigger:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(17, 24, 39, 0.3);
}

.canvas-switcher-trigger:focus-visible {
  outline: 2px solid rgba(30, 100, 220, 0.45);
  outline-offset: 2px;
}

.canvas-switcher-dialog {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: block;
  background: #f3f3ef;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 170ms ease, visibility 170ms ease;
}

.canvas-switcher-dialog.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.canvas-switcher-panel {
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #f3f3ef;
  box-shadow: none;
}

.canvas-switcher-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #dadad4;
  padding: 14px;
  background: rgba(243, 243, 239, 0.95);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.canvas-switcher-new,
.canvas-switcher-close {
  width: 24px;
  height: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.canvas-switcher-close {
  border: 1px solid rgba(17, 24, 39, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: #3a3f46;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.canvas-switcher-new {
  border: 0;
  background: transparent;
  color: #292d33;
  cursor: pointer;
  font-size: 29px;
  transform: translateY(-1px);
}

.canvas-switcher-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  padding: 16px;
}

.canvas-tile {
  position: relative;
  outline: none;
}

.canvas-tile-open {
  position: relative;
  width: 100%;
  min-height: 210px;
  border-radius: 12px;
  border: 1px solid #d9d9d4;
  background: linear-gradient(168deg, #ffffff 0%, #f3f3ef 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  padding: 0;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.canvas-tile:hover .canvas-tile-open {
  border-color: #c7c7c0;
}

.canvas-tile:focus-visible .canvas-tile-open {
  border-color: #7ca1d8;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(80, 129, 226, 0.25);
}

.canvas-tile.is-active .canvas-tile-open {
  border-color: #bdbdb6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.canvas-tile-title {
  display: block;
  font-size: 15px;
  font-weight: 620;
  line-height: 1.25;
  color: #111111;
  cursor: text;
}

.canvas-tile-title.is-editing {
  cursor: text;
  outline: none;
}

.canvas-tile-meta,
.canvas-tile-updated {
  display: block;
  font-size: 12px;
  line-height: 1.25;
  color: rgba(26, 26, 26, 0.8);
}

.canvas-tile-preview {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(143, 178, 226, 0.2) 0%, rgba(143, 178, 226, 0) 45%),
    radial-gradient(circle at 84% 76%, rgba(140, 206, 182, 0.2) 0%, rgba(140, 206, 182, 0) 42%),
    #f8f8f5;
}

.canvas-tile-preview.is-empty::after {
  content: "";
  position: absolute;
  inset: 14% 12%;
  border-radius: 10px;
  border: 1px dashed rgba(120, 120, 112, 0.32);
}

.canvas-preview-note {
  position: absolute;
  border: 1px solid rgba(80, 93, 112, 0.28);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(17, 24, 39, 0.08);
  overflow: hidden;
  padding: 1px 2px;
}

.canvas-preview-note-text {
  display: block;
  font-size: 8px;
  line-height: 1.2;
  color: rgba(35, 37, 41, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(243, 243, 239, 0.97) 0%,
    rgba(243, 243, 239, 0.82) 20%,
    rgba(243, 243, 239, 0.38) 46%,
    rgba(243, 243, 239, 0.06) 72%,
    rgba(243, 243, 239, 0) 100%
  );
  pointer-events: none;
}

.canvas-tile-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 12px 11px;
  display: grid;
  gap: 4px;
  z-index: 1;
}

.canvas-tile-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border: 1px solid #d6d6d2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #585858;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity 120ms ease;
}

.canvas-tile:hover .canvas-tile-delete,
.canvas-tile:focus-within .canvas-tile-delete {
  opacity: 1;
}

.canvas-tile-delete:disabled {
  opacity: 0.45;
  cursor: default;
}

.shortcut-help-trigger {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 10000;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(17, 24, 39, 0.22);
  border-radius: 50%;
  background: #ffffff;
  color: #222222;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.shortcut-help-trigger:hover {
  background: #ffffff;
  border-color: rgba(17, 24, 39, 0.3);
}

.shortcut-help-trigger:focus-visible {
  outline: 2px solid rgba(30, 100, 220, 0.45);
  outline-offset: 2px;
}

.shortcut-help-dialog {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(20px, 12vh, 160px) 14px 14px;
  background: rgba(14, 18, 24, 0.48);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.shortcut-help-dialog.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.shortcut-help-panel {
  width: min(460px, calc(100vw - 24px));
  max-height: min(500px, calc(100dvh - 34px));
  overflow: auto;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
  padding: 0;
  transform-origin: center;
  transform: scale(0.97);
  transition: transform 170ms ease;
}

.shortcut-help-dialog.is-open .shortcut-help-panel {
  transform: scale(1);
}

.shortcut-help-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 40px;
  padding: 9px 9px;
  border-bottom: 1px solid #dddddd;
}

.shortcut-tab {
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  color: #000000;
  cursor: pointer;
  position: relative;
  transition: color 140ms ease;
}

.shortcut-tab.is-muted {
  color: #a8a8a8;
}

.shortcut-tab.is-muted:hover {
  color: #8f8f8f;
}

.shortcut-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  background: #000;
}

.shortcut-tab:focus-visible {
  outline: 2px solid rgba(30, 100, 220, 0.45);
  outline-offset: 2px;
}

.shortcut-pane.is-hidden {
  display: none;
}

.shortcut-help-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shortcut-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid #e0e0e0;
}

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

.shortcut-action {
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 1.15;
  color: #2f2f2f;
}

.shortcut-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.shortcut-plain {
  font-size: 12px;
  color: #7c7c7c;
  line-height: 1.2;
  align-self: center;
}

.shortcut-help-list kbd {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica,
    Arial, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.1;
  padding: 4px 7px;
  border: 1px solid #cccccc;
  border-radius: 8px;
  background: #f3f3f3;
  white-space: normal;
}

.shortcut-pane-feedback {
  padding: 10px 9px 11px;
  display: grid;
  gap: 8px;
}

.shortcut-pane-settings {
  padding: 10px 9px 11px;
}

.settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cccccc;
  border-radius: 8px;
  background: #fafafa;
  color: #222222;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 10px;
  text-align: center;
  cursor: pointer;
}

.settings-action:hover {
  background: #f1f1f1;
  border-color: #bdbdbd;
}

.settings-action:focus-visible {
  outline: 2px solid rgba(30, 100, 220, 0.45);
  outline-offset: 2px;
}

.shortcut-pane-projects {
  padding: 12px 9px 13px;
}

.more-projects-intro {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.35;
  color: #2f2f2f;
}

.more-projects-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.more-projects-links li {
  font-size: 13px;
  line-height: 1.35;
  color: #2f2f2f;
}

.project-logo {
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #d0d0d0;
  margin-right: 6px;
  vertical-align: -4px;
}

.more-projects-links a {
  color: #5f5f5f;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.08em;
}

.feedback-input {
  width: 100%;
  min-height: 86px;
  resize: none;
  border: 1px solid #cccccc;
  border-radius: 8px;
  background: #fafafa;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  color: #222222;
  padding: 8px 9px;
}

.feedback-input:focus-visible {
  outline: none;
  border-color: #8f8f8f;
}

.feedback-send {
  justify-self: end;
  border: 1px solid #000;
  border-radius: 8px;
  background: #000;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  min-width: 66px;
  padding: 7px 14px;
  cursor: pointer;
  text-align: center;
}

.feedback-send:hover {
  background: #1a1a1a;
}

.feedback-send.is-sending {
  font-size: 16px;
}

@media (max-width: 680px) {
  .canvas-switcher-trigger {
    width: 24px;
    height: 24px;
    left: 10px;
    top: 10px;
  }

  .canvas-switcher-dialog {
    background: #f3f3ef;
  }

  .canvas-switcher-panel {
    width: 100vw;
    max-height: 100dvh;
  }

  .canvas-switcher-header {
    padding: 10px;
  }

  .canvas-switcher-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .canvas-tile-open {
    min-height: 180px;
  }

  .shortcut-help-dialog {
    padding-top: clamp(14px, 5vh, 28px);
  }

  .shortcut-help-panel {
    max-height: calc(100dvh - 28px);
  }

  .shortcut-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .shortcut-action {
    font-size: 12px;
  }

  .shortcut-help-list kbd {
    font-size: 10px;
    padding: 3px 6px;
  }
}

@media (max-height: 520px) {
  .shortcut-help-dialog {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .shortcut-help-panel {
    max-height: calc(100dvh - 20px);
  }
}
