:root {
    --board-bg: #c8a97e;
    --sidebar-bg: #f5ede0;
    --header-bg: #3d2b1f;
    --ui-font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --cork-texture: repeating-linear-gradient(
        120deg,
        rgba(180,130,80,0.10) 0px, rgba(180,130,80,0.10) 2px,
        transparent 2px, transparent 8px
    ), repeating-linear-gradient(
        60deg,
        rgba(150,100,50,0.08) 0px, rgba(150,100,50,0.08) 2px,
        transparent 2px, transparent 10px
    );

    --yellow: #fdf4b8;
    --yellow-shadow: #e8d84a40;
    --pink: #fde0e0;
    --pink-shadow: #e8a4a440;
    --sage: #d8edda;
    --sage-shadow: #7ab87e40;
    --sky: #d6eaf8;
    --sky-shadow: #5ba3d040;
    --peach: #fde8d3;
    --peach-shadow: #e8965040;
    --lavender: #ead6f5;
    --lavender-shadow: #9b5ec840;
    --bone: #f4efd8;
    --bone-shadow: #cdd5df40;   
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

body {
  font-family: var(--ui-font);
  background: #91c7d9;
  min-height: 100vh;
  overflow: hidden;
  color: #24170f;
}

/* ── HEADER ── */
header {
  position: relative;
  z-index: 5;
  background: rgba(61,43,31,0.92);
  padding: 14px 28px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 4px solid #2a1a10;
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
}

h1 {
  font-family: var(--ui-font);
  font-size: 1.6rem;
  font-weight: 700;
  color: #f5ede0;
  letter-spacing: 0;
}

.tagline {
  font-size: 0.85rem;
  color: #c8a97e;
  font-style: italic;
}

/* ── LAYOUT ── */
.layout {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: calc(100vh - 62px);
  padding: 28px;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 218px;
  min-width: 218px;
  background: rgba(245, 237, 224, 0.664);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(100,64,35,0.2);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  z-index: 10;
}

.form-label {
  font-family: var(--ui-font);
  font-size: 0.78rem;
  color: #6b4226;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}

/* ── BOARD ── */
#grid {
  position: relative;
  flex: 1 1 920px;
  max-width: 1040px;
  height: min(660px, 100%);
  background: var(--board-bg);
  background-image: var(--cork-texture);
  overflow: hidden;
  border: 14px solid #7b4f2c;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.18),
    inset 0 0 70px rgba(83,48,23,0.24),
    0 18px 45px rgba(0,0,0,0.32);
  /* drop zone */
}

#grid.drag-over {
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,0.3),
    inset 0 0 70px rgba(83,48,23,0.24),
    0 18px 45px rgba(0,0,0,0.32);
}

.board-label {
  position: absolute;
  bottom: 14px;
  right: 18px;
  font-family: 'Caveat', cursive;
  font-size: 1rem;
  color: rgba(80,50,20,0.35);
  pointer-events: none;
  letter-spacing: 1px;
}

/* ── CARD (shared) ── */
.card {
  position: absolute;
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  height: 142px;
  min-height: 142px;
  max-height: 142px;
  padding: 12px 14px 20px;
  border-radius: 2px;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.12);
  font-family: var(--ui-font);
  font-size: 0.9rem;
  line-height: 1.45;
  cursor: default;
  overflow: visible;
  transition: box-shadow 0.15s, transform 0.15s;
  /* subtle paper fold bottom-right */
  background-image: linear-gradient(135deg, transparent 90%, rgba(0,0,0,0.06) 100%);
}

.card:hover {
  box-shadow: 4px 8px 20px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.12);
  z-index: 9999 !important;
}

.card .card-title,
.card p {
  overflow: hidden;
}

.card .card-title {
  min-height: 1.25em;
  max-height: 2.5em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card p {
  flex: 1;
  margin-top: 6px;
  font-size: 0.84rem;
  opacity: 0.88;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

/* COLORS */
.card[data-color="yellow"]   { background-color: var(--yellow);   --card-shadow: var(--yellow-shadow); }
.card[data-color="pink"]     { background-color: var(--pink);     --card-shadow: var(--pink-shadow); }
.card[data-color="sage"]     { background-color: var(--sage);     --card-shadow: var(--sage-shadow); }
.card[data-color="sky"]      { background-color: var(--sky);      --card-shadow: var(--sky-shadow); }
.card[data-color="peach"]    { background-color: var(--peach);    --card-shadow: var(--peach-shadow); }
.card[data-color="lavender"] { background-color: var(--lavender); --card-shadow: var(--lavender-shadow); }
.card[data-color="bone"] { background-color: var(--bone); --card-shadow: var(--bone-shadow); }

/* ── THUMBTACK / PIN ── */
.pin {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #ff8888, #cc2222 55%, #881111);
  box-shadow: 0 2px 5px rgba(0,0,0,0.45), inset 0 1px 2px rgba(255,255,255,0.4);
  z-index: 2;
}

.pin::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 9px;
  background: linear-gradient(to bottom, #aaa, #777);
  border-radius: 0 0 2px 2px;
}

/* ── META ROW ── */
.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  opacity: 0.55;
  margin-bottom: 4px;
  margin-top: 4px;
}

.ts { white-space: nowrap; flex-shrink: 0; }

/* ── CARD BODY TYPOGRAPHY ── */
.card b {
  display: block;
}

.card b, .card .card-title {
  font-family: var(--ui-font);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 3px;
  word-break: break-word;
}

.card p {
  font-size: 0.84rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  opacity: 0.9;
}

/* ── COMPOSER CARD (sidebar) ── */
.draggable-source {
  position: relative;
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  height: 142px;
  min-height: 142px;
  max-height: 142px;
  cursor: grab;
  user-select: none;
  margin-top: 8px;
}

.draggable-source:active { cursor: grabbing; }

.draggable-source .pin,
#drag-ghost .pin {
  display: none;
}

