:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #17171c;
  --muted: #6b6b76;
  --border: #e3e3e8;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --ok-bg: #e6f6ea;
  --ok-text: #1e7b34;
  --warn-bg: #fff4e0;
  --warn-text: #9a5b00;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1b1b20;
    --text: #ececf1;
    --muted: #9a9aa6;
    --border: #2d2d35;
    --accent: #6f8cff;
    --accent-text: #0d0d12;
    --danger: #ff6b6b;
    --ok-bg: #16301e;
    --ok-text: #7ad48f;
    --warn-bg: #33270f;
    --warn-text: #f0b85a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

input[type="text"], input[type="password"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

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

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-weight: 500;
}

.login-box {
  max-width: 380px;
  margin: 60px auto;
}

.album-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.album-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
}

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

.album-cover {
  aspect-ratio: 4 / 3;
  background: var(--border) center / cover no-repeat;
}

.album-card-body { padding: 12px 14px; }
.album-card-title { font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-empty { background: var(--border); color: var(--muted); }

.file-field {
  display: block;
  padding: 14px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 12px;
}

.file-field input { display: block; margin-top: 8px; max-width: 100%; }

.preview {
  display: block;
  max-width: 100%;
  max-height: 180px;
  margin-top: 10px;
  border-radius: 8px;
}

.progress {
  height: 8px;
  margin: 12px 0 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

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

.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.page-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
}

.page-media img, .page-media video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #000;
}

.page-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

.qr-image {
  width: 180px;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  display: block;
  margin-bottom: 12px;
}

.viewer-link {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  z-index: 100;
}

.toast.is-error { background: var(--danger); color: #fff; }

[hidden] { display: none !important; }
