:root {
  --bg: #f6efe9;
  --surface: #fffaf6;
  --surface-2: #f1e7e0;
  --ink: #2b2226;
  --muted: #7d6e73;
  --line: #e6d8d0;
  --accent: #b8454a;
  --accent-ink: #fff;
  --sage: #5f7a6a;
  --daiso: #c93a63;
  --seria: #4f7f73;
  --cando: #c8872b;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 30, 30, 0.06), 0 10px 30px -18px rgba(60, 30, 30, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --font-display: "Fraunces", "Zen Kaku Gothic New", serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  /* 斜めの淡いウォッシュ（放射状グラデーションは一部環境で境界が出るため線形に） */
  background: linear-gradient(115deg, rgba(95, 122, 106, 0.10), transparent 40%, transparent 60%, rgba(184, 69, 74, 0.10)), var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- トップバー ---------- */
.topbar { max-width: 1100px; margin: 0 auto; padding: 12px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__owned { display: grid; justify-items: end; line-height: 1; gap: 3px; }
.topbar__label { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.topbar__count { display: flex; align-items: baseline; gap: 3px; font-family: var(--font-display); }
.topbar__num { font-size: 22px; font-weight: 500; }
.topbar__of { font-size: 12px; color: var(--muted); }
.add-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 14px -8px rgba(184,69,74,0.7); transition: transform 200ms var(--ease);
}
.add-btn:active { transform: scale(0.92); }
.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variation-settings: "opsz" 144;
}
.logo__btn { all: unset; cursor: pointer; font: inherit; color: inherit; letter-spacing: inherit; }
.logo__ruby { position: relative; display: inline-block; line-height: 1; }
/* 読み: l の後ろから始め、G や l の高さ（アセンダー）より内側に収める */
.logo__yomi {
  position: absolute; left: 0.04em; top: 0.1em;
  font-family: var(--font-body); font-size: 0.22em; font-weight: 500; letter-spacing: 0.3em;
  color: var(--accent); white-space: nowrap; line-height: 1;
}
.logo__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.logo::after { content: ""; display: inline-block; width: 0.3em; height: 0.3em; margin-left: 0.12em; border-radius: 50%; background: var(--accent); vertical-align: 0.05em; }

/* ---------- ツールバー ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  padding: 8px 0 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.toolbar__inner { max-width: 1100px; margin: 0 auto; padding: 0 12px; }
.toolbar__row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.segmented { display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 5px 4px; color: var(--muted);
  display: grid; justify-items: center; gap: 0; line-height: 1.15;
  transition: background 200ms var(--ease), color 200ms;
}
.segmented button span { font-size: 13px; font-weight: 500; white-space: nowrap; }
.segmented button small { font-size: 10px; font-family: var(--font-display); opacity: 0.75; min-height: 12px; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 10px; color: var(--muted); height: 40px;
}
.search input { flex: 1; border: 0; background: transparent; padding: 0; outline: none; min-width: 0; font-size: 15px; }
.search:focus-within { border-color: var(--accent); }
.filter-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.filter-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge[hidden] { display: none; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-style: normal; display: grid; place-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 13px; color: var(--muted);
}
.chips button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.toolbar__row--family { margin-top: 6px; gap: 6px; }
.family-strip { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent); }
.view-switch { flex: none; display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.view-switch button {
  width: 34px; height: 28px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background 200ms var(--ease), color 200ms;
}
.view-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.family-strip::-webkit-scrollbar { display: none; }
.family-strip button {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: transparent;
  border-radius: 999px; padding: 3px; font-size: 12px; color: var(--muted);
}
.family-strip button i { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); transition: transform 200ms var(--ease); }
.family-strip button span { display: none; }
.family-strip button[aria-pressed="true"] { border-color: var(--ink); background: var(--surface); }
.family-strip button[aria-pressed="true"] i { transform: scale(0.85); }
@media (min-width: 720px) {
  .topbar { padding-top: 22px; padding-bottom: 10px; }
  .logo { font-size: 40px; }
  .topbar__num { font-size: 26px; }
  .add-btn { width: 42px; height: 42px; }
  .toolbar { padding: 10px 0 8px; }
  .toolbar__inner { padding: 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; }
  .segmented { display: inline-flex; }
  .segmented button { padding: 6px 16px; }
  .toolbar__row { margin-top: 0; }
  .toolbar__row--family { grid-column: 1 / -1; gap: 10px; }
  .family-strip button { padding: 3px 10px 3px 4px; }
  .family-strip button span { display: inline; }
  .family-strip button[aria-pressed="true"] { color: var(--ink); }
  .filter-btn { padding: 0 16px; }
}

/* ---------- グリッド ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px; }
.result-count { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-family: var(--font-display); font-style: italic; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 18px 14px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; } main { padding-top: 20px; } }

/* カード = 色のタイル + 名前。写真は使わず、カラー名から推定した色と質感で描く */
.card { position: relative; }
.card__main { display: block; width: 100%; border: 0; background: transparent; padding: 0; text-align: left; border-radius: 16px; }
.card__main:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card__swatch {
  position: relative; display: block; aspect-ratio: 1; border-radius: 16px; overflow: hidden; isolation: isolate;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(43, 34, 38, 0.08), 0 6px 14px -8px color-mix(in srgb, var(--swatch) 70%, black);
  transition: transform 250ms var(--ease), box-shadow 250ms var(--ease);
}
.card__main:active .card__swatch { transform: scale(0.95); }
/* ツヤ: 左上のハイライトと下部の落ち */
.card__swatch::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 60% at 22% 12%, rgba(255,255,255,0.55), rgba(255,255,255,0.08) 45%, transparent 70%),
    linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.10));
}
.card__swatch::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
/* 質感ごとの表現 */
.fin-glitter { background: linear-gradient(145deg, color-mix(in srgb, var(--swatch) 88%, white), var(--swatch) 55%, color-mix(in srgb, var(--swatch) 85%, black)); }
.fin-glitter::after {
  background-image:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='140'%20height='140'%3E%3Cfilter%20id='g'%20x='0'%20y='0'%20width='100%'%20height='100%'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.55'%20numOctaves='2'%20seed='11'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%200.96%200%200%200%200%200.85%200%200%200%2026%20-18'/%3E%3C/filter%3E%3Crect%20width='100%'%20height='100%'%20filter='url(%23g)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='96'%20height='96'%3E%3Cfilter%20id='g'%20x='0'%20y='0'%20width='100%'%20height='100%'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.95'%20numOctaves='2'%20seed='3'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%201%200%200%200%200%201%200%200%200%2022%20-14'/%3E%3C/filter%3E%3Crect%20width='100%'%20height='100%'%20filter='url(%23g)'/%3E%3C/svg%3E"),
    linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.28) 50%, transparent 70%);
  background-size: 140px 140px, 96px 96px, 100% 100%;
  mix-blend-mode: screen;
}
.fin-pearl::after {
  background: linear-gradient(115deg, transparent 25%, rgba(255,255,255,0.55) 45%, rgba(255,255,255,0.15) 55%, transparent 75%);
}
.fin-magnet { background: linear-gradient(160deg, color-mix(in srgb, var(--swatch) 70%, black) 0%, var(--swatch) 45%, color-mix(in srgb, var(--swatch) 75%, black) 100%); }
.fin-magnet::after {
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.75) 47%, rgba(255,255,255,0.9) 50%, rgba(255,255,255,0.35) 54%, transparent 64%);
  filter: blur(0.5px);
}
.fin-sheer { background: linear-gradient(135deg, color-mix(in srgb, var(--swatch) 45%, white) 0%, var(--swatch) 70%); }
.fin-sheer::after {
  background:
    repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,0.12) 10px 12px),
    linear-gradient(315deg, transparent 55%, rgba(255,255,255,0.35));
}
.fin-aurora { background: linear-gradient(135deg, var(--swatch) 0%, #f7d6e6 30%, #d3e6f8 55%, #e3f5d8 75%, var(--swatch) 100%); }
.fin-aurora::after {
  background-image: radial-gradient(circle, rgba(255,255,255,0.9) 0.6px, transparent 1.2px);
  background-size: 8px 8px; opacity: 0.7;
}
.fin-matte::before { background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.06)); }
.fin-clear {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.2)),
    repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 14px 14px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.card__code {
  position: absolute; left: 8px; top: 7px; z-index: 3; font-family: var(--font-display); font-size: 12px; font-weight: 500; letter-spacing: 0.02em;
  color: var(--ink-on); opacity: 0.85;
}
.card__check {
  position: absolute; top: 7px; right: 7px; z-index: 3; width: 24px; height: 24px; border-radius: 50%;
  background: var(--sage); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  transform: scale(0); transition: transform 300ms var(--ease);
}
.is-owned .card__check { transform: scale(1); }
.is-owned .card__swatch { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sage), 0 6px 14px -8px color-mix(in srgb, var(--swatch) 70%, black); }
.card:not(.is-owned) .card__swatch { opacity: 0.92; }
.card__body { display: grid; gap: 1px; padding: 8px 22px 0 4px; }
.card__title { font-weight: 700; font-size: 13px; line-height: 1.3; }
.card__sub { font-size: 11px; color: var(--muted); line-height: 1.3; }
.card__more {
  position: absolute; right: -4px; bottom: -4px; width: 30px; height: 30px; border: 0; background: transparent; border-radius: 50%;
  color: var(--muted); font-size: 18px; line-height: 1;
}
.card__more:hover { background: var(--surface-2); }
.dup { color: var(--accent); font-weight: 700; }
.disc { color: var(--muted); font-weight: 700; border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; }
.card.is-discontinued .card__swatch { filter: saturate(0.6); }
/* リスト表示 */
.grid--list { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 720px) { .grid--list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 8px 12px; } }
.grid--list .card { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.grid--list .card.is-owned { border-color: color-mix(in srgb, var(--sage) 45%, var(--line)); }
.grid--list .card__main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 10px; border-radius: 14px; }
.grid--list .card__swatch { flex: none; width: 46px; height: 46px; aspect-ratio: auto; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(43,34,38,0.08); }
.grid--list .is-owned .card__swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--sage); }
.grid--list .card__code { display: none; }
.card__codetext { display: none; }
.grid--list .card__codetext { display: inline; }
/* リストではタイルの右下の内側に重ねる（角丸の外に出すと overflow で切れるため） */
.grid--list .card__check {
  width: 18px; height: 18px; font-size: 10px; top: auto; right: 3px; bottom: 3px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.85);
}
.grid--list .card__body { flex: 1; min-width: 0; padding: 0; }
.grid--list .card__title { font-size: 14px; }
.grid--list .card__more { position: static; margin-right: 4px; }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.empty__hint { font-size: 13px; }

