:root {
  --bg: #111;
  --fg: #eee;
  --muted: #999;
  --line: #2a2a2a;
  --accent: #f5b301;
  --panel: #1a1a1a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 16px; background: rgba(17,17,17,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-left: auto; color: var(--muted); font-size: 14px; }
.tools label { display: flex; align-items: center; gap: 6px; }
.tools input[type=text] { width: 130px; padding: 4px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.count { font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 6px; }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
.card { position: relative; aspect-ratio: 1; background: #222; overflow: hidden; cursor: pointer; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.card:hover img { transform: scale(1.03); }
.card .star { position: absolute; top: 6px; right: 6px; }
.card .badge { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 6px; font-size: 12px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.card .badge span { background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 10px; }
.card .fname { position: absolute; right: 6px; bottom: 6px; font-size: 11px; color: rgba(255,255,255,.75); text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.star { background: rgba(0,0,0,.45); border: 0; border-radius: 50%; width: 34px; height: 34px; font-size: 22px; line-height: 1; color: #fff; cursor: pointer; display: grid; place-items: center; }
.star.on { color: var(--accent); }
.star:hover { background: rgba(0,0,0,.7); }

.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-columns: 1fr 320px; background: rgba(0,0,0,.96); }
.lb-figure { margin: 0; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 16px; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 32px); object-fit: contain; }
.lb-panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px; overflow-y: auto; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lb-name { font-size: 13px; color: var(--muted); word-break: break-all; }
.lb-stars { font-size: 13px; color: var(--muted); margin: 8px 0 12px; min-height: 1.4em; }
.comments { list-style: none; margin: 0 0 12px; padding: 0; flex: 1; }
.comments li { padding: 8px 0; border-top: 1px solid var(--line); }
.comments li b { font-weight: 600; margin-right: 6px; }
.comments li time { font-size: 12px; color: var(--muted); float: right; }
.comments li p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form textarea { width: 100%; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.comment-form button { align-self: flex-end; padding: 6px 14px; background: var(--accent); color: #000; border: 0; border-radius: 4px; cursor: pointer; font-weight: 600; }
.comment-form button:disabled { opacity: .5; cursor: default; }

.lb-close, .lb-prev, .lb-next { position: absolute; z-index: 2; background: rgba(0,0,0,.5); border: 0; color: #fff; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; font-size: 28px; line-height: 1; display: grid; place-items: center; }
.lb-close { top: 12px; left: 12px; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: 12px; }
.lb-next { right: 332px; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.2); }

@media (max-width: 760px) {
  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-figure { padding: 8px; }
  .lb-figure img { max-height: 55vh; }
  .lb-panel { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  .lb-next { right: 12px; }
  .lb-prev, .lb-next { top: 27vh; }
}
.empty { padding: 40px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

.logout { color: var(--muted); font-size: 13px; text-decoration: none; }
.logout:hover { color: var(--fg); }
.login-body { display: grid; align-content: center; justify-items: center; min-height: 100vh; padding: 24px 0; }
.login { width: min(340px, 90vw); display: flex; flex-direction: column; gap: 12px; padding: 32px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 600; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login input { padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font-size: 16px; }
.login input[aria-invalid] { border-color: #c0392b; }
.login-error { color: #e74c3c !important; }
.login button { padding: 10px; background: var(--accent); color: #000; border: 0; border-radius: 4px; font-weight: 600; cursor: pointer; }
