/* マチブセ: 3列×セル高さ固定の2Dグリッド。各パーツが「列x・行y・横w・縦h」を持ち、置いた場所に入る（900px未満は2列・600px未満は1列） */
:root{
  --bg:#F2F3F7; --surface:#FFFFFF; --surface-2:#E9EBF2;
  --ink:#1C1E2B; --ink-2:#4E5268; --ink-3:#6E7389; --line:#DCDFE9;
  --accent:#9A6B06; --accent-soft:#FFF0C9;
  --good:#1F8A4C; --good-soft:#DDF4E4;
  --warn:#B8431F; --warn-soft:#FBE3DA;
  --dl:#3D7EDB; --dl-soft:#E3EDFB; --fz:#D43F8F; --fz-soft:#FBE4F0;
  /* 端末のフォントだけ（Google Fonts は使わない: 1回の表示で 111 件の取得・Google に IP が渡るため。2026-10-31 しょうちゃん決定） */
  --display:'Hiragino Maru Gothic ProN','BIZ UDPGothic','Yu Gothic UI','Meiryo','Noto Sans JP',system-ui,sans-serif;
  --body:system-ui,-apple-system,'Segoe UI','Hiragino Sans','Hiragino Kaku Gothic ProN','Yu Gothic UI','Meiryo','Noto Sans JP',sans-serif;
  --r:8px; --cell:172px; --gap:8px; --cols:3;
  color-scheme:light;
}
@media (max-width:899px){ :root{--cols:2} }
@media (max-width:599px){ :root{--cols:1} }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme:dark;
    --bg:#12141F; --surface:#1B1E2E; --surface-2:#252939;
    --ink:#F5F6FA; --ink-2:#CFD3E0; --ink-3:#A3A9BF; --line:#343A52;
    --accent:#F0B33A; --accent-soft:#3A2F12;
    --good:#5BC98C; --good-soft:#173224;
    --warn:#FF8A70; --warn-soft:#3A211B;
    --dl:#5B93E6; --dl-soft:#1E2C47; --fz:#E25BA6; --fz-soft:#3A1E31;
  }
}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#12141F; --surface:#1B1E2E; --surface-2:#252939;
  --ink:#F5F6FA; --ink-2:#CFD3E0; --ink-3:#A3A9BF; --line:#343A52;
  --accent:#F0B33A; --accent-soft:#3A2F12;
  --good:#5BC98C; --good-soft:#173224;
  --warn:#FF8A70; --warn-soft:#3A211B;
  --dl:#5B93E6; --dl-soft:#1E2C47; --fz:#E25BA6; --fz-soft:#3A1E31;
}
*{box-sizing:border-box}
html{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:var(--body); font-size:13px; line-height:1.45;
  padding:0 max(30px,env(safe-area-inset-right,0px)) 28px max(30px,env(safe-area-inset-left,0px));
  font-variant-numeric:tabular-nums; min-height:100%;
}
@media (max-width:599px){ body{padding-left:max(16px,env(safe-area-inset-left,0px)); padding-right:max(16px,env(safe-area-inset-right,0px))} }
h1,h2,h3{font-family:var(--display); margin:0; text-wrap:balance; line-height:1.25}
p{margin:0}
a{color:inherit}
button,select,input{font:inherit; color:inherit}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
[hidden]{display:none !important}
.wrap{max-width:1640px; margin:0 auto}
.muted{color:var(--ink-3)}

/* ヘッダー */
.app-head{display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px; padding:10px 0 8px}
.logo{display:flex; align-items:center; gap:8px; text-decoration:none}
.logo .mark{width:30px; height:30px; border-radius:8px; background:var(--accent-soft); display:grid; place-items:center}
.logo .name{font-family:var(--display); font-weight:700; font-size:20px; line-height:1}
.logo .kanji{font-size:10px; color:var(--ink-2); letter-spacing:.2em; margin-top:2px}
.head-meta{margin-left:auto; display:flex; flex-wrap:wrap; gap:6px; align-items:center; font-size:12px; color:var(--ink-2)}
.pill{border:1px solid var(--line); border-radius:999px; padding:2px 9px; background:var(--surface); text-decoration:none}
/* 言語のプルダウン（pill と同じ見た目。矢印は自前） */
select.langsel{font:inherit; font-size:12px; color:var(--ink); cursor:pointer; appearance:none; -webkit-appearance:none; padding:2px 22px 2px 9px;
  background:var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 8px center}
