:root {
  --accent: #E8743B;
  --accent-soft: #FDEBDD;
  --bg: #FFFAF5;
  --card: #FFFFFF;
  --text: #2B2420;
  --sub: #8A7E76;
  --line: #EEE4DC;
  --star: #F2B233;
  --danger: #D64545;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: var(--accent); }

.page { max-width: 760px; margin: 0 auto; padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 250, 245, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px 16px 8px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.02em; margin: 0; flex: 1; }
.brand span { color: var(--accent); }
.title-sm { flex: 1; font-weight: 700; font-size: 16px; text-align: center; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  border: none; background: transparent; padding: 6px 8px; border-radius: 10px;
  font-size: 15px; color: var(--text); min-width: 40px; min-height: 36px;
}
.icon-btn:active { background: var(--accent-soft); }
.text-btn { border: none; background: transparent; color: var(--accent); font-weight: 700; padding: 6px 8px; }

.search {
  margin-top: 8px; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
}
.search input { border: none; outline: none; flex: 1; background: transparent; min-width: 0; font-size: 16px; }
.search .clear { border: none; background: transparent; color: var(--sub); padding: 0 4px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chip.type.on { background: var(--text); border-color: var(--text); }

.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px 0; color: var(--sub); font-size: 13px; }
.toolbar select { border: none; background: transparent; color: var(--text); font-weight: 600; font-size: 13px; }

/* ---------- 一覧カード ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 16px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 3px rgba(60, 40, 20, 0.08); border: none; padding: 0; text-align: left;
  display: flex; flex-direction: column;
}
.card:active { transform: scale(0.98); }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.thumb .ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 38px; }
.badge {
  position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600;
}
.badge.youtube { background: #E62117; }
.card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.card-title { font-weight: 700; font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stars { color: var(--star); font-size: 13px; letter-spacing: 1px; }
.stars .off { color: #E3D8CF; }
.meta { color: var(--sub); font-size: 11px; }

.empty { text-align: center; color: var(--sub); padding: 48px 24px; }
.empty .big { font-size: 48px; }

.fab {
  position: fixed; right: 20px; bottom: calc(24px + var(--safe-bottom)); z-index: 20;
  background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 14px 20px; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(232, 116, 59, 0.45);
}

/* ---------- 詳細 ---------- */
.hero { position: relative; background: var(--accent-soft); }
.hero img { width: 100%; max-height: 60vh; object-fit: contain; background: #000; }
.hero .ph { height: 180px; display: flex; align-items: center; justify-content: center; font-size: 64px; }
.yt-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; background: #000; }
.detail { padding: 16px; }
.detail h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.4; }
.rate { display: flex; gap: 2px; margin: 4px 0 8px; }
.rate button { border: none; background: transparent; font-size: 28px; color: #E3D8CF; padding: 0 2px; line-height: 1; }
.rate button.on { color: var(--star); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag { background: var(--accent-soft); color: #A4501F; border-radius: 999px; padding: 2px 10px; font-size: 13px; border: none; }
.section { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.section h3 { margin: 0 0 6px; font-size: 14px; color: var(--sub); }
.pre { white-space: pre-wrap; word-break: break-word; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  border: none; border-radius: 12px; padding: 13px; font-weight: 700; font-size: 15px; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.outline { background: var(--card); color: var(--accent); border: 1.5px solid var(--accent); }
.btn.ghost { background: transparent; color: var(--sub); }
.btn.danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* ---------- メニュー・ダイアログ ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; }
.sheet p { margin: 0 0 8px; text-align: center; }
.viewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; background: rgba(255,255,255,0.2); color: #fff; border: none; border-radius: 999px; padding: 8px 14px; font-weight: 700; }

/* ---------- 入力フォーム ---------- */
.form { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--sub); font-size: 12px; margin-left: 4px; }
.field input[type=text], .field input[type=url], .field input[type=date], .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  padding: 10px 12px; font-size: 16px; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 110px; resize: vertical; }
.types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.types button {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600;
}
.types button .ico { font-size: 22px; }
.types button.on { border-color: var(--accent); background: var(--accent-soft); color: #A4501F; }
.img-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.img-item { position: relative; }
.img-item img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: center top; border-radius: 8px; }
.img-item button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 999px; border: none; background: var(--text); color: #fff; font-size: 13px; line-height: 1; }
.field label.img-add { aspect-ratio: 1; margin: 0; cursor: pointer; border: 1.5px dashed var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--accent); font-size: 12px; font-weight: 700; background: var(--card); }
.img-add input { display: none; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 8px; }
.tag-input .tag { display: inline-flex; align-items: center; gap: 4px; }
.field .tag-input input[type=text] { border: none; padding: 2px 4px; border-radius: 0; width: auto; outline: none; flex: 1; min-width: 120px; font-size: 16px; background: transparent; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest .chip { font-size: 12px; padding: 2px 10px; }
.yt-preview { margin-top: 8px; border-radius: 10px; overflow: hidden; }
.yt-preview img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

/* ---------- 設定 ---------- */
.list-item { display: block; width: 100%; text-align: left; background: var(--card); border: none; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.list-item small { display: block; color: var(--sub); }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(43, 36, 32, 0.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; max-width: 90vw; text-align: center;
}
