/* Light theme (default) */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #dde1e9;
  --text: #1a1f2a;
  --muted: #5e6a7d;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --shadow-hover: rgba(0, 0, 0, 0.10);
  --radius: 10px;
  font-family: system-ui, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #1a1f2a;
  --border: #2a3344;
  --text: #e8eaef;
  --muted: #8b95a8;
  --accent: #6c9ef8;
  --accent-text: #0f1218;
  --danger: #e85d5d;
  --shadow-hover: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-header nav {
  display: flex;
  gap: 0.25rem;
}

.site-header nav a {
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: color 0.15s, background 0.15s;
}

.site-header nav a:hover {
  color: var(--text);
  background: var(--border);
  text-decoration: none;
}

/* ── Container ── */
.container {
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2.5rem 2.5rem;
}

/* ── Footer ── */
.site-footer-icp {
  text-align: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--muted);
}

.site-footer-icp a {
  color: var(--muted);
}

.site-footer-icp a:hover {
  color: var(--accent);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.page-info {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Page title ── */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

/* ── Filters ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.filters input {
  flex: 1;
  min-width: 240px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s;
}

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

/* ── Photo grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px var(--shadow-hover);
  text-decoration: none;
}

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

.card-title {
  display: block;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  color: var(--muted);
  padding: 4rem 0;
  text-align: center;
  font-size: 1rem;
}

/* ── Form ── */
.form-card {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.field input,
.field textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--muted);
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-weight: 600;
}

.btn.primary:hover {
  background: #89b4ff;
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn.danger:hover {
  background: rgba(232, 93, 93, 0.12);
}

.btn.small {
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* In light mode: show moon (click to go dark) */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* In dark mode: show sun (click to go light) */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── HTMX ── */
.htmx-indicator {
  visibility: hidden;
}

.htmx-indicator.htmx-request {
  visibility: visible;
}

/* ── Photo detail ── */
.detail {
  display: grid;
  gap: 2rem;
}

@media (min-width: 800px) {
  .detail {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.detail-figure {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.detail-figure img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 85vh;
  object-fit: contain;
}

.detail-desc {
  color: var(--muted);
  white-space: pre-wrap;
}

.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

.meta-list dt {
  margin: 0;
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem 0;
}

/* ── Edit page ── */
.thumb-preview img {
  max-width: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

/* ── Manage table ── */
.manage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.manage-table th,
.manage-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.manage-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.manage-table tbody tr:hover td {
  background: var(--surface);
}

.cell-thumb img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
}

.cell-actions {
  white-space: nowrap;
}

.upload-result:empty {
  display: none;
}
