:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  gap: 16px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.subtitle,
.muted {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.hidden {
  display: none !important;
}

/* ============================ Форма входа ============================ */

#form-login {
  display: grid;
  gap: 6px;
  max-width: 320px;
}

label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

input {
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

button {
  padding: 10px 16px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  margin-top: 16px;
}

.error {
  margin: 16px 0 0;
  color: var(--error);
  font-size: 14px;
}

.room-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.room-option {
  padding: 18px;
  font-weight: 600;
}

/* ============================ Галерея ============================ */

.gallery-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.gallery-room {
  font-size: 18px;
  font-weight: 600;
}

.gallery-back {
  margin-bottom: 12px;
  padding: 8px 12px;
  color: var(--accent);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-note {
  padding: 0 4px;
}

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

.tile {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tile img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  cursor: zoom-in;
  background: #eceef1;
  display: block;
}

.tile figcaption {
  padding: 8px 10px;
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.tile-name {
  font-weight: 600;
  word-break: break-all;
}

.tile-download {
  color: var(--accent);
  text-decoration: none;
  justify-self: start;
}

/* ============================ Просмотр кадра ============================ */

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  z-index: 100;
}

.viewer-meta {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 1;
}

.viewer img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 24px;
  line-height: 1;
  border-radius: 50%;
}

.viewer-download {
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  padding: 8px 16px;
}
