:root {
  --paper: #F3EFE8;
  --paper-2: #E7E1D6;
  --ink: #1F1D1A;
  --ink-2: #5E5850;
  --ink-3: #8F887D;
  --line: #D8D1C4;
  --accent: #B5462F;
  --accent-soft: #F1DCD3;
  --card: #FBF9F5;
  --mark: #F6E3A8;
  --shadow: 0 1px 2px rgba(40, 30, 20, .08), 0 8px 24px -12px rgba(40, 30, 20, .28);
  --f-title: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --f-latin: "Cormorant Garamond", Georgia, serif;
  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17161A;
    --paper-2: #24222A;
    --ink: #EDE8DF;
    --ink-2: #B5AEA3;
    --ink-3: #7F786F;
    --line: #34313A;
    --accent: #E07A5F;
    --accent-soft: #3A2620;
    --card: #1E1D22;
    --mark: #5A4A1C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px -12px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt";
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
body.sheet-open { overflow: hidden; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- 見出し ---------- */
.masthead {
  display: flex; align-items: baseline; gap: 12px;
  padding: calc(20px + env(safe-area-inset-top)) var(--gutter) 6px;
}
.brand { margin: 0; font-family: var(--f-title); font-weight: 700; font-size: 26px; letter-spacing: .08em; }
.brand-sub { margin: 0; color: var(--ink-3); font-size: 12px; letter-spacing: .2em; }

/* ---------- 分類チップ ---------- */
.filters {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px var(--gutter);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-n { font-size: 11px; color: var(--ink-3); }
.chip[aria-pressed="true"] .chip-n { color: inherit; opacity: .6; }
.chip.small { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.chip.orig::after { content: "元"; font-size: 10px; color: var(--ink-3); margin-left: 2px; }
.chip.orig[aria-pressed="true"]::after { color: inherit; opacity: .6; }
.dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* ---------- 棚：段組みで高さの違う絵が流れる面 ---------- */
main { padding: 8px var(--gutter) 48px; }
.shelf { columns: 2; column-gap: 14px; }
@media (min-width: 640px) { .shelf { columns: 3; column-gap: 20px; } }
@media (min-width: 1000px) { .shelf { columns: 4; column-gap: 26px; } main { max-width: 1280px; margin: 0 auto; } }

.card {
  display: block; width: 100%; break-inside: avoid;
  margin: 0 0 22px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  transform: translateY(var(--nudge, 0)) rotate(var(--tilt, 0));
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
.shelf .card:first-child { margin-top: 0; }
.card-frame {
  position: relative; overflow: hidden; border-radius: 4px;
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s;
}
.card:active .card-frame { transform: scale(.97); }
@media (hover: hover) {
  .card:hover .card-frame { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(40,30,20,.08), 0 18px 34px -14px rgba(40,30,20,.4); }
}
.card img { display: block; width: 100%; height: auto; }
.card-name {
  display: block; padding: 8px 2px 0;
  font-family: var(--f-title); font-weight: 500; font-size: 14px; line-height: 1.45; letter-spacing: .02em;
}
.tmp-badge {
  position: absolute; top: 6px; left: 6px;
  font-size: 10px; line-height: 1; padding: 4px 6px; border-radius: 3px;
  background: rgba(255,255,255,.82); color: #6b5a3c;
}
@keyframes rise { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }

/* 見本画像が無い画風の色面 */
.plane { position: relative; width: 100%; aspect-ratio: 3 / 4; }
.plane-bands { position: absolute; left: 0; right: 0; bottom: 0; height: 38%; display: flex; }
.plane-bands span { flex: 1 1 0; }

.empty { color: var(--ink-3); text-align: center; padding: 40px 0; }

/* ---------- 詳細シート ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(20, 16, 12, .45);
  animation: fade .2s both;
}
.sheet {
  position: fixed; z-index: 21; left: 0; right: 0; bottom: 0;
  height: 94dvh; max-height: 94vh;
  background: var(--paper); border-radius: 16px 16px 0 0; overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet.in { transform: translateY(0); }
@media (min-width: 760px) {
  .sheet { left: 50%; right: auto; width: 720px; margin-left: -360px; top: 3vh; bottom: 3vh; height: auto; max-height: none; border-radius: 14px;
    transform: translateY(24px); opacity: 0; transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s; }
  .sheet.in { transform: none; opacity: 1; }
}
@keyframes fade { from { opacity: 0; } }
.sheet-scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.sheet-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(20, 16, 12, .55); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hero { margin: 0; background: var(--paper-2); }
.hero img { display: block; width: 100%; max-height: 56vh; object-fit: contain; background: var(--paper-2); }
.hero .plane { aspect-ratio: 16 / 10; }
.sheet-body { padding: 18px var(--gutter) 0; }
.d-head { margin-bottom: 14px; }
.d-cat { margin: 0; font-size: 12px; color: var(--ink-3); letter-spacing: .08em; }
.d-name { margin: 2px 0 0; font-family: var(--f-title); font-weight: 700; font-size: 24px; line-height: 1.35; letter-spacing: .03em; }
.d-name-en { margin: 2px 0 0; font-family: var(--f-latin); font-style: italic; font-size: 17px; color: var(--ink-2); }

.d-block { margin: 0 0 24px; }
.d-h { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .2em; color: var(--ink-3); }
.d-h-row { display: flex; align-items: baseline; gap: 14px; }
.d-h-row .d-h { margin-bottom: 10px; }
.text-btn { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 4px 0 10px; cursor: pointer; }

.swatches { display: flex; gap: 8px; }
.swatch {
  flex: 1 1 0; min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; text-align: center;
}
.swatch-color { display: block; height: 56px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .12s; }
.swatch:active .swatch-color { transform: scale(.94); }
.swatch-hex { display: block; margin-top: 5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--ink-2); letter-spacing: .02em; }

.features { display: grid; grid-template-columns: 3.2em 1fr; gap: 6px 10px; margin: 0; }
.features dt { font-family: var(--f-title); font-weight: 700; color: var(--ink-2); }
.features dd { margin: 0; }

.axis { margin-bottom: 12px; }
.axis-label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.axis-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 2px; }
.axis-chips::-webkit-scrollbar { display: none; }

.prompt-box { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 10px 12px 12px; margin-bottom: 10px; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.lang { font-size: 11px; font-weight: 700; letter-spacing: .2em; color: var(--ink-3); }
.copy-btn {
  min-height: 34px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  font-size: 13px; cursor: pointer;
}
.copy-btn:active, .md-btn:active { transform: scale(.96); }
.prompt { margin: 0; font-size: 14px; line-height: 1.7; word-break: break-word; }
.prompt[lang="en"] { font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif; }
mark.added { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.md-btn {
  display: block; width: 100%; min-height: 48px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--paper); font-weight: 700; font-size: 15px; letter-spacing: .05em; cursor: pointer;
}

.notes { font-size: 13px; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.tags-label { font-size: 12px; color: var(--ink-3); margin-right: 4px; }
.tag { padding: 2px 10px; border-radius: 999px; background: var(--paper-2); font-size: 12px; }
.caution { margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--ink); border-radius: 0 6px 6px 0; }
.source { margin: 0; font-size: 12px; color: var(--ink-3); }

/* ---------- トースト ---------- */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14px;
  transition: opacity .2s, transform .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .sheet, .toast, .card-frame { transition: none; }
}
