/* ==========================================================================
   CLIP. — stylesheet
   白基調 / 画像が主役 / 余白とタイポで高級感 / モバイルファースト
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f5f3;
  --ink: #141414;
  --ink-2: #6f6f6f;
  --ink-3: #a8a8a8;
  --line: #ebeae7;
  --danger: #b4443a;

  --font-display: "Cormorant Garamond", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;

  --gutter: 14px;
  --gap: 10px;
  --radius: 3px;
  --radius-lg: 18px;

  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.32, .72, 0, 1);
  --dur: 260ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100vh;
  min-height: 100dvh;
}

body.is-locked { overflow: hidden; }

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

img { display: block; max-width: 100%; }

[hidden] { display: none !important; }

/* 視覚的に隠す（label 経由のクリックは効く） */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 22px;
  height: 22px;
  display: block;
  flex: none;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px var(--gutter) 6px;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: .06em;
  line-height: 1;
}

.brand__dot { color: var(--ink-3); }

.brand__sub {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.tabs {
  position: relative;
  display: flex;
  gap: 22px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 12px 0 11px;
  font-size: 12.5px;
  letter-spacing: .12em;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--dur) var(--ease-out);
}
.tab.is-active { color: var(--ink); }

.tab__count {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0;
  color: var(--ink-3);
  min-width: 1ch;
}
.tab__count:empty { display: none; }

.tabs__indicator {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1.5px;
  width: 0;
  background: var(--ink);
  transform: translateX(0);
  transition: transform 320ms var(--ease-spring), width 320ms var(--ease-spring);
  will-change: transform, width;
}

/* --------------------------------------------------------------------------
   Grid（マソンリー: CSS multi-column）
   -------------------------------------------------------------------------- */

.main {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--gap) var(--gutter) calc(110px + var(--safe-bottom));
}

.grid {
  column-count: 2;
  column-gap: var(--gap);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.grid.is-switching {
  opacity: 0;
  transform: translateY(6px);
}

@media (min-width: 640px)  { .grid { column-count: 3; } :root { --gutter: 20px; --gap: 14px; } }
@media (min-width: 1024px) { .grid { column-count: 4; } :root { --gutter: 28px; --gap: 18px; } }
@media (min-width: 1440px) { .grid { column-count: 5; } }

/* Card */

.card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 var(--gap);
  position: relative;
  animation: card-in 420ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.card.is-leaving {
  animation: card-out 220ms var(--ease-out) both;
  pointer-events: none;
}
@keyframes card-out {
  to { opacity: 0; transform: scale(.97); }
}

.card__media {
  display: block;
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-soft);
  aspect-ratio: var(--ar, auto);
}
.card__media:not([style*="--ar"]) { min-height: 120px; }

.card__media::after {
  /* ローディング中のシマー */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.7) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  opacity: 1;
  transition: opacity 300ms;
}
.card.is-loaded .card__media::after { opacity: 0; animation: none; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 420ms var(--ease-out), transform 700ms var(--ease-out);
}
.card.is-loaded .card__img { opacity: 1; transform: none; }
.card.is-error .card__media { background: var(--bg-soft); }
.card.is-error .card__media::after { animation: none; opacity: 0; }
.card.is-error .card__media::before {
  content: "画像を読み込めません";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-3);
}

.card__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 4px 2px 0;
  position: relative;
}

.card__title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__title:empty { visibility: hidden; }

.card__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  margin-right: -6px;
}

.card__btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  border-radius: 50%;
  transition: color 180ms var(--ease-out), transform 180ms var(--ease-spring);
}
.card__btn .icon { width: 19px; height: 19px; }
.card__btn:active { transform: scale(.86); }
.card__btn--quiet { color: #c4c4c4; }
@media (hover: hover) {
  .card__btn:hover { color: var(--ink); }
}

.card.is-clipped .card__btn[data-action="clip"] { color: var(--ink); }
.card.is-wanted  .card__btn[data-action="want"] { color: var(--ink); }

/* 2段階削除の確認行 */
.card__confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px 0 0;
  background: var(--bg);
  font-size: 11.5px;
  color: var(--ink-2);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.card.is-confirming .card__confirm {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.card.is-confirming .card__actions,
.card.is-confirming .card__title { visibility: hidden; }

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--ink);
  background: var(--bg);
}
.chip--danger { color: #fff; background: var(--danger); border-color: var(--danger); }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 18vh var(--gutter) 10vh;
  animation: card-in 500ms var(--ease-out) both;
}
.empty__eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
  letter-spacing: .08em;
}
.empty__title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: .02em;
}
.empty__text {
  margin: 0 auto 28px;
  max-width: 30em;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.9;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--ink);
  background: var(--bg);
  transition: transform 160ms var(--ease-spring), background 160ms, color 160ms, border-color 160ms, opacity 160ms;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--block { width: 100%; }
.btn--danger { border-color: var(--line); color: var(--danger); }
.btn--danger.is-armed { background: var(--danger); border-color: var(--danger); color: #fff; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255,255,255,.85);
  transition: transform 160ms var(--ease-spring), background 160ms;
}
.icon-btn:active { transform: scale(.9); }

