/* Nocturne Archive — v0.4.1
 * 雨夜の紫陽花。写真が主役、装飾は退く。
 * コントラスト（WCAG 2.2）
 *   雨霧の白 #D9E3F1 × サファイア面 #2B5CC4 = 約4.7:1（ボタン文字）
 *   淡い紫陽花 #A79DE8 × 墨紺 #0D1320 = 約7.6:1（小さい文字に使う紫）
 *   鈍い灰青 #8B94A8 × 墨紺 #0D1320 = 約6.1:1
 *   #3F7FE8 と #7A6FCA は線・図形・大きな要素だけに使う
 */

:root {
  --night: #06070B;
  --ink: #0D1320;
  --deep: #111B32;
  --sapphire: #3F7FE8;
  --sapphire-face: #2B5CC4;
  --sapphire-light: #7EABFF;
  --hydrangea: #7A6FCA;
  --hydrangea-text: #A79DE8;
  --hydrangea-blue: #6F91C8;
  --mist: #D9E3F1;
  --muted: #8B94A8;
  --danger: #C96A7A;
  --line: rgba(217, 227, 241, 0.14);
  --line-strong: rgba(217, 227, 241, 0.28);

  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --mincho: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "BIZ UDMincho", serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock-h: 64px;
  --t-quick: 180ms;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--night);
  background-image:
    radial-gradient(60rem 40rem at 85% -10%, rgba(122, 111, 202, 0.10), transparent 60%),
    radial-gradient(50rem 35rem at -10% 110%, rgba(111, 145, 200, 0.08), transparent 60%);
  background-attachment: fixed;
  color: var(--mist);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--sapphire-light);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.4rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--mist);
  font: inherit;
  font-size: 0.97rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-quick) ease, border-color var(--t-quick) ease;
}
.btn:active { background: rgba(217, 227, 241, 0.06); }
.btn-primary {
  background: var(--sapphire-face);
  border-color: rgba(126, 171, 255, 0.45);
}
.btn-primary:active { background: #24509F; }
.btn-quiet { border-color: var(--line); }
.btn-small { min-height: 44px; padding: 0 1rem; font-size: 0.9rem; }
label.btn { user-select: none; -webkit-user-select: none; }

.chip {
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

/* 表紙 */
.cover {
  min-height: calc(100svh - 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--safe-top) + 3rem) 1.5rem 2rem;
}
.cover-emblem { width: 104px; height: 110px; margin-bottom: 1.6rem; }
.cover-title {
  margin: 0;
  font-family: var(--mincho);
  font-weight: 500;
  font-size: 1.9rem;
  letter-spacing: 0.06em;
  line-height: 1.3;
}
.cover-sub { margin: 0.5rem 0 2.6rem; color: var(--muted); font-size: 0.88rem; letter-spacing: 0.08em; }
.cover-actions { display: grid; gap: 0.75rem; width: min(100%, 300px); }
.cover-note { margin: 2.2rem 0 0.8rem; color: var(--muted); font-size: 0.86rem; line-height: 1.8; }

/* 展示室 */
.gallery { min-height: 80svh; padding: calc(var(--safe-top) + 1.2rem) 14px calc(var(--dock-h) + var(--safe-bottom) + 2rem); }
.gallery-head { max-width: 1200px; margin: 0 auto 1.2rem; padding: 0 4px; }
.gallery-title-row { display: flex; align-items: center; gap: 0.6rem; }
.head-emblem { width: 28px; height: 30px; }
.gallery-title { margin: 0; font-family: var(--mincho); font-weight: 500; font-size: 1.35rem; letter-spacing: 0.08em; }
.save-state { display: flex; align-items: center; gap: 0.45rem; margin: 0.6rem 0 0; font-size: 0.9rem; }
.save-state svg { width: 14px; height: 14px; flex: none; }
.save-state.is-dirty { color: var(--mist); }
.save-state.is-dirty svg { color: var(--hydrangea-text); }
.save-state.is-saved { color: var(--muted); }
.save-state.is-saved svg { color: var(--sapphire-light); }
.album-stats { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.82rem; }

.confirm-row {
  margin: 0.8rem 0 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(126, 171, 255, 0.35);
  border-radius: 10px;
  background: var(--deep);
}
.confirm-text { margin: 0 0 0.6rem; font-size: 0.86rem; }
.save-state.is-verified { color: var(--mist); }
.save-state.is-verified svg { color: var(--sapphire-light); }
.save-state.is-warn { color: var(--danger); }

.grid {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 1200px;
  column-count: 2;
  column-gap: 12px;
}
@media (min-width: 720px) { .grid { column-count: 3; column-gap: 16px; } .gallery { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1080px) { .grid { column-count: 4; column-gap: 20px; } }

.tile { break-inside: avoid; margin: 0 0 14px; }
.tile-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tile-frame {
  display: block;
  border-radius: 3px;
  overflow: hidden;
  background: var(--ink);
  outline: 1px solid var(--line);
  outline-offset: -1px;
}
.tile-img { display: block; width: 100%; height: auto; }
.tile-placeholder {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 3 / 4;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  white-space: pre-line;
  background:
    repeating-linear-gradient(135deg, rgba(122, 111, 202, 0.06) 0 8px, transparent 8px 16px),
    var(--ink);
}
.tile-placeholder.is-broken { color: var(--danger); }
.tile-cap { display: block; margin-top: 0.35rem; font-family: var(--mincho); font-size: 0.78rem; color: var(--muted); letter-spacing: 0.06em; }

.empty { max-width: 360px; margin: 3.5rem auto; text-align: center; }
.empty-emblem { width: 64px; height: 68px; opacity: 0.55; }
.empty-title { margin: 1rem 0 0.2rem; font-family: var(--mincho); font-size: 1.1rem; }
.empty-body { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* 下部の操作（片手で届く位置） */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(13, 19, 32, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.dock-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--mist);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dock-primary { background: var(--sapphire-face); border-color: rgba(126, 171, 255, 0.45); }
.badge {
  margin-left: 0.45rem;
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--night);
  color: var(--mist);
  font-size: 0.78rem;
  line-height: 1.5rem;
}

/* 鑑賞（全画面） */
.viewer {
  position: fixed; inset: 0;
  z-index: 30;
  background: var(--night);
  display: grid;
  grid-template-rows: 1fr auto;
}
.viewer-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 56px) 8px 8px;
  min-height: 0;
  touch-action: pan-y pinch-zoom;
}
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-msg { max-width: 300px; color: var(--muted); text-align: center; font-size: 0.92rem; }
.viewer-top {
  position: absolute;
  top: calc(var(--safe-top) + 6px);
  right: 8px;
  left: 8px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.viewer-chip { background: rgba(13, 19, 32, 0.8); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--mist);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:disabled { color: rgba(217, 227, 241, 0.25); cursor: default; }

/* 美術館のキャプション */
.plate {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  padding: 10px 10px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.plate-text { text-align: center; min-width: 0; }
.plate-no { margin: 0; color: var(--hydrangea-text); font-family: var(--mincho); font-size: 0.78rem; letter-spacing: 0.14em; }
.plate-title {
  margin: 0.1rem 0;
  font-family: var(--mincho);
  font-size: 1.02rem;
  letter-spacing: 0.04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plate-meta { margin: 0; color: var(--muted); font-size: 0.78rem; }

/* シート（ダイアログ） */
.sheet {
  width: min(calc(100% - 24px), 420px);
  max-height: calc(100svh - 24px);
  padding: 1.4rem 1.3rem 1.2rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--ink);
  color: var(--mist);
  overflow: auto;
}
.sheet::backdrop { background: rgba(6, 7, 11, 0.72); }
.sheet-title { margin: 0 0 0.6rem; font-family: var(--mincho); font-weight: 500; font-size: 1.15rem; }
.sheet-body { margin: 0 0 0.8rem; color: var(--mist); font-size: 0.92rem; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }
.sheet-actions .btn { white-space: nowrap; }
.sheet-actions .btn-primary { flex: 1 1 auto; }
.sheet-actions-stack { flex-direction: column-reverse; }
.sheet-actions-stack .btn { width: 100%; }
.field-label { display: block; margin: 0.8rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); }
.field {
  width: 100%;
  min-height: 48px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--night);
  color: var(--mist);
  font: inherit;
  font-size: 16px; /* iPhone の自動ズームを防ぐ */
}
.select {
  min-height: 44px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--night);
  color: var(--mist);
  font: inherit;
  font-size: 16px;
}
.warn {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-left: 2px solid var(--hydrangea);
  background: rgba(122, 111, 202, 0.08);
  font-size: 0.86rem;
}
.error { margin: 0.8rem 0 0; color: var(--danger); font-size: 0.88rem; }

