:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-muted: #6b6b66;
  --line: #e5e3dc;
  --accent: #8b6f47;
  --accent-soft: #f3ede1;
  --tenant: #2e5f3a;
  --landlord: #6b3b8e;
  --error: #b03030;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --radius: 6px;
  --max-w: 1100px;
  --font-serif: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  color: var(--ink);
}

h1 { font-size: 1.7rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }

p { margin: 0 0 0.8em; }

.muted { color: var(--ink-muted); }
.small { font-size: 0.85rem; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: all 120ms ease;
}
button:hover { background: var(--accent-soft); border-color: var(--accent); }
button[type="submit"] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
button[type="submit"]:hover {
  background: var(--accent);
  border-color: var(--accent);
}

input, textarea {
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  width: 100%;
  color: var(--ink);
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Lang toggle */
#lang-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  box-shadow: var(--shadow);
}
#lang-toggle button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--ink-muted);
}
#lang-toggle button.active {
  background: var(--ink);
  color: white;
}

/* Login */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 2.2rem 2rem;
  max-width: 420px;
  width: 100%;
}
.login-card h1 { margin-bottom: 0.2em; }
.login-card form { margin-top: 1.5rem; }
.login-card label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}
.login-card input {
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  text-align: center;
  font-feature-settings: "tnum";
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  margin-top: 1rem;
  font-size: 1rem;
}
.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.8rem;
}

/* Main app */
#app-view {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.2rem;
  margin-bottom: 1.5rem;
}
.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.user-box {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
}
#user-name { font-weight: 500; color: var(--ink); }
.intro {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--ink-muted);
  max-width: 720px;
}

/* Room nav */
#room-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.6rem 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
}
#room-nav a {
  text-decoration: none;
  color: var(--ink-muted);
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--surface);
  transition: all 120ms ease;
  white-space: nowrap;
}
#room-nav a:hover {
  color: var(--ink);
  border-color: var(--accent);
}
#room-nav a .count {
  margin-left: 0.4em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

/* Room sections */
.room-section {
  margin-bottom: 2.5rem;
  scroll-margin-top: 4rem;
}
.room-section h2 {
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
  margin-bottom: 1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.photo-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 150ms ease;
  display: flex;
  flex-direction: column;
  position: relative;
}
.photo-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.photo-card .img-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #ddd;
  overflow: hidden;
}
.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-card .meta {
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.photo-card .badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.photo-card .badge.has-new {
  background: #fff1ed;
  color: #c2451f;
}

/* Lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.94);
  z-index: 100;
  display: flex;
  flex-direction: column;
}
#lightbox[hidden] { display: none; }

#lb-close, #lb-prev, #lb-next {
  position: absolute;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 102;
  transition: background 150ms ease;
}
#lb-close { top: 1rem; right: 1rem; }
#lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
#lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
#lb-close:hover, #lb-prev:hover, #lb-next:hover {
  background: rgba(255,255,255,0.2);
}

.lb-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 4rem 4rem 1rem;
  gap: 1.5rem;
}

.lb-image-wrap {
  flex: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 0;
}
#lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.lb-exif {
  position: absolute;
  bottom: -1rem;
  left: 0;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.lb-side {
  flex: 1;
  max-width: 420px;
  background: var(--surface);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.lb-side h3 {
  margin-bottom: 0.5rem;
}
.lb-side p {
  color: var(--ink);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.comments-block {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.comments-block h4 {
  margin-bottom: 0.8rem;
  flex-shrink: 0;
}
.comments-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1rem;
  min-height: 80px;
}
.comments-list:empty::before {
  content: attr(data-empty);
  display: block;
  color: var(--ink-muted);
  font-style: italic;
  font-size: 0.9rem;
}
.comment {
  border-left: 3px solid var(--line);
  padding: 0.3rem 0 0.3rem 0.8rem;
  margin-bottom: 0.8rem;
}
.comment.tenant { border-left-color: var(--tenant); }
.comment.landlord { border-left-color: var(--landlord); }
.comment .who {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.1rem;
}
.comment.tenant .who { color: var(--tenant); }
.comment.landlord .who { color: var(--landlord); }
.comment .when {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-left: 0.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}
.comment .body {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#lb-comment-form {
  flex-shrink: 0;
}
#lb-comment-form textarea {
  resize: vertical;
  font-size: 0.9rem;
}
#lb-comment-form button {
  margin-top: 0.5rem;
  width: 100%;
}

/* Responsive */
@media (max-width: 800px) {
  .lb-content {
    flex-direction: column;
    padding: 3.5rem 1rem 1rem;
  }
  .lb-side {
    max-width: none;
    max-height: 45vh;
  }
  #lb-prev { left: 0.3rem; }
  #lb-next { right: 0.3rem; }
}

@media (max-width: 500px) {
  #app-view { padding: 1rem 0.7rem 2rem; }
  h1 { font-size: 1.35rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
}
