/* =========================================================
   Coffee Notes — awesome-design-skills「cafe」をベースに
   ミルクのような明るい地に、コーヒーの木（葉・実）やキャラメルの色を差す。
   カードは枠線ではなく、やわらかい影と色の面で区切る（縁取りの線・帯は使わない）。
   ========================================================= */
:root {
  /* color tokens（cafe） */
  --primary: #6B4530;       /* コーヒー：ボタン・数字 */
  --primary-hover: #573826;
  --secondary: #F3E9DC;     /* セグメントの地など */
  --surface: #FAF3EA;       /* カードの中の面・入力欄 */
  --text: #3A2A20;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #C62828;

  /* 派生トークン */
  --bg: #FFF9F2;            /* ページ背景：ミルク */
  --card: #FFFFFF;
  --muted: #7B6656;         /* 補助テキスト（bg・card 上で 4.5:1 以上） */
  --line: #EFE4D6;          /* ごく薄い区切り（表・見出し下だけ） */
  --accent: #A65A24;        /* 小見出しの文字（card 上で 4.5:1 以上） */
  --bean-off: #EADFD2;      /* 豆アイコン（未点灯） */
  --bean-crease: #FFF9F2;
  --focus: #D98A3D;
  --on-primary: #FFFFFF;

  /* 差し色：-soft は面、-ink はその上の文字（4.5:1 以上） */
  --caramel: #E3A04D; --caramel-soft: #FDEFD9; --caramel-ink: #87500F;
  --leaf: #6FA25F;    --leaf-soft: #E8F2E2;    --leaf-ink: #3B6833;
  --cherry: #D9543E;  --cherry-soft: #FCE7E0;  --cherry-ink: #A13826;
  --sky: #7FB0D3;     --sky-soft: #E4F0F8;     --sky-ink: #2D5B7A;
  --berry: #C76A92;   --berry-soft: #F9E8EF;   --berry-ink: #8B3A60;
  --sand: #C49A73;    --sand-soft: #F5ECE1;    --sand-ink: #6E4A33;

  --roast-light: #C4925F;
  --roast-medium-light: #A06D43;
  --roast-medium: #7E512F;
  --roast-medium-dark: #5C3920;
  --roast-dark: #3B2517;

  /* spacing（2/4/8/12/16/24/32/48） */
  --s-1: 2px; --s-2: 4px; --s-3: 8px; --s-4: 12px; --s-5: 16px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  /* radius：角はやわらかく */
  --r-sm: 8px; --r-md: 14px; --r-lg: 22px; --r-pill: 999px;

  --font: "Poppins", "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  /* 影は暗い縁に見えないよう、薄く広く */
  --shadow: 0 1px 2px rgba(107, 69, 48, .04), 0 6px 18px rgba(107, 69, 48, .07);
  --shadow-hover: 0 2px 4px rgba(107, 69, 48, .05), 0 10px 28px rgba(107, 69, 48, .11);
  --shadow-float: 0 6px 20px rgba(107, 69, 48, .25);   /* 画面の上に浮かぶボタン */
}

