*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--base);
  color: var(--ink);
  font: 400 var(--fs-body)/1.7 var(--font);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  overflow-wrap: anywhere;
}
html.lock, html.lock body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--deep); }
:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; }
svg { display: block; flex: none; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: calc(var(--s2) + env(safe-area-inset-left));
  padding-right: calc(var(--s2) + env(safe-area-inset-right));
}

/* ---- ヘッダー帯 ---- */
.band { background: var(--mint); }
.bar { height: 48px; display: flex; align-items: center; justify-content: space-between; }
.mark { font-size: var(--fs-body); font-weight: 900; color: var(--ink); text-decoration: none; height: 48px; display: flex; align-items: center; letter-spacing: .04em; }
.head { padding: var(--s3) 0; }
.head h1 { margin: 0; font-size: var(--fs-h1); font-weight: 900; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.head p { margin: var(--s1) 0 0; word-break: keep-all; overflow-wrap: anywhere; }
.nb { white-space: nowrap; }
.meta { font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }

/* ---- ナビ ---- */
.topnav { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--base); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tablink {
  flex: 1; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink); text-decoration: none; font-size: var(--fs-note); font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.tablink.on { background: var(--ink); color: var(--base); }
.navlink { height: 48px; padding: 0 var(--s2); display: flex; align-items: center; gap: var(--s1); color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.navlink.on { background: var(--ink); color: var(--base); }

/* ---- 数字タイル ---- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s1); margin-top: var(--s3); }
.tile {
  text-align: left; background: var(--base); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s2); min-height: 88px; display: flex; flex-direction: column; justify-content: space-between; gap: var(--s1);
}
.tiles3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 359px) {
  .tiles3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles3 .tile:first-child { grid-column: 1 / -1; }
}
.tile .num { font-size: var(--fs-h1); font-weight: 900; line-height: 1.3; }
.tile .lab { font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }
.tile[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--base); }
.tile[aria-pressed="true"] .lab { color: var(--base); }
.tile[aria-disabled="true"] { background: var(--surface); cursor: default; }

/* ---- 札 ---- */
.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s1); border-radius: var(--r);
  font-size: var(--fs-note); font-weight: 700; line-height: 1; white-space: nowrap; flex: none;
}
.tag.live { background: var(--accent); color: var(--ink); }
.tag.norm { background: var(--base); color: var(--ink); border: 1px solid var(--ink); }
.tag.sleep { background: var(--surface); color: var(--sub); }

/* ---- 検索・並び替え ---- */
.tools { margin-top: var(--s2); display: grid; gap: var(--s1); }
.search { position: relative; }
.search input {
  width: 100%; height: var(--tap); border: 0; border-radius: var(--r); background: var(--surface);
  padding: 0 var(--tap); font-size: var(--fs-body); -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--sub); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: 2px solid var(--deep); outline-offset: 0; }
.search-ic { position: absolute; left: var(--s2); top: var(--s1); height: var(--s4); display: flex; align-items: center; color: var(--sub); pointer-events: none; }
.clear { position: absolute; right: 0; top: 0; width: var(--tap); height: var(--tap); border: 0; background: none; display: flex; align-items: center; justify-content: center; color: var(--ink); }
.clear[hidden] { display: none; }
.seg { display: grid; gap: var(--s1); }
.seg2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button {
  min-height: var(--tap); border: 0; border-radius: var(--r); background: var(--surface); color: var(--ink);
  padding: var(--s1); font-size: var(--fs-body); font-weight: 700; line-height: 1.4; text-align: center;
}
.seg button .sn { display: block; word-break: keep-all; overflow-wrap: anywhere; }
.seg button .sc { display: block; font-size: var(--fs-note); font-weight: 400; line-height: 1.6; color: var(--sub); }
.seg4 button .sn { font-size: var(--fs-note); font-weight: 700; line-height: 1.6; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--base); }
.seg button[aria-pressed="true"] .sc { color: var(--base); }
.count { margin: 0; font-size: var(--fs-note); line-height: 1.6; color: var(--sub); min-height: 21px; }

/* ---- カテゴリ目次 ---- */
.toc { margin-top: var(--s3); }
.toc[hidden] { display: none; }
.toc-list { column-count: 1; column-gap: var(--s2); }
.toc a {
  display: flex; align-items: center; gap: var(--s2); height: 72px; padding: 0 var(--s2); margin: 0 0 var(--s1);
  background: var(--mint); border-radius: var(--r); color: var(--ink); text-decoration: none; break-inside: avoid;
}
.toc a svg { color: var(--deep); }
.toc .tn { font-weight: 700; flex: 1; min-width: 0; line-height: 1.4; word-break: keep-all; overflow-wrap: anywhere; }
.toc .tc { font-size: var(--fs-note); color: var(--sub); white-space: nowrap; display: flex; align-items: center; gap: var(--s1); }

/* ---- セクション見出し ---- */
.sec-h { display: flex; align-items: center; gap: var(--s1); margin: var(--s6) 0 var(--s2); padding-bottom: var(--s1); border-bottom: 1px solid var(--line); scroll-margin-top: var(--s2); }
.sec-h svg { color: var(--deep); }
.sec-h h2 { margin: 0; font-size: var(--fs-h2); font-weight: 700; line-height: 1.4; word-break: keep-all; overflow-wrap: anywhere; }
.sec-h .sc { margin-left: auto; font-size: var(--fs-note); color: var(--sub); white-space: nowrap; }
#list > .sec-h:first-child { margin-top: var(--s3); }

