:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #f5f7fb;
  --bar: #20242c;
  --bar-ink: #f8fafc;
  --yellow: #fff2a8;
  --blue: #d8ebff;
  --green: #dff6df;
  --pink: #ffe0ec;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(32, 36, 44, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 36, 44, 0.045) 1px, transparent 1px),
    #eef2f6;
  background-size: 24px 24px;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  color: var(--bar-ink);
  background: var(--bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 180ms ease;
}

.collapsed-actions {
  position: fixed;
  z-index: 22;
  top: 6px;
  right: 10px;
  display: none;
  gap: 5px;
}

.collapsed-actions button {
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(32, 36, 44, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  color: #20242c;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 26px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(31, 35, 40, 0.1);
}

body.topbar-collapsed .topbar {
  transform: translateY(-100%);
}

body.topbar-collapsed .collapsed-actions {
  display: flex;
}

body.topbar-collapsed .board {
  padding-top: 38px;
}

.brand {
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 700;
}

.app-version {
  margin-left: 6px;
  color: #aab4c2;
  font-size: 11px;
  font-weight: 650;
}

.status {
  min-width: 92px;
  font-size: 12px;
  color: #cbd5e1;
  text-align: right;
}

.user-pill {
  max-width: 120px;
  overflow: hidden;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #dbe4ef;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.active-users {
  max-width: 220px;
  color: #a7f3d0;
}

.board-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.board-tab {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #aab4c2;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.board-tab.active {
  background: #f8fafc;
  color: #20242c;
}

.board-tab[data-board-tab="personal"].active {
  background: #fff1df;
  color: #9a4b00;
}

.board-tab[data-board-tab="shared"].active {
  background: #e7f0ff;
  color: #1d4f91;
}

.button,
.icon-button,
.note-color {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.button {
  height: 32px;
  padding: 0 13px;
  cursor: pointer;
  white-space: nowrap;
}

.danger-button {
  border-color: #fecaca;
  color: #b42318;
}

.topbar .button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.top-letter {
  min-width: 24px;
  padding: 0 4px;
  color: #aab4c2;
  font-size: 14px;
  font-weight: 800;
}

.ghost-link,
.trash-link {
  height: 28px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: #9aa4b2;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-link:hover,
.trash-link:hover {
  color: #dbe4ef;
}

.hidden {
  display: none !important;
}

.board {
  position: relative;
  height: 100%;
  padding-top: 48px;
  overflow: auto;
  transition: padding-top 180ms ease;
}

.empty-board {
  position: absolute;
  top: 82px;
  left: 24px;
  padding: 9px 12px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 13px;
}

.note {
  position: absolute;
  display: grid;
  grid-template-rows: 38px 1fr 78px;
  min-width: 220px;
  min-height: 160px;
  border: 1px solid rgba(31, 35, 40, 0.16);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(31, 35, 40, 0.14);
  resize: both;
  overflow: hidden;
}

.note[data-color="yellow"] {
  background: var(--yellow);
}

.note[data-color="blue"] {
  background: var(--blue);
}

.note[data-color="green"] {
  background: var(--green);
}

.note[data-color="pink"] {
  background: var(--pink);
}

.note[data-color="white"] {
  background: var(--white);
}

.note-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px 4px;
  cursor: grab;
  user-select: none;
}

.note.dragging .note-head {
  cursor: grabbing;
}

.note.file-drop-target {
  outline: 2px solid rgba(22, 163, 74, 0.82);
  outline-offset: 3px;
  box-shadow:
    0 12px 28px rgba(31, 35, 40, 0.14),
    0 0 0 4px rgba(22, 163, 74, 0.16);
}

.note-title {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.note-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.icon-button {
  width: 25px;
  height: 25px;
  padding: 0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.note-body {
  width: 100%;
  height: 100%;
  padding: 8px 10px;
  border: 0;
  outline: 0;
  resize: none;
  overflow: auto;
  background: transparent;
  color: var(--ink);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.note.closed {
  height: 38px !important;
  min-height: 38px;
  resize: none;
}

.note.closed .note-body,
.note.closed .note-foot {
  display: none;
}

.note.palette-hidden {
  grid-template-rows: 38px 1fr 35px;
}

.note-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 109px 26px;
  grid-template-rows: 36px 22px;
  grid-template-areas:
    "attachments palette palette"
    "attachments updated collapse";
  gap: 7px 9px;
  align-items: center;
  padding: 5px 8px 8px;
}

.note.palette-hidden .note-foot {
  grid-template-columns: minmax(0, 1fr) 109px 26px;
  grid-template-rows: 22px;
  grid-template-areas: "attachments updated collapse";
}

.note.palette-hidden .color-palette {
  display: none;
}

.color-palette {
  grid-area: palette;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-self: end;
  width: 144px;
  padding: 6px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  background: #fff;
}

.color-swatch {
  position: relative;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(31, 35, 40, 0.2);
  border-radius: 6px;
  cursor: pointer;
}

.color-swatch[data-color="yellow"] {
  background: var(--yellow);
  border-color: #d8ca7b;
}

.color-swatch[data-color="blue"] {
  background: var(--blue);
  border-color: #adc2d5;
}

.color-swatch[data-color="green"] {
  background: var(--green);
  border-color: #b1ccb4;
}

.color-swatch[data-color="pink"] {
  background: var(--pink);
  border-color: #d2b0bc;
}

.color-swatch[data-color="white"] {
  background: var(--white);
  border-color: #cdd1d5;
}

.color-swatch.active {
  z-index: 1;
  box-shadow:
    0 0 0 1px #fff,
    0 0 0 3px rgba(74, 74, 74, 0.72);
}

.color-swatch.active::after {
  content: none;
}

.updated {
  grid-area: updated;
  justify-self: end;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-attachments {
  grid-area: attachments;
  display: flex;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
}

.note-collapse {
  grid-area: collapse;
  position: relative;
  width: 26px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 0;
  cursor: pointer;
}

.note-collapse::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 5px;
  background: currentColor;
  clip-path: polygon(0 0, 50% 62%, 100% 0, 100% 38%, 50% 100%, 0 38%);
  content: "";
  transform: translate(-50%, -50%);
}

.note.palette-hidden .note-collapse::before {
  transform: translate(-50%, -50%) rotate(180deg);
}

.attachment-item {
  display: inline-flex;
  min-width: 0;
  max-width: 146px;
  height: 23px;
}

.attachment-link {
  min-width: 0;
  max-width: 118px;
  height: 23px;
  padding: 3px 7px;
  border: 1px solid rgba(31, 35, 40, 0.14);
  border-right: 0;
  border-radius: 6px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background: rgba(255, 255, 255, 0.64);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.attachment-remove {
  width: 24px;
  height: 23px;
  padding: 0;
  border: 1px solid rgba(31, 35, 40, 0.14);
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.remote-focus {
  display: none;
  max-width: 76px;
  height: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(31, 35, 40, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  color: #1f2937;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.note.has-remote-focus .remote-focus {
  display: block;
}

.note.has-remote-focus {
  border-color: #2563eb;
  box-shadow:
    0 12px 28px rgba(31, 35, 40, 0.14),
    0 0 0 2px rgba(37, 99, 235, 0.24) inset;
}

.modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 70px 16px 16px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 96px);
  overflow: hidden;
  border: 1px solid rgba(31, 35, 40, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
}

.modal-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

.auth-panel {
  width: min(360px, 100%);
}

.auth-form,
.users-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.auth-form input,
.user-create input,
.user-create select,
.reset-pin {
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.auth-error {
  min-height: 16px;
  color: #b42318;
  font-size: 12px;
}

.user-create {
  display: grid;
  grid-template-columns: 1fr 100px 90px auto;
  gap: 8px;
}

.users-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}

.user-row {
  display: grid;
  grid-template-columns: 1fr 72px 120px auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background: #fff;
}

.user-row.disabled-user {
  color: var(--muted);
  background: #f8fafc;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-role {
  color: var(--muted);
  font-size: 12px;
}

.trash-list {
  display: grid;
  gap: 1px;
  max-height: calc(100vh - 150px);
  overflow: auto;
  background: var(--line);
}

.trash-empty,
.trash-item {
  background: #fff;
}

.trash-empty {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.trash-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.trash-main {
  min-width: 0;
}

.trash-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.trash-preview,
.trash-date {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.trash-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 560px) and (pointer: coarse) {
  body {
    overflow: auto;
    background-size: 18px 18px;
  }

  .topbar {
    flex-wrap: wrap;
    align-content: center;
    height: auto;
    min-height: 92px;
    gap: 7px;
    padding: 7px 10px 10px;
    box-shadow: 0 10px 22px rgba(31, 35, 40, 0.18);
  }

  .brand {
    font-size: 14px;
  }

  .status {
    display: none;
  }

  .board-tabs {
    order: 2;
    flex: 1 1 100%;
    justify-content: center;
  }

  .board-tab {
    padding: 0 8px;
    font-size: 11px;
  }

  .board {
    display: grid;
    gap: 12px;
    height: auto;
    min-height: 100%;
    padding: 128px 10px 18px;
    overflow: visible;
  }

  .empty-board {
    position: static;
    padding: 14px;
    text-align: center;
  }

  .note {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    max-width: none;
    min-height: calc(100dvh - 150px);
    height: auto !important;
    resize: none;
    grid-template-rows: 42px minmax(300px, 1fr) 78px;
  }

  .note.palette-hidden {
    grid-template-rows: 42px minmax(300px, 1fr) 35px;
  }

  .note-head {
    cursor: default;
  }

  .note-title,
  .note-body,
  .button,
  .note-color {
    font-size: 16px;
  }

  .topbar .button {
    height: 30px;
    padding: 0 9px;
    font-size: 12px;
  }

  .ghost-link,
  .trash-link {
    font-size: 12px;
  }

  .modal {
    padding: 62px 8px 8px;
  }

  .trash-item {
    grid-template-columns: 1fr;
  }

  .trash-actions {
    justify-content: flex-end;
  }

  .user-create,
  .user-row {
    grid-template-columns: 1fr;
  }

  .note-body {
    min-height: 190px;
    overflow: auto;
  }

  .icon-button {
    width: 32px;
    height: 30px;
    font-size: 12px;
  }

  .updated {
    font-size: 12px;
  }

  .note-collapse {
    width: 26px;
    height: 22px;
    border-radius: 6px;
  }
}
