:root {
  --bg: #f7f5f2;
  --paper: #ffffff;
  --ink: #141311;
  --mute: #7a746c;
  --line: #e4dfd7;
  --line-strong: #cfc8bd;
  --accent: #141311;
  --danger: #8a2a2a;
  --header-h: 64px;
  --gutter: 8px;
  --max: 1280px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Jost", sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}
.site-header .inner {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.wordmark {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 1.05rem;
  justify-self: center;
  grid-column: 2;
}
.nav-left { justify-self: start; display: flex; gap: 22px; }
.nav-right { justify-self: end; display: flex; gap: 22px; }
.site-header nav a {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
}
.site-header nav a:hover,
.site-header nav a.is-active { color: var(--ink); }

.hero {
  padding: 64px 20px 36px;
  text-align: center;
}
.hero h1 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.hero p {
  margin: 0 auto;
  max-width: 420px;
  color: var(--mute);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px 80px;
}
.section-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0 0 16px;
}

.collage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter);
}
.collage-card {
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.collage-card a.thumb {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--paper);
}
.collage-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fbfaf8;
}
.collage-card .meta {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.collage-card .title {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.05rem;
  line-height: 1.2;
}
.collage-card .count {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
  white-space: nowrap;
}
.empty-note {
  color: var(--mute);
  text-align: center;
  padding: 80px 20px;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 20px 48px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
}

/* Library lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,19,17,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 24px;
}
.lightbox.is-open { display: flex; }
.lightbox .sheet {
  background: var(--paper);
  max-width: 720px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
  position: relative;
}
.lightbox img { width: 100%; height: auto; background: #fbfaf8; }
.lightbox .sheet-meta { padding: 16px 20px 24px; }
.lightbox h2 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  margin: 0 0 6px;
  font-size: 2rem;
}
.lightbox .close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
}

/* Closet */
body.closet-page { background: var(--bg); }
.closet-app {
  display: grid;
  grid-template-columns: 300px 1fr 220px;
  gap: 0;
  min-height: calc(100vh - var(--header-h));
  border-top: 0;
}
.tray, .tools, .stage-wrap {
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.tools { border-right: 0; border-left: 1px solid var(--line); }
.tray { display: flex; flex-direction: column; min-height: 0; }
.tray-head, .tools-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.tray-head h2, .tools-head h2, .stage-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 10px;
  font-weight: 400;
  color: var(--mute);
}
.search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 0;
  outline: none;
}
.search:focus { border-color: var(--ink); background: var(--paper); }
.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.cats button {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cats button.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.item-list {
  overflow: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: 1;
}
.item-tile {
  border: 1px solid var(--line);
  background: #fbfaf8;
  aspect-ratio: 1;
  cursor: grab;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-tile img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.item-tile:hover { border-color: var(--ink); }

.stage-wrap {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-width: 0;
}
.canvas-frame {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  width: min(100%, 520px);
  aspect-ratio: 4 / 5;
  box-shadow: none;
  position: relative;
}
.canvas-frame canvas { display: block; }
.stage-hint {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

.tools { padding: 0 0 24px; display: flex; flex-direction: column; gap: 8px; }
.tools .group { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.tools label.field { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); }
.tools input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 8px 10px;
  outline: none;
}
.tools input[type="text"]:focus { border-color: var(--ink); background: var(--paper); }
.tools button.act {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
}
.tools button.act:hover { border-color: var(--ink); }
.tools button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  text-align: center;
  padding: 12px 10px;
}
.tools button.primary:hover { opacity: 0.9; }
.tools .status { font-size: 12px; color: var(--mute); min-height: 1.4em; }
.tools .status.err { color: var(--danger); }

/* Login (also used by gate.php, kept in sync) */
.login-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
.login-panel {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 48px 40px;
  text-align: center;
}
.login-panel .wordmark { display: block; margin-bottom: 28px; }
.login-panel h1 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  font-size: 2.4rem;
  margin: 0 0 8px;
}
.login-panel .lede { color: var(--mute); margin: 0 0 28px; font-size: 14px; }
.login-panel form { display: flex; flex-direction: column; gap: 10px; }
.login-panel input[type="password"] {
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 12px 14px;
  outline: none;
  text-align: center;
}
.login-panel input[type="password"]:focus { border-color: var(--ink); background: var(--paper); }
.login-panel button {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 12px 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
}
.login-error { color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 980px) {
  .collage-grid { grid-template-columns: repeat(2, 1fr); }
  .closet-app { grid-template-columns: 1fr; }
  .tray { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .tools { border-left: 0; border-top: 1px solid var(--line); }
  .site-header .inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 0 14px;
  }
  .wordmark { letter-spacing: 0.2em; font-size: 0.95rem; margin-right: auto; }
  .nav-left, .nav-right { display: flex; }
  .hero { padding: 40px 16px 24px; }
}
@media (max-width: 640px) {
  .collage-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .wrap { padding: 0 12px 56px; }
}