/* ダークテーマ：端末の設定に合わせる（data-theme で明示されたときはそちらを優先） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #E6BE95;
    --primary-hover: #F0CFAC;
    --secondary: #362C25;
    --surface: #2E2620;
    --text: #F4EBE1;
    --bg: #1A1411;
    --card: #251E19;
    --muted: #BFAC99;
    --line: #3A3029;
    --accent: #EBAA6E;
    --bean-off: #4A3C31;
    --bean-crease: #251E19;
    --focus: #EBAA6E;
    --on-primary: #1E1814;
    --danger: #F87171;
    --caramel-soft: #3A2C1C; --caramel-ink: #F2C58E;
    --leaf-soft: #233021;    --leaf-ink: #AFD69F;
    --cherry-soft: #3A231D;  --cherry-ink: #F4A592;
    --sky-soft: #1E2C36;     --sky-ink: #A3CDEA;
    --berry-soft: #36222C;   --berry-ink: #EBAACA;
    --sand-soft: #332820;    --sand-ink: #E2C3A3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-float: 0 6px 20px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #E6BE95;
  --primary-hover: #F0CFAC;
  --secondary: #362C25;
  --surface: #2E2620;
  --text: #F4EBE1;
  --bg: #1A1411;
  --card: #251E19;
  --muted: #BFAC99;
  --line: #3A3029;
  --accent: #EBAA6E;
  --bean-off: #4A3C31;
  --bean-crease: #251E19;
  --focus: #EBAA6E;
  --on-primary: #1E1814;
  --danger: #F87171;
  --caramel-soft: #3A2C1C; --caramel-ink: #F2C58E;
  --leaf-soft: #233021;    --leaf-ink: #AFD69F;
  --cherry-soft: #3A231D;  --cherry-ink: #F4A592;
  --sky-soft: #1E2C36;     --sky-ink: #A3CDEA;
  --berry-soft: #36222C;   --berry-ink: #EBAACA;
  --sand-soft: #332820;    --sand-ink: #E2C3A3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-float: 0 6px 20px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* タブごとの色（見出しの面・下のタブ・空の状態の挿絵） */
body { --tab-soft: var(--leaf-soft); --tab-ink: var(--leaf-ink); --tab-art: url("../img/illust/beans.svg"); }
body[data-tab="logs"] { --tab-soft: var(--caramel-soft); --tab-ink: var(--caramel-ink); --tab-art: url("../img/illust/logs.svg"); }
body[data-tab="brew"] { --tab-soft: var(--cherry-soft); --tab-ink: var(--cherry-ink); --tab-art: url("../img/illust/brew.svg"); }
body[data-tab="equipment"] { --tab-soft: var(--sand-soft); --tab-ink: var(--sand-ink); --tab-art: url("../img/illust/equipment.svg"); }
body[data-tab="columns"] { --tab-soft: var(--berry-soft); --tab-ink: var(--berry-ink); --tab-art: url("../img/illust/columns.svg"); }
.tabs a[data-tab="beans"] { --tab-soft: var(--leaf-soft); --tab-ink: var(--leaf-ink); }
.tabs a[data-tab="logs"] { --tab-soft: var(--caramel-soft); --tab-ink: var(--caramel-ink); }
.tabs a[data-tab="brew"] { --tab-soft: var(--cherry-soft); --tab-ink: var(--cherry-ink); }
.tabs a[data-tab="equipment"] { --tab-soft: var(--sand-soft); --tab-ink: var(--sand-ink); }
.tabs a[data-tab="columns"] { --tab-soft: var(--berry-soft); --tab-ink: var(--berry-ink); }

* { 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.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
h1, h2, h3 { line-height: 1.35; margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s-1);
}

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  /* backdrop-filter は使わない（スマホで下に固定するタブの基準がずれるため） */
  background: var(--bg);
}
.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}
.brand { display: flex; align-items: center; gap: var(--s-3); text-decoration: none; color: var(--text); }
.logo { width: 32px; height: 32px; color: var(--primary); }
.brand-name { display: block; font-weight: 700; font-size: 1.1rem; line-height: 1.2; letter-spacing: .01em; }
.tagline { display: block; font-size: .72rem; color: var(--muted); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { box-shadow: var(--shadow-hover); }

.tabs {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--s-5);
  display: flex;
  gap: var(--s-2);
}
.tabs a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  padding: 0 var(--s-4);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--r-pill);
}
.tabs svg { width: 20px; height: 20px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--tab-ink); background: var(--tab-soft); font-weight: 600; }