/* inline inputs inside card composer */
.inline-input {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--ui-font);
  color: #2b1a0e;
  width: 100%;
  resize: none;
}

.cat-input {
  font-size: 0.72rem;
  opacity: 0.6;
  width: 70%;
}

.title-input {
  font-size: 0.92rem;
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
}

.body-input {
  font-size: 0.84rem;
  min-height: 62px;
  max-height: 62px;
  line-height: 1.35;
  opacity: 0.85;
  overflow: hidden;
}

.char-count {
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-size: 0.68rem;
  opacity: 0.4;
  font-family: var(--ui-font);
}

.char-count.warning { opacity: 0.9; color: #c0392b; }

/* ── COLOR PICKER ── */
.color-picker {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.color-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}

.color-btn[data-color="yellow"]   { background: var(--yellow); }
.color-btn[data-color="pink"]     { background: var(--pink); }
.color-btn[data-color="sage"]     { background: var(--sage); }
.color-btn[data-color="sky"]      { background: var(--sky); }
.color-btn[data-color="peach"]    { background: var(--peach); }
.color-btn[data-color="lavender"] { background: var(--lavender); }
.color-btn[data-color="bone"] { background: var(--bone); }

.color-btn.active, .color-btn:hover {
  border-color: #6b4226;
  transform: scale(1.2);
}

/* ── HINTS & MESSAGES ── */
.drag-hint {
  font-size: 0.78rem;
  color: #9a7055;
  text-align: center;
  font-style: italic;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.rate-msg {
  background: #fde8d3;
  border: 1px solid #e8965a;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: #7a3b10;
  text-align: center;
}

.hidden { display: none !important; }

/* ── DRAG GHOST ── */
#drag-ghost {
  position: fixed;
  pointer-events: none;
  opacity: 0.85;
  z-index: 99999;
  transform: rotate(-3deg) scale(1.05);
  transition: transform 0.1s;
}

/* ── NOTE POPUP ── */
.note-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,20,5,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  backdrop-filter: blur(2px);
}

.note-popup {
  background: var(--yellow);
  border-radius: 3px;
  padding: 36px 40px 30px;
  max-width: min(680px, calc(100vw - 36px));
  max-height: min(78vh, 720px);
  overflow: auto;
  width: 90%;
  box-shadow: 6px 12px 30px rgba(0,0,0,0.35);
  position: relative;
  font-family: var(--ui-font);
}

.note-popup .pin {
  top: -12px;
  left: 50%;
}

.note-popup .popup-cat {
  font-size: 0.85rem;
  opacity: 0.5;
  margin-top: 6px;
}

.note-popup .popup-title {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 4px 0 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.note-popup .popup-body {
  font-size: 1.12rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-popup .popup-time {
  font-size: 0.75rem;
  opacity: 0.4;
  margin-top: 14px;
}

.note-popup .popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.4;
  font-family: var(--ui-font);
}

.note-popup .popup-close:hover { opacity: 1; }

/* Pin card animation */
@keyframes pinCard {
  0% { transform: var(--base-rot) translateY(-18px) scale(1.06); opacity: 0.7; }
  60% { transform: var(--base-rot) translateY(2px) scale(1.01); }
  100% { transform: var(--base-rot); opacity: 1; }
}

/* ── THE PHYSICAL BOARD MOBILE LAYOUT ── */
@media (max-width: 760px) {
  body {
    overflow: hidden; /* Stop the whole page from rubber-banding */
  }

  /* 1. THE VIEWPORT */
  .layout {
    display: block; 
    /* Increased dock subtraction from 85px to 150px to fit larger note */
    height: calc(100dvh - 62px - 150px); 
    overflow: auto; 
    padding: 20px; 
  }

  /* 2. THE PHYSICAL BOARD */
  #grid {
    width: 1040px;
    min-width: 1040px;
    height: 660px;
    min-height: 660px;
    margin: 0; 
    border: 14px solid #7b4f2c;
    border-radius: 8px;
    box-shadow:
      inset 0 0 0 2px rgba(255,255,255,0.18),
      inset 0 0 70px rgba(83,48,23,0.24),
      0 18px 45px rgba(0,0,0,0.32);
  }

  .board-label {
    bottom: 14px;
    right: 18px;
  }

  /* 3. THE BOTTOM DOCK */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px; /* Taller to fit the larger card */
    background: rgba(245, 237, 224, 0.98); 
    border: none;
    border-top: 2px solid rgba(100,64,35,0.2);
    border-radius: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    
    /* Use Grid to perfectly divide the left and right sides */
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    padding: 10px 14px;
    gap: 8px;
  }

  .form-label, .drag-hint {
    display: none; 
  }

  /* BIGGER COMPOSER: Placed on the left side, spanning both rows */
  #card-composer {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    margin: 0;
    transform: scale(0.88); /* Scaled up for much easier visibility and dragging */
    transform-origin: left center;
  }

  /* HORIZONTAL COLORS: Placed on the top right */
  .color-picker {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    width: auto; /* Removed the 55px constraint so they stay horizontal */
    justify-content: flex-end; /* Align to the right side of the screen */
    align-self: end;
    gap: 6px; /* Slightly tighter gap so they all fit on small phone screens */
  }

  /* Make color buttons slightly easier to tap on mobile */
  .color-btn {
    width: 22px;
    height: 22px;
  }

  /* RATE MESSAGE: Placed on the bottom right, under the colors */
  #rate-msg {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    align-self: start;
    justify-self: flex-end;
    font-size: 0.75rem; /* Slightly smaller text to fit nicely */
    padding: 6px 8px;
    margin: 0;
    text-align: center;
  }
}