.fab {
  position: fixed;
  z-index: 30;
  right: calc(var(--gutter) + 4px);
  bottom: calc(22px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 28px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.12);
  transition: transform 220ms var(--ease-spring), opacity 200ms;
}
.fab .icon { width: 26px; height: 26px; }
.fab:active { transform: scale(.92); }
body.is-locked .fab { opacity: 0; pointer-events: none; transform: scale(.8); }

/* --------------------------------------------------------------------------
   Sheets（ボトムシート / モーダル）
   -------------------------------------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 20, .32);
  opacity: 0;
  transition: opacity 280ms var(--ease-out);
  touch-action: none; /* 背面のスクロールを防ぐ */
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100vh - 24px - var(--safe-top));
  max-height: calc(100dvh - 24px - var(--safe-top));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px var(--gutter) calc(22px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 380ms var(--ease-spring);
  will-change: transform;
}

.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet.is-open .sheet__panel { transform: none; }

.sheet__handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 2px;
  background: var(--line);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet__head .icon-btn { margin-right: -8px; }

.sheet__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: .04em;
}

/* 追加シートの中身 */

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 128px;
  padding: 18px;
  border: 1px dashed #d6d4d0;
  border-radius: 12px;
  color: var(--ink);
  background: var(--bg-soft);
  cursor: pointer;
  transition: background 160ms, border-color 160ms, transform 160ms var(--ease-spring);
}
.pick:active { transform: scale(.985); }
.pick.is-dragover { border-color: var(--ink); background: #fff; }
.pick .icon { width: 28px; height: 28px; color: var(--ink-2); }
.pick__label { font-size: 13.5px; letter-spacing: .08em; }
.pick__hint { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }

.or {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 14px;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-3);
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.form { display: grid; gap: 10px; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  outline: none;
  transition: border-color 160ms;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-bottom-color: var(--ink); }
.input.is-invalid { border-bottom-color: var(--danger); }

.form .btn { margin-top: 10px; }

.url-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 2px;
}
.url-preview img {
  width: 64px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.url-preview.is-error img { opacity: .25; }
.url-preview__msg {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.6;
}

/* 詳細シート */

.sheet--detail .sheet__panel {
  top: 0;
  max-height: none;
  border-radius: 0;
  padding: 0 0 calc(28px + var(--safe-bottom));
}

.detail__close {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 10px;
  z-index: 2;
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 240ms var(--ease-out) 120ms, transform 160ms var(--ease-spring);
}
.sheet.is-open .detail__close { opacity: 1; }

.detail__figure {
  margin: 0;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  min-height: 42vh;
  max-height: 72vh;
  max-height: 72dvh;
}
.detail__img {
  width: 100%;
  max-height: 72vh;
  max-height: 72dvh;
  object-fit: contain;
}

.detail__body {
  padding: 22px var(--gutter) 0;
  max-width: 680px;
  margin: 0 auto;
}

.detail__status {
  display: flex;
  gap: 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  letter-spacing: .06em;
  color: var(--ink-3);
  min-height: 1.4em;
}
.detail__status span + span::before { content: "·"; margin-right: 14px; }

.detail__title {
  width: 100%;
  margin-top: 6px;
  border: 0;
  padding: 4px 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: .01em;
  outline: none;
}
.detail__title::placeholder { color: var(--ink-3); }

.detail__note {
  width: 100%;
  margin-top: 8px;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
  outline: none;
}
.detail__note::placeholder { color: var(--ink-3); }
.detail__note:focus { color: var(--ink); }

.detail__source {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--ink-3);
}
.detail__source .icon { width: 18px; height: 18px; }
.detail__source-input {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--ink-2);
  outline: none;
  text-overflow: ellipsis;
}
.detail__source-open {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink);
}

.detail__meta {
  margin: 14px 0 0;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-3);
}

.detail__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 26px;
}
.detail__actions .btn--danger { grid-column: 1 / -1; }
.detail__actions .btn.is-on { background: var(--ink); color: #fff; }

/* デスクトップでは中央モーダル */
@media (min-width: 760px) {
  .sheet__panel {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(520px, calc(100vw - 48px));
    max-height: calc(100vh - 64px);
    border-radius: var(--radius-lg);
    padding: 14px 28px 28px;
    transform: translate(-50%, -46%) scale(.98);
    opacity: 0;
    transition: transform 320ms var(--ease-spring), opacity 240ms var(--ease-out);
  }
  .sheet.is-open .sheet__panel { transform: translate(-50%, -50%); opacity: 1; }
  .sheet__handle { display: none; }

  .sheet--detail .sheet__panel {
    top: 50%;
    bottom: auto;
    width: min(1040px, calc(100vw - 64px));
    max-height: calc(100vh - 64px);
    border-radius: var(--radius-lg);
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr);
    overflow: hidden;
  }
  .detail__close {
    top: 20px;
    left: 20px;
    color: #fff;
    background: rgba(20,20,20,.35);
  }
  .detail__figure {
    min-height: 0;
    max-height: none;
    height: 100%;
    max-height: calc(100vh - 64px);
  }
  .detail__img { max-height: calc(100vh - 64px); }
  .detail__body {
    padding: 44px 36px 36px;
    overflow-y: auto;
    max-height: calc(100vh - 64px);
  }
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 60;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  letter-spacing: .04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-spring);
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   Motion preference
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
}
