/* ==========================================================================
   あとでみよ📌  スタイルシート
   方針：老若男女・マニュアル不要。大きめの文字とボタン、迷わない導線、やさしい配色。
   ========================================================================== */

:root {
  --brand-a: #ff7eb3;
  --brand-b: #ff9a76;
  --brand-grad: linear-gradient(135deg, #ff7eb3 0%, #ff9a76 100%);
  --danger: #e0455f;

  --bg: #fff5f7;
  --surface: #ffffff;
  --surface-2: #fff0f4;
  --text: #33272a;
  --text-soft: #7a6d72;
  --line: #f1dfe5;
  --shadow: 0 6px 20px rgba(255, 126, 179, 0.18);
  --shadow-lg: 0 12px 34px rgba(255, 126, 179, 0.28);
  --ring: rgba(255, 126, 179, 0.22);

  --radius: 20px;
  --radius-sm: 14px;
  --tap: 52px;               /* 最低タップサイズ */

  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
          "Yu Gothic UI", "Meiryo", system-ui, -apple-system, sans-serif;
}

/* アプリ側で「ダーク」を選んだとき */
:root[data-theme="dark"] {
  --bg: #1b1418;
  --surface: #271c22;
  --surface-2: #31232a;
  --text: #ffeef4;
  --text-soft: #c7a9b4;
  --line: #3d2c34;
  --danger: #ff8095;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.5);
  --ring: rgba(255, 154, 118, 0.3);
}

/* 端末が「ダーク」設定のとき（アプリ側で明示的にライトを選んでいなければ従う） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1418;
    --surface: #271c22;
    --surface-2: #31232a;
    --text: #ffeef4;
    --text-soft: #c7a9b4;
    --line: #3d2c34;
    --danger: #ff8095;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.5);
    --ring: rgba(255, 154, 118, 0.3);
  }
}

* { box-sizing: border-box; }

/* hidden 属性は必ず非表示（class の display 指定に勝たせる） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

button { font-family: inherit; cursor: pointer; }

/* キーボード操作でも「今どこにいるか」が見えるように */
:focus-visible {
  outline: 3px solid var(--brand-a);
  outline-offset: 2px;
}
.app-header :focus-visible { outline-color: #fff; }

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--shadow);
}
.app-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.logo-emoji { font-size: 1.35rem; }
.header-back, .header-menu {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
}
.header-back:active, .header-menu:active { background: rgba(255,255,255,0.34); }

/* ===== メイン ===== */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 8px;
}

.section-lead {
  margin: 6px 2px 16px;
  color: var(--text-soft);
  font-size: 0.98rem;
}
.page-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 2px 14px;
  font-size: 1.25rem;
  font-weight: 800;
}
.page-heading .count-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
  padding: 2px 12px;
  border-radius: 999px;
}

/* 保存できない環境のおしらせ */
.storage-note {
  max-width: 720px;
  margin: 14px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 0.9rem;
}

/* ===== コレクション一覧（グリッド） ===== */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.collection-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  color: var(--text);
}
.collection-card:active { transform: scale(0.97); }
.collection-card .cc-emoji { font-size: 2rem; }
.collection-card .cc-name { display: block; margin-top: 10px; font-weight: 800; font-size: 1.05rem; }
.collection-card .cc-count { display: block; margin-top: 2px; color: var(--text-soft); font-size: 0.9rem; }
.collection-card.is-add {
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--line);
  background: transparent;
  box-shadow: none;
  color: var(--text-soft);
  font-weight: 700;
}