/* ---------- レイアウト ---------- */
main { max-width: 1040px; margin: 0 auto; padding: var(--s-6) var(--s-5) var(--s-8); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
/* 一覧ページの見出し：タブの色の面に挿絵を添える */
main > .page-head:first-child {
  position: relative;
  align-items: center;
  min-height: 120px;
  padding: var(--s-6) 168px var(--s-6) var(--s-6);
  border-radius: var(--r-lg);
  background: var(--tab-soft) var(--tab-art) no-repeat right var(--s-5) bottom / auto 112%;
}
main > .page-head:first-child .eyebrow { color: var(--tab-ink); }
main > .page-head:first-child h1 { font-size: 1.9rem; }
.lead { max-width: 64ch; margin-bottom: var(--s-5); }
.section { margin-top: var(--s-7); }
.section > h2 { margin-bottom: var(--s-4); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 var(--s-6); }

/* セグメント（ページ内の切り替え） */
.segmented {
  display: flex;
  gap: var(--s-1);
  padding: var(--s-1);
  background: var(--secondary);
  border-radius: var(--r-pill);
  margin-bottom: var(--s-5);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg {
  flex: 1 0 auto;
  min-height: 38px;
  padding: 0 var(--s-5);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(107, 69, 48, .1); }

.filter-chips { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-5); }
.filter-chip {
  min-height: 36px;
  padding: 0 var(--s-5);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- カード ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-5); }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5);
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.card .actions { margin-top: auto; }


/* 豆ガイドのタイル：スマホでも2列で一覧しやすく */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); }
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.tile h3 { font-size: 1.05rem; }
.tile .eyebrow { margin: 0; }
/* 焙煎度は、見出しの前の丸い色で示す */
.roast-tile h3 { display: flex; align-items: center; gap: var(--s-3); }
.roast-tile h3::before { content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--roast); }
.roast-scale { display: flex; height: 12px; border-radius: 999px; overflow: hidden; margin-bottom: var(--s-5); }
.roast-scale span { flex: 1; }
.roast-light { --roast: var(--roast-light); }
.roast-medium-light { --roast: var(--roast-medium-light); }
.roast-medium { --roast: var(--roast-medium); }
.roast-medium-dark { --roast: var(--roast-medium-dark); }
.roast-dark { --roast: var(--roast-dark); }
.roast-scale span { background: var(--roast); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--secondary);
  color: var(--text);
  font-size: .78rem;
}
.chip.soft { background: var(--surface); color: var(--muted); }
.roast-chip { background: var(--roast); color: #fff; }

.flavor { font-size: .92rem; }
.meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: .8rem; color: var(--muted); }
.memo { white-space: pre-wrap; font-size: .9rem; padding: var(--s-3) var(--s-4); background: var(--caramel-soft); border-radius: var(--r-sm); }
.next { font-size: .9rem; }
.next .eyebrow { display: inline; margin-right: var(--s-3); }
.recipe { font-size: .9rem; padding: var(--s-3) var(--s-4); background: var(--surface); border-radius: var(--r-sm); }
.recipe .eyebrow, .grind-card .small .eyebrow { display: block; }

/* 豆アイコン（評価） */
.beans { display: inline-flex; align-items: center; gap: 1px; vertical-align: middle; }
/* <use> の中身には CSS セレクタが届かないので、カスタムプロパティで色を渡す */
.bean { width: 18px; height: 18px; --bean-fill: var(--bean-off); }
.beans.sm .bean { width: 14px; height: 14px; }
.bean.on { --bean-fill: var(--primary); }
.score { display: flex; align-items: center; gap: var(--s-2); flex: none; }

.trait-row, .taste, .cond, .facts { margin: 0; }
.trait-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.trait-row div, .taste div { display: flex; align-items: center; gap: var(--s-3); }
.trait-row dt, .taste dt { font-size: .8rem; color: var(--muted); min-width: 2.5em; }
.trait-row dd, .taste dd { margin: 0; }
.taste { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s-2) var(--s-4); }

