/* こぐまちゃんライフナビ：Instagramの画面構造（プロフィール・ハイライト・3列グリッド・ストーリー）を借り、
   色は独自パレット。Instagramのロゴ・グラデーションは使わない。トークンは :root に1組だけ */
:root {
  --bg: #FFFFFF;
  --field: #F2F0EC;        /* 検索欄・サブボタンの塗り（背景色 #FAF8F5 系） */
  --primary: #BDD7E6;      /* 主色：選択中の塗り・アバター */
  --primary-soft: #E6F0F6;
  --text: #24272B;
  --text-sub: #5A5F66;
  --action: #597E93;
  --action-strong: #46687B; /* 白文字を載せる塗り（4.5:1確保） */
  --action-hover: #3A5868;
  --line: #E4E1DC;
  --warn-bg: #FFF4E0;
  --warn-text: #7A4B00;
  --story-bg: #111315;
  --focus: #24272B;
  --radius: 8px;
  --tap: 44px;
  --wrap: 600px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
a { color: var(--action-strong); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 30; background: var(--text); color: #fff; min-height: var(--tap); padding: 0 12px; display: inline-flex; align-items: center; }
.skip:focus { left: 8px; }
.muted { color: var(--text-sub); }
.small { display: block; font-size: 12px; }
main { max-width: var(--wrap); margin: 0 auto; }

/* ---------- 上部バー ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar-in { max-width: var(--wrap); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 16px; min-height: 52px; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; min-height: var(--tap); }
.unofficial { font-size: 10px; font-weight: 700; border: 1px solid var(--text); border-radius: 3px; padding: 0 4px; line-height: 16px; }
.top-actions { display: flex; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--tap); min-height: var(--tap); padding: 0 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; }
.fav-count:not(:empty) { position: absolute; top: 6px; right: 2px; background: var(--action-strong); color: #fff; border-radius: 9px; font-size: 10px; min-width: 18px; line-height: 18px; text-align: center; padding: 0 4px; }
.preview-bar { margin: 0; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; text-align: center; padding: 2px 8px; }

/* ---------- プロフィール ---------- */
.profile { padding: 16px 16px 4px; }
.profile-top { display: flex; align-items: center; gap: 24px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; background: var(--primary); color: var(--text); font-weight: 700; width: 32px; height: 32px; font-size: 15px; }
.avatar.lg { width: 84px; height: 84px; font-size: 36px; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--primary); margin: 5px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.stats { flex: 1; display: flex; justify-content: space-around; list-style: none; margin: 0; padding: 0; text-align: center; }
.stats li { display: flex; flex-direction: column; line-height: 1.3; }
.stats b { font-size: 17px; }
.stats span { font-size: 13px; color: var(--text-sub); }
.profile-name { margin: 12px 0 0; font-size: 15px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.handle { font-weight: 400; color: var(--text-sub); font-size: 13px; }
.profile-bio { margin: 2px 0 0; font-size: 14px; }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.btn-sub { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: var(--tap); padding: 0 10px; border-radius: var(--radius); background: var(--field); color: var(--text); font-weight: 700; font-size: 14px; text-decoration: none; }
.btn-sub svg { width: 15px; height: 15px; }
.btn-sub:hover { background: var(--line); }

.featured { margin-top: 12px; }

/* ---------- 検索 ---------- */
.search { position: relative; margin: 12px 16px 0; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-sub); pointer-events: none; }
.search input { width: 100%; height: var(--tap); padding: 0 12px 0 38px; font: inherit; font-size: 16px; color: var(--text); background: var(--field); border: 1px solid transparent; border-radius: 10px; }
.search input:focus { background: var(--bg); border-color: var(--text); outline: none; }
.search input::placeholder { color: #6E7278; }

/* ---------- ハイライト ---------- */
.highlights { display: flex; gap: 14px; list-style: none; margin: 0; padding: 14px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.highlights::-webkit-scrollbar { display: none; }
.hl { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 70px; padding: 0; background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; }
.hl-ring { width: 66px; height: 66px; border-radius: 50%; padding: 3px; background: var(--line); }
.hl-img { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; border: 2px solid var(--bg); background: var(--field); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; }
.hl-img img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.hl-label { font-size: 12px; line-height: 1.3; white-space: nowrap; max-width: 74px; overflow: hidden; text-overflow: ellipsis; }
.hl[aria-pressed="true"] .hl-ring { background: var(--action-strong); }
.hl[aria-pressed="true"] .hl-label { font-weight: 700; }

/* ---------- タブ ---------- */
.tabs { display: flex; border-top: 1px solid var(--line); position: sticky; top: 53px; z-index: 10; background: var(--bg); }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); background: none; border: 0; border-top: 2px solid transparent; margin-top: -1px; font: inherit; font-size: 13px; color: var(--text-sub); cursor: pointer; }
.tab svg { width: 18px; height: 18px; }
.tab[aria-selected="true"] { color: var(--text); font-weight: 700; border-top-color: var(--text); background: var(--primary-soft); }
.panel-note { margin: 8px 16px; font-size: 12px; color: var(--text-sub); }
.count { margin: 0; padding: 0 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.count:not(:empty) { padding-block: 4px; }
.count b { font-size: 16px; }
.conds { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.cond { background: var(--primary-soft); padding: 1px 8px; border-radius: 3px; font-size: 12px; }
.reset { margin-left: auto; min-height: var(--tap); padding: 0 6px; background: none; border: 0; font: inherit; font-size: 13px; color: var(--action-strong); font-weight: 700; cursor: pointer; }

/* ---------- 3列グリッド ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; list-style: none; margin: 0; padding: 0; }
.tile { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--field); }
.tile > a, .tile > button { position: absolute; inset: 0; display: block; color: inherit; text-decoration: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.tile-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 6px 6px; font-size: 11px; line-height: 1.35; font-weight: 700; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-card { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8px; background: var(--primary); }
.tile-card-q { background: var(--bg); border-radius: 6px; padding: 8px; font-size: 12px; font-weight: 700; line-height: 1.4; text-align: center; }
.tile a:focus-visible, .tile button:focus-visible { outline-offset: -3px; }

.grid .post-tile { aspect-ratio: 4 / 5; } /* 埋め込みの画像部分(4:5)だけを見せる */
.post-tile .post-open { padding: 0; border: 0; background: var(--field); cursor: pointer; }
.post-frame { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
/* 公式埋め込み（最小幅326px）を縮小し、上部の名前欄を外して画像部分をマスに収める。--s はJSで設定 */
.post-frame iframe { position: absolute; top: 0; left: 0; width: 326px; height: 620px; border: 0; transform-origin: 0 0; transform: translateY(calc(var(--s, .38) * var(--head, -54px))) scale(var(--s, .38)); }
.post-kind { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .6); border-radius: 3px; padding: 0 5px; line-height: 18px; }

.empty { padding: 32px 16px; text-align: center; color: var(--text-sub); }
.empty p { margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; margin: 8px 0 0; padding: 0; }
.chip { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; font: inherit; font-size: 14px; color: var(--text); background: var(--field); border: 0; border-radius: 22px; cursor: pointer; }

/* ---------- 商品の行 ---------- */
.prows { list-style: none; margin: 0; padding: 0; }
.prow a { display: flex; gap: 12px; align-items: center; padding: 12px 16px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.prow-icon { width: 52px; height: 52px; border-radius: var(--radius); background: var(--primary-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.prow-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prow-brand { font-weight: 700; }
.prow-name { font-size: 13px; color: var(--text-sub); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 0; }
.badge { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 3px; white-space: nowrap; font-weight: 700; }
.badge.rel { background: var(--text); color: #fff; }
.badge.conf { background: var(--primary-soft); color: var(--text); }
.badge.conf-inferred, .badge.conf-unverified, .badge.warn, .badge.ad { background: var(--warn-bg); color: var(--warn-text); }

/* ---------- 詳細（投稿画面の構成） ---------- */
.post-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.post-who { display: flex; flex-direction: column; line-height: 1.3; }
.post-name { font-weight: 700; font-size: 14px; }
.post-sub { font-size: 12px; color: var(--text-sub); }
.post-media { margin: 0; background: var(--story-bg); display: flex; justify-content: center; }
.post-media img { width: 100%; max-width: 440px; height: auto; }
.text-media { aspect-ratio: 4 / 5; align-items: center; background: var(--primary); padding: 24px; }
.text-media p { background: var(--bg); border-radius: 10px; padding: 16px; font-weight: 700; font-size: 18px; text-align: center; margin: 0; }
.post-actions { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; }
.post-actions .icon-btn .small { color: var(--text-sub); }
.save { color: var(--text); }
.save.with-label { font-weight: 700; font-size: 14px; padding: 0 12px; border-radius: var(--radius); }
.save[aria-pressed="true"] { background: var(--primary); }
.save[aria-pressed="true"] svg { fill: var(--text); }
.save:not(.with-label) .save-label { display: none; }
.post-body { padding: 0 16px; }
.post-title { font-size: 19px; line-height: 1.45; margin: 4px 0 6px; }
.post-answer { margin: 0; font-size: 15px; }
.post-answer b { margin-right: 6px; }
.points { margin: 10px 0 0; padding-left: 1.2em; }
.points li { margin: 3px 0; }
.editor-note { font-size: 13px; color: var(--text-sub); margin: 12px 0 0; }
.editor-note b { color: var(--text); margin-right: 8px; }
.caution { background: var(--warn-bg); color: var(--warn-text); font-size: 13px; padding: 10px 12px; border-radius: var(--radius); margin: 12px 0 0; }
.hashtags { display: flex; flex-wrap: wrap; gap: 0 12px; margin: 6px 0 0; }
.hashtags a { display: inline-flex; align-items: center; min-height: var(--tap); text-decoration: none; font-weight: 700; }
.post-body h2, .prose h2 { font-size: 15px; margin: 24px 0 4px; }
.section-h { font-size: 15px; margin: 28px 16px 10px; }

.product { border-top: 1px solid var(--line); padding: 12px 0; }
.product-brand { margin: 0; font-size: 12px; color: var(--text-sub); font-weight: 700; }
.product-name { margin: 0 0 4px; font-size: 16px; }
.product-name a { color: var(--text); display: inline-flex; align-items: center; min-height: var(--tap); }
.facts { display: grid; grid-template-columns: 6.5em 1fr; gap: 6px 12px; margin: 8px 0 0; font-size: 14px; }
.facts dt { color: var(--text-sub); }
.facts dd { margin: 0; }
.code-row { display: flex; align-items: center; gap: 8px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 15px; background: var(--primary-soft); padding: 2px 8px; border-radius: 3px; }
.copy { min-height: var(--tap); padding: 0 14px; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); background: var(--field); border: 0; border-radius: var(--radius); cursor: pointer; }
.offers { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 18px; font-weight: 700; font-size: 14px; color: #fff; background: var(--action-strong); border-radius: var(--radius); text-decoration: none; }
.btn:hover { background: var(--action-hover); }
.btn svg { width: 16px; height: 16px; }
.source { margin-top: 20px; border-top: 1px solid var(--line); }
.related { margin-top: 8px; }

.page { padding: 0 16px; }
.page .grid, .page .prows { margin-inline: -16px; }
.page-h { font-size: 20px; margin: 4px 0 12px; }
.lead { color: var(--text-sub); margin: -4px 0 12px; font-size: 14px; }
.prose p { margin: 0 0 12px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0 6px; margin: 4px 0 0; padding: 0 16px; font-size: 12px; color: var(--text-sub); }
.crumbs li + li::before { content: "/"; margin-right: 6px; }
.crumbs li[aria-current] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.crumbs a { color: var(--text-sub); display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---------- ストーリー閲覧 ---------- */
dialog { padding: 0; border: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .85); }
.story { width: 100%; max-width: 440px; height: 100%; max-height: 100dvh; margin: auto; background: var(--story-bg); color: #fff; }
.story-in { position: relative; height: 100%; display: flex; flex-direction: column; }
.story-bars { display: flex; gap: 3px; padding: 8px 8px 0; }
.story-bars span { flex: 1; height: 2px; border-radius: 1px; background: rgba(255, 255, 255, .35); }
.story-bars span.on { background: #fff; }
.story-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 10px; }
.story-name { font-weight: 700; font-size: 14px; }
.story-date { font-size: 12px; color: rgba(255, 255, 255, .8); }
.story-close { margin-left: auto; color: #fff; }
.story-media { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.story-media img { max-height: 100%; width: auto; object-fit: contain; }
.story-text { padding: 24px; }
.story-text p { background: var(--bg); color: var(--text); border-radius: 10px; padding: 16px; font-weight: 700; font-size: 18px; margin: 0; }
.story-nav { position: absolute; top: 42%; width: var(--tap); height: var(--tap); border-radius: 50%; border: 0; background: rgba(255, 255, 255, .88); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.story-nav.prev { left: 6px; }
.story-nav.next { right: 6px; }
.story-nav[hidden] { display: none; }
.story-sheet { background: var(--bg); color: var(--text); border-radius: 14px 14px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.sheet-q { margin: 0; font-weight: 700; font-size: 16px; line-height: 1.45; }
.sheet-a { margin: 4px 0 10px; font-size: 14px; color: var(--text-sub); }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .save { background: var(--field); }
.sheet-actions .save[aria-pressed="true"] { background: var(--primary); }

.post-dialog { width: min(100%, 420px); max-height: 92dvh; margin: auto; border-radius: 12px; background: var(--bg); }
.post-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 16px; border-bottom: 1px solid var(--line); }
.post-dialog-head a { font-weight: 700; display: inline-flex; align-items: center; min-height: var(--tap); }
.post-dialog-body iframe { display: block; width: 100%; height: min(80dvh, 720px); border: 0; }

/* ---------- フッター ---------- */
.site-footer { max-width: var(--wrap); margin: 40px auto 0; padding: 16px 16px 40px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-sub); }
.notice { margin: 0 0 8px; }
.foot-links { list-style: none; display: flex; flex-wrap: wrap; gap: 0 14px; margin: 0; padding: 0; }
.foot-links a { color: var(--text-sub); display: inline-flex; align-items: center; min-height: var(--tap); }

@media (min-width: 640px) {
  .grid { gap: 4px; }
  .profile-top { gap: 48px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
