:root {
  --bg: #f0ead8;
  --ink: #2b2620;
  --muted: #7a715f;
  --line: rgba(43, 38, 32, 0.12);
  --p1: #3aa46f;
  --p2: #3d7fd9;
  --p3: #b5821e;
  --p4: #d4577e;
  --note-yellow: #fff3a3;
  --note-pink: #ffd1e3;
  --note-blue: #c7e6ff;
  --note-green: #d2f5c4;
  --note-orange: #ffe0b8;
  --note-purple: #e6d6ff;
}

* { box-sizing: border-box; }

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

body {
  font-family: "IBM Plex Sans KR", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(rgba(43, 38, 32, 0.055) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(240, 234, 216, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.title-wrap h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.save-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.25s ease;
  white-space: nowrap;
}
.save-status.visible { opacity: 1; }

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: #fdf9ee;
  box-shadow: 0 2px 0 rgba(43, 38, 32, 0.35);
}
.btn-primary:hover { background: #443c32; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn-ghost:hover { background: rgba(43, 38, 32, 0.05); color: var(--ink); }

/* ---------- board & lanes ---------- */
.board {
  position: relative;
  flex: 1;
  overflow: auto;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* each phase = 1/4 of full width */
  width: 100%;
  min-width: 1920px;
  min-height: calc(100vh - 70px);
}

.lane {
  border-right: 2px dashed var(--line);
  padding: 18px 20px;
}
.lane:last-child { border-right: none; }
.lane[data-phase="p4"] { background: rgba(212, 87, 126, 0.05); }

.lane-header h2 {
  margin: 8px 0 4px;
  font-size: 17px;
  font-weight: 700;
}
.lane-header p {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 340px;
}

.lane-chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
}
.chip-p1 { background: var(--p1); }
.chip-p2 { background: var(--p2); }
.chip-p3 { background: var(--p3); }
.chip-p4 { background: var(--p4); }

/* ---------- notes ---------- */
.notes-layer {
  position: absolute;
  inset: 0;
  min-width: 1920px;
  pointer-events: none;
}
.notes-layer .note { pointer-events: auto; }

.note {
  position: absolute;
  width: 218px;
  min-height: 150px;
  padding: 30px 14px 14px;
  background: var(--note-yellow);
  box-shadow: 1px 3px 8px rgba(43, 38, 32, 0.22);
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
}
.note.dragging {
  cursor: grabbing;
  box-shadow: 4px 10px 22px rgba(43, 38, 32, 0.3);
  z-index: 999 !important;
  transition: none;
}

.note[data-color="yellow"] { background: var(--note-yellow); }
.note[data-color="pink"]   { background: var(--note-pink); }
.note[data-color="blue"]   { background: var(--note-blue); }
.note[data-color="green"]  { background: var(--note-green); }
.note[data-color="orange"] { background: var(--note-orange); }
.note[data-color="purple"] { background: var(--note-purple); }

/* tape */
.note::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 78px;
  height: 20px;
  background: rgba(255, 255, 255, 0.5);
  border-left: 1px dashed rgba(43, 38, 32, 0.12);
  border-right: 1px dashed rgba(43, 38, 32, 0.12);
  box-shadow: 0 1px 2px rgba(43, 38, 32, 0.08);
}

.note-phase {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
}
.note-phase.chip-p1 { background: var(--p1); }
.note-phase.chip-p2 { background: var(--p2); }
.note-phase.chip-p3 { background: var(--p3); }
.note-phase.chip-p4 { background: var(--p4); }

.note-delete {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(43, 38, 32, 0.4);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.note:hover .note-delete { opacity: 1; }
.note-delete:hover { background: rgba(43, 38, 32, 0.12); color: var(--ink); }

.note-title {
  font-family: "Gaegu", "IBM Plex Sans KR", sans-serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 6px;
  word-break: keep-all;
}

.note-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(43, 38, 32, 0.78);
  margin: 0;
  white-space: pre-wrap;
  word-break: keep-all;
}

/* ---------- dialog ---------- */
.note-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(440px, calc(100vw - 40px));
  box-shadow: 0 24px 60px rgba(43, 38, 32, 0.35);
}
.note-dialog::backdrop {
  background: rgba(43, 38, 32, 0.45);
  backdrop-filter: blur(2px);
}

.note-dialog form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
  font-family: "IBM Plex Sans KR", system-ui, sans-serif;
}

.note-dialog h3 { margin: 0 0 2px; font-size: 17px; }

.note-dialog label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.note-dialog input[type="text"],
.note-dialog textarea,
.note-dialog select {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fbf8f0;
  resize: vertical;
}
.note-dialog input:focus,
.note-dialog textarea:focus,
.note-dialog select:focus {
  outline: 2px solid rgba(61, 127, 217, 0.45);
  outline-offset: 1px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.color-picker { display: flex; gap: 7px; padding-top: 3px; }

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(43, 38, 32, 0.15);
  background: var(--c);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.selected {
  border-color: var(--ink);
  transform: scale(1.12);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- read-only mode ---------- */
body.readonly .edit-only { display: none; }
body.readonly .note { cursor: default; }
body.readonly .note-delete { display: none; }

.user-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- comments ---------- */
.comments-layer {
  position: absolute;
  inset: 0;
  min-width: 1920px;
  pointer-events: none;
  z-index: 1500;
}
.comments-layer > * { pointer-events: auto; }

body.comment-mode .board { cursor: crosshair; }
body.comment-mode .note { pointer-events: none; }
#commentModeBtn.active {
  background: var(--p2);
  color: #fff;
  border-color: transparent;
}

.comment-pin {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -100%);
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(43, 38, 32, 0.3));
  transition: transform 0.1s ease;
  padding: 0;
}
.comment-pin:hover { transform: translate(-50%, -100%) scale(1.2); }

.comment-popup {
  position: absolute;
  width: 260px;
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(43, 38, 32, 0.25);
  padding: 12px 14px;
  font-size: 13px;
  z-index: 2000;
}

.comment-popup .comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--muted);
}
.comment-popup .comment-author { font-weight: 700; color: var(--ink); }
.comment-popup .comment-text {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: keep-all;
}

.comment-popup textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fbf8f0;
  resize: vertical;
  box-sizing: border-box;
}
.comment-popup textarea:focus { outline: 2px solid rgba(61, 127, 217, 0.45); }

.comment-popup .popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}
.comment-popup .btn { padding: 6px 12px; font-size: 12.5px; }

.comment-delete {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.comment-delete:hover { background: rgba(43, 38, 32, 0.08); color: #c0392b; }

@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; }
}
