:root {
  --bg: #0d0d0d;
  --card: #161616;
  --line: #2a2a2a;
  --text: #f3f1ec;
  --muted: #9a958c;
  --accent: #e8dcc6;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 "Segoe UI", "Helvetica Neue", sans-serif;
  min-height: 100vh;
}

a { color: inherit; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(13, 13, 13, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.find-box { flex: 1; max-width: 22rem; }
.find-box input {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
}
.find-list { list-style: none; margin: 0; padding: 0; }
.find-list li + li { border-top: 1px solid var(--line); }
.find-list a {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding: 0.75rem 0;
  text-decoration: none;
}
.find-list strong { display: block; }
.find-list .meta { margin: 0.15rem 0 0; }
.find-cover {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  flex: 0 0 56px;
  background: var(--card);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.18em;
  word-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  font-size: 0.92rem;
}

.top-actions { display: flex; gap: 1.1rem; }
.top-actions a { color: var(--muted); text-decoration: none; font-size: 0.92rem; }
.top-actions a:hover { color: var(--text); }
.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 10.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem;
  display: grid;
}
.menu-list a {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  text-decoration: none;
}
.menu-list a:hover { background: #222; color: var(--text); }
.tree-head h1 { margin-bottom: 0.4rem; }
.tree-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  touch-action: pan-y;
}
.tree-page > .tree-list { padding-left: 0; }
.tree-item.closed > .tree-list { display: none; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.2rem;
  border-radius: 8px;
}
.tree-row:hover { background: #1b1b1b; }
.tree-row a { text-decoration: none; font-weight: 600; }
.tree-meta { color: var(--muted); font-size: 0.82rem; }
.tree-drag,
.tree-twist,
.tree-cut,
.tree-del {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}
.tree-drag {
  display: none;
  touch-action: none;
  width: 1.6rem;
  padding: 0;
  font-size: 1.05rem;
  letter-spacing: -0.12em;
  cursor: grab;
}
@media (pointer: coarse) {
  .tree-drag { display: inline-flex; justify-content: center; }
}
.tree-twist { width: 1.4rem; padding: 0; }
.tree-item.closed > .tree-row .tree-twist { transform: rotate(-90deg); }
.tree-twist.ghost { visibility: hidden; }
.tree-cut:hover,
.tree-del:hover { color: var(--text); }
.tree-status { color: var(--accent); }

.page { max-width: 920px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page.narrow { max-width: 460px; }

h1 { font-size: 1.7rem; font-weight: 600; margin: 0 0 0.25rem; letter-spacing: -0.02em; }
.meta { color: var(--muted); margin: 0 0 1rem; }
.meta a { color: var(--accent); }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.4rem;
}
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--text); font-weight: 600; }

.profile {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  margin-bottom: 1.6rem;
}
.avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 92px;
  background: var(--card);
  border: 1px solid var(--line);
}
.avatar.ghost {
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--accent);
}
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.button {
  display: inline-block;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.chip {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.grid.doors {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.tile.photo,
.grid.doors .tile,
.viewer-frame img,
.viewer-full img {
  -webkit-touch-callout: none;
  user-select: none;
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0.8rem 1.4rem;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(100%, 420px);
  display: grid;
  gap: 0.5rem;
}
.sheet-action,
.sheet-cancel {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.sheet-lead {
  margin: 0 0 0.15rem;
  color: var(--text);
  font-weight: 600;
  text-align: center;
}
.sheet-action { background: var(--card); color: var(--text); }
.sheet-action.danger { background: #3a1515; color: #f3c4c4; }
.sheet-cancel { background: var(--text); color: var(--bg); }

.tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--card);
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
}
.tile-ghost {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--accent);
}
.tile-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.6rem 0.55rem 0.5rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  font-size: 0.92rem;
  font-weight: 600;
}

.feed { list-style: none; margin: 0 auto; padding: 0; max-width: 470px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 1.2rem;
  overflow: hidden;
}
.card-head {
  display: block;
  padding: 0.7rem 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.card-image { display: block; aspect-ratio: 1; }
.card-caption { margin: 0; padding: 0.75rem 0.85rem 1rem; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}
.empty .actions { justify-content: center; margin-top: 1rem; }

.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.form input[type="text"],
.form textarea,
.form input[type="file"] {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  font: inherit;
}
.hint { color: #6d6a64; font-weight: 400; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #000;
}
.viewer[hidden] { display: none; }
.viewer-scroller {
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  scrollbar-width: thin;
}
.viewer-slide {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0 0.55rem;
}
.viewer-slide:first-child { padding-top: 2.8rem; }
.viewer-slide:last-child { padding-bottom: 2rem; }
.viewer-frame {
  display: grid;
  place-items: center;
}
.viewer-frame img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 88dvh;
  object-fit: contain;
  cursor: zoom-in;
}
.viewer-caption {
  color: var(--accent);
  margin: 0.4rem 0.8rem 0;
  max-width: 40rem;
  text-align: left;
}
.viewer-caption[hidden] { display: none; }
.viewer-close,
.viewer-count {
  position: fixed;
  z-index: 33;
  color: white;
}
.viewer-close {
  top: 0.55rem;
  right: 0.85rem;
  background: none;
  border: 0;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.viewer-count {
  top: 0.95rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: #c8c4bb;
  pointer-events: none;
}
.viewer-full {
  position: absolute;
  inset: 0;
  z-index: 32;
  background: #000;
  display: grid;
  place-items: center;
}
.viewer-full[hidden] { display: none; }
.viewer-full img {
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
}
.viewer-prev,
.viewer-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: white;
  font-size: 2.4rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  opacity: 0.7;
}
.viewer-prev { left: 0.2rem; }
.viewer-next { right: 0.2rem; }
.viewer-prev:hover,
.viewer-next:hover { opacity: 1; }

@media (max-width: 640px) {
  .profile { flex-direction: column; align-items: flex-start; }
}
