/* studio27 — gallery */
.gallery-wrap { max-width: 1400px; margin: 0 auto; padding: 4px 16px 60px; }
.gallery-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.gallery-head h1 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 850;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  background: linear-gradient(180deg, #fff, var(--gold-2) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub { margin: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* filters */
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  margin-bottom: 16px;
  position: sticky;
  top: 8px;
  z-index: 20;
}
.filters .grow { grid-column: 1 / -1; }
.filters #f-clear { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .filters { grid-template-columns: 1fr 170px 170px 200px auto; align-items: center; }
  .filters .grow, .filters #f-clear { grid-column: auto; }
}

.new-banner { position: sticky; top: 80px; z-index: 19; display: flex; justify-content: center; margin: -6px 0 10px; }

/* grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel-solid);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s, box-shadow 0.2s, border-color 0.2s;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(246, 196, 83, 0.5); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), var(--glow-gold); }
.tile .thumb { aspect-ratio: 3 / 4; width: 100%; object-fit: cover; background: #0a0c24; }
.tile .thumb-ph { aspect-ratio: 3 / 4; display: grid; place-items: center; color: var(--faint); background: #0a0c24; font-size: 0.8rem; }
.tile .styles {
  position: absolute;
  top: 8px; right: 8px;
}
.tile .src { position: absolute; top: 8px; left: 8px; }
.tile .info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 28px 10px 9px;
  background: linear-gradient(180deg, transparent, rgba(4, 4, 18, 0.92));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 6px;
}
.tile .sender { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .time { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.tile.fresh { animation: fresh 1.2s ease; }
@keyframes fresh { 0% { transform: scale(0.85); opacity: 0; box-shadow: 0 0 0 3px var(--magenta); } 60% { box-shadow: 0 0 30px var(--magenta); } 100% { transform: none; opacity: 1; } }

.empty-state { text-align: center; padding: 60px 16px; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--gold); opacity: 0.85; }
.loader { display: flex; justify-content: center; padding: 28px; }
.load-more { display: flex; justify-content: center; padding: 20px; }
.sentinel { height: 1px; }
.error-line { text-align: center; color: #ffc2cc; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: stretch; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 2, 12, 0.82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0;
  background: linear-gradient(180deg, #0f1236, #090b26);
  border: 1px solid var(--line);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
@media (min-width: 900px) {
  .modal { align-items: center; padding: 24px; }
  .modal-panel { border-radius: 20px; max-height: calc(100vh - 48px); box-shadow: var(--shadow); }
}
.modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(12, 14, 44, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.m-head-text { flex: 1; min-width: 0; }
.modal-head h2 { margin: 0; font-size: 1.15rem; color: var(--gold-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub { margin: 0; font-size: 0.85rem; }
.m-close svg { width: 22px; height: 22px; }
.view-toggle span { min-height: 38px; padding: 6px 12px; font-size: 0.85rem; }
@media (max-width: 560px) {
  .view-toggle { order: 3; width: 100%; }
  .view-toggle label { flex: 1; }
  .view-toggle span { width: 100%; }
}

.m-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.m-compare { position: relative; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .split { gap: 6px; } }
.pane { margin: 0; }
.pane-img {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(62vh, 760px);
  border: 1px solid var(--line);
}
@media (max-width: 560px) { .pane-img { height: 46vh; } }
.pane-img img { width: 100%; height: 100%; object-fit: contain; }
.pane figcaption { text-align: center; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* before/after slider */
.compare {
  --pos: 50%;
  --cmp-h: min(66vh, 800px);
  position: relative;
  width: min(100%, calc(var(--cmp-h) * 0.75));
  height: auto;
  max-height: var(--cmp-h);
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: ew-resize;
}
@media (max-width: 560px) { .compare { --cmp-h: 58vh; } }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.c-before { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos)) 0 0); -webkit-clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.c-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--pos);
  width: 44px;
  margin-left: -22px;
  display: flex;
  justify-content: center;
  cursor: ew-resize;
  outline: none;
}
.c-handle::before { content: ""; width: 3px; height: 100%; background: #fff; box-shadow: 0 0 12px rgba(0, 0, 0, 0.6), 0 0 18px rgba(246, 196, 83, 0.6); }
.c-knob {
  position: absolute;
  top: 50%;
  width: 46px; height: 46px;
  margin-top: -23px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), var(--glow-gold);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a1d00' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E"), linear-gradient(135deg, var(--gold-2), var(--gold));
  background-size: 24px, cover;
  background-position: center;
  background-repeat: no-repeat;
}
.c-handle:focus-visible .c-knob { outline: 3px solid #fff; outline-offset: 2px; }
.c-label {
  position: absolute;
  top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
}
.c-label-l { left: 10px; }
.c-label-r { right: 10px; }

.m-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(6, 7, 26, 0.86);
  border-radius: 12px;
  padding: 20px;
  font-weight: 650;
}
.m-status.err { color: #ffd6dd; }

/* result strip */
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.strip button {
  position: relative;
  flex: none;
  width: 84px;
  padding: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  background: #0a0c24;
  overflow: hidden;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.strip button[aria-selected="true"] { border-color: var(--gold); box-shadow: var(--glow-gold); }
.strip img, .strip .ph { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: grid; place-items: center; font-size: 0.68rem; color: var(--muted); padding: 0; }
.strip .ph { padding: 4px; text-align: center; }
.strip .lbl {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.4);
}
.strip .st { position: absolute; top: 4px; left: 4px; font-size: 0.6rem; padding: 1px 6px; }

.m-info { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .m-info { grid-template-columns: 1.3fr 1fr; } }
.prompt-box, .meta-box { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.prompt-head h3 { margin: 0; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.prompt-text { margin: 0; white-space: pre-wrap; line-height: 1.55; color: var(--text); font-size: 0.95rem; max-height: 260px; overflow: auto; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 0.9rem; }
.meta dt { color: var(--muted); font-weight: 600; }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.dl-row, .admin-row { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-row { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }

body.modal-open { overflow: hidden; }
