:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg-soft: #eef1f7;
  --card: #ffffff;
  --text: #1d2430;
  --muted: #6b7688;
  --line: #e3e7ef;
  --line-strong: #ccd3e0;
  --control: #ffffff;
  --accent: #ff5f6d;
  --accent-soft: rgba(255, 95, 109, .12);
  --ok: #1f9d63;
  --danger: #d34b4b;
  --warn: #b3761a;
  --shadow: 0 8px 26px rgba(28, 40, 64, .10);
  --shadow-soft: 0 2px 8px rgba(28, 40, 64, .07);
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  padding: calc(12px + var(--safe-top)) 0 calc(48px + var(--safe-bottom));
  max-width: 1180px;
  margin: 0 auto;
}

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

h2, h3 { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ff5f6d, #ffa25b);
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-soft);
}

.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .2px; }

.searchbar {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}

.field {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--control);
  border-radius: var(--radius);
  padding: 11px 13px;
  outline: none;
  box-shadow: var(--shadow-soft);
}

.field::placeholder { color: #9aa4b4; }

.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--control);
  border-radius: var(--radius);
  padding: 10px 15px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, #ff5f6d, #ff8a5b); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { color: #fff; filter: brightness(1.04); }
.btn.ghost { background: rgba(255, 255, 255, .9); }
.btn.vote { min-width: 150px; font-weight: 700; border-color: var(--accent); color: var(--accent); }
.btn.vote:hover { background: var(--accent-soft); }
.btn.vote.voted { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.vote.voted:hover { color: #fff; filter: brightness(1.04); }

.hint { margin: 0 16px 14px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

main { padding: 0 16px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 13px;
}

.grid.compact { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.card-poster {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--bg-soft);
}

.card-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-mine {
  position: absolute;
  left: 7px; bottom: 7px;
  background: var(--ok);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.card-votes {
  position: absolute;
  right: 7px; bottom: 7px;
  background: rgba(20, 28, 42, .78);
  backdrop-filter: blur(2px);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
}

.grid-sentinel {
  height: 1px;
  margin-top: 14px;
}

.card-title {
  padding: 8px 9px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  min-height: 42px;
}

.empty {
  padding: 50px 12px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.empty.small { padding: 16px 0; font-size: 13px; }

.detail {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: var(--bg);
  z-index: 30;
  padding-bottom: calc(48px + var(--safe-bottom));
}

.detail-hero { position: relative; min-height: 260px; }

.detail-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-hero-mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28) 0%, rgba(255, 255, 255, .82) 52%, var(--bg) 100%);
}

.detail-hero .back { position: absolute; top: calc(14px + var(--safe-top)); left: 14px; z-index: 2; }

.detail-hero-body {
  position: relative;
  padding: 128px 16px 16px;
  max-width: 780px;
}

.detail-hero-body h2 { font-size: 22px; line-height: 1.35; color: #10141c; }

.meta { margin-top: 9px; color: #4a5464; font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }

.meta span { background: rgba(255, 255, 255, .86); border-radius: 999px; padding: 4px 11px; box-shadow: var(--shadow-soft); }

.detail-body { padding: 16px 16px 0; max-width: 920px; }

.vote-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.intro { color: #3b4453; line-height: 1.78; font-size: 14px; white-space: pre-wrap; }

.block { margin: 24px 0; }
.block h3 { font-size: 15px; margin-bottom: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #222a36;
  color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 12px 30px rgba(20, 30, 50, .26);
  max-width: 88vw;
  text-align: center;
}

@media (max-width: 560px) {
  .brand-title { font-size: 15.5px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .detail-hero-body { padding-top: 104px; }
}