.cond { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--s-3); }
.cond div { padding: var(--s-3); background: var(--surface); border-radius: var(--r-sm); }
.cond dt { font-size: .72rem; color: var(--muted); }
.cond dd { margin: 0; font-size: .9rem; font-weight: 500; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); }
.facts div { padding: var(--s-4); background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); }
.facts dt { font-size: .75rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.stat { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4) var(--s-5); background: var(--caramel-soft); border-radius: var(--r-md); }
.stat:nth-child(2) { background: var(--leaf-soft); }
.stat:nth-child(3) { background: var(--berry-soft); }
.stat-label { font-size: .75rem; color: var(--muted); }
.stat-value { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: var(--s-3); }
.stat-value.small { font-size: .95rem; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
/* 空の状態にはタブの挿絵を出す */
.empty::before { content: ""; width: 160px; height: 120px; margin-bottom: var(--s-2); border-radius: var(--r-lg); background: var(--tab-soft) var(--tab-art) no-repeat center / contain; }
.empty strong { color: var(--text); }
.empty .btn { margin-top: var(--s-3); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn.sm { min-height: 36px; padding: 0 var(--s-4); font-size: .82rem; }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 2px 8px rgba(107, 69, 48, .18); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.ghost:hover { background: var(--secondary); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.actions.end { justify-content: flex-end; }
.link-btn { white-space: nowrap; border: 0; background: none; color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; text-decoration: underline; padding: var(--s-2); }

/* ---------- フォーム ---------- */
.panel {
  padding: var(--s-6);
  margin-bottom: var(--s-6);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.panel > h2 { margin-bottom: var(--s-4); }
.form-section { font-size: .8rem; color: var(--muted); font-weight: 500; margin: var(--s-5) 0 var(--s-3); padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.req { font-size: .7rem; color: var(--danger); margin-left: var(--s-2); }

label { display: flex; flex-direction: column; gap: var(--s-2); font-size: .82rem; color: var(--muted); }
label small { color: var(--accent); font-size: .75rem; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
textarea { min-height: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
select.compact { width: auto; }
.inline-field { flex-direction: row; align-items: center; gap: var(--s-3); max-width: 360px; margin-bottom: var(--s-5); white-space: nowrap; }

.rating-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.bean-input { border: 0; border-radius: var(--r-md); background: var(--surface); padding: var(--s-3) var(--s-4); margin: 0; }
.bean-input legend { float: left; width: 100%; }
.bean-input legend { font-size: .82rem; color: var(--muted); padding: 0 var(--s-2); }
.bean-input-row { display: flex; align-items: center; gap: var(--s-1); }
.bean-choice { position: relative; cursor: pointer; padding: var(--s-1); }
.bean-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.bean-choice .bean { width: 28px; height: 28px; transition: transform .1s; }
.bean-choice:hover .bean { transform: scale(1.1); }
.bean-choice input:focus-visible + .bean { outline: 2px solid var(--focus); border-radius: 50%; }
.bean-input .link-btn { margin-left: auto; }

/* ---------- 手順・表・アコーディオン ---------- */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
ol.steps li { counter-increment: step; position: relative; padding-left: 32px; font-size: .92rem; }
ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 2px;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--caramel-soft);
  color: var(--caramel-ink);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
}

.tips {
  margin: var(--s-5) 0 0;
  padding: var(--s-4) var(--s-5) var(--s-4) var(--s-7);
  background: var(--leaf-soft);
  border-radius: var(--r-md);
  font-size: .88rem;
}

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--card); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow); }
.table th { text-align: left; font-size: .75rem; font-weight: 500; color: var(--muted); background: var(--surface); }
.table th, .table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

.accordion { display: grid; gap: var(--s-3); }
details { background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); }
summary { cursor: pointer; padding: var(--s-4) var(--s-5); font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-family: var(--mono); color: var(--accent); font-size: 1.1rem; }
details[open] summary::after { content: "−"; }
details ul { margin: 0; padding: 0 var(--s-5) var(--s-5) var(--s-7); display: grid; gap: var(--s-2); font-size: .92rem; }

/* ---------- 挽き目マップ ---------- */
.legend { display: inline-block; width: 18px; height: 8px; border-radius: 999px; vertical-align: middle; margin: 0 var(--s-2) 0 var(--s-3); }
.legend:first-child { margin-left: 0; }
.legend-rec { background: var(--caramel); }
.legend-off { background: transparent; border: 1.5px dashed var(--accent); }
.legend-start { width: 10px; height: 10px; border-radius: 50%; background: var(--cherry); }

.gmap { padding: var(--s-5); background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); }
.gmap-axis { display: flex; justify-content: space-between; margin-left: var(--gm-label, 168px); font-size: .72rem; color: var(--muted); margin-bottom: var(--s-3); }
.gmap-axis span:last-child::after { content: " →"; }
.gmap-axis span:first-child::before { content: "← "; }
.gmap-row { display: grid; grid-template-columns: var(--gm-label, 168px) 1fr; align-items: center; min-height: 40px; }
.gmap-label { font-size: .85rem; padding-right: var(--s-4); }
.gmap-track { position: relative; height: 28px; border-radius: 999px; background: var(--surface); }
.gmap-off { position: absolute; top: 3px; bottom: 3px; border: 1.5px dashed var(--accent); border-radius: 999px; }
.gmap-rec { position: absolute; top: 8px; bottom: 8px; background: var(--caramel); border-radius: 999px; opacity: .9; }
.gmap-start { position: absolute; top: 50%; width: 0; height: 0; }
.gmap-start::before {
  content: "";
  position: absolute;
  left: -7px; top: -7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cherry);
  border: 2px solid var(--card);
}
.gmap-start span { position: absolute; left: 10px; top: -22px; font-size: .7rem; color: var(--accent); font-weight: 500; }
.gmap-ticks { position: relative; height: 18px; margin-left: var(--gm-label, 168px); margin-top: var(--s-2); font-size: .68rem; color: var(--muted); border-top: 1px solid var(--line); }
.gmap-ticks span { position: absolute; top: 2px; transform: translateX(-50%); }

