:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7079;
  --line: #e6e5e1;
  --mm: #f5a81c;
  --mm-dark: #d98c00;
  --rjm: #ed1b24;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }

/* Sign in */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px 22px; box-shadow: 0 12px 40px rgba(20, 20, 30, 0.06);
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { width: 190px; align-self: center; margin-bottom: 4px; }
.login-card h1 { font-size: 20px; margin: 0; text-align: center; letter-spacing: -0.01em; }
.login-card p.muted { margin: -6px 0 6px; text-align: center; font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.login-card input {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fbfbfa; color: var(--text);
  font-size: 16px;
}
.login-card input:focus { outline: none; border-color: var(--mm); box-shadow: 0 0 0 3px rgba(245, 168, 28, 0.2); background: #fff; }
.error { color: #c4141c; font-size: 13px; margin: 0; min-height: 1em; }
.btn-primary {
  border: 0; border-radius: 10px; padding: 12px; background: var(--text); color: #fff; font-weight: 600;
}
.btn-primary:disabled { opacity: 0.6; }
.powered { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.powered img { height: 16px; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mm-logo { height: 40px; }
.divider { width: 1px; height: 26px; background: var(--line); }
.brand-title { font-weight: 600; white-space: nowrap; }
.account { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.rjm-mark img { height: 22px; display: block; }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.btn-ghost:hover { border-color: #cfcdc7; }

/* Toolbar */
.toolbar { max-width: 1200px; margin: 0 auto; padding: 20px 16px 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segmented { display: inline-flex; background: #ebeae6; border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.segmented span { color: var(--muted); font-weight: 400; margin-left: 2px; }
#store-filter {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 36px 7px 14px; font-size: 13px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7079' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
}
.hint { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* Gallery */
.gallery { max-width: 1200px; margin: 0 auto; padding: 8px 16px 48px; }
.visit { margin-top: 26px; }
.visit-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 10px; }
.visit-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.visit-head span { font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { position: relative; margin: 0; }
.thumb {
  display: block; width: 100%; aspect-ratio: 1; border: 0; padding: 0; border-radius: var(--radius); overflow: hidden;
  background: #e9e8e4; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.thumb:hover img { transform: scale(1.03); }
.thumb .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.play {
  position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px 4px 7px;
  border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px; font-weight: 500;
}
.play::before { content: ""; border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.tile figcaption { margin-top: 8px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cap-title, .cap-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-title { font-size: 13px; font-weight: 500; }
.cap-sub { font-size: 12px; color: var(--muted); }
.star {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, 0.92); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); display: grid; place-items: center;
  color: #9a9ea6; transition: transform 0.15s ease;
}
.star:hover { transform: scale(1.08); }
.star svg { width: 19px; height: 19px; }
.star.on { color: var(--mm); }
.star.on svg { fill: currentColor; }
.tile.shared .thumb { box-shadow: 0 0 0 3px var(--mm); }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 20; background: #0e0e10; display: flex; flex-direction: column; color: #fff; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.viewer-meta { display: flex; flex-direction: column; min-width: 0; }
.viewer-meta strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-meta span { font-size: 13px; color: #a9acb3; }
.viewer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.v-btn { border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13px; text-decoration: none; }
.v-btn.icon { width: 34px; padding: 7px 0; text-align: center; }
.v-btn.on { background: var(--mm); border-color: var(--mm); color: #16181d; font-weight: 600; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 28px; line-height: 1; z-index: 1;
}
.v-nav.prev { left: 12px; }
.v-nav.next { right: 12px; }

@media (max-width: 640px) {
  .mm-logo { height: 32px; }
  .brand-title, .divider, .who { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .v-nav { display: none; }
}
