:root {
  --brand: #1f6feb;
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --danger: #c62828;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111317; --card: #1b1e24; --text: #e8eaed; --muted: #9aa0a6; --line: #2c3038; }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); }
.ok { background: color-mix(in srgb, var(--brand) 10%, transparent); padding: .75rem 1rem; border-radius: 8px; }
code { font-size: 1.1em; font-weight: 600; user-select: all; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 16px; background: var(--card); border-bottom: 3px solid var(--brand);
}
.brand { text-decoration: none; color: var(--text); }
.logo { height: 36px; display: block; }
.logo-text { font-weight: 700; font-size: 1.1rem; }
.top nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.top nav form { margin: 0; }
.phone { font-weight: 600; text-decoration: none; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
body.narrow main { max-width: 440px; padding-top: 10vh; }
section { margin-bottom: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.center { text-align: center; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > label { flex: 1 1 200px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input, textarea, select {
  font: inherit; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%;
}
input[type=checkbox] { width: auto; }
select { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .65rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); border-color: currentColor; background: none; }
.btn:disabled { opacity: .6; cursor: wait; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }

.drop {
  position: relative; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; cursor: pointer; font-weight: 400; align-items: center;
}
.drop.over, .drop.has-files { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.progress { position: relative; height: 28px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--brand); opacity: .25; transition: width .2s; }
.progress .ptext { position: relative; display: block; text-align: center; line-height: 28px; font-size: .9rem; }

.albums { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.albums a {
  display: flex; gap: .9rem; align-items: center; padding: .6rem; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.albums img, .albums .nocover { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; }
.albums .meta { display: flex; flex-direction: column; min-width: 0; }
.albums .expired { opacity: .5; }

.share { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.share input { flex: 1 1 260px; font-family: ui-monospace, monospace; font-size: .95rem; }
.share-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }

.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid li { position: relative; }
.grid img { display: block; width: 100%; aspect-ratio: 4/3; height: auto; object-fit: cover; border-radius: 6px; background: var(--line); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 4px; } }
.grid.manage form { position: absolute; top: 6px; right: 6px; margin: 0; }
.del { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.danger { text-align: right; }

.gallery-head { margin-bottom: 1rem; }
.note { white-space: normal; margin: 0 0 1rem; }
.gallery-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.users { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: .95rem; }
.users th, .users td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.users .actions { display: flex; gap: 1rem; justify-content: flex-end; }
.users .actions form { margin: 0; }
.users .inactive td { opacity: .5; }
@media (max-width: 640px) { .users { display: block; overflow-x: auto; } }

.lightbox {
  position: fixed; inset: 0; background: #000; z-index: 10;
  display: flex; align-items: center; justify-content: center; touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100% - 56px); object-fit: contain; user-select: none; }
.lightbox button {
  position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0;
  font-size: 34px; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; line-height: 1;
}
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) { .lb-prev, .lb-next { display: none; } }
.lb-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; color: #ddd;
}
.lb-dl { color: #fff; }
.alert { color: var(--danger); font-weight: 600; font-size: .9rem; }
.dups { margin: .5rem 0; padding-left: 1.2rem; }
.error .dups { color: var(--text); }
div.error { background: color-mix(in srgb, var(--danger) 8%, transparent); padding: .75rem 1rem; border-radius: 8px; }
div.error[hidden] { display: none; }
.warn { background: color-mix(in srgb, #f59e0b 15%, transparent); padding: .75rem 1rem; border-radius: 8px; }
.result { background: color-mix(in srgb, var(--brand) 10%, transparent); padding: .75rem 1rem; border-radius: 8px; }
