:root {
  --sand: #f5f0e8;
  --sand-dark: #e8dfd0;
  --ocean: #1a7a8c;
  --ocean-light: #4aa3b5;
  --ocean-dark: #0d4f5c;
  --sunset: #c25b3a;
  --sunset-light: #e07a5a;
  --green: #3a7a3a;
  --green-light: #5a9a5a;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --white: #ffffff;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--sand);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--ocean); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--ocean-dark), var(--ocean));
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--white);
}
.site-title:hover { text-decoration: none; opacity: 0.9; }
.site-title span { color: var(--sand-dark); }

.header-right { display: flex; align-items: center; gap: 12px; }

.auth-btn {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-btn:hover { background: rgba(255,255,255,0.25); text-decoration: none; }

.user-badge {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Navigation */
.site-nav {
  background: var(--white);
  border-bottom: 1px solid var(--sand-dark);
  position: sticky;
  top: 64px;
  z-index: 99;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.nav-btn {
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--text); background: var(--sand); }
.nav-btn.active {
  color: var(--ocean);
  border-bottom-color: var(--ocean);
}

/* Main content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  width: 100%;
  margin-top: -8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--ocean); color: var(--white); }
.btn-primary:hover { background: var(--ocean-dark); }
.btn-sunset { background: var(--sunset); color: var(--white); }
.btn-sunset:hover { background: #a84a2a; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--sand-dark); }
.btn-ghost:hover { background: var(--sand); color: var(--text); }
.btn-danger { background: #dc2626; color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hidden { display: none !important; }

/* Cards grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card.dragging { opacity: 0.4; }
.card.drag-over { box-shadow: 0 0 0 3px var(--ocean); }
.card .drag-handle {
  cursor: grab; color: var(--text-muted); font-size: 1.1rem;
  padding: 4px; user-select: none; line-height: 1;
}
.card .drag-handle:active { cursor: grabbing; }

.card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.card-body { padding: 16px; }

.card-body h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-body .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-body .card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* Video embed */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-wrap iframe, .video-wrap video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* Document list */
.doc-list { display: flex; flex-direction: column; gap: 12px; }
.doc-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}
.doc-item:hover { box-shadow: var(--shadow-lg); }
.doc-item.dragging { opacity: 0.4; }
.doc-item.drag-over { box-shadow: 0 0 0 3px var(--ocean); }
.doc-item .drag-handle {
  cursor: grab; color: var(--text-muted); font-size: 1.1rem;
  padding: 4px; user-select: none;
}
.doc-item .drag-handle:active { cursor: grabbing; }

.doc-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700;
  flex-shrink: 0;
}
.doc-icon.pdf { background: #fee2e2; color: #dc2626; }
.doc-icon.doc { background: #dbeafe; color: #2563eb; }
.doc-icon.xls { background: #dcfce7; color: #16a34a; }
.doc-icon.ppt { background: #fef3c7; color: #d97706; }
.doc-icon.txt { background: #f3f4f6; color: #6b7280; }
.doc-icon.other { background: var(--sand); color: var(--text-muted); }

.doc-info { flex: 1; min-width: 0; }
.doc-info h3 { font-size: 1rem; font-weight: 600; }
.doc-info .meta { font-size: 0.8rem; color: var(--text-muted); }

/* Discussion */
.thread {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.thread-header {
  padding: 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}
.thread-header:hover { background: rgba(0,0,0,0.01); }
.thread-header h3 { font-size: 1.05rem; font-weight: 600; }
.thread-header .meta { font-size: 0.8rem; color: var(--text-muted); }

.thread-body {
  padding: 0 16px 16px;
  display: none;
}
.thread-body.open { display: block; }
.thread-body p { margin-bottom: 12px; line-height: 1.7; color: var(--text); }

.reply {
  margin: 12px 0 0 24px;
  padding: 12px;
  background: var(--sand);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--ocean-light);
}
.reply .meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.reply p { font-size: 0.92rem; }

/* Modal / Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal h2 { font-size: 1.3rem; margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--sand-dark);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(26,122,140,0.1);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Drag & drop zone */
.drop-zone {
  border: 2px dashed var(--sand-dark);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--sand);
}
.drop-zone:hover { border-color: var(--ocean-light); background: #efe9dd; }
.drop-zone.drag-over { border-color: var(--ocean); background: #e0f0f3; }
.drop-zone.has-files { border-style: solid; border-color: var(--ocean-light); padding: 16px 20px; }
.drop-zone-icon { font-size: 2rem; margin-bottom: 8px; }
.drop-zone p { color: var(--text-muted); font-size: 0.9rem; }
.drop-zone p strong { color: var(--ocean); }

/* File preview cards in modal */
.file-previews { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.file-preview {
  display: flex; gap: 12px; align-items: start;
  background: var(--white); border: 1px solid var(--sand-dark);
  border-radius: var(--radius-sm); padding: 12px;
}
.file-preview-thumb {
  width: 64px; height: 64px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0; background: var(--sand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; overflow: hidden;
}
.file-preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-preview-body { flex: 1; min-width: 0; }
.file-preview-body .fp-name {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-preview-body .fp-size { font-size: 0.78rem; color: var(--text-muted); }
.file-preview-body input,
.file-preview-body textarea {
  width: 100%; margin-top: 6px; padding: 6px 8px;
  border: 1px solid var(--sand-dark); border-radius: 6px;
  font-size: 0.85rem; font-family: inherit;
}
.file-preview-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.2rem; padding: 4px; line-height: 1;
}
.file-preview-remove:hover { color: #dc2626; }

/* Edit inline form */
.edit-inline input,
.edit-inline textarea {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--sand-dark); border-radius: 6px;
  font-size: 0.85rem; font-family: inherit; margin-bottom: 6px;
}
.edit-inline .edit-actions { display: flex; gap: 6px; }

/* Lightbox */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* Login prompt */
.login-prompt {
  text-align: center;
  padding: 32px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 24px 0;
}
.login-prompt h3 { margin-bottom: 8px; }
.login-prompt p { color: var(--text-muted); margin-bottom: 16px; }

/* Loading */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--sand-dark);
  border-top-color: var(--ocean);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Video card specific */
.video-thumb {
  position: relative;
  background: #000;
}
.video-thumb .play-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.5rem;
  transition: background 0.2s;
}
.video-thumb:hover .play-btn { background: var(--sunset); }

/* Responsive */
@media (max-width: 768px) {
  .header-inner { height: 56px; }
  .site-title { font-size: 1.1rem; }
  .site-nav { top: 56px; }
  .nav-btn { padding: 10px 16px; font-size: 0.82rem; }
  .card-grid { grid-template-columns: 1fr; }
  .modal { padding: 16px; margin: 10px; }
}

/* Hero section */
.hero-section {
  background: linear-gradient(135deg, var(--ocean-dark), var(--ocean), var(--ocean-light));
  color: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  margin-bottom: 32px;
  text-align: center;
}
.hero-section h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.hero-section p {
  font-size: 1.05rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Info cards for home */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.info-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.info-card:hover { box-shadow: var(--shadow-lg); }
.info-card .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}
.info-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.info-card p { font-size: 0.9rem; color: var(--text-muted); }

/* Welcome section */
.welcome-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  text-align: center;
}
.welcome-section h2 { font-size: 1.4rem; margin-bottom: 8px; }
.welcome-section p { color: var(--text-muted); max-width: 700px; margin: 0 auto; line-height: 1.7; }
