:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #5c6670;
  --accent: #2563eb;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --err: #991b1b;
  --err-bg: #fee2e2;
  --border: #d8dee4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #1a222c;
    --text: #e8edf2;
    --muted: #9aa7b5;
    --border: #2d3845;
    --ok-bg: #14532d;
    --err-bg: #7f1d1d;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 52rem;
  padding: 1.25rem;
  font: 16px/1.5 system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header { margin-bottom: 1.5rem; }
h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
h2 { margin: 1.75rem 0 0.75rem; font-size: 1.1rem; }
h3 { margin: 0 0 0.75rem; font-size: 1rem; }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

input[type="text"],
input[type="file"],
input:not([type]),
textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

textarea {
  min-height: 65vh;
  resize: vertical;
  font: 0.95rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button {
  margin-top: 0.25rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: var(--muted);
}

button.danger {
  background: #b91c1c;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.topnav form { margin: 0; }
.topnav button { margin: 0; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-wrap {
  width: min(100%, 24rem);
}

.hint, .slug {
  color: var(--muted);
  font-size: 0.88rem;
}

.slug::before { content: "· "; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.page form { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.warn { color: #b45309; font-size: 0.9rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.85rem;
}

.asset {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
}

.asset img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--bg);
  border-radius: 6px;
}

.asset p {
  min-height: 2.5rem;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
}
