/* =========================================================
   十夢 tendreams — gallery & admin (extends style.css tokens)
   ========================================================= */
body.sub { background: var(--ink); color: var(--paper); }
body.sub.light { background: var(--paper); color: var(--ink); }

.sub-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--gutter);
  background: rgba(11,11,11,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-dark);
  color: var(--paper);
}
.back-link { font-family: var(--f-mincho); font-size: 13px; text-decoration: none; opacity: .8; display: inline-flex; gap: 8px; align-items: center; }
.back-link:hover { opacity: 1; }

/* ---------- gallery hero ---------- */
.g-hero {
  display: grid; grid-template-columns: auto 1fr; gap: clamp(20px, 4vw, 56px); align-items: end;
  padding: clamp(48px, 8vw, 100px) var(--gutter) clamp(32px, 4vw, 48px);
  max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto;
}
.g-hero .kan { font-family: var(--f-brush); font-size: clamp(96px, 14vw, 180px); line-height: .9; filter: url(#sumi); }
.g-hero h1 { font-family: var(--f-mincho); font-weight: 800; font-size: clamp(28px, 4vw, 48px); letter-spacing: .06em; margin: 0 0 6px; line-height: 1.3; }
.g-hero h1 small { display: block; font-size: .4em; color: var(--grey); letter-spacing: .14em; margin-top: 4px; }
.g-hero p { margin: 10px 0 0; color: var(--grey-2); font-size: 14px; max-width: 40em; }

/* ---------- filters ---------- */
.filters {
  position: sticky; top: 61px; z-index: 30;
  background: rgba(11,11,11,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line-dark); border-bottom: 1px solid var(--line-dark);
}
.filters-inner {
  max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto;
  padding: 14px var(--gutter);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-family: var(--f-latin); font-style: italic; font-size: 13px; letter-spacing: .08em; color: var(--grey); }
.field > span b { font-family: var(--f-mincho); font-style: normal; font-weight: 600; font-size: 11px; margin-left: 6px; color: var(--grey-2); }
select, input[type="text"], input[type="month"], input[type="password"] {
  width: 100%; min-width: 0;
  appearance: none; -webkit-appearance: none;
  font: inherit; font-size: 14px; letter-spacing: .02em;
  color: inherit; background: transparent;
  border: 1px solid currentColor; border-radius: 0;
  padding: 10px 12px; line-height: 1.4;
}
.sub:not(.light) select, .sub:not(.light) input { border-color: rgba(255,255,255,.35); }
.light select, .light input[type="text"], .light input[type="month"], .light input[type="password"] { border-color: rgba(0,0,0,.35); background: #fff; }
select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px;
}
select option, select optgroup { background: var(--ink); color: var(--paper); }
select:focus, input:focus, button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.btn {
  font: inherit; font-family: var(--f-mincho); font-weight: 600; font-size: 14px; letter-spacing: .1em;
  padding: 10px 18px; cursor: pointer;
  border: 1px solid currentColor; background: transparent; color: inherit;
  transition: background .25s, color .25s;
  white-space: nowrap;
}
.btn:hover { background: currentColor; }
.sub:not(.light) .btn:hover { color: var(--ink); background: var(--paper); }
.light .btn:hover { color: var(--paper); background: var(--ink); }
.btn.solid { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.light .btn.solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.solid:hover { opacity: .85; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 12px; }

.g-status {
  max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto;
  padding: 18px var(--gutter) 0;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--grey-2);
}
.g-status .count { font-family: var(--f-latin); font-style: italic; font-size: 22px; color: var(--paper); }
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 10px; border: 1px solid currentColor; border-radius: 99px;
  background: transparent; color: inherit; cursor: pointer; font-family: inherit; line-height: 1.6;
}
.chip:hover { background: rgba(255,255,255,.1); }

/* ---------- justified grid ---------- */
.g-grid {
  max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto;
  padding: 18px var(--gutter) 100px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.g-grid::after { content: ""; flex-grow: 999999; }
.g-item {
  --ar: 1.5;
  position: relative;
  flex-grow: calc(var(--ar) * 100);
  width: calc(var(--ar) * 230px);
  display: flex; flex-direction: column;
  color: var(--paper);
}
.g-open {
  position: relative; display: block; width: 100%;
  margin: 0; padding: 0; border: 0; cursor: zoom-in;
  background: #161616; color: inherit; overflow: hidden;
  font: inherit; text-align: left;
}
.g-open::before { content: ""; display: block; padding-bottom: calc(100% / var(--ar)); }
.g-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(.15); transition: transform .6s cubic-bezier(.2,.7,.1,1), filter .4s, opacity .5s; opacity: 0; }
.g-item img.loaded { opacity: 1; }
.g-open:hover img, .g-open:focus-visible img { transform: scale(1.04); filter: none; }
.g-item .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  font-size: 11.5px; line-height: 1.5; letter-spacing: .04em;
  opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s;
}
.g-item .cap b { display: block; font-family: var(--f-mincho); font-weight: 600; font-size: 12.5px; }
.g-open:hover .cap, .g-open:focus-visible .cap { opacity: 1; transform: none; }

