*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light dark;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ebe9e4;
  --text: #191917;
  --muted: #74726c;
  --line: #e2e0da;
  --accent: #191917;
  --on-accent: #ffffff;
  --focus: #3b6cff;
  --danger: #d23f31;
  --star: #f5a700;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
  --shadow-md: 0 2px 6px rgb(0 0 0 / .04), 0 14px 36px rgb(0 0 0 / .09);
  --gutter: clamp(16px, 4vw, 48px);

  font-family: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1b1b19;
    --surface-2: #262624;
    --text: #f0efea;
    --muted: #9a988f;
    --line: #2e2e2b;
    --accent: #f0efea;
    --on-accent: #111110;
    --shadow-md: 0 2px 6px rgb(0 0 0 / .3), 0 14px 36px rgb(0 0 0 / .45);
  }
}

body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.is-readonly [data-owner], body:not(.is-readonly) [data-viewer] { display: none !important; }
.icon { display: inline-flex; }
.icon svg { display: block; }
.spacer { flex: 1; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  margin: 0 1px;
  font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  vertical-align: middle;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { border-color: var(--accent); opacity: .86; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: transparent; }
.btn[aria-pressed="true"] .icon { color: var(--star); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover { color: var(--text); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 18px var(--gutter);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand-mark .bg { fill: var(--accent); }
.brand-mark .fg { fill: var(--on-accent); }
.brand-name { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.15; }
.brand-sub { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.header-actions { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }

.search { position: relative; display: flex; flex: 0 1 380px; align-items: center; min-width: 0; }
.search-icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.search input:focus { border-color: var(--text); }
.search kbd { position: absolute; right: 12px; pointer-events: none; }
.search input:focus ~ kbd,
.search input:not(:placeholder-shown) ~ kbd { display: none; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.menu-panel button {
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu-panel button:hover { background: var(--surface-2); }
.menu-panel hr { margin: 4px 6px; border: 0; border-top: 1px solid var(--line); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: grid;
  gap: 14px;
  padding: 2px var(--gutter) 24px;
}
.toolbar-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.view-switch { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.view-switch button:hover { color: var(--text); }
.view-switch button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.select {
  height: 32px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center / 11px;
  font-size: 13px;
  appearance: none;
  cursor: pointer;
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-scroll {
  flex: 1;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
  padding-right: 32px;
}
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--surface); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: inherit; opacity: .65; }
.chip.is-empty { opacity: .45; }
.chip-group {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  padding: 0 2px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
}
.chips-sm { gap: 4px; }
.chips-sm .chip { height: 24px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.chips-sm .chip:hover { color: var(--text); }

/* ---------- Grid & Card ---------- */
main { padding: 0 var(--gutter) 96px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: 36px 28px;
}

.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.is-new { animation: card-in .45s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } }

.card-figure {
  position: relative;
  border-radius: var(--radius);
  transition: transform .3s cubic-bezier(.2, .7, .2, 1);
}
.card:hover .card-figure { transform: translateY(-3px); }

.card-media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transition: box-shadow .3s;
}
.card:hover .card-media { box-shadow: var(--shadow-md), 0 0 0 1px var(--line); }

.fav {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / .88);
  color: #8d8a82;
  box-shadow: 0 1px 4px rgb(0 0 0 / .18);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .2s, transform .2s, color .2s;
}
.fav:hover { color: #3d3b36; }
.card:hover .fav, .fav:focus-visible, .fav[aria-pressed="true"] { opacity: 1; transform: none; }
.fav[aria-pressed="true"] { color: var(--star); }

.card-badges { position: absolute; bottom: 10px; left: 10px; z-index: 2; display: flex; gap: 6px; pointer-events: none; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgb(17 17 16 / .78);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.badge.is-busy { animation: pulse 1.4s ease-in-out infinite; }
.badge.is-error { background: var(--danger); }
.badge.is-todo { background: rgb(255 255 255 / .92); color: #191917; box-shadow: 0 1px 4px rgb(0 0 0 / .15); }

.card-body { display: grid; gap: 6px; min-width: 0; padding: 0 2px; }
.card-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-host {
  flex: 1 1 0;
  min-width: 40px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-edit { width: 30px; height: 30px; margin-left: auto; opacity: 0; }
.card:hover .card-edit, .card-edit:focus-visible { opacity: 1; }
.card-memo {
  display: -webkit-box;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (hover: none) {
  .fav, .card-edit { opacity: 1; transform: none; }
}

/* ---------- Thumbnail ---------- */
.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface-2);
  container-type: inline-size;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity .45s, transform .7s cubic-bezier(.2, .7, .2, 1);
}
.thumb.is-loaded img { opacity: 1; }
.thumb--sp { aspect-ratio: 9 / 16; }
.grid.is-sp { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 32px 22px; }
.card:hover .thumb img { transform: scale(1.03); }

.ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  background: linear-gradient(135deg, hsl(var(--hue) 72% 87%), hsl(calc(var(--hue) + 45) 62% 74%));
  color: hsl(var(--hue) 45% 22%);
}
@media (prefers-color-scheme: dark) {
  .ph {
    background: linear-gradient(135deg, hsl(var(--hue) 32% 24%), hsl(calc(var(--hue) + 45) 36% 15%));
    color: hsl(var(--hue) 60% 84%);
  }
}
.ph-initial { font-size: 56px; font-size: 20cqi; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.ph-host { font-size: 12px; font-weight: 600; opacity: .7; }
.thumb.is-pending .ph::after {
  content: "スクリーンショットを生成中…";
  position: absolute;
  right: 0;
  bottom: 12px;
  left: 0;
  font-size: 11px;
  text-align: center;
  opacity: .75;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Parts ---------- */
.parts-grid { columns: 280px; column-gap: 26px; }
.part-card { display: grid; gap: 10px; margin-bottom: 30px; break-inside: avoid; }
.part-media-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transition: box-shadow .25s, transform .3s cubic-bezier(.2, .7, .2, 1);
}
.part-card:hover .part-media-btn { box-shadow: var(--shadow-md), 0 0 0 1px var(--line); transform: translateY(-2px); }
.part-media, .dpart-img { position: relative; overflow: hidden; background: var(--surface-2); }
.part-media img, .dpart-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity .35s;
}
.part-media.is-wide img, .dpart-img.is-wide img { object-position: left center; }
.part-media.is-loaded img, .dpart-img.is-loaded img { opacity: 1; }
.part-body { display: grid; gap: 2px; min-width: 0; padding: 0 2px; }
.part-cat { font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted); }
.part-label { margin: 0; font-size: 14px; font-weight: 650; line-height: 1.45; }
.part-site {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.part-site:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Empty ---------- */
.empty { display: grid; justify-items: center; gap: 6px; padding: 10vh 16px; text-align: center; }
.empty h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.empty p { margin: 0 0 16px; color: var(--muted); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 14px; }
.empty-art { position: relative; width: 240px; height: 140px; margin-bottom: 28px; }
.empty-art span {
  position: absolute;
  top: 20px;
  left: 45px;
  width: 150px;
  height: 94px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.empty-art span:nth-child(1) { background: linear-gradient(135deg, #ffd6a5, #ff9a8b); transform: rotate(-11deg) translate(-44px, 8px); }
.empty-art span:nth-child(2) { background: linear-gradient(135deg, #b5ead7, #73c2fb); transform: rotate(9deg) translate(44px, 6px); }
.empty-art span:nth-child(3) { background: linear-gradient(135deg, #e9dcff, #a78bfa); }

.no-result { padding: 12vh 0; color: var(--muted); text-align: center; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgb(0 0 0 / .28);
  overflow: auto;
}
.dialog::backdrop {
  background: rgb(15 15 12 / .45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.dialog[open] { animation: dialog-in .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 4px 24px; }
.dialog-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.dialog-body { display: grid; gap: 18px; padding: 12px 24px 8px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 16px 20px 20px; }

/* ---------- Form ---------- */
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > span, .field > label, .field > legend { padding: 0; font-size: 12px; font-weight: 650; color: var(--muted); }
.field > legend { margin-bottom: 6px; }
.field em { font-style: normal; color: var(--danger); }
.input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent); }
textarea.input { min-height: 80px; resize: vertical; line-height: 1.7; }
.hint { font-size: 12px; color: var(--muted); }
.hint:empty { display: none; }
.hint.is-error { color: var(--danger); }
.hint.is-warn { color: #b86e00; }

.segmented { display: inline-flex; justify-self: start; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); cursor: pointer; transition: color .15s; }
.segmented span:hover { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); }

.thumb-preview { overflow: hidden; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.thumb-empty {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  padding: 16px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.thumb-preview.is-drop {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  padding: 16px;
  border: 2px dashed var(--line);
  background: var(--bg);
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.thumb-preview.is-drop:hover, .thumb-preview.is-drop.is-over { border-color: var(--text); color: var(--text); }
.thumb-preview.is-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.thumb-preview.has-image .drop-msg {
  position: absolute;
  bottom: 10px;
  left: 50%;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / .7);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .15s;
}
.thumb-preview.has-image:hover .drop-msg { opacity: 1; }

/* ---------- Detail ---------- */
.dialog-wide { width: min(1200px, calc(100vw - 32px)); }
.detail { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(290px, 1fr); }
.detail-media { max-height: calc(100dvh - 48px); overflow: auto; background: var(--surface-2); }
.detail-media .thumb--full.is-loaded { aspect-ratio: auto; }
.detail-media .thumb--full.is-loaded img { position: relative; height: auto; }
.detail-media .thumb--full.is-loaded .ph { display: none; }
.detail-info { display: flex; flex-direction: column; gap: 14px; max-height: calc(100dvh - 48px); padding: 14px 20px 24px 26px; overflow: auto; }
.detail-bar { display: flex; align-items: center; gap: 2px; margin: 0 -6px 4px -10px; }
.detail-pos { margin-left: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.detail-title { margin: 0; font-size: 24px; letter-spacing: -0.02em; line-height: 1.3; overflow-wrap: anywhere; }
.detail-url { font-size: 13px; color: var(--muted); text-decoration: none; word-break: break-all; }
.detail-url:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.detail-memo { margin: 0; font-size: 14px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-memo.is-empty { color: var(--muted); }
.detail-date { margin: 0; font-size: 12px; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 10px; }

/* LP全体ビューア（サイト詳細） */
.detail--site, .detail--part { height: min(940px, calc(100dvh - 48px)); grid-template-rows: minmax(0, 1fr); }
.detail--site .detail-media, .detail--part .detail-media { height: 100%; max-height: none; }
.lp-scroll { position: relative; padding-bottom: 32px; overflow: auto; overscroll-behavior: contain; }
.lp-toolbar {
  position: sticky;
  top: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 12px auto;
  padding: 0 12px;
  pointer-events: none;
}
.lp-toolbar > * { pointer-events: auto; }
.lp-switch, .lp-pages { display: flex; flex-wrap: wrap; width: max-content; max-width: 100%; background: var(--surface); box-shadow: var(--shadow-md); }
.lp-switch input:checked + span, .lp-pages input:checked + span { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.dpart-page { font-size: 11px; color: var(--muted); }
.detail-foot { margin: 10px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.device-switch button { padding: 0 14px; }
.lp-stack { position: relative; }
.lp-stack.is-column { max-width: 430px; margin: 0 auto; box-shadow: var(--shadow-md); }
.lp-stack.is-phone {
  max-width: 390px;
  margin: 0 auto;
  border-radius: 30px;
  overflow: hidden;
  box-shadow: 0 0 0 8px #1d1d1b, var(--shadow-md);
}
.lp-stack img { display: block; width: 100%; height: auto; background: var(--surface); }
.lp-hl {
  position: absolute;
  border: 3px solid var(--focus);
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / .38);
  pointer-events: none;
  animation: hl-in .45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes hl-in { from { opacity: 0; transform: scale(1.03); } }
.lp-empty { display: grid; gap: 16px; padding: 28px; }
.lp-empty .thumb { border-radius: 12px; }
.lp-empty p { margin: 0; font-size: 13px; color: var(--muted); }

.dparts { display: grid; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dparts-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.dparts-group h4 { margin: 0 0 8px; font-size: 12px; font-weight: 650; color: var(--muted); }
.dparts-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.dpart { position: relative; }
.dpart-main { display: grid; gap: 6px; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.dpart-img { border-radius: 8px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .15s; }
.dpart-main:hover .dpart-img { box-shadow: 0 0 0 2px var(--muted); }
.dpart.is-current .dpart-img { box-shadow: 0 0 0 3px var(--focus); }
.dpart-label { font-size: 12px; line-height: 1.45; }
.dpart-zoom {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: rgb(255 255 255 / .92);
  color: #191917;
  box-shadow: 0 1px 4px rgb(0 0 0 / .2);
  opacity: 0;
}
.dpart-zoom:hover { background: #fff; color: #191917; }
.dpart:hover .dpart-zoom, .dpart-zoom:focus-visible { opacity: 1; }
.dparts-empty { margin: 0; font-size: 13px; line-height: 1.8; color: var(--muted); }

/* パーツ詳細 */
.part-full { display: grid; place-items: start center; padding: 28px; overflow: auto; }
.part-full img { display: block; max-width: 100%; height: auto; border-radius: 8px; box-shadow: var(--shadow-md); }
.part-source {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.part-source:hover { border-color: var(--muted); }
.part-source .thumb { border-radius: 6px; }
.part-source .ph-initial { font-size: 22px; }
.part-source .ph-host { display: none; }
.part-source-title { display: block; font-size: 13px; font-weight: 650; }
.part-source-host { display: block; font-size: 12px; color: var(--muted); }

@media (hover: none) {
  .dpart-zoom { opacity: 1; }
}

@media (max-width: 800px) {
  .detail { grid-template-columns: 1fr; }
  .detail-media, .detail-info { max-height: none; overflow: visible; }
  .detail--site, .detail--part { height: auto; }
  .detail--site .detail-media, .detail--part .detail-media { height: auto; max-height: 70vh; overflow: auto; }
}

/* ---------- Help ---------- */
.help { gap: 22px; padding-bottom: 26px; }
.help h3 { margin: 0 0 6px; font-size: 14px; }
.help p, .help ul, .help ol { margin: 0; font-size: 13px; line-height: 1.8; color: var(--muted); }
.help ul, .help ol { padding-left: 1.2em; }
.help code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font-size: 12px; }
.bookmarklet { margin-top: 12px; cursor: grab; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  inset: auto auto 24px 50%;
  display: none;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  height: auto;
  margin: 0;
  padding: 10px 12px 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
  overflow: visible;
}
.toast.is-show { display: flex; animation: toast-in .25s cubic-bezier(.2, .8, .2, 1); }
.toast:not(:has(button)) { padding-right: 18px; }
.toast-action {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Drag overlay ---------- */
body.is-dragging::after {
  content: "ドロップして追加";
  position: fixed;
  inset: 12px;
  z-index: 100;
  display: grid;
  place-items: center;
  border: 2px dashed var(--text);
  border-radius: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .site-header { padding-top: 14px; padding-bottom: 14px; }
  .header-actions { flex-basis: 100%; }
  .search { flex: 1; }
  .search kbd { display: none; }
  .toolbar { gap: 10px; }
  .view-switch button { padding: 0 14px; }
  .grid { gap: 28px; }
  .parts-grid { columns: 2 150px; column-gap: 14px; }
}