.grind-card .card-top h3 { font-size: 1.05rem; }
.big-click { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; flex: none; }
.big-click .mono { font-size: 2rem; font-weight: 500; color: var(--primary); }
.big-click small { font-size: .7rem; color: var(--muted); margin-top: var(--s-2); }

.sources ul { margin: var(--s-3) 0 0; padding-left: var(--s-6); font-size: .85rem; display: grid; gap: var(--s-2); }

/* ---------- タイマー ---------- */
.timer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.timer-clock { font-size: 3.5rem; font-weight: 500; text-align: center; color: var(--primary); margin: var(--s-4) 0 var(--s-3); }
.timer-bar { height: 8px; background: var(--secondary); border-radius: 999px; overflow: hidden; margin-bottom: var(--s-5); }
.timer-bar span { display: block; height: 100%; width: 0; background: var(--caramel); transition: width .25s linear; }
.timer-steps { list-style: none; padding: 0; margin: 0 0 var(--s-5); display: grid; gap: var(--s-2); }
.timer-steps li { display: flex; gap: var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); color: var(--muted); }
.timer-steps li .mono { min-width: 3em; }
.timer-steps li.done { text-decoration: line-through; opacity: .6; }
.timer-steps li.now { background: var(--caramel-soft); color: var(--text); font-weight: 600; }

/* ---------- ダイアログ ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--card); color: var(--text); width: min(440px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.dialog::backdrop { background: rgba(30, 20, 14, .45); }
.dialog-inner { padding: var(--s-6); display: grid; gap: var(--s-4); }
.file-btn { position: relative; flex-direction: row; background: var(--surface); color: var(--text); }
.file-btn:hover { background: var(--secondary); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

.site-footer { max-width: 1040px; margin: 0 auto; padding: var(--s-6) var(--s-5) var(--s-8); text-align: center; font-size: .78rem; color: var(--muted); }

/* ---------- 解説（挽き目の基本・器具の解説） ---------- */
.link-btn.inline { padding: 0; font-size: inherit; color: var(--primary); }
.sub-head { margin: var(--s-6) 0 var(--s-3); }

