:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8a97a3);
  --card: var(--tg-theme-secondary-bg-color, #232e3c);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --free: #2ecc71;
  --busy: #e74c3c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app { max-width: 640px; margin: 0 auto; padding: 12px; }

header h1 { font-size: 20px; margin: 8px 0 16px; text-align: center; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.field { margin-bottom: 12px; }
label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 4px; }

input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  padding: 12px 16px;
  transition: opacity .15s;
}
button:active { opacity: .7; }
button:disabled { opacity: .4; cursor: default; }

.primary { width: 100%; background: var(--accent); color: var(--accent-text); font-weight: 600; }

.hint { font-size: 13px; color: var(--hint); margin: 8px 0 0; }
.muted { color: var(--hint); font-size: 14px; }

.room-title { font-size: 16px; font-weight: 600; margin: 4px 0 10px; }

.category-title {
  font-size: 18px;
  font-weight: 700;
  margin: 18px 4px 10px;
  color: var(--accent);
}
.furniture { padding: 0; overflow: hidden; }
.fur-photo {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
}
.fur-head { padding: 12px 16px 4px; }
.fur-name { font-size: 16px; font-weight: 600; }
.fur-desc { font-size: 13px; color: var(--hint); margin-top: 3px; }
.furniture .bed { margin: 8px 12px; }
.furniture .bed:last-child { margin-bottom: 14px; }

.bed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  margin-bottom: 8px;
}
.bed .name { font-size: 15px; }
.bed .status { font-size: 12px; margin-top: 2px; }
.status.free { color: var(--free); }
.status.busy { color: var(--busy); }
.status.mine { color: var(--accent); font-weight: 600; }

.bed button.book { background: var(--free); color: #fff; padding: 8px 14px; }
.bed button.taken { background: transparent; color: var(--busy); border: 1px solid var(--busy); }

.booking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.booking-item:last-child { border-bottom: none; }
.booking-item .info { font-size: 14px; }
.booking-item .dates { font-size: 12px; color: var(--hint); }
.booking-item button.cancel { background: transparent; color: var(--busy); border: 1px solid var(--busy); padding: 6px 12px; font-size: 13px; }

h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- Моменты ---------- */
.hidden { display: none !important; }
.back {
  padding: 8px 4px 12px;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}
.album {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 12px;
  cursor: pointer;
}
.album-cover {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.album-cover.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: var(--bg);
}
.album-name { font-size: 16px; font-weight: 600; }
.album-count { font-size: 13px; color: var(--hint); margin-top: 3px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell .play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.7);
  background: rgba(0,0,0,.15);
}

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.94);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.viewer img, .viewer video {
  max-width: 100%;
  max-height: 92vh;
  border-radius: 8px;
}
.viewer-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 16px;
  font-size: 26px;
  color: #fff;
  cursor: pointer;
  z-index: 101;
}