/* thumbnail footer: date + like */
.g-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 2px 2px; min-height: 34px;
}
.g-bar .meta { font-size: 11px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* like button */
.like {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px; min-height: 28px;
  border: 1px solid rgba(255,255,255,.28); border-radius: 99px;
  background: transparent; color: var(--paper);
  font: inherit; font-family: var(--f-latin); font-size: 15px; line-height: 1; letter-spacing: .02em;
  cursor: pointer; transition: background .2s, border-color .2s, color .2s;
}
.like svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.like:hover { border-color: var(--paper); }
.like[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.like[aria-pressed="true"] svg { fill: currentColor; }
.like.pop svg { transform: scale(1.35); }
.like[disabled] { opacity: .6; cursor: progress; }
.like .n { min-width: 1ch; font-variant-numeric: tabular-nums; }
.lb-meta .like { font-size: 17px; padding: 6px 14px 6px 12px; }
.lb-meta .like svg { width: 18px; height: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 300; transform: translate(-50%, 20px);
  background: var(--paper); color: var(--ink); padding: 10px 18px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.g-empty { width: 100%; text-align: center; padding: 80px 0; color: var(--grey-2); font-family: var(--f-mincho); }
.g-empty .kan { display: block; font-family: var(--f-brush); font-size: 110px; line-height: 1; color: var(--paper); filter: url(#sumi); margin-bottom: 12px; }

/* ---------- lightbox ---------- */
.lb {
  position: fixed; inset: 0; z-index: 200;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(6,6,6,.97); color: var(--paper);
  display: none;
}
.lb[open] { display: grid; grid-template-rows: 1fr auto; }
.lb::backdrop { background: rgba(0,0,0,.9); }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 56px 64px 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .25s; }
.lb-stage img.loading { opacity: .25; }
.lb-btn {
  position: absolute; background: none; border: 0; color: var(--paper); cursor: pointer;
  font-family: var(--f-latin); font-size: 34px; line-height: 1; padding: 14px; opacity: .7;
}
.lb-btn:hover { opacity: 1; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-close { right: 10px; top: 6px; font-size: 30px; }
.lb-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 24px;
  padding: 14px clamp(16px, 4vw, 64px) 20px;
  border-top: 1px solid var(--line-dark);
  font-size: 13px;
}
.lb-meta .title { font-family: var(--f-mincho); font-weight: 600; font-size: 15px; }
.lb-meta .ev { color: var(--grey-2); margin-left: 10px; font-size: 12px; }
.lb-meta .drivers { display: flex; gap: 6px; flex-wrap: wrap; }
.lb-meta .idx { font-family: var(--f-latin); font-style: italic; font-size: 16px; color: var(--grey-2); }
.lb-meta .copy { font-size: 11px; color: var(--grey); }

/* ---------- admin ---------- */
.admin-wrap { max-width: 980px; margin: 0 auto; padding: clamp(40px, 7vw, 80px) var(--gutter) 100px; }
.admin-wrap h1 { font-family: var(--f-mincho); font-weight: 800; font-size: clamp(26px, 3.4vw, 38px); letter-spacing: .06em; margin: 0 0 6px; }
.admin-wrap .lead { color: #555; font-size: 14px; margin: 0 0 32px; }
.panel { border: 1px solid var(--line-light); background: rgba(255,255,255,.55); padding: clamp(18px, 3vw, 32px); margin-bottom: 28px; }
.panel h2 { font-size: 18px; margin: 0 0 18px; display: flex; align-items: baseline; gap: 12px; }
.panel h2 i { font-family: var(--f-brush); font-style: normal; font-size: 30px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.light .field > span { color: #555; }
.hint { font-size: 12px; color: #777; margin: 2px 0 0; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid rgba(0,0,0,.35); background: #fff; padding: 6px; min-height: 46px; }
.tags input { border: 0 !important; flex: 1; min-width: 140px; padding: 6px !important; outline: none; }
.tags .chip { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tags .chip:hover { opacity: .8; }

.drop {
  display: grid; place-items: center; text-align: center; gap: 6px;
  border: 1.5px dashed rgba(0,0,0,.4); background: #fff;
  padding: 34px 16px; cursor: pointer; transition: background .2s, border-color .2s;
}
.drop.over { background: #ecebe6; border-color: var(--ink); }
.drop .kan { font-family: var(--f-brush); font-size: 54px; line-height: 1; }
.drop p { margin: 0; font-size: 14px; }
.drop small { color: #777; }

.file-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.file-list li { position: relative; background: #ddd; aspect-ratio: 3 / 2; overflow: hidden; }
.file-list img { width: 100%; height: 100%; object-fit: cover; }
.file-list .rm { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.file-list .st { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; padding: 2px 6px; background: rgba(0,0,0,.65); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-list li.done .st { background: rgba(0,0,0,.85); }
.file-list li.err .st { background: #000; text-decoration: underline; }
.file-list li.busy::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.45); animation: pulse-bg 1s ease-in-out infinite alternate; }
@keyframes pulse-bg { to { background: rgba(255,255,255,.15); } }

.upload-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-top: 22px; }
.meter { flex: 1; min-width: 200px; height: 4px; background: rgba(0,0,0,.12); position: relative; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ink); transition: width .3s; }
.msg { font-size: 13px; margin: 12px 0 0; min-height: 1.6em; }
.msg.error { font-weight: 600; text-decoration: underline; }

.batch-list { list-style: none; margin: 0; padding: 0; }
.batch-list li { display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-light); }
.batch-list .cover { width: 96px; aspect-ratio: 3 / 2; background: #ccc; object-fit: cover; }
.batch-list .t { font-family: var(--f-mincho); font-weight: 600; font-size: 15px; }
.batch-list .d { font-size: 12px; color: #666; }

.login-box { max-width: 420px; margin: 12vh auto 0; padding: 0 var(--gutter); text-align: center; }
.login-box .kan { font-family: var(--f-brush); font-size: 120px; line-height: 1; filter: url(#sumi); }
.login-box form { display: grid; gap: 14px; margin-top: 24px; text-align: left; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .filters-inner { grid-template-columns: 1fr 1fr; }
  .filters-inner .btn { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .filters { position: static; }
  .g-hero { grid-template-columns: 1fr; gap: 6px; }
  .g-item { width: calc(var(--ar) * 140px); }
  .lb-stage { padding: 48px 6px 6px; }
  .lb-prev, .lb-next { top: auto; bottom: -6px; transform: none; }
  .form-grid { grid-template-columns: 1fr; }
  .batch-list li { grid-template-columns: 72px 1fr; }
  .batch-list li .btn { grid-column: 2; justify-self: start; }
  .batch-list .cover { width: 72px; }
}
.sub-header .brand { flex-shrink: 0; }
.sub-header .brand-kanji { white-space: nowrap; }
@media (max-width: 640px) { .back-link { font-size: 11.5px; text-align: right; line-height: 1.5; } }