/* ---- スキルカード ---- */
.cards { column-count: 1; column-gap: var(--s2); }
.card {
  display: block; width: 100%; text-align: left; background: var(--base); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s2); margin: 0 0 var(--s2); break-inside: avoid; min-height: var(--tap);
}
.card.is-sleep { background: var(--surface); }
.card .r1 { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s1); }
.card .name { font-weight: 700; line-height: 1.7; min-width: 0; overflow-wrap: anywhere; }
.card .cat { display: block; margin-top: var(--s1); font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }
.card .sum {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: var(--s1); word-break: keep-all; overflow-wrap: anywhere; min-width: 0;
}
.card .cmeta { display: block; margin-top: var(--s1); font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }

/* ---- 空状態 ---- */
.empty { margin-top: var(--s3); background: var(--surface); border-radius: var(--r); padding: var(--s3); display: grid; gap: var(--s2); justify-items: start; }
.empty p { margin: 0; display: flex; gap: var(--s1); align-items: center; }

/* ---- ボタン ---- */
.btn { height: var(--tap); padding: 0 var(--s3); border: 0; border-radius: var(--r); font-size: var(--fs-body); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); white-space: nowrap; }
.btn.primary { background: var(--deep); color: var(--base); }
.btn.quiet { background: var(--surface); color: var(--ink); }
.btn.block { width: 100%; }

.foot { margin: var(--s6) 0 0; font-size: var(--fs-note); line-height: 1.6; color: var(--sub); word-break: keep-all; overflow-wrap: anywhere; }

/* ---- 詳細シート ---- */
.sheet-bg { position: fixed; inset: 0; z-index: 30; background: rgba(20, 32, 31, .48); opacity: 0; transition: opacity 200ms; }
.sheet-bg.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; max-height: 90vh; max-height: 90dvh;
  background: var(--base); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 200ms;
}
.sheet.open { transform: translateY(0); }
.sheet[hidden], .sheet-bg[hidden] { display: none; }
.sheet-top { display: flex; justify-content: flex-end; padding: var(--s1) var(--s1) 0; }
.sheet-x { width: var(--tap); height: var(--tap); border: 0; background: none; display: flex; align-items: center; justify-content: center; }
.sheet-body { overflow: auto; padding: 0 var(--s2) var(--s2); display: grid; gap: var(--s2); align-content: start; -webkit-overflow-scrolling: touch; }
.sheet-body h2 { margin: 0; font-size: var(--fs-h2); font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sheet-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }
.sheet-body p { margin: 0; word-break: keep-all; overflow-wrap: anywhere; }
.desc { font-size: var(--fs-note); line-height: 1.6; color: var(--sub); max-height: 248px; overflow: auto; background: var(--surface); border-radius: var(--r); padding: var(--s2); white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-body .path { font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }
.sheet-foot { padding: var(--s2) var(--s2) calc(var(--s2) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* ---- やりたいことカード ---- */
.wcard { position: relative; background: var(--base); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 var(--s2); overflow: hidden; }
.wcard.open::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent-soft); }
.wrow { width: 100%; display: grid; grid-template-columns: 24px minmax(0, 1fr) 24px; gap: var(--s2); align-items: start; text-align: left; padding: var(--s2); border: 0; background: none; min-height: var(--tap); }
.wrow > svg { margin-top: 2px; }
.wtitle {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 700; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere;
}
.wcard.open .wtitle { display: block; overflow: visible; }
.wmeta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s1); font-size: var(--fs-note); line-height: 1.6; color: var(--sub); }
.wmeta .star { display: inline-flex; align-items: center; gap: 4px; }
.chev { transition: transform 160ms; }
.wcard.open .chev { transform: rotate(180deg); }
.wbody { padding: 0 var(--s2) var(--s2) calc(var(--s2) + 24px + var(--s2)); display: grid; gap: var(--s2); }
.wbody[hidden] { display: none; }
.wmemo { margin: 0; font-size: var(--fs-note); line-height: 1.6; color: var(--sub); word-break: keep-all; overflow-wrap: anywhere; }
.kids { list-style: none; margin: 0; padding: 0 0 0 var(--s2); border-left: 1px solid var(--line); }
.kids .kids { margin-top: var(--s1); }
.kids li { margin: var(--s1) 0 0; word-break: keep-all; overflow-wrap: anywhere; }
.kids li:first-child { margin-top: 0; }
.wbody code, .card code { background: var(--surface); border-radius: 4px; padding: 0 var(--s1); font: inherit; overflow-wrap: anywhere; }
.wbody strong { font-weight: 700; }
.wbody a, .wmemo a { color: var(--deep); }

/* ---- 640〜 ---- */
@media (min-width: 640px) {
  .wrap { padding-left: calc(var(--s3) + env(safe-area-inset-left)); padding-right: calc(var(--s3) + env(safe-area-inset-right)); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toc-list, .cards { column-count: 2; }
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: min(640px, calc(100% - 48px)); max-height: 85vh; max-height: 85dvh;
    border-radius: var(--r); transform: translate(-50%, -48%); opacity: 0; transition: transform 200ms, opacity 200ms;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
}
/* やりたいこと: 長文を読みやすくする最大幅720 */
.narrow .wrap { max-width: 768px; }
/* ---- 960〜（PC） ---- */
@media (min-width: 960px) {
  .tabbar { display: none; }
  body { padding-bottom: var(--s6); }
  .topnav { display: flex; }
  .toc-list { column-count: 4; }
  .cards { column-count: 3; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-bg, .chev { transition: none; }
}
