/* Бумажный стикер: неровный край, лёгкий разворот, загнутый уголок */
.sticker {
  position: relative;
  border-radius: 2px 10px 3px 8px / 8px 3px 10px 2px;
  padding: 9px 10px 8px;
  color: var(--paper-ink);
  cursor: grab;
  box-shadow: var(--shadow-sticker);
  border: none;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .14s ease, box-shadow .14s ease, filter .14s;
  user-select: none;
  background-color: var(--paper, var(--paper-0));
  background-image:
    /* волокна бумаги */
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .016) 0 1px, transparent 1px 4px),
    /* тень от загнутого угла и общий световой градиент */
    linear-gradient(160deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 42%),
    linear-gradient(200deg, rgba(0, 0, 0, .1), rgba(0, 0, 0, 0) 30%);
}

/* Загнутый уголок */
.sticker::after {
  content: "";
  position: absolute; right: 0; bottom: 0;
  width: 16px; height: 16px;
  background: linear-gradient(135deg, transparent 48%, rgba(0, 0, 0, .16) 50%, rgba(255, 255, 255, .45) 52%);
  border-bottom-right-radius: 3px;
}

.sticker:hover { transform: rotate(var(--tilt, 0deg)) translateY(-2px); box-shadow: var(--shadow-sticker-drag); }
.sticker.dragging { opacity: .4; cursor: grabbing; }
.sticker.link-source { outline: 2px dashed var(--accent-blue); outline-offset: 3px; }
.sticker.link-hover { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
.sticker.selected { outline: 2px solid var(--accent-purple); outline-offset: 3px; }

.sticker .title { font-weight: 600; font-size: 12.5px; word-break: break-word; letter-spacing: .1px; }
.sticker.crossed .title { text-decoration: line-through; opacity: .6; }

.sticker .meta {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-top: 5px; font-size: 11px; color: var(--paper-ink-soft);
}
.sticker .who {
  background: rgba(0, 0, 0, .1); border-radius: 999px; padding: 0 6px; white-space: nowrap;
}
.sticker .hours { font-variant-numeric: tabular-nums; }

/* Верхняя полоса: звёзды слева, отметки статуса справа */
.sticker .top-line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin: -2px 0 2px;
}
.sticker .stars { font-size: 10px; letter-spacing: -1px; color: rgba(0, 0, 0, .5); }
.sticker .status-row { display: inline-flex; gap: 3px; }
.sticker .status-btn {
  width: 20px; height: 18px; padding: 0; line-height: 1; font-size: 11px; font-weight: 700;
  border-radius: 5px; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, .18);
  background: rgba(255, 255, 255, .45); color: rgba(0, 0, 0, .45);
}
.sticker .status-btn:hover { background: #fff; color: var(--paper-ink); }
.sticker .status-btn.on.done { background: #2f9e44; border-color: #26773a; color: #fff; }
.sticker .status-btn.on.transferred { background: #d9860f; border-color: #a9680c; color: #fff; }
.sticker .status-btn.on.cancelled { background: #c9382e; border-color: #9c2b23; color: #fff; }

/* Закрытая задача уходит в неактивный цвет */
.sticker.closed { filter: saturate(.25); }
.sticker.closed .title { opacity: .6; }

.sticker .links { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.sticker .links a {
  font-size: 10px; text-decoration: none; color: var(--paper-ink);
  background: rgba(255, 255, 255, .55); border-radius: 4px; padding: 0 5px;
  border: 1px solid rgba(0, 0, 0, .08);
}
.sticker .links a:hover { background: #fff; }
.sticker .links a, .sticker .links button {
  font-size: 10px; text-decoration: none; color: var(--paper-ink);
  background: rgba(255, 255, 255, .55); border-radius: 4px; padding: 1px 6px;
  border: 1px solid rgba(0, 0, 0, .08); cursor: pointer;
}
.sticker .links a.sheet { background: rgba(63, 185, 80, .45); font-weight: 600; }
.sticker .links a.task { background: rgba(88, 166, 255, .45); font-weight: 600; }
.sticker .links a.doc { background: rgba(188, 140, 255, .4); font-weight: 600; }
.sticker .links button.attach { background: rgba(210, 153, 34, .45); font-weight: 600; }

.sticker .status-dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(0, 0, 0, .35);
}
.sticker .status-dot.not_started { background: transparent; }
.sticker .status-dot.in_progress { background: #fff; }
.sticker .status-dot.done { background: #17692d; }
.sticker .status-dot.transferred { background: #9a5b12; }
.sticker .status-dot.cancelled { background: #7d2019; }

/* Метка типа задачи и признаки вложений */
.sticker .type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 0 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .55); color: var(--paper-ink); white-space: nowrap;
}
.sticker .type-badge i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.sticker .marks { display: inline-flex; gap: 4px; font-size: 10px; color: var(--paper-ink-soft); }
.sticker .marks span { display: inline-flex; align-items: center; gap: 2px; }

.sticker .handle { position: absolute; right: 5px; bottom: 4px; display: none; gap: 3px; }
.sticker:hover .handle { display: flex; }
.sticker .handle button {
  width: 18px; height: 18px; padding: 0; line-height: 1; font-size: 10px;
  border-radius: 5px; border: 1px solid rgba(0, 0, 0, .18);
  background: rgba(255, 255, 255, .7); color: var(--paper-ink); cursor: pointer;
}
.sticker .handle button:hover { background: #fff; }

/* ------------------------------------------------- канцелярская кнопка */
.pin-handle {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  cursor: crosshair; opacity: 0; pointer-events: none;
  transition: opacity .12s, transform .12s;
  background:
    radial-gradient(circle at 34% 30%, #fff, rgba(255, 255, 255, .1) 42%, transparent 46%),
    radial-gradient(circle at 50% 50%, var(--pin-color, var(--accent-blue)) 60%, rgba(0, 0, 0, .35));
  box-shadow: 0 2px 4px rgba(0, 0, 0, .45);
  z-index: 4;
}
/* Булавки появляются только при наведении на сам стикер */
.sticker:hover .pin-handle, .pin-handle.armed { opacity: .95; pointer-events: all; }
.pin-handle:hover { transform: scale(1.5); }
.pin-handle.top { top: -5px; left: 50%; margin-left: -4.5px; }
.pin-handle.right { right: -5px; top: 50%; margin-top: -4.5px; }
.pin-handle.bottom { bottom: -5px; left: 50%; margin-left: -4.5px; }
.pin-handle.left { left: -5px; top: 50%; margin-top: -4.5px; }

/* Стикер лежит на доске свободно: координаты — внутри своей ячейки */
.sticker {
  position: absolute;
  width: var(--sticker-width, calc(var(--col-width) - 22px));
  min-height: var(--sticker-height, auto);
  z-index: 3;
}
/* Растянутый лист лежит под обычными: иначе он накрывает соседние задачи */
.sticker.spanning { z-index: 2; }
.sticker.spanning:hover { z-index: 6; }
.sticker .resize {
  position: absolute; display: none; z-index: 5;
  background: rgba(0, 0, 0, .12); border-radius: 2px;
}
.sticker:hover .resize { display: block; }
.sticker .resize:hover { background: rgba(0, 0, 0, .3); }
/* Ручки размера — по углам: стороны заняты булавками связей */
.sticker .resize { width: 11px; height: 11px; border-radius: 3px; }
.sticker .resize.se { right: 0; bottom: 0; cursor: nwse-resize; }
.sticker .resize.ne { right: 0; top: 0; cursor: nesw-resize; }
.sticker .resize.sw { left: 0; bottom: 0; cursor: nesw-resize; }
.sticker.resizing { opacity: .85; }

/* Цепочка ответственных */
.sticker .chain { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.sticker .chain .step {
  background: rgba(0, 0, 0, .1); border-radius: 999px; padding: 0 6px; white-space: nowrap;
}
.sticker .chain .step.current { background: rgba(255, 255, 255, .62); font-weight: 600; }
.sticker .chain i { opacity: .5; font-style: normal; }

/* Призрак при перетаскивании */
.drag-ghost { position: fixed; pointer-events: none; z-index: 300; opacity: .92; }

/* Легенда */
.legend { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-secondary); }
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 3px;
  vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .3); }
.legend .line { display: inline-block; width: 16px; height: 0; border-top: 2px solid; margin-right: 3px;
  vertical-align: 4px; }


/* SMART-подсказка и срок */
.sticker .smart-line { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 10px; }
.sticker .smart-badge {
  padding: 0 5px; border-radius: 4px; font-weight: 600;
  background: rgba(255, 255, 255, .5); color: var(--paper-ink);
}
.sticker .smart-badge.low { background: rgba(248, 81, 73, .35); }
.sticker .smart-badge.mid { background: rgba(210, 153, 34, .35); }
.sticker .smart-badge.ok { background: rgba(63, 185, 80, .35); }
.sticker .due { color: var(--paper-ink-soft); }
.sticker .due.overdue { color: #a3231a; font-weight: 700; }
