* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #fff;
  color: #111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: #fff;
}
.logo {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex: none; text-decoration: none;
  background: #fff; transition: background .15s;
}
.logo:hover { background: #e9e9e9; }
.nav-pill {
  height: 48px; padding: 0 16px; border-radius: 24px;
  display: flex; align-items: center; font-size: 16px; font-weight: 600;
  color: #111; text-decoration: none; flex: none; transition: background .15s;
}
.nav-pill:hover { background: #e9e9e9; }
.nav-pill.active { background: #111; color: #fff; }
.searchbox {
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 16px; border-radius: 24px;
  background: #e9e9e9; min-width: 0;
}
.searchbox:focus-within { box-shadow: 0 0 0 4px rgba(0, 116, 232, .35); background: #fff; }
.searchbox svg { flex: none; color: #5f5f5f; }
.searchbox input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 16px; color: #111;
}
.count-chip {
  flex: none; font-size: 14px; color: #5f5f5f; padding: 0 8px;
  white-space: nowrap;
}

/* ---------- masonry ---------- */
.grid-wrap { padding: 4px 16px 80px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: 8px;
  gap: 0 16px;
  justify-content: center;
}
@media (max-width: 540px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 0 8px; }
  .grid-wrap { padding: 4px 8px 80px; }
}

.pin { position: relative; cursor: zoom-in; }
.pin-media {
  position: relative; border-radius: 16px; overflow: hidden; background: #e9e9e9;
}
.pin-media img {
  display: block; width: 100%; height: auto; min-height: 60px;
}
.pin-media video.preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 16px;
}
.pin-overlay {
  position: absolute; inset: 0; border-radius: 16px;
  background: rgba(0,0,0,0); transition: background .15s;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 12px; opacity: 0; pointer-events: none;
}
.pin:hover .pin-overlay { background: rgba(0,0,0,.35); opacity: 1; }
.pin-overlay .save-btn {
  align-self: flex-end;
  background: #e60023; color: #fff; border: 0; border-radius: 24px;
  height: 40px; padding: 0 16px; font-size: 15px; font-weight: 700;
  cursor: pointer; pointer-events: auto;
}
.pin-overlay .save-btn:hover { background: #ad081b; }
.pin-overlay .pin-stats {
  display: flex; gap: 10px; color: #fff; font-size: 13px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.pin-title {
  margin: 6px 4px 14px; font-size: 13.5px; font-weight: 600; line-height: 1.3;
  color: #111; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.play-badge {
  position: absolute; top: 10px; left: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.play-badge svg { width: 12px; height: 12px; }

.sentinel { height: 400px; }
.loading-row {
  display: flex; justify-content: center; padding: 32px; color: #5f5f5f; font-size: 14px;
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid #e9e9e9; border-top-color: #e60023;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  max-width: 460px; margin: 96px auto; text-align: center; color: #5f5f5f;
  padding: 0 24px;
}
.empty-state .big { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { color: #111; font-size: 22px; margin: 0 0 8px; }
.empty-state p { font-size: 15px; line-height: 1.6; margin: 0; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 40px 16px;
}
.modal {
  background: #fff; border-radius: 32px; max-width: 1016px; width: 100%;
  display: flex; overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,.3);
  min-height: 420px;
}
.modal-media {
  flex: 1 1 55%; background: #000; display: flex;
  align-items: center; justify-content: center; min-width: 0;
}
.modal-media video, .modal-media img {
  width: 100%; height: auto; max-height: 82vh; display: block; object-fit: contain;
}
.modal-body {
  flex: 1 1 45%; min-width: 0; padding: 28px;
  display: flex; flex-direction: column; gap: 14px; max-height: 82vh; overflow-y: auto;
}
.modal-close {
  position: fixed; top: 18px; left: 18px; z-index: 110;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: #fff; color: #111; font-size: 20px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.modal-close:hover { background: #e9e9e9; }
.modal-body h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 700; }
.modal-body .desc { color: #5f5f5f; font-size: 14px; line-height: 1.55; margin: 0; }
.byline { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: #e9e9e9; color: #111; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center; text-transform: uppercase;
}
.byline a { color: #111; font-weight: 600; text-decoration: none; font-size: 15px; }
.byline a:hover { text-decoration: underline; }
.byline .model-tag { color: #5f5f5f; font-size: 13px; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-chip {
  background: #e9e9e9; border-radius: 16px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; color: #111;
}
.stat-chip span { color: #5f5f5f; font-weight: 500; margin-right: 4px; }
.prompt-box {
  background: #f4f4f4; border-radius: 16px; padding: 16px;
  font-size: 13.5px; line-height: 1.65; white-space: pre-wrap;
  word-break: break-word; color: #211922; max-height: 320px; overflow-y: auto;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  height: 44px; padding: 0 18px; border-radius: 22px; border: 0;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-red { background: #e60023; color: #fff; }
.btn-red:hover { background: #ad081b; }
.btn-gray { background: #e9e9e9; color: #111; }
.btn-gray:hover { background: #dadada; }

@media (max-width: 760px) {
  .modal { flex-direction: column; }
  .modal-media video, .modal-media img { max-height: 50vh; }
  .modal-body { max-height: none; }
  .modal-backdrop { padding: 16px 8px; }
  .count-chip { display: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #111; color: #fff; border-radius: 24px; padding: 12px 22px;
  font-size: 15px; font-weight: 600; z-index: 200;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