/* 処理中 */
.busy {
  position: fixed; inset: 0;
  z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(6, 7, 11, 0.8);
}
.busy-card {
  width: min(100%, 360px);
  padding: 1.3rem 1.3rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--ink);
}
.busy-text { margin: 0 0 0.9rem; font-size: 0.95rem; }
.busy-sub { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.82rem; }
.rain { height: 3px; border-radius: 3px; background: var(--deep); overflow: hidden; }
.rain-fill { height: 100%; width: 0; background: var(--sapphire-light); transition: width var(--t-quick) linear; }
.rain-fill.is-indeterminate { width: 30%; animation: drizzle 1.4s ease-in-out infinite; }
@keyframes drizzle { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* 目隠し */
.veil {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--night);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.veil-mark { width: 56px; height: 60px; opacity: 0.5; margin-bottom: 0.6rem; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 18px);
  z-index: 50;
  width: fit-content;
  max-width: 420px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--deep);
  font-size: 0.9rem;
}

/* 試験室 */
.lab {
  max-width: 1200px;
  margin: 0 auto calc(var(--dock-h) + var(--safe-bottom) + 1.5rem);
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}
.lab > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.lab-body { padding: 0.5rem 0 1rem; }
.lab-note { margin: 0 0 0.8rem; }
.lab-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.7rem; }
.lab-label { color: var(--mist); }
.diag { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.82rem; }
.diag th, .diag td { padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.diag th { color: var(--muted); font-weight: 400; width: 46%; }
.diag td { color: var(--mist); word-break: break-all; }
.log {
  min-height: 3rem;
  max-height: 16rem;
  overflow: auto;
  margin: 0.6rem 0;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--night);
  color: var(--mist);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}