.basics { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); }
.basic { padding: var(--s-4) var(--s-5); background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); }
.basic h3 { font-size: .95rem; margin-bottom: var(--s-2); }

.grind-ladder { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-3); }
.grind-ladder li {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.grind-ladder li > div { padding: 0 var(--s-2) var(--s-2); }
.grind-photo { display: block; border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 1; background: var(--secondary); }
.grind-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.grind-photo:hover img { transform: scale(1.04); }
@media (max-width: 900px) {
  .grind-ladder { grid-template-columns: 1fr; }
  .grind-ladder li { flex-direction: row; align-items: center; }
  .grind-photo { flex: none; width: 112px; }
}

.explain { margin: 0; display: grid; gap: var(--s-3); }
.explain div { display: grid; grid-template-columns: 6.5em 1fr; gap: var(--s-3); font-size: .9rem; }
.explain dt { color: var(--muted); font-size: .8rem; padding-top: 1px; }
.explain dd { margin: 0; }
.tool-card { scroll-margin-top: 140px; }

/* ---------- 淹れ方：一覧 ---------- */
.filter-chip .count { margin-left: var(--s-1); font-size: .75rem; opacity: .7; }
.filter-chip.sm { min-height: 32px; padding: 0 var(--s-4); font-size: .8rem; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-5); }
.method-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  position: relative;
  padding: var(--s-5) var(--s-5) var(--s-5) 76px;
  background: var(--card);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