select.langsel:focus-visible{outline:2px solid var(--accent); outline-offset:1px}
/* トップの見出し（検索語入りの h1）。tagline の上に1行。年齢確認の見出しは .gate-title（h1 を2つにしない） */
.tagline-h{font-size:15px; font-weight:700; margin:2px 0 4px; max-width:72ch}
.gate-title{font-family:var(--display); font-weight:700; font-size:20px; line-height:1.25; margin-bottom:8px}
.tagline{font-size:12.5px; color:var(--ink-2); margin:0 0 8px; max-width:72ch; line-height:1.5}
.tagline b{color:var(--ink)}
.tools{display:flex; flex-wrap:wrap; gap:4px 10px; align-items:center; margin:0 0 8px; font-size:11.5px; color:var(--ink-2)}
.notice{background:var(--accent-soft); color:var(--ink); border-radius:var(--r); padding:8px 12px; font-size:12.5px; margin:0 0 8px}
.foot{margin-top:18px; font-size:11.5px; color:var(--ink-3); display:flex; flex-wrap:wrap; gap:4px 14px}
.foot a{color:var(--ink-2)}

/* ボタン */
.btn{border:1px solid var(--line); background:var(--surface); border-radius:6px; padding:3px 8px; font-size:12px; cursor:pointer; line-height:1.4; white-space:nowrap; text-decoration:none; display:inline-block}
.btn.sm{padding:1px 6px; font-size:11px}
.btn.dl{border-color:var(--dl); color:var(--dl)} .btn.fz{border-color:var(--fz); color:var(--fz)}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#1C1E2B; font-weight:700}
.btn.cta{display:inline-flex; align-items:center; gap:7px; background:var(--accent); border-color:var(--accent); color:#1C1E2B; font-weight:700; font-size:13.5px; padding:6px 14px; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,.18)}
.btn.cta:hover{filter:brightness(1.06)}
body.edit .btn.cta{background:var(--good); border-color:var(--good); color:#fff}
.btn[disabled]{opacity:.5; cursor:default}
.mini{border:1px solid var(--line); background:var(--surface); border-radius:5px; padding:1px 6px; font-size:11px; cursor:pointer; line-height:1.5}

/* セルのグリッド（位置は JS が grid-column / grid-row をインラインで与える） */
.grid{display:grid; grid-template-columns:repeat(var(--cols),minmax(0,1fr)); grid-auto-rows:var(--cell); gap:var(--gap); position:relative}
.card{
  --tint:var(--surface);
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r);
  background:color-mix(in oklab, var(--tint) 16%, var(--surface)); border-color:color-mix(in oklab, var(--tint) 40%, var(--line));
  padding:8px 10px 8px; display:flex; flex-direction:column; gap:5px; min-width:0; min-height:0; overflow:hidden;
}
.body{flex:1; min-height:0; overflow:auto; display:flex; flex-direction:column; gap:5px; scrollbar-width:thin}
.body::-webkit-scrollbar,.tw::-webkit-scrollbar{width:6px; height:6px}
.body::-webkit-scrollbar-thumb,.tw::-webkit-scrollbar-thumb{background:var(--line); border-radius:3px}
.card-head{display:flex; align-items:center; gap:6px; flex-wrap:wrap; min-height:22px}
.card-head h2{font-size:14px}
.card-head .sub{color:var(--ink-3); font-size:11px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.cellsz{display:none; font-size:10.5px; color:var(--ink-3); border:1px solid var(--line); border-radius:4px; padding:0 4px}
body.edit .cellsz{display:inline-block}
.sel{font-size:11px; border:1px solid var(--line); border-radius:999px; background:var(--surface); color:var(--ink-2); padding:0 6px; max-width:58%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; line-height:1.6}
.empty{color:var(--ink-3); font-size:12px; padding:6px 0}

/* 共通の小物 */
.chips{display:flex; flex-wrap:wrap; gap:4px}
.chip{display:inline-flex; align-items:center; gap:4px; padding:2px 7px; border-radius:6px; background:var(--surface-2); font-size:12px; line-height:1.4; border:0; cursor:default}
.chip b{font-size:14px; font-family:var(--display)}
.chip.sm{padding:0 6px; font-size:11px} .chip.sm b{font-size:12px}
.chip.good{background:var(--good-soft); color:var(--good)}
.chip.warn{background:var(--warn-soft); color:var(--warn)}
.chip.acc{background:var(--accent-soft); color:var(--accent)}
.store{display:inline-block; padding:0 5px; border-radius:4px; font-size:10px; font-weight:700; letter-spacing:.03em; line-height:1.6}
.store.dl{background:var(--dl-soft); color:var(--dl)}
.store.fz{background:var(--fz-soft); color:var(--fz)}
.badge{display:inline-block; padding:0 5px; border-radius:4px; font-size:10px; font-weight:700; line-height:1.6; white-space:nowrap}
.badge.low{background:var(--accent-soft); color:var(--accent)}
.badge.soon{background:var(--warn-soft); color:var(--warn)}
.badge.cheap{background:var(--good-soft); color:var(--good)}
.badge.only{background:var(--surface-2); color:var(--ink-2)}
.price{font-family:var(--display); font-weight:700; font-size:13.5px}
.strike{text-decoration:line-through; color:var(--ink-3); font-weight:400; font-size:11px}
.rows{display:flex; flex-direction:column; gap:3px}
.row{display:flex; align-items:center; gap:7px; min-width:0}
.row .t{flex:1; min-width:0}
.row .t .title{display:flex; align-items:center; gap:6px; min-width:0; font-weight:500; font-size:12.5px}
.row .t .title .tt{min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.row .t .title>:not(.tt){flex:none}
.row .t .circle{font-size:11px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.thumb{flex:none; width:30px; height:30px; border-radius:5px; display:grid; place-items:center; font-size:9px; font-weight:700; color:var(--ink-2); background:var(--surface-2); overflow:hidden}
.thumb img{width:100%; height:100%; object-fit:cover; display:block}

/* ウォッチ中の作品（表組み） */
.tw{overflow:auto; flex:1; min-height:0}
.wt{border-collapse:collapse; width:100%; min-width:640px; font-size:12px}
.wt th{font-weight:500; font-size:10.5px; color:var(--ink-3); letter-spacing:.04em; text-align:left; padding:0 6px 3px 0; border-bottom:1px solid var(--line); white-space:nowrap; position:sticky; top:0; background:var(--surface); z-index:1}
.wt td{padding:3px 6px 3px 0; border-bottom:1px solid var(--line); vertical-align:middle; white-space:nowrap}
.wt td.t{white-space:normal; min-width:0; max-width:0; width:44%}
.wt td.t .title{font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block}
.wt td.t .circle{font-size:10.5px; color:var(--ink-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block}
.wt td.num{font-variant-numeric:tabular-nums}
.wt td.num .pc{font-size:10px; color:var(--ink-3); margin-left:3px}
.wt td.num.win{font-weight:700}
.wt .thumb{width:28px; height:28px}
.wt td.act{white-space:nowrap}
.wt td.act label{display:inline-flex; align-items:center; gap:2px; font-size:11px; color:var(--ink-2); cursor:pointer; margin-left:4px}
.wt tr.bought td{opacity:.45}
.wt tbody tr{cursor:pointer}
.wt tbody tr.picked td{background:var(--accent-soft)}
.wt .x{border:0; background:transparent; color:var(--ink-3); cursor:pointer; font-size:14px; padding:0 4px; line-height:1}
.wt .x:hover{color:var(--warn)}
.diff{font-weight:700}
.diff.good{color:var(--good)} .diff.n{color:var(--ink-3); font-weight:400}

/* 店対決 */
.stack{display:flex; height:12px; border-radius:6px; overflow:hidden; gap:2px; background:var(--bg)}
.stack span{display:block; height:100%}
.stack .a{background:var(--fz)} .stack .b{background:var(--dl)} .stack .c{background:var(--ink-3)}
.legend{display:flex; flex-wrap:wrap; gap:2px 10px; font-size:11px; color:var(--ink-2)}
.legend i{display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:4px; vertical-align:-1px}
.big{display:flex; flex-wrap:wrap; gap:4px 16px; align-items:baseline}
.big .n{font-family:var(--display); font-weight:700; font-size:21px; line-height:1}
.big .l{font-size:11px; color:var(--ink-2)}

/* 価格の推移 */
.spark{position:relative}
.spark svg{display:block; width:100%; height:96px}
.tip{position:absolute; pointer-events:none; display:none; background:var(--surface); border:1px solid var(--line); border-radius:6px; padding:4px 8px; font-size:11.5px; box-shadow:0 4px 14px rgba(0,0,0,.12); white-space:nowrap; z-index:2}
.tip b{font-family:var(--display)}
.rng{display:inline-flex; border:1px solid var(--line); border-radius:5px; overflow:hidden}
.rng button{border:0; background:var(--surface); padding:0 6px; font-size:10.5px; cursor:pointer; color:var(--ink-2)}
.rng button[aria-pressed="true"]{background:var(--surface-2); color:var(--ink); font-weight:700}

/* 周期の目安 */
.cycle{display:flex; flex-direction:column; gap:2px}
.bar{position:relative; height:6px; border-radius:3px; background:var(--surface-2); overflow:hidden}
.bar i{position:absolute; left:0; top:0; bottom:0; border-radius:3px; background:var(--accent)}
.cycle .l{display:flex; justify-content:space-between; font-size:10.5px; color:var(--ink-3)}

/* 探す */
.search{display:flex; gap:5px; width:100%}
.search input{flex:1; min-width:0; border:1px solid var(--line); border-radius:6px; padding:5px 8px; background:var(--surface); color:var(--ink); font-size:12px}
.hint{color:var(--ink-3); font-size:11px; line-height:1.4}

/* 保存と引き継ぎ */
.codebox{flex:1; min-width:160px; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11px; border:1px solid var(--line); border-radius:6px; padding:3px 6px; background:var(--surface-2); color:var(--ink-2); min-height:0}

/* 並べ替えモード（位置・セル数・色・外す） */
.shelf{display:none; position:fixed; z-index:40; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:8px 10px; box-shadow:0 8px 24px rgba(0,0,0,.18); font-size:12px; flex-direction:column; gap:6px}
body.edit .shelf{display:flex}
.shelf h3{font-size:13px}
.shelf .list{display:flex; flex-direction:column; gap:5px}
.shelf.over{outline:2px solid var(--accent); outline-offset:-2px}
.tile{display:flex; align-items:center; gap:6px; border:1px dashed var(--line); border-radius:6px; padding:5px 7px; cursor:grab; touch-action:none; background:var(--bg); user-select:none; -webkit-user-select:none}
.tile .nm{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:500}
.tile .sz{font-size:10.5px; color:var(--ink-3); white-space:nowrap}
.tile .dot{width:10px; height:10px; border-radius:50%; flex:none; box-shadow:0 0 0 1px var(--line)}
.ghost.tile{height:auto; width:200px}
@media (min-width:900px){
  .shelf{right:max(30px,env(safe-area-inset-right,0px)); top:12px; bottom:12px; width:216px; overflow:auto}
  body.edit .wrap{padding-right:232px}
}
@media (max-width:899px){
  .shelf{left:max(16px,env(safe-area-inset-left,0px)); right:max(16px,env(safe-area-inset-right,0px)); bottom:calc(12px + env(safe-area-inset-bottom,0px)); max-height:36vh; overflow:auto}
  .shelf .list{flex-direction:row; flex-wrap:wrap}
  .tile{flex:1 1 150px}
  body.edit{padding-bottom:38vh}
}
.ctl{display:none; align-items:center; gap:4px; margin-left:auto; flex-wrap:wrap}
body.edit .ctl{display:flex}
.ctl2{display:none; width:100%; align-items:center; gap:6px; flex-wrap:wrap; padding-top:2px; font-size:11px; color:var(--ink-3)}
body.edit .card.coloring .ctl2{display:flex}
.sw{width:16px; height:16px; border-radius:50%; border:2px solid var(--surface); box-shadow:0 0 0 1px var(--line); cursor:pointer; padding:0; flex:none}
.sw[aria-pressed="true"]{box-shadow:0 0 0 2px var(--accent)}
.sw.none{background:var(--surface); position:relative}
.sw.none::after{content:""; position:absolute; left:2px; right:2px; top:50%; height:1.5px; background:var(--ink-3); transform:rotate(-45deg)}
.swc{width:24px; height:18px; padding:0; border:1px solid var(--line); border-radius:4px; background:var(--surface); cursor:pointer; flex:none}
body.edit .card{outline:2px dashed var(--line); outline-offset:-2px; user-select:none; -webkit-user-select:none}
body.edit .card-head{cursor:grab; touch-action:none; margin:-4px -6px 0; padding:4px 6px; border-radius:6px}
body.edit .card-head:hover{background:var(--surface-2)}
body.edit .card-head .ctl, body.edit .card-head .ctl *, body.edit .card-head .sel{cursor:default; touch-action:auto}
body.edit .card-head .ctl button{cursor:pointer}
.grip{display:none; flex:none; width:24px; height:24px; align-items:center; justify-content:center; border:0; background:transparent; color:var(--ink-3); border-radius:6px; padding:0; margin-left:-4px; cursor:grab}
body.edit .grip{display:inline-flex}
body.dragging, body.dragging *{cursor:grabbing !important}
.card.placeholder{opacity:.4; outline:2px dashed var(--accent)}
.card.kb-grabbed{outline:2px solid var(--accent); box-shadow:0 8px 24px rgba(0,0,0,.18)}
.ghost{position:fixed; z-index:50; pointer-events:none; opacity:.92; box-shadow:0 14px 36px rgba(0,0,0,.28); transform:scale(1.02); margin:0}
.ghost .ctl{display:none}
.card.flash{animation:flash 700ms cubic-bezier(.25,.1,.25,1)}
@keyframes flash{from{background:var(--accent-soft)} to{background:var(--surface)}}
.live{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}
.seg{display:inline-flex; border:1px solid var(--line); border-radius:5px; overflow:hidden; align-items:stretch}
.seg .lb{font-size:10.5px; color:var(--ink-3); padding:1px 5px; background:var(--surface-2); display:inline-flex; align-items:center}
.seg button{border:0; background:var(--surface); padding:1px 7px; font-size:11px; cursor:pointer}
.seg button[aria-pressed="true"]{background:var(--accent); color:#1C1E2B; font-weight:700}
@media (prefers-reduced-motion: reduce){ .card{transition:none !important} .card.flash{animation:none} .ghost{transition:none !important} }

/* Cookie設定の帯（フッターのリンクから出す） */
.cookie{position:fixed; left:0; right:0; bottom:0; z-index:90; background:var(--surface); color:var(--ink); border-top:1px solid var(--line); box-shadow:0 -2px 12px rgba(0,0,0,.2); padding:10px max(30px,env(safe-area-inset-right,0px)) calc(10px + env(safe-area-inset-bottom,0px)) max(30px,env(safe-area-inset-left,0px)); font-size:12.5px}
.cookie .in{max-width:1640px; margin:0 auto; display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px}
.cookie .in p{flex:1 1 260px; min-width:0}

/* 使い方・ポリシー（静的ページ） */
.doc{max-width:72ch; background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:14px 18px; font-size:13px; margin-top:8px}
.doc h1{font-size:20px; margin-bottom:8px}
.doc h2{font-size:14px; margin:14px 0 4px}
.doc p{margin:0 0 6px}
.doc ul{margin:0 0 6px; padding-left:18px}
.doc li{margin:2px 0}
.doc kbd{font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11px; border:1px solid var(--line); border-radius:4px; padding:0 4px; background:var(--surface-2)}
