:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1c1b19;
  --muted: #6b6a66;
  --line: #e2e0dc;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --pin: #1f6f5c;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --card: #212125;
    --ink: #f1efec;
    --muted: #a6a49f;
    --line: #34343a;
    --accent: #4fbfa3;
    --accent-ink: #10221d;
    --pin: #4fbfa3;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }

h1 { font-size: 1.5rem; margin: 8px 0 2px; letter-spacing: -.01em; }
.lead { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }

/* Gate */
.gate { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 14px; }
.gate h1 { margin: 0; }
.gate p { color: var(--muted); margin: 0; }
.gate form { display: flex; gap: 8px; }
.gate input {
  font-size: 1.15rem; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--ink); width: 160px; text-align: center;
}
.gate .err { color: #c0392b; min-height: 1.2em; font-size: .9rem; }

button {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px;
  padding: 12px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }

/* Floor tabs */
.tabs { display: flex; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.tabs button { flex: 1 1 auto; min-width: 96px; }
.tabs button[aria-selected="false"] { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }

/* Plan */
.planbox { position: relative; border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.planbox img.plan { display: block; width: 100%; height: auto; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 30px; height: 30px; min-width: 30px; padding: 0;
  border-radius: 50%; background: var(--pin); color: #fff;
  font-size: .9rem; font-weight: 700; line-height: 30px; text-align: center;
  box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 2px 6px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  .pin { box-shadow: 0 0 0 3px rgba(20,20,22,.9), 0 2px 6px rgba(0,0,0,.6); }
}
.hint { color: var(--muted); font-size: .85rem; margin: 10px 2px 4px; }

/* Room list */
.roomlist { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.roomlist li button {
  width: 100%; text-align: left; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); font-weight: 500; display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 12px;
}
.roomlist .num {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: .8rem; font-weight: 700; display: grid; place-items: center;
}
.roomlist .rn { font-weight: 600; }
.roomlist .rm { color: var(--muted); font-size: .85rem; font-weight: 400; }
.roomlist .cnt { margin-left: auto; color: var(--muted); font-size: .8rem; }

.allbtn { margin-top: 18px; width: 100%; }

/* Sheet (room detail) */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: none; align-items: flex-end; justify-content: center; z-index: 40;
}
.sheet-back.open { display: flex; }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 8px 16px 28px;
  -webkit-overflow-scrolling: touch;
}
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 12px; }
.sheet h2 { margin: 0 0 2px; font-size: 1.25rem; }
.sheet .mal { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.note {
  background: var(--card); border: 1px dashed var(--line); border-radius: 12px;
  padding: 12px 14px; color: var(--muted); font-size: .9rem; margin: 0 0 16px;
}
.note.tiltak { border-style: solid; color: var(--ink); white-space: pre-wrap; }
.note.tilstand, .note.merknad { border-style: dotted; margin-bottom: 8px; }
.note .merke {
  display: block; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 4px;
}
.note.tiltak .merke { color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid button { padding: 0; border-radius: 10px; overflow: hidden; background: var(--line); aspect-ratio: 1 / 1; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet .close { margin-top: 18px; width: 100%; }
.empty { color: var(--muted); font-size: .9rem; padding: 8px 0 4px; }

/* Lightbox */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.94); display: none; z-index: 60; touch-action: pan-y; }
.lb.open { display: block; }
.lb img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.lb .x, .lb .nav { position: absolute; background: rgba(0,0,0,.5); color: #fff; border: 0; }
.lb .x { top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; font-size: 1.3rem; }
.lb .nav { top: 50%; transform: translateY(-50%); width: 46px; height: 64px; font-size: 1.5rem; border-radius: 10px; }
.lb .prev { left: 8px; }
.lb .next { right: 8px; }
.lb .count { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #fff; font-size: .9rem; opacity: .85; }

footer { margin-top: 30px; color: var(--muted); font-size: .8rem; text-align: center; }
a { color: var(--accent); }
