:root {
  --note-yellow: #ffd84a;
  --note-orange: #ff9f45;
  --note-red:    #ff7d6d;
  --note-pink:   #ff8ec4;
  --note-purple: #bd8cf5;
  --note-blue:   #6fb2ff;
  --note-teal:   #45d3bd;
  --note-green:  #a3e05a;

  --bg: #f1ede4;
  --panel: #fffdf8;
  --ink: #26231d;
  --muted: #7c7568;
  --line: #ded7c9;
  --danger: #b91c1c;

  --shadow: 0 1px 2px rgba(0, 0, 0, .10), 0 6px 14px rgba(0, 0, 0, .07);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(0, 0, 0, .045) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; cursor: pointer; }

.ghost {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 8px 12px;
}
.ghost:hover { background: #fff; border-color: #c9c0ae; }
.ghost.small { padding: 5px 9px; font-size: 13px; }
.ghost.danger { color: var(--danger); }

/* ------------------------------- Login --------------------------------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 20px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 100%);
  padding: 26px;
  background: color-mix(in srgb, var(--note-yellow) 45%, #fff);
  border-radius: 3px;
  box-shadow: var(--shadow);
  transform: rotate(-1.2deg);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card label { font-size: 13px; color: #6b6350; }
.login-card input {
  font: inherit;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 6px;
  background: rgba(255, 255, 255, .75);
}
.login-card button {
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
}
.login-card button:disabled { opacity: .6; }
.error { margin: 0; color: var(--danger); font-size: 13px; }

/* ------------------------------- Layout -------------------------------- */

.app { display: flex; height: 100dvh; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 220px;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar h1 { margin: 0 0 6px; font-size: 16px; }
.sidebar-footer { margin-top: auto; padding-top: 12px; }

.board-list { display: flex; flex-direction: column; gap: 4px; }
.board-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  color: inherit;
  width: 100%;
}
.board-list button:hover { background: #f6f2e9; }
.board-list button[aria-current="true"] { background: #efe9dc; border-color: var(--line); font-weight: 600; }
.board-list .dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.board-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.board-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.board-header h2 { margin: 0; font-size: 18px; }
.spacer { flex: 1; }

.columns {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  overflow-x: auto;
  flex: 1;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 270px;
  max-height: 100%;
  padding: 12px;
  background: rgba(255, 253, 248, .72);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.column.drop-target { border-color: #9c9384; background: #fffdf8; }
.column-head { display: flex; align-items: center; gap: 6px; }
.column-head h3 { margin: 0; font-size: 14px; flex: 1; }
.column-head h3.editable { cursor: text; }
.column-head .count { color: var(--muted); font-size: 12px; }
.column-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 24px;
  overflow-x: hidden;   /* the slight card rotation would cause scrollbars */
  overflow-y: auto;
  padding: 3px;         /* room for shadow and rotation */
  margin: -3px;
}

.add-column { flex: 0 0 200px; }

/* -------------------------------- Note --------------------------------- */

.note {
  position: relative;
  padding: 12px 12px 8px;
  border-radius: 3px;
  box-shadow: var(--shadow);
  background: var(--note-yellow);
  cursor: grab;
  word-break: break-word;
}
.note:nth-child(3n)   { transform: rotate(.7deg); }
.note:nth-child(3n+1) { transform: rotate(-.6deg); }
.note.dragging { opacity: .4; }
.note.editing { cursor: default; transform: none; }


/* Dark custom board color: lighten the note text and its chrome. */
.note-on-dark { color: #fff; }
.note-on-dark .note-text.empty::before,
.note-on-dark .note-board { color: rgba(255, 255, 255, .6); }
.note-on-dark .icon-btn { background: rgba(255, 255, 255, .18); color: rgba(255, 255, 255, .9); }
.note-on-dark .icon-btn:hover { background: rgba(255, 255, 255, .3); }
.note-on-dark textarea { background: rgba(0, 0, 0, .25); color: #fff; border-color: rgba(255, 255, 255, .3); }

.note-text { white-space: pre-wrap; min-height: 20px; }
.note-text.empty::before { content: "Empty — click to write"; color: rgba(0, 0, 0, .35); }

.note textarea {
  width: 100%;
  min-height: 90px;
  font: inherit;
  background: rgba(255, 255, 255, .6);
  border: 1px solid rgba(0, 0, 0, .15);
  border-radius: 4px;
  padding: 6px;
  resize: vertical;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .12s;
}
.note:hover .note-actions,
.note:focus-within .note-actions { opacity: 1; }
@media (hover: none) { .note-actions { opacity: 1; } }

.icon-btn {
  border: 0;
  background: rgba(0, 0, 0, .06);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(0, 0, 0, .65);
}
.icon-btn:hover { background: rgba(0, 0, 0, .12); }

.swatches { display: flex; gap: 4px; }
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .18);
  padding: 0;
}
.swatch[aria-pressed="true"] { outline: 2px solid rgba(0, 0, 0, .45); outline-offset: 1px; }

.placeholder {
  height: 46px;
  border: 2px dashed #b3aa98;
  border-radius: 6px;
  background: rgba(255, 255, 255, .35);
}

/* "Move to" menu (touch fallback for drag & drop) */
.menu {
  position: absolute;
  z-index: 20;
  right: 8px;
  top: 8px;
  min-width: 150px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 13px;
}
.menu button:hover { background: #f2ede2; }
.menu button:disabled { color: var(--muted); cursor: default; }
.menu .menu-label { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; }

.empty-hint { color: var(--muted); padding: 24px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.only-mobile { display: none; }

@media (max-width: 720px) {
  .only-mobile { display: inline-block; }
  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .sidebar.open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 30; }
  .column { flex-basis: 82vw; }
}

/* ----------------------------- Board dialog ----------------------------- */

.board-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
}
.board-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.board-dialog form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-top: 8px solid var(--preview, var(--note-yellow));
  border-radius: 13px 13px 0 0;
}
.board-dialog h2 { margin: 0 0 4px; font-size: 17px; }
.board-dialog label { font-size: 13px; color: var(--muted); }
.hint-inline { font-size: 12px; }
.board-dialog input {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
.board-dialog .swatches { gap: 8px; margin: 2px 0 6px; flex-wrap: wrap; }
.board-dialog .swatch { width: 26px; height: 26px; }

/* Custom color: the native color input sits invisibly inside the swatch. */
.swatch-custom { position: relative; overflow: hidden; }
.swatch-custom input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  padding: 0;
  border: 0;
  background: none;
  opacity: 0;
  cursor: pointer;
}
.swatch-custom .pen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 12px;
  pointer-events: none;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dialog-actions .submit {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
}


/* Which board a note belongs to, shown in the all-boards view */
.note-board {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, .42);
  margin-bottom: 5px;
}

.board-list .dot-all {
  background: conic-gradient(
    var(--note-yellow), var(--note-orange), var(--note-red), var(--note-pink),
    var(--note-purple), var(--note-blue), var(--note-teal), var(--note-green),
    var(--note-yellow)
  );
}
.board-list .overview-link { margin-bottom: 4px; }
