/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cork: #c8922a;
  --cork-dark: #a07020;
  --cork-bg: #d4a848;
  --header-bg: #2d1f0e;
  --accent: #e53935;
  --accent-hover: #c62828;
  --text: #2c1810;
  --text-light: #6b4c2a;
  --white: #fff;
  --shadow-card: 0 6px 20px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.15);
  --shadow-card-hover: 0 12px 36px rgba(0,0,0,0.32), 0 4px 12px rgba(0,0,0,0.2);
  --radius: 2px;
  --font-hand: 'Caveat', cursive;
  --font-ui: 'Inter', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background-color: #1a0f00;
  min-height: 100vh;
  color: var(--text);
}

/* ===== HEADER ===== */
.site-header {
  background: var(--header-bg);
  border-bottom: 3px solid #8B5E0A;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 72px;
}

.header-left { flex: 1; }

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-pin { font-size: 2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }

.site-title {
  font-family: var(--font-hand);
  font-size: 1.9rem;
  font-weight: 700;
  color: #f5d88a;
  line-height: 1.1;
  letter-spacing: 0.5px;
}

.site-subtitle {
  font-size: 0.72rem;
  color: #c9a45a;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e0c07a;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.btn-pin-memory {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(229,57,53,0.4);
}
.btn-pin-memory:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(229,57,53,0.5); }
.btn-pin-memory:active { transform: translateY(0); }

/* ===== TOOLBAR ===== */
.toolbar {
  background: #3d2808;
  border-bottom: 2px solid #6b4010;
  padding: 12px 24px;
  position: sticky;
  top: 72px;
  z-index: 99;
}

.toolbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 0 0 280px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #a07840;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  color: #f0d090;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}
.search-input::placeholder { color: #8a6030; }
.search-input:focus { border-color: #c9903a; background: rgba(255,255,255,0.12); }

.filter-label { color: #a07840; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }

.dept-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.dept-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: #c9a060;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font-ui);
}
.dept-chip:hover { background: rgba(255,255,255,0.12); }
.dept-chip.active { background: #c9903a; border-color: #c9903a; color: white; font-weight: 600; }

.sort-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 7px 12px;
  color: #c9a060;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  margin-left: auto;
}
.sort-select option { background: #3d2808; color: #f0d090; }

/* ===== CORK BOARD ===== */
.board-wrapper {
  background:
    radial-gradient(ellipse at 20% 30%, rgba(180,120,40,0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(140,90,20,0.25) 0%, transparent 50%),
    repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 4px
    ),
    repeating-linear-gradient(
      90deg, transparent, transparent 2px,
      rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 4px
    ),
    #c8922a;
  min-height: calc(100vh - 140px);
  padding: 40px 32px;
}

.board {
  max-width: 1400px;
  margin: 0 auto;
  columns: 4 280px;
  column-gap: 0;
  position: relative;
}

/* ===== MEMORY CARD ===== */
.memory-card {
  display: inline-block;
  width: 100%;
  padding: 12px;
  break-inside: avoid;
  margin-bottom: 0;
  cursor: pointer;
}

.card-inner {
  position: relative;
  border-radius: var(--radius);
  padding: 24px 20px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  will-change: transform;
}

.card-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}

/* Tape effect top */
.card-inner::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 18px;
  background: rgba(255, 220, 150, 0.55);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.memory-card:hover .card-inner {
  transform: rotate(0deg) scale(1.04) !important;
  box-shadow: var(--shadow-card-hover);
  z-index: 10;
}

/* Push pin */
.card-pin {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.pin-head {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin: 0 auto 2px;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.4);
  position: relative;
}
.pin-head::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
}

.pin-needle {
  width: 2px;
  height: 12px;
  background: linear-gradient(to bottom, #aaa, #666);
  margin: 0 auto;
  border-radius: 0 0 2px 2px;
}

/* Card content */
.card-dept {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(0,0,0,0.45);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(0,0,0,0.15);
}

.card-message {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  line-height: 1.5;
  color: #2c1a0a;
  margin-bottom: 10px;
  word-break: break-word;
  overflow-wrap: break-word;
  /* Limit preview */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-image {
  width: 100%;
  border-radius: 2px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: block;
  object-fit: cover;
  max-height: 200px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.card-author {
  font-family: var(--font-hand);
  font-size: 1.05rem;
  font-weight: 700;
  color: #3d2008;
}

.card-meta {
  font-size: 0.68rem;
  color: rgba(0,0,0,0.35);
  margin-top: 2px;
}

.card-like-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  color: rgba(0,0,0,0.4);
  padding: 4px 8px;
  border-radius: 20px;
  transition: all 0.2s;
}
.card-like-btn:hover { background: rgba(0,0,0,0.08); color: #e53935; }
.card-like-btn.liked { color: #e53935; }
.card-like-btn.liked .like-heart { animation: heartPop 0.3s ease; }

@keyframes heartPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ===== EMPTY STATE ===== */
.board-empty {
  text-align: center;
  padding: 80px 20px;
  grid-column: 1/-1;
}
.empty-icon { font-size: 4rem; margin-bottom: 16px; opacity: 0.6; }
.board-empty p { font-family: var(--font-hand); font-size: 1.6rem; color: rgba(80,40,0,0.6); line-height: 1.5; }

/* ===== LOADING ===== */
.loading-spinner {
  text-align: center;
  padding: 60px;
  width: 100%;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(80,40,0,0.2);
  border-top-color: #8B5E0A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { font-family: var(--font-hand); font-size: 1.2rem; color: rgba(80,40,0,0.5); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f5f5f5;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
}
.modal-close:hover { background: #e0e0e0; color: #333; }

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 28px;
}
.modal-pin { font-size: 2rem; }
.modal-title { font-size: 1.4rem; font-weight: 700; color: #2c1810; }
.modal-desc { font-size: 0.85rem; color: #888; margin-top: 2px; }

/* Form */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.optional { font-weight: 400; text-transform: none; color: #999; }

.form-input, .form-textarea {
  width: 100%;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: #333;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
}
.form-input:focus, .form-textarea:focus { border-color: #c9903a; background: white; }

.form-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-hand);
  font-size: 1.1rem;
}

.char-count { text-align: right; font-size: 0.75rem; color: #aaa; margin-top: 4px; }
.char-count.warn { color: #ff9800; }
.char-count.danger { color: #f44336; }

/* Upload */
.upload-area {
  border: 2px dashed #ddd;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
  background: #fafafa;
  position: relative;
}
.upload-area:hover { border-color: #c9903a; }
.upload-area.dragover { border-color: #c9903a; background: #fff8f0; }

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-placeholder {
  padding: 28px 20px;
  text-align: center;
  color: #aaa;
  pointer-events: none;
}
.upload-placeholder svg { margin-bottom: 10px; opacity: 0.5; }
.upload-placeholder p { font-size: 0.9rem; margin-bottom: 4px; }
.upload-hint { font-size: 0.75rem; }

.upload-preview {
  position: relative;
  padding: 12px;
}
.upload-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.remove-photo {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  z-index: 3;
}
.remove-photo:hover { background: rgba(0,0,0,0.8); }

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

.btn-cancel {
  background: none;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-cancel:hover { border-color: #bbb; color: #333; }

.btn-submit {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(229,57,53,0.3);
}
.btn-submit:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ===== DETAIL MODAL ===== */
.detail-modal {
  max-width: 640px;
  background: #fffef8;
  position: relative;
}

.detail-paper {
  background: #fffef8;
  border-left: 4px solid transparent;
  padding: 4px 0 0;
}

.detail-dept-badge {
  display: inline-block;
  background: #f5e6c8;
  color: #8B5E0A;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 14px;
}

.detail-message {
  font-family: var(--font-hand);
  font-size: 1.6rem;
  line-height: 1.55;
  color: #2c1a0a;
  margin-bottom: 20px;
  word-break: break-word;
}

.detail-image {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  margin-bottom: 20px;
  display: block;
}

.detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px dashed #ddd;
  margin-top: 4px;
}

.detail-author { font-family: var(--font-hand); font-size: 1.2rem; font-weight: 700; color: #3d2008; }
.detail-date { font-size: 0.75rem; color: #aaa; margin-top: 2px; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #2c1810;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  max-width: 360px;
}
.toast.success { border-left: 4px solid #4CAF50; }
.toast.error { border-left: 4px solid #f44336; }
.toast.info { border-left: 4px solid #2196F3; }
.toast.fadeOut { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-stats { display: none; }
  .board { columns: 2 160px; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar-inner { gap: 10px; }
  .search-wrap { flex: 1; }
  .board-wrapper { padding: 24px 16px; }
  .modal { padding: 24px 20px; }
  .site-title { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .board { columns: 1; }
  .btn-pin-memory span { display: none; }
}

/* ===== NEW CARD ANIMATION ===== */
.memory-card.new-card .card-inner {
  animation: dropIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropIn {
  from { opacity: 0; transform: scale(0.7) translateY(-20px); }
  to { opacity: 1; }
}

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

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  border-color: #555;
  transform: scale(1.18);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--header-bg);
  border-top: 2px solid #8B5E0A;
  text-align: center;
  padding: 18px 24px;
  font-size: 0.82rem;
  color: #a07840;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.site-footer strong { color: #f5d88a; font-weight: 600; }
.site-footer a { color: #c9a45a; text-decoration: none; }
.site-footer a:hover { color: #f5d88a; text-decoration: underline; }
.footer-sep { opacity: 0.4; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,94,10,0.4); border-radius: 3px; }
.modal::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }
