/* ==========================================================================
   Stickies — shared styles. Design tokens taken from the Figma prototype.
   ========================================================================== */
:root {
  --paper: #F0EBE3;
  --line: #D4CFC8;
  --line-soft: #E8E3DC;
  --primary: #5B4FCF;
  --primary-dark: #4A3EBE;
  --primary-soft: #C5A3FF;
  --ink: #1A1A2E;
  --muted: #7A7A8C;
  --card: #FFFFFF;
  --yellow: #FFE566;
  --radius: 16px;
  --font-body: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.spacer { flex: 1; }
.inline { display: inline; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(240, 235, 227, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1152px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.brand-logo {
  width: 32px; height: 32px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; box-shadow: 0 1px 3px rgba(0,0,0,.12);
  background: linear-gradient(135deg, #FFE566 0%, #FF8FAB 50%, #C5A3FF 100%);
}
.brand-logo.big { width: 56px; height: 56px; font-size: 28px; border-radius: 18px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }

.search { position: relative; flex: 1; min-width: 150px; }
.search span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--muted); }
.search input {
  width: 100%; padding: 9px 12px 9px 32px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); font-weight: 500; font-size: 14px;
}
.search input:focus { outline: none; border-color: var(--primary); }
.search input::placeholder { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 700;
  border: 2px solid var(--line); background: transparent; color: var(--ink);
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--line-soft); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { border: 2px solid var(--line); color: var(--primary); }
.btn-ghost:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger { color: #DC2626; border-color: #F0C7C7; }
.btn-danger:hover { background: #FDECEC; }
.btn-mini { padding: 4px 8px; font-size: 12px; border-width: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; padding: 5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; background: var(--line-soft); color: var(--muted);
}
.pill.on { background: var(--primary); color: #fff; }

.user-box { display: flex; align-items: center; gap: 8px; margin-left: 4px; padding-left: 10px; border-left: 1px solid var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
}
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.user-name-sm { font-size: 13px; font-weight: 700; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: var(--muted); font-size: 15px; padding: 2px 6px; }
.logout:hover { color: #EF4444; }
.menu-btn { background: none; border: none; font-size: 18px; color: var(--muted); display: none; }

/* ---------------------------------------------------------------- layout */
.layout { display: flex; flex: 1; max-width: 1152px; width: 100%; margin: 0 auto; }
.sidebar {
  width: 208px; flex-shrink: 0; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line);
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.sidebar-title {
  font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .14em; margin: 0 0 8px 4px;
}
.sidebar-title + .sidebar-title { margin-top: 16px; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: transparent; border-radius: 12px;
  font-size: 13px; font-weight: 700; color: var(--ink); transition: background .15s;
}
.nav-item:hover { background: var(--line-soft); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11px; font-weight: 500; color: var(--muted); }
.nav-item.active .count { color: rgba(255,255,255,.75); }
.drag-over-folder { outline: 2px dashed var(--primary); outline-offset: 2px; }

.board-main { flex: 1; padding: 24px; overflow-y: auto; min-width: 0; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.board-title { font-size: 24px; font-weight: 700; }
.board-sub { font-size: 13px; font-weight: 700; color: var(--muted); }

.section { margin-bottom: 24px; }
.section-label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; margin: 0 0 12px; }
.folder-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.folder-toggle { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; background: none; border: none; padding: 0; text-align: left; }
.folder-icon {
  width: 32px; height: 32px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.folder-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 11px; font-weight: 800; color: var(--muted); background: var(--line-soft); border-radius: 999px; padding: 2px 8px; line-height: 1.5; }
.chip-admin { background: #EDE9FE; color: #5B4FCF; }
.chip-off { background: #FDECEC; color: #B91C1C; }
.chev { color: var(--muted); font-size: 12px; margin-left: auto; }
.folder-del { opacity: 0; background: none; border: none; color: var(--muted); font-size: 12px; padding: 4px; border-radius: 8px; transition: opacity .15s; }
.folder-head:hover .folder-del { opacity: 1; }
.folder-del:hover { color: #EF4444; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.empty-note { grid-column: 1 / -1; font-size: 13px; font-style: italic; font-weight: 500; color: var(--muted); padding: 6px 0; }

/* ------------------------------------------------------------------ notes */
.note {
  position: relative; display: flex; flex-direction: column;
  border-radius: var(--radius); box-shadow: 0 4px 10px rgba(0,0,0,.08);
  min-height: 180px; overflow: visible;
  transform: rotate(var(--r, 0deg));
  transition: height .3s cubic-bezier(.4,0,.2,1), transform .2s, box-shadow .2s;
}
.note:hover { box-shadow: 0 12px 24px rgba(0,0,0,.16); }
.note::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}
.note.dragging { opacity: .45; transform: rotate(var(--r, 0deg)) scale(.97); }
.note.drop-target { outline: 3px dashed rgba(91,79,207,.65); outline-offset: 3px; }
.note.folded { height: 52px; min-height: 52px; overflow: hidden; }
.fold-corner { position: absolute; top: 0; right: 0; width: 28px; height: 28px; overflow: hidden; border-top-right-radius: var(--radius); }
.fold-corner::before {
  content: ""; position: absolute; top: 0; right: 0;
  filter: drop-shadow(-1px 1px 1px rgba(0,0,0,.1));
  border-top: 0 solid transparent; border-bottom: 28px solid transparent;
  border-left: 0 solid transparent; border-right: 28px solid rgba(0,0,0,.12);
}
.note-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 6px; cursor: pointer; user-select: none; }
.fold-toggle { font-size: 13px; background: none; border: none; padding: 0; line-height: 1; }
.grip { font-size: 12px; line-height: 1; opacity: .28; cursor: grab; user-select: none; }
.note:hover .grip { opacity: .7; }
.grip:active { cursor: grabbing; }
.note-title {
  flex: 1; font-weight: 800; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  outline: none; min-width: 20px;
}
.note-title:focus { border-bottom: 1px dashed currentColor; }
.note-menu-wrap { position: relative; }
.menu-dots {
  width: 24px; height: 24px; border: none; background: transparent; border-radius: 999px;
  font-size: 13px; opacity: 0; transition: opacity .15s;
}
.note:hover .menu-dots, .note:focus-within .menu-dots { opacity: 1; }
.menu-dots:hover { background: rgba(0,0,0,.1); }
@media (hover: none) { .menu-dots { opacity: 1; } }
.note-menu {
  position: absolute; right: 0; top: 28px; width: 168px; z-index: 40;
  background: #fff; border: 1px solid var(--line-soft); border-radius: 12px;
  box-shadow: 0 16px 32px rgba(0,0,0,.18); overflow: hidden; color: var(--ink);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: none; font-size: 13px; font-weight: 600; color: var(--ink);
}
.menu-item:hover { background: var(--paper); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 2px 0; }
.menu-label { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; padding: 8px 12px 4px; }
.menu-item .dot { width: 12px; height: 12px; border-radius: 999px; border: 1px solid rgba(0,0,0,.1); }
.menu-item input[type="datetime-local"] { font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 5px; width: 100%; }

.note-body { flex: 1; display: flex; flex-direction: column; padding: 0 12px 12px; gap: 8px; }
.note-text {
  flex: 1; width: 100%; min-height: 96px; background: transparent; border: none; resize: none;
  font-size: 13px; line-height: 1.6; font-weight: 500;
}
.note-text:focus { outline: none; }
.note-text::placeholder { color: currentColor; opacity: .45; }
.note-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 999px; border: 1px solid rgba(0,0,0,.1); transition: transform .12s; }
.swatch:hover { transform: scale(1.12); }
.swatch.on { box-shadow: 0 0 0 2px currentColor, 0 0 0 4px #fff; }
.folder-select {
  font-size: 11px; font-weight: 700; background: rgba(0,0,0,.1); border: none;
  border-radius: 8px; padding: 3px 6px; cursor: pointer; max-width: 120px;
}
.note-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 10px; font-weight: 700; opacity: .62; padding: 0 12px 10px; }
.due-badge { display: inline-flex; align-items: center; gap: 4px; background: rgba(0,0,0,.1); border-radius: 999px; padding: 1px 7px; }
.due-badge.late { background: rgba(220,38,38,.22); }

/* locked + folded states */
.locked-panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px 0; cursor: pointer; }
.locked-panel .big { font-size: 28px; }
.locked-panel .hint { font-size: 11px; font-weight: 800; opacity: .65; }
.blurred { filter: blur(4px); user-select: none; pointer-events: none; }

/* checklist */
.checklist { display: flex; flex-direction: column; gap: 6px; }
.cl-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 500; }
.cl-item input[type=checkbox] { width: 15px; height: 15px; margin-top: 3px; accent-color: var(--primary); flex-shrink: 0; }
.cl-item.done .cl-text { text-decoration: line-through; opacity: .58; }
.cl-text { flex: 1; word-break: break-word; background: none; border: none; color: inherit; font: inherit; text-align: left; padding: 0; }
.cl-del { border: none; background: none; font-size: 11px; opacity: .4; }
.cl-del:hover { opacity: 1; color: #B91C1C; }
.cl-add { width: 100%; background: transparent; border: none; border-bottom: 1px dashed currentColor; font-size: 12px; padding: 3px 0; opacity: .85; }
.cl-add:focus { outline: none; opacity: 1; }
.cl-add::placeholder { color: currentColor; opacity: .5; }
.cl-progress { font-size: 10px; font-weight: 800; opacity: .6; }

/* --------------------------------------------------------------- modals */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4); backdrop-filter: blur(4px); padding: 16px;
}
.modal {
  background: #fff; border-radius: 18px; box-shadow: 0 24px 48px rgba(0,0,0,.25);
  padding: 22px; width: 340px; max-width: 100%; max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 19px; }
.modal .field-label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.modal input[type=text], .modal input[type=password], .modal input[type=datetime-local], .modal select {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #FAFAF8; font-weight: 500;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; justify-content: center; padding: 10px; }
.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick { width: 36px; height: 36px; border: none; border-radius: 10px; font-size: 17px; background: transparent; }
.icon-pick.on { background: var(--paper); box-shadow: 0 0 0 2px var(--primary); }
.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-pick { width: 28px; height: 28px; border-radius: 999px; border: 1px solid rgba(0,0,0,.1); }
.color-pick.on { box-shadow: 0 0 0 2px currentColor, 0 0 0 4px #fff; }
.pin-input { text-align: center; letter-spacing: 8px; font-size: 18px; font-weight: 800; font-family: var(--font-mono); }
.shake { animation: shake .45s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.modal-error { font-size: 12px; font-weight: 700; color: #B91C1C; }
.modal-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ---------------------------------------------------------------- alerts */
.alert { border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.alert-error { background: #FDECEC; color: #9B1C1C; }
.alert-ok { background: #E7F7EF; color: #0F5132; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1A1A2E; color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 12px; z-index: 80; box-shadow: 0 10px 24px rgba(0,0,0,.25);
}

/* ------------------------------------------------------- simple pages */
.page-plain { background: var(--paper); }
.simple-shell { min-height: 100vh; display: flex; flex-direction: column; }
.simple-main { flex: 1; width: 100%; max-width: 1152px; margin: 0 auto; padding: 24px; }
.simple-main.narrow { max-width: 720px; }
.panel { background: #fff; border: 1px solid var(--line-soft); border-radius: 18px; box-shadow: 0 4px 12px rgba(0,0,0,.06); overflow: hidden; }
.panel + .panel { margin-top: 16px; }
.panel-pad { padding: 20px; }
.panel-title { font-size: 16px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stack input, .stack select { border: 2px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; font-weight: 500; color: var(--ink); background: #FAFAF8; text-transform: none; letter-spacing: 0; }
.stack input:focus, .stack select:focus { outline: none; border-color: var(--primary); }
.user-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); padding: 12px 14px; background: #FAF8F5; border-bottom: 1px solid var(--line-soft);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .row-off { opacity: .55; }
.user-cell { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.dlg { border: none; border-radius: 18px; padding: 22px; width: 340px; max-width: 92vw; box-shadow: 0 24px 48px rgba(0,0,0,.28); }
.dlg::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(3px); }
.dlg-form { display: flex; flex-direction: column; gap: 12px; }
.dlg-form h3 { font-size: 19px; }
.dlg-form label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dlg-form input, .dlg-form select { border: 2px solid var(--line-soft); border-radius: 12px; padding: 9px 12px; background: #FAFAF8; font-weight: 500; }
.dlg-form input:focus, .dlg-form select:focus { outline: none; border-color: var(--primary); }
.dlg-actions { display: flex; gap: 8px; margin-top: 4px; }
.dlg-actions .btn { flex: 1; justify-content: center; padding: 10px; }

.err-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.err-card { background: #fff; border-radius: 18px; padding: 32px; text-align: center; box-shadow: 0 12px 32px rgba(0,0,0,.1); }
.err-emoji { font-size: 40px; }
.err-card h1 { font-size: 34px; margin: 6px 0 4px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: 258px;
    height: 100vh; background: var(--paper); border-right: 1px solid var(--line);
    transform: translateX(-102%); transition: transform .22s ease; padding-top: 20px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .board-main { padding: 18px 14px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .note { min-height: 158px; }
  .board-title { font-size: 20px; }
  .topbar-inner { gap: 8px; padding: 10px 12px; }
  .user-name-sm { display: none; }
  .section-label { font-size: 11px; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .note-title { font-size: 12px; }
  .note-text { min-height: 84px; }
  .btn span.lbl-hide { display: none; }
  .board-head { margin-bottom: 16px; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}
