:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-hover: #1f232c;
  --border: #262a33;
  --text: #f2f3f5;
  --text-muted: #9aa0ab;
  --accent: #6c8bff;
  --accent-hover: #8aa2ff;
  --danger: #ff6b6b;
  --danger-hover: #ff8787;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 56px 32px;
}

/* ---------- Public gallery ---------- */

.site-header {
  text-align: center;
  margin-bottom: 48px;
}

.site-header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 28px;
}

@media (max-width: 1100px) {
  .panel-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .panel-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.panel {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.panel:hover {
  transform: translateY(-6px) scale(1.02);
  background: var(--surface-hover);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.panel-image-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #000;
}

.panel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.panel:hover .panel-image {
  transform: scale(1.07);
}

.panel-title {
  padding: 14px 16px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.35;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
}

/* ---------- Admin: login ---------- */

.admin-body {
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-form {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form h1 {
  font-size: 1.4rem;
  margin: 0 0 8px;
  text-align: center;
}

/* ---------- Admin: shared form elements ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="file"] {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #0c0e12;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease;
}

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

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

.btn-small { padding: 6px 12px; font-size: 0.8rem; }

.btn-danger { background: var(--danger); color: #1a0a0a; }
.btn-danger:hover { background: var(--danger-hover); }

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

/* ---------- Admin: layout ---------- */

.admin-page { max-width: 900px; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.admin-header h1 { font-size: 1.6rem; margin: 0; }
.admin-header-actions { display: flex; gap: 10px; }

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
}

.admin-card h2 {
  font-size: 1.1rem;
  margin: 0 0 18px;
}

.admin-card h2 .hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin: 0 0 20px;
}
.flash-success { background: rgba(108, 139, 255, 0.15); color: var(--accent-hover); }
.flash-error { background: rgba(255, 107, 107, 0.15); color: var(--danger-hover); }

.panel-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.current-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Admin: panel list / drag-drop ---------- */

.panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.panel-row-ghost {
  opacity: 0.4;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 4px;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.panel-row-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.panel-row-info {
  flex: 1;
  min-width: 0;
}

.panel-row-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.panel-row-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.panel-row-actions form { margin: 0; }