/* ===== 投稿カード ===== */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.12s ease;
}
.post-card:active { transform: scale(0.985); }
.post-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: none;
  background: transparent;
  text-align: left;
  color: var(--text);
  min-height: var(--tap);
}
.sns-chip {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 50px; height: 50px;
  border-radius: 14px;
  color: #fff;
}
.sns-chip svg { width: 26px; height: 26px; }
.post-body { flex: 1; min-width: 0; }
/* SNS名の文字色。X や TikTok は地の色が暗いので、ダークでは明るい方を使う */
.sns-name { color: var(--sns, var(--text-soft)); }
:root[data-theme="dark"] .sns-name { color: var(--sns-dark, var(--sns, var(--text-soft))); }
:root[data-theme="dark"] .sns-chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sns-name { color: var(--sns-dark, var(--sns, var(--text-soft))); }
  :root:not([data-theme="light"]) .sns-chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
}
.post-title {
  display: block;
  font-weight: 700;
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 0.85rem;
}
.post-meta .sns-name { flex-shrink: 0; font-weight: 700; }
.post-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-go {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  color: var(--brand-a);
}
.post-more {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 48px;
  border: none;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--text-soft);
}
.post-more:active { background: var(--surface-2); }

/* ===== 空の状態 ===== */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}
.empty .empty-emoji { font-size: 3.4rem; }
.empty .empty-title { margin: 14px 0 6px; font-size: 1.15rem; font-weight: 800; color: var(--text); }
.empty .empty-text { font-size: 0.98rem; }
.empty .empty-arrow { margin-top: 18px; font-size: 1.6rem; animation: bounce 1.4s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(8px)} }

/* ===== FAB（追加ボタン） ===== */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 60px;
  padding: 0 22px 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  transition: transform 0.12s ease;
}
.fab:active { transform: scale(0.94); }
.fab-label { padding-right: 2px; }

/* ===== シート（モーダル） ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(51, 39, 42, 0.5);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 8px 22px calc(26px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 44px; height: 5px;
  margin: 8px auto 14px;
  border-radius: 999px;
  background: var(--line);
}
.sheet-title { margin: 0 0 18px; font-size: 1.2rem; font-weight: 800; }
.sheet-sub {
  margin: -12px 0 16px;
  color: var(--text-soft);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.confirm-text { margin: 0 0 6px; font-size: 1.02rem; }
.confirm-note { margin: 6px 0 0; color: var(--text-soft); font-size: 0.88rem; }

.field-label {
  display: block;
  margin: 16px 0 4px;
  font-weight: 700;
  font-size: 0.98rem;
}
.field-label .optional { color: var(--text-soft); font-weight: 500; font-size: 0.85rem; }
.field-hint { margin: 0 0 8px; color: var(--text-soft); font-size: 0.85rem; }
.field-input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.02rem;
}
.field-input:focus {
  outline: none;
  border-color: var(--brand-a);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

.sns-detected {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.95rem;
}
.sns-detected .sns-chip { width: 34px; height: 34px; border-radius: 10px; }
.sns-detected .sns-chip svg { width: 18px; height: 18px; }

/* コレクション選択（チップ） */
.collection-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}
.pick-chip.is-on {
  border-color: transparent;
  background: var(--brand-grad);
  color: #fff;
}
.pick-chip.is-new { border-style: dashed; color: var(--text-soft); }

/* アイコン選択 */
.emoji-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-chip {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 1.5rem;
  line-height: 1;
}
.emoji-chip.is-on { border-color: transparent; background: var(--brand-grad); box-shadow: var(--shadow); }

/* シートのアクション */
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}
.btn {
  flex: 1;
  min-height: var(--tap);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 800;
}
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; }
.btn-ghost { background: var(--surface-2); color: var(--text-soft); flex: 0 0 34%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { transform: scale(0.98); }

/* メニュー */
.sheet--menu .menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 10px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
}
.sheet--menu .menu-item:active { background: var(--surface-2); }
.sheet--menu .menu-item--danger { color: var(--danger); }
.menu-ico { font-size: 1.4rem; }
.sheet-close { margin-top: 20px; flex: 1; width: 100%; }

/* ===== トースト ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 90%;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* アクセシビリティ：操作を減らしたい人向け */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