a.method-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
/* 抽出の種類のアイコン（透過式・浸漬式・加圧式） */
.method-card::before {
  content: "";
  position: absolute;
  left: var(--s-5);
  top: var(--s-5);
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--type-soft, var(--secondary)) var(--type-icon, none) no-repeat center / 32px;
}
.method-card.type-pour { --type-soft: var(--caramel-soft); --type-icon: url("../img/illust/t-pour.svg"); }
.method-card.type-immersion { --type-soft: var(--leaf-soft); --type-icon: url("../img/illust/t-immersion.svg"); }
.method-card.type-pressure { --type-soft: var(--cherry-soft); --type-icon: url("../img/illust/t-pressure.svg"); }
.method-card.serve-iced { --type-soft: var(--sky-soft); }
.method-card h3 { margin: 0; }
.method-card .eyebrow { margin: 0; }
.method-card.placeholder { background: transparent; box-shadow: none; justify-content: center; }
.method-meta { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.method-meta div { padding: var(--s-2) var(--s-3); background: var(--surface); border-radius: var(--r-sm); }
.method-meta dt { font-size: .7rem; color: var(--muted); }
.method-meta dd { margin: 0; font-size: .8rem; font-weight: 500; }
.method-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.method-go { color: var(--accent); font-weight: 600; }

/* ---------- 淹れ方：詳細 ---------- */
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: var(--s-2); color: var(--muted); font-size: .85rem; text-decoration: none; }
.back-link:hover { color: var(--primary); }
.brew-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.brew-side { position: sticky; top: 140px; }
.brew-main { display: grid; gap: var(--s-5); }
.brew-main .panel { margin-bottom: 0; }
.brew-main .cond { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.calc { display: grid; gap: var(--s-3); margin-bottom: 0; }
.calc .eyebrow { margin: 0; }
.calc-label { margin: var(--s-2) 0 0; font-size: .8rem; color: var(--muted); font-weight: 500; }
.stepper { display: flex; align-items: center; gap: var(--s-3); }
.stepper input {
  flex: 1;
  min-width: 0;
  height: 56px;
  text-align: center;
  font-family: var(--mono);
  font-size: 1.8rem;
  color: var(--primary);
}
.stepper .unit { color: var(--muted); }
.step-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary);
  font: inherit;
  font-size: 1.4rem;
  cursor: pointer;
}
.step-btn:hover { background: var(--caramel-soft); }
.quick { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ratio-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.ratio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-2);
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.ratio small { font-size: .7rem; color: var(--muted); }
.ratio.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ratio.active small { color: var(--on-primary); opacity: .8; }
.calc-result { margin-top: var(--s-3); padding: var(--s-4) var(--s-5); background: var(--caramel-soft); border-radius: var(--r-md); }
.calc-result .calc-label { margin: 0; }
.calc-big { margin: 0; color: var(--primary); line-height: 1.1; }
.calc-big .mono { font-size: 3rem; font-weight: 500; }
.calc-big .unit { margin-left: var(--s-2); font-size: 1rem; color: var(--muted); }
.calc-sub { margin: var(--s-3) 0 0; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); font-size: .85rem; }
.calc-sub div { display: flex; gap: var(--s-2); }
.calc-sub dt { color: var(--muted); }
.calc-sub dd { margin: 0; font-weight: 500; }
.btn.full { width: 100%; justify-content: center; }
.timer-steps li .what { flex: 1; }
.timer-steps li .pour { color: var(--primary); font-weight: 600; }
@media (max-width: 900px) {
  .brew-layout { grid-template-columns: 1fr; }
  .brew-side { position: static; }
}
@media (max-width: 640px) {
  .brew-main .cond { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-grid { grid-template-columns: 1fr; gap: var(--s-4); }
}

/* ---------- 淹れ方：ホット／アイスと有名レシピ ---------- */
.group-title { margin: var(--s-7) 0 var(--s-4); font-size: 1.05rem; }
.group-title:first-of-type { margin-top: var(--s-5); }
.group-note { margin: calc(-1 * var(--s-2)) 0 var(--s-4); }
.recipe-by { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); font-size: .85rem; font-weight: 500; }
.recipe-summary { max-width: 64ch; margin: var(--s-3) 0 0; }
.rank {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 var(--s-3);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--secondary);
  color: var(--muted);
}
.rank-contest { background: var(--primary); color: var(--on-primary); }
.rank-popular { background: var(--caramel-soft); color: var(--caramel-ink); }
.rank-reference { background: var(--leaf-soft); color: var(--leaf-ink); }
.rank-unverified { background: var(--surface); color: var(--muted); }
.ratio-fixed { margin: 0; display: flex; align-items: baseline; gap: var(--s-3); }
.ratio-fixed .mono { font-size: 1.2rem; color: var(--primary); }
.calc-note { margin: 0; padding: var(--s-3) var(--s-4); background: var(--caramel-soft); border-radius: var(--r-sm); }
.calc-note[hidden] { display: none; }