/* ---------- フッター ---------- */
.site-foot { max-width: 1100px; margin: 40px auto 0; padding: 20px 16px 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.7; }
.site-foot p { margin: 0 0 8px; }
.site-foot b { color: var(--ink); }
.site-foot__links { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: inherit; text-decoration: underline; padding: 0; cursor: pointer; }

/* ---------- シート（dialog） ---------- */
.sheet {
  /* ブラウザ既定の max-width/height (100% - 6px - 2em) を打ち消して画面幅いっぱいに出す */
  border: 0; padding: 0; width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--ink); box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}
@media (min-width: 640px) { .sheet { width: 560px; margin: auto; border-radius: 22px; } }
.sheet::backdrop { background: rgba(43, 34, 38, 0.45); backdrop-filter: blur(2px); }
.sheet[open] { animation: rise 320ms var(--ease); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.sheet__head h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 22px; }
.icon-btn { width: 36px; height: 36px; border: 0; background: var(--surface-2); border-radius: 50%; }
.form { display: grid; gap: 12px; padding: 6px 18px 18px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field em { font-style: normal; color: var(--accent); margin-left: 4px; }
.field input, .field select { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; font-size: 15px; color: var(--ink); width: 100%; }
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-input { display: flex; }
.color-input input[type="color"] { flex: 1; width: 100%; height: 42px; padding: 3px; border-radius: 10px; cursor: pointer; }
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
.sheet__foot { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.sheet__foot--pad { padding: 6px 18px 18px; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 16px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--danger { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--danger-ghost { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); width: 100%; }
.menu-section { padding: 10px 18px 16px; border-top: 1px solid var(--line); }
.menu-section:first-of-type { border-top: 0; }
.menu-section h3 { margin: 0 0 4px; font-size: 14px; }
.hint { margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.notes { margin: 0 0 10px; padding-left: 18px; font-size: 12px; color: var(--muted); display: grid; gap: 6px; line-height: 1.55; }
.terms { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--surface-2); }
.terms summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.terms summary::-webkit-details-marker { display: none; }
.terms summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
.terms[open] summary::after { content: "－"; }
.terms ol { margin: 0 0 8px; padding-left: 18px; font-size: 12px; color: var(--ink); display: grid; gap: 8px; line-height: 1.6; }
.terms ol b { display: block; font-size: 12px; }
.menu-section--danger { padding-bottom: 22px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 200ms, transform 300ms var(--ease); z-index: 40; max-width: calc(100vw - 32px);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