/* v0.3.0 ─ 部屋・選択・書き出し */
.head-actions { margin-left: auto; display: flex; gap: 6px; }
.head-actions .btn { min-height: 40px; padding: 0 0.8rem; font-size: 0.85rem; }

.rooms {
  display: flex;
  gap: 4px;
  margin: 1rem 0 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rooms::-webkit-scrollbar { display: none; }
.room-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.room-tab[aria-pressed="true"] { color: var(--mist); border-color: rgba(126, 171, 255, 0.55); background: var(--deep); }
.room-count { font-size: 0.78rem; color: var(--muted); }
.room-tab[aria-pressed="true"] .room-count { color: var(--sapphire-light); }
.room-hint { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.82rem; }

.tile-btn[aria-pressed="true"] .tile-frame { outline: 2px solid var(--sapphire-light); outline-offset: 2px; }
.tile-check {
  display: none;
  position: absolute;
  top: 6px; left: 6px;
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 1.5px solid var(--mist);
  background: rgba(6, 7, 11, 0.55);
}
.is-selecting .tile-check { display: block; }
.tile-btn[aria-pressed="true"] .tile-check { background: var(--sapphire-face); border-color: var(--sapphire-light); }
.tile-btn[aria-pressed="true"] .tile-check::after {
  content: "";
  position: absolute;
  left: 8px; top: 4px;
  width: 6px; height: 11px;
  border: solid var(--mist);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tile-frame { position: relative; }

.dock-select {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto auto;
}
.select-count { grid-column: 1 / -1; margin: 0 0 2px; color: var(--muted); font-size: 0.82rem; text-align: center; }
.dock-danger { color: var(--danger); border-color: rgba(201, 106, 122, 0.45); }
.dock-btn:disabled { opacity: 0.4; cursor: default; }

.sheet-form { margin: 0; }
.warn-text { margin: 0 0 0.5rem; }
.check-row { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.86rem; cursor: pointer; }
.check-row input { width: 20px; height: 20px; margin-top: 0.15rem; accent-color: var(--sapphire-face); flex: none; }
.file-name { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.86rem; color: var(--sapphire-light); word-break: break-all; }

/* PC では下の操作を中央にまとめ、横に伸びすぎないようにする */
@media (min-width: 720px) {
  .dock { left: 50%; right: auto; transform: translateX(-50%); width: min(640px, calc(100% - 48px)); bottom: 16px; border: 1px solid var(--line); border-radius: 14px; padding-bottom: 8px; }
  .gallery { padding-bottom: calc(var(--dock-h) + 4rem); }
}

.open-any { margin: 0.2rem 0 0; text-align: center; }
.link-btn { display: inline-flex; align-items: center; min-height: 44px; color: var(--sapphire-light); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }

/* 選択中は、知らせを操作の上へずらす */
.is-selecting ~ .toast, body:has(.is-selecting) .toast { bottom: calc(var(--dock-h) + var(--safe-bottom) + 48px); }

/* v0.3.1 */
.key-name { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.82rem; }
.key-name strong { color: var(--sapphire-light); font-weight: 500; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.choices { display: grid; gap: 0.5rem; margin: 0 0 0.9rem; }
.choice-row { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice-row:has(input:checked) { border-color: rgba(126, 171, 255, 0.55); background: var(--deep); }
.choice-row input { width: 20px; height: 20px; margin-top: 0.2rem; accent-color: var(--sapphire-face); flex: none; }
.choice-title { display: block; font-size: 0.92rem; }
.choice-body { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.warn-text { white-space: pre-line; }
.warn-small { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.8rem; }

/* v0.4.0 ─ 探す・並べる・お気に入り・作品の情報 */
.tools { margin: 0.8rem 0 0; display: grid; gap: 0.55rem; }
.search { min-height: 44px; -webkit-appearance: none; appearance: none; }
.scope-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.scope-label { color: var(--muted); font-size: 0.82rem; margin-right: 2px; }
.tool-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  min-height: 40px; padding: 0 0.8rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 0.84rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-btn[aria-pressed="true"] { color: var(--mist); border-color: rgba(126, 171, 255, 0.55); background: var(--deep); }
.chip-gem { width: 15px; height: 15px; opacity: 0.5; }
.chip-btn[aria-pressed="true"] .chip-gem { opacity: 1; }
.select-small { min-height: 40px; font-size: 14px; max-width: 12.5rem; }
.cols-group { display: inline-flex; margin-left: auto; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cols-btn { min-width: 40px; min-height: 40px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.88rem; cursor: pointer; }
.cols-btn + .cols-btn { border-left: 1px solid var(--line); }
.cols-btn[aria-pressed="true"] { background: var(--deep); color: var(--mist); }
.result-line { margin: 0; color: var(--mist); font-size: 0.86rem; }

/* 列の切り替え（CSS の段組みをやめ、並び順どおりに置く） */
.grid { columns: auto; display: grid; gap: 0 12px; grid-auto-flow: row; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 4px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
  .grid.cols-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.cols-5 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (min-width: 1080px) {
  .grid.cols-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 20px; }
  .grid.cols-3 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .grid.cols-5 { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
.tile { margin: 0; min-width: 0; }
.grid.cols-2 .tile-frame { aspect-ratio: var(--ar, 3 / 4); }
.grid.cols-3 .tile-frame, .grid.cols-5 .tile-frame { aspect-ratio: 1 / 1; }
.tile-frame { display: block; }
.tile-img { width: 100%; height: 100%; object-fit: cover; }
.tile-placeholder { aspect-ratio: auto; height: 100%; }
.grid.cols-5 .tile-cap { display: none; }
.grid.cols-5 .tile-frame { border-radius: 1px; }
.grid.cols-3 .tile-cap { font-size: 0.72rem; }
.tile-fav { display: none; position: absolute; right: 6px; bottom: 6px; width: 18px; height: 18px; filter: drop-shadow(0 0 2px rgba(6, 7, 11, 0.7)); }
.is-fav .tile-fav { display: block; }
.grid.cols-5 .tile-fav { width: 12px; height: 12px; right: 3px; bottom: 3px; }
.grid.cols-5 .tile-check { width: 18px; height: 18px; top: 3px; left: 3px; }
.grid.cols-5 .tile-btn[aria-pressed="true"] .tile-check::after { left: 5px; top: 2px; width: 5px; height: 9px; }

.dock-select { grid-template-columns: repeat(3, 1fr); }

.viewer-fav svg { width: 26px; height: 26px; opacity: 0.35; filter: grayscale(0.6); }
.viewer-fav[aria-pressed="true"] svg { opacity: 1; filter: none; }
.plate-tags { margin: 0.15rem 0 0; color: var(--hydrangea-text); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 0.5rem; }
.tag-list:empty { display: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.2rem 0.15rem 0.7rem; border: 1px solid rgba(167, 157, 232, 0.4); border-radius: 999px; color: var(--hydrangea-text); font-size: 0.85rem; }
.tag-x { min-width: 32px; min-height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.tag-add { display: flex; gap: 6px; }
.tag-add .field { flex: 1; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.5rem 0 0; }
.tag-suggest-btn { min-height: 36px; padding: 0 0.7rem; border: 1px dashed var(--line-strong); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 0.82rem; cursor: pointer; }
.textarea { min-height: 6.5rem; padding: 0.7rem 0.9rem; line-height: 1.6; resize: vertical; }
.field-hint { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.8rem; }
/* 下の操作に「試験室」が隠れないよう、余白を margin ではなく padding で取る（短いページでもスクロールできる） */
.lab { margin-bottom: 0; padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + 2rem); }