/* ---------- タイマー（スマホで淹れながら） ---------- */
.timer-next { margin: 0 0 var(--s-4); text-align: center; font-size: .9rem; font-weight: 500; color: var(--text); min-height: 1.5em; }
.timer-dock {
  position: fixed;
  left: var(--s-4);
  right: var(--s-4);
  bottom: var(--s-5);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
}
.timer-dock[hidden] { display: none; }
.dock-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dock-clock { font-size: 1.6rem; font-weight: 500; color: var(--primary); }
.dock-text { display: grid; min-width: 0; }
.dock-row { display: flex; gap: var(--s-2); min-width: 0; align-items: baseline; }
.dock-now { min-width: 0; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-pour { flex: none; font-size: .8rem; font-weight: 600; color: var(--primary); }
.dock-next { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-toggle { flex: none; }
.timer { scroll-margin-top: var(--s-5); }

/* ---------- スマホ ---------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.35rem; }
  main { padding: var(--s-5) var(--s-5) var(--s-8); }
  .icon-btn span { display: none; }
  .icon-btn { padding: 0 var(--s-3); }

  /* タブは画面下に固定 */
  .tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    padding: var(--s-1) var(--s-2) calc(var(--s-1) + env(safe-area-inset-bottom));
    background: var(--card);
    box-shadow: 0 -4px 20px rgba(107, 69, 48, .08);
    justify-content: space-around;
    gap: 0;
  }
  .tabs a {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: var(--s-1);
    min-height: 56px;
    padding: 0;
    font-size: .7rem;
    border-bottom: 0;
  }
  .tabs a.active { border-radius: var(--r-md); }
  body { padding-bottom: 72px; }

  .grid-cards { grid-template-columns: 1fr; gap: var(--s-4); }
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .tile { padding: var(--s-4); }
  .tile p.small { font-size: .8rem; }
  .tile .trait-row { flex-direction: column; gap: var(--s-1); }
  .form-grid { grid-template-columns: 1fr; }
  .rating-grid { grid-template-columns: 1fr; }
  .panel { padding: var(--s-5); }
  .gmap { padding: var(--s-4); --gm-label: 88px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .facts div { padding: var(--s-3) var(--s-4); }
  .gmap-label { font-size: .75rem; line-height: 1.3; }
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- スマホ：淹れ方まわり ---------- */
@media (max-width: 640px) {
  /* タブは下にあるので、上のヘッダーは固定せず画面を広く使う */
  .site-header { position: static; }
  /* 絞り込みは横にスクロールする1行に */
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--s-5)); margin-right: calc(-1 * var(--s-5)); padding: 0 var(--s-5) var(--s-1); scrollbar-width: none; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip { flex: none; min-height: 40px; }
  .filter-chip.sm { min-height: 40px; }
  .quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .quick::-webkit-scrollbar { display: none; }
  .quick .filter-chip { flex: 1 0 auto; }
  /* タイマーは大きく、ボタンは親指で押しやすく */
  .timer-clock { font-size: 4rem; }
  .timer-actions { display: grid; grid-template-columns: 2fr 1fr; }
  .timer-actions .btn { min-height: 52px; font-size: 1rem; }
  .timer-steps li { padding: var(--s-3); gap: var(--s-3); font-size: .9rem; }
  .timer-dock { left: var(--s-3); right: var(--s-3); bottom: calc(72px + env(safe-area-inset-bottom)); }
  body:has(.timer-dock:not([hidden])) { padding-bottom: 156px; }
  .brew-layout { gap: var(--s-4); }
  .calc { gap: var(--s-2); }
  .calc-big .mono { font-size: 2.6rem; }
}

/* 削除ボタン：1回目のタップで確認の状態にする */
.btn.armed { background: var(--danger); border-color: var(--danger); color: var(--on-primary); }
.copy-area { width: 100%; min-height: 120px; font-family: var(--mono); font-size: .75rem; }

/* ---------- コラム ---------- */
.feature {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-6);
  margin-bottom: var(--s-6);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.feature .eyebrow { color: var(--berry-ink); }
.feature p { margin: 0; }
.feature .eyebrow { margin: 0; }
.title-link { padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.title-link:hover { color: var(--primary); text-decoration: underline; }
.excerpt { margin: 0; font-size: .9rem; color: var(--muted); }
.column-card .actions { align-items: center; }
.back { margin-bottom: var(--s-4); padding-left: 0; font-size: .85rem; }
.column-detail { display: flex; flex-direction: column; gap: var(--s-4); max-width: 72ch; }
.column-detail h1 { margin: 0; }
.column-lead { margin: 0; font-size: 1.02rem; color: var(--muted); }
.column-body { font-size: 1rem; line-height: 1.9; }
.column-body p { margin: 0 0 var(--s-5); }
.column-body h3 { font-size: 1.1rem; margin: var(--s-6) 0 var(--s-3); color: var(--accent); }
.column-body > :first-child { margin-top: 0; }
.sources { padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: .85rem; }
.sources ul { margin: var(--s-2) 0 0; padding-left: var(--s-5); }
.sources li { overflow-wrap: anywhere; }
.next-column {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  width: 100%;
  max-width: 72ch;
  padding: var(--s-5);
  text-align: left;
  background: var(--card);
  border: 0;
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.next-column:hover { box-shadow: var(--shadow-hover); }
.next-column .eyebrow { margin: 0; }
