:root {
  --bg: #fff;
  --fg: #111;
  --muted: #8a8a8a;
  --line: #ececec;
  --line-strong: #d6d6d6;
  --tile: #f4f4f4;
  --danger: #c0392b;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ---- tab bar ---- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  gap: 76px;
  height: calc(env(safe-area-inset-top, 0px) + 104px);
  padding: env(safe-area-inset-top, 0px) 0 0;
  margin: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  font-size: 26px;
  font-weight: 450;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand small { margin-left: 10px; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.tabs {
  flex: 1;
  display: flex;
  gap: 32px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--fg); font-weight: 500; border-bottom-color: var(--fg); }
.bar-links { display: flex; align-items: center; gap: 20px; font-size: 12px; white-space: nowrap; }
.bar-links a, .bar-links button {
  color: var(--muted); text-decoration: none; background: none; border: 0; font: inherit; padding: 0; cursor: pointer;
}
.bar-links a:hover, .bar-links button:hover { color: var(--fg); }

main { max-width: 1600px; margin: 0 auto; padding: 110px 56px 80px; }
main:has(#folder-view:not([hidden])) { padding-top: 48px; }

/* ---- folders ---- */
.folders {
  display: grid;
  grid-template-columns: repeat(3, 190px);
  gap: 54px 30px;
}
.folder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}
.folder svg { width: 84px; height: 61px; transition: transform 0.15s; }
.folder:hover svg { transform: translateY(-2px); }
.folder span { font: 13px/1.3 var(--mono); text-align: center; }

.crumbs { display: flex; gap: 10px; margin-bottom: 28px; font: 12px var(--mono); color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--fg); }
.crumbs span:last-child { color: var(--fg); }

.about { max-width: 560px; margin: 0; font-size: 15px; line-height: 1.7; white-space: pre-line; }

/* ---- photo grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--tile);
  cursor: zoom-in;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s;
}
.tile img.loaded { opacity: 1; }
.empty { color: var(--muted); font: 12px var(--mono); padding: 40px 0; }

/* ---- lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
}
.lb-top, .lb-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font: 12px var(--mono);
}
.lb-top { padding-top: calc(env(safe-area-inset-top, 0px) + 14px); color: #999; }
.lb-bottom { justify-content: center; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); }
.lb-close { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; }
.lb-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  border: 0;
  background: none;
  color: #fff;
  font-size: 36px;
  opacity: 0.4;
  cursor: pointer;
}
.lb-nav:hover { opacity: 1; }
.lb-prev { left: 0; text-align: left; padding-left: 20px; }
.lb-next { right: 0; text-align: right; padding-right: 20px; }

/* ---- controls ---- */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.lightbox .btn { background: #fff; border-color: #fff; color: #000; padding: 11px 28px; font: 500 14px/1.5 -apple-system, BlinkMacSystemFont, sans-serif; }
input[type="text"], input[type="password"], textarea {
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  min-width: 0;
}
input:focus, textarea:focus { outline: none; border-color: var(--fg); }

@media (max-width: 640px) {
  .bar { gap: 32px; margin: 0 16px; padding-inline: 4px; height: calc(env(safe-area-inset-top, 0px) + 68px); }
  .brand { font-size: 21px; }
  .tabs { gap: 24px; }
  main { padding: 48px 12px; }
  main:has(#folder-view:not([hidden])) { padding: 24px 2px; }
  main:has(#folder-view:not([hidden])) .crumbs { padding: 0 18px; }
  .folders { grid-template-columns: repeat(3, 1fr); gap: 40px 8px; }
  .folder svg { width: 64px; height: 46px; }
  .folder span { font-size: 11px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 2px; }
  .lb-nav { display: none; }
}
