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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0d6efd;
  --warning-bg: #fff3cd;
  --warning-text: #664d03;
  --placeholder-start: #dee2e6;
  --placeholder-end: #adb5bd;
}

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

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

header a.site-title {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}

header a.site-title:hover {
  opacity: 0.75;
}

.notice {
  background: var(--warning-bg);
  color: var(--warning-text);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.logout-form {
  margin-left: auto;
}

.logout-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.logout-button:hover {
  background: var(--bg);
}

/* Main content */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

h1 {
  font-size: 1.625rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card a {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.thumb-placeholder {
  height: 140px;
  background: linear-gradient(135deg, var(--placeholder-start) 0%, var(--placeholder-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #fff;
  user-select: none;
}

.card-body {
  padding: 0.75rem;
}

.card-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.card-cover {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--placeholder-start) 0%, var(--placeholder-end) 100%);
}

/* Pagination */
.pagination {
  margin-top: 1.5rem;
  text-align: center;
}

.next-link {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.next-link:hover {
  background: var(--surface);
}

.empty-note {
  color: var(--muted);
  margin-top: 1.5rem;
}

/* Photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.photo {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--placeholder-start) 0%, var(--placeholder-end) 100%);
}

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

/* Login form */
.login-box {
  max-width: 400px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem 2.5rem;
}

.login-box h1 {
  font-size: 1.625rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.form-error {
  background: #f8d7da;
  color: #842029;
  border-radius: 6px;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.login-form .field {
  display: block;
  margin-bottom: 1rem;
}

.login-form .field span {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

.login-form button {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.login-form button:hover {
  opacity: 0.9;
}

/* Navigation */
.back-link {
  display: inline-block;
  margin-bottom: 1.25rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* Welcome/login placeholder */
.welcome-box {
  max-width: 440px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  text-align: center;
}

.welcome-box h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.welcome-box .subtitle {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

.placeholder-note {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  text-align: left;
}

/* 404 / error */
.not-found {
  text-align: center;
  margin-top: 5rem;
}

.not-found .code {
  font-size: 4rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
}

.not-found h1 {
  font-size: 1.375rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.not-found p {
  color: var(--muted);
  margin-top: 0.5rem;
}

.not-found a {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--accent);
  text-decoration: none;
}

.not-found a:hover {
  text-decoration: underline;
}

/* Admin user table */
.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.25rem;
  font-size: 0.875rem;
}

.user-table th,
.user-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.user-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 600px) {
  header {
    padding: 0.75rem 1rem;
  }

  main {
    padding: 1rem;
  }

  .welcome-box {
    margin: 2rem auto;
    padding: 1.5rem;
  }
}
