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

:root {
  --bg: #0f0f12;
  --surface: #1a1a22;
  --surface-hover: #22222e;
  --border: #2a2a38;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --accent: #6c5ce7;
  --accent-hover: #7f70f0;
  --danger: #e74c3c;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

/* ── Login ─────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-row .btn-primary,
.topbar-actions .btn-primary,
.toolbar .btn-primary,
.filters-bar .btn-primary {
  width: auto;
}

.login-card .btn-primary {
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.error-msg {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 0.75rem;
  min-height: 1.25rem;
}

/* ── Layout ────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1,
.topbar-brand {
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-brand {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

.topbar-brand:hover {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.375rem;
  font-weight: 600;
}

.page-header-centered {
  justify-content: center;
  text-align: center;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.back-link:hover {
  color: var(--text);
}

/* ── Toolbar / search ──────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.toolbar-centered {
  justify-content: center;
}

.search-input {
  flex: 0 1 360px;
  width: 100%;
  min-width: 200px;
  max-width: 360px;
  padding: 0.625rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.btn-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── People grid ───────────────────────────────────────────── */

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  color: inherit;
  display: block;
  position: relative;
}

.person-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.person-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.star-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, transform 0.15s;
}

.star-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  color: #ffd54f;
  transform: scale(1.1);
}

.star-btn.starred {
  color: #ffd54f;
}

.person-card:hover .star-btn {
  background: rgba(0, 0, 0, 0.65);
}

.person-thumb {
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.person-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-thumb .placeholder {
  font-size: 2.5rem;
  color: var(--text-muted);
  opacity: 0.4;
}

.person-info {
  padding: 0.75rem;
}

.person-info h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Filters bar ───────────────────────────────────────────── */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filters-bar select {
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}

.filters-bar .spacer {
  flex: 1;
}

/* ── Social links ───────────────────────────────────────────── */

.socials-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.75rem 0 1.25rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.social-link:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--text);
}

.social-link-instagram:hover { border-color: #e1306c; }
.social-link-tiktok:hover { border-color: #69c9d0; }
.social-link-snapchat:hover { border-color: #fffc00; color: #fffc00; }
.social-link-vsco:hover { border-color: #9ab; }

/* ── Content grid ──────────────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
  position: relative;
}

.content-card.content-starred {
  border-color: #ffd54f;
}

.content-card:hover {
  border-color: var(--accent);
}

.content-card-preview {
  cursor: pointer;
}

.content-preview {
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.content-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.content-preview .file-icon {
  font-size: 2rem;
  color: var(--text-muted);
}

.content-meta {
  padding: 0.625rem 0.75rem;
}

.content-meta .filename {
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-meta .date {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.tag {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  background: var(--bg);
  border-radius: 3px;
  color: var(--text-muted);
}

/* ── Modal ─────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.75);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal-overlay.active {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.modal-overlay[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.125rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal img {
  display: block;
  max-width: 85vw;
  max-height: 80vh;
  object-fit: contain;
}

.modal-info {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.modal-info h3 {
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.modal-info p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Add person modal form ─────────────────────────────────── */

.modal-form {
  padding: 1.5rem;
  width: 400px;
  max-width: 90vw;
}

.modal-form h3 {
  margin-bottom: 1.25rem;
}

.modal-form .form-group {
  margin-bottom: 1rem;
}

.modal-form .btn-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}

.upload-drop-zone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.875rem;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}

.upload-drop-zone.dragover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.upload-file-list {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

.upload-count {
  display: block;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.upload-file-names {
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
}

.upload-file-names li {
  padding: 0.15rem 0;
  word-break: break-all;
}

.upload-drop-hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.upload-empty {
  color: var(--text-muted);
}

main.container.page-dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

/* ── Upload overlay ────────────────────────────────────────── */

.upload-progress {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  z-index: 150;
  font-size: 0.875rem;
}

.upload-progress.active {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

input[type="file"] {
  display: none;
}

/* ── Content card stars ────────────────────────────────────── */

.content-star-btn {
  top: 0.375rem;
  right: 0.375rem;
}

.content-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ── Floating preview panels ───────────────────────────────── */

#preview-panels-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 250;
}

.preview-panel {
  position: fixed;
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(420px, 40vw);
  height: min(360px, 45vh);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-panel.dragging,
.preview-panel.resizing {
  opacity: 0.92;
}

.preview-panel.dragging {
  cursor: grabbing;
}

.preview-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}

.preview-panel.dragging .preview-panel-header {
  cursor: grabbing;
}

.preview-drag-handle {
  flex: 1;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.preview-star-btn,
.preview-close-btn {
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.preview-star-btn:hover,
.preview-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.preview-star-btn.starred {
  color: #ffd54f;
}

.preview-panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #000;
}

.preview-panel-body img,
.preview-panel-body video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 1;
}

.preview-resize-handle::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  opacity: 0.6;
}

.preview-resize-handle:hover::after {
  opacity: 1;
}

.preview-file-fallback {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.preview-file-fallback span {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.preview-file-fallback .btn {
  margin-top: 0.75rem;
  width: auto;
  display: inline-flex;
}
