/* kiuno-anime-viewer — mobile-first */

:root {
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-elev-2: #1f2433;
  --fg: #e6e8ee;
  --fg-muted: #98a0b3;
  --fg-faint: #6a7388;
  --border: #2a3142;
  --accent: #5dd2ff;
  --accent-2: #ffae5d;
  --accent-soft: #1e3344;
  --star: #ffc857;
  --heart: #ff6b8a;
  --share: #5dd2ff;
  --review: #ff7a59;
  --bg-overlay: rgba(0, 0, 0, 0.65);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 -4px 24px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --radius-sm: 8px;
  --header-h-mobile: 108px;
  --header-h-desktop: 96px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, "Segoe UI", "PingFang TC", "Noto Sans CJK TC",
        "Microsoft JhengHei", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }

[x-cloak] { display: none !important; }

/* ========== Header (sticky, mobile-first) ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(15, 17, 21, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 6px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.header__row1 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.header__title small {
  display: none;
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-muted);
  margin-left: 6px;
}
.header__nav {
  display: flex;
  gap: 4px;
}
.header__nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--fg-muted);
  font-size: 13px;
  white-space: nowrap;
}
.header__nav a.active {
  background: var(--bg-elev-2);
  color: var(--fg);
}
.header__nav a.version-link {
  color: var(--fg-faint);
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  padding: 6px 8px;
}
.header__nav a.version-link:hover { color: var(--accent); }

/* 更新提醒紅點 (留言 / 版號 nav link) */
.header__nav a {
  position: relative;
}
.header__nav a.has-new::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: #ff4757;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg);
}

.search {
  flex: 1;
  position: relative;
  min-width: 0;
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search::before {
  content: "🔍";
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}

.header__row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.header__row2::-webkit-scrollbar { display: none; }

.toggle, .pill-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.toggle[aria-pressed="true"] {
  background: var(--heart);
  border-color: var(--heart);
  color: #1a1f2e;
  font-weight: 600;
}
.pill-btn:active { background: var(--bg-elev-2); }

.count {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-faint);
  padding: 0 6px;
  white-space: nowrap;
}

/* 召喚陣按鈕：橘黃 glow 主視覺色 (recommends/season-bar 內 .actions button + header pill-btn 通用) */
.season-bar__header .actions .ritual-btn,
.recommend-bar__header .actions .ritual-btn,
.ritual-btn-all {
  background: linear-gradient(135deg, rgba(255,174,93,0.18), rgba(255,140,60,0.08)) !important;
  border-color: rgba(255,174,93,0.55) !important;
  color: #ffae5d !important;
  box-shadow: 0 0 8px rgba(255,174,93,0.25), inset 0 0 6px rgba(255,174,93,0.12);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, background 0.2s;
}
.season-bar__header .actions .ritual-btn:hover,
.recommend-bar__header .actions .ritual-btn:hover,
.ritual-btn-all:hover {
  background: linear-gradient(135deg, rgba(255,174,93,0.32), rgba(255,140,60,0.16)) !important;
  box-shadow: 0 0 14px rgba(255,174,93,0.5), inset 0 0 8px rgba(255,174,93,0.2);
  transform: translateY(-1px);
}

select.pill-btn {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%2398a0b3' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ========== Filter chips (cats / tags / status banners) ========== */
.chips-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.chip.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.chip-remove::after { content: " ×"; color: rgba(0,0,0,0.6); }

.banner {
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.banner.shared { background: rgba(93,210,255,0.1); }
.banner.local-mode { background: rgba(255,174,93,0.1); }
.banner button {
  margin-left: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  flex: 0 0 auto;
}

/* ========== Season picks bar (當季新番推薦) ========== */
.season-bar {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,143,177,0.06), var(--bg-elev) 60%);
  padding: 10px 12px 12px;
}
.season-bar__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}
.season-bar__title {
  color: #ff8fb1;
  font-size: 14px;
}
.season-bar__header .count { color: var(--fg-faint); font-weight: normal; font-size: 12px; }
.season-bar__header .updated { color: var(--fg-faint); font-weight: normal; font-size: 11px; }
.season-bar__header .actions { margin-left: auto; display: flex; gap: 6px; }
.season-bar__header .actions button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

/* ========== Recommend bar ========== */
.recommend-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 10px 12px 12px;
}
.recommend-bar__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.recommend-bar__header .star-glyph { color: var(--star); }
.recommend-bar__header .count { margin: 0; padding: 0; }
.recommend-bar__header .actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.recommend-bar__header .actions button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}
.recommend-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 110px), 1fr));
  gap: 8px;
}
.mini-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.mini-card:active { transform: scale(0.97); }
.mini-card .cover {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--accent-soft) center/cover no-repeat;
}
.mini-card .title {
  font-size: 11px;
  line-height: 1.4;
  padding: 6px 6px 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* ========== Card grid (mobile = 2 cards/row) ========== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 10px;
  padding: 12px;
  padding-bottom: 80px;
}
.card {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.card:active { transform: scale(0.97); }
.card .cover {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--accent-soft) center/cover no-repeat;
  position: relative;
}
.card .info { padding: 8px 10px 10px; }
.card .title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  min-height: 2.8em;
}
.card .meta {
  font-size: 11px;
  color: var(--fg-muted);
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}
.stars { color: var(--star); font-weight: 600; }

/* card icons — 用 inline-block + 固定 line-height 避免 flex 在某些行動
   瀏覽器把 emoji/CJK glyph 撐爆 box；empty state 不畫底 (只有符號 +
   text-shadow)，filled 才有圓形實心底，避免空狀態的「大黑橢圓」感 */
.card .icon {
  position: absolute;
  top: 8px;
  display: inline-block;
  width: 26px;
  height: 26px;
  min-width: 26px;
  max-width: 26px;
  min-height: 26px;
  max-height: 26px;
  padding: 0;
  border: none;
  /* 半透明圓底：白底也有對比，深底也不會太搶 */
  background: rgba(0, 0, 0, 0.42);
  border-radius: 50%;
  text-align: center;
  font-size: 18px;
  line-height: 26px;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.card .icon.star { left: 8px; color: var(--star); }
.card .icon.heart { right: 8px; color: var(--heart); }
.card .icon.share { right: 40px; color: var(--share); font-size: 16px; }
.card .icon.empty { color: rgba(255,255,255,0.85); }
.card .icon.filled {
  background: rgba(0, 0, 0, 0.78);
}
.card .icon.readonly { cursor: default; pointer-events: none; }

/* ========== Empty state ========== */
.empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-muted);
}

/* ========== Infinite scroll sentinel ========== */
.load-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 80px;
  min-height: 60px;
  color: var(--fg-muted);
  font-size: 12px;
}
.load-sentinel__hint { opacity: 0.6; }

/* ========== Bottom drawer (detail; mobile default) ========== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 88vh;
  max-height: 88vh;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.30, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom);
}
.drawer.open { transform: translateY(0); }
.drawer__handle {
  width: 36px; height: 4px;
  background: var(--fg-faint);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
  cursor: pointer;
}
.drawer__close {
  position: absolute;
  top: 8px; right: 8px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 22px;
  color: var(--fg-muted);
  border-radius: 50%;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.drawer__close:active { background: var(--bg-elev-2); }
.drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail__cover {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #000;
}
.detail__content { padding: 14px 18px 24px; }
.detail__name {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.3;
}
.detail__alias {
  color: var(--fg-muted);
  font-size: 13px;
  margin: 0 0 10px;
  line-height: 1.5;
}
.detail__alias div { margin: 2px 0; }

.detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--fg-muted);
  margin: 8px 0 14px;
}

.detail__rating {
  background: var(--bg-elev-2);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.detail__rating .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}
.detail__rating .main {
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.detail__rating .self {
  color: var(--accent-2);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.detail__synopsis {
  font-size: 14px;
  line-height: 1.7;
  color: #cdd2dc;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.detail__section {
  margin-top: 14px;
}
.detail__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--fg-faint);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.detail__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.detail__chips .chip {
  background: var(--bg-elev-2);
  border-color: var(--border);
  font-size: 11px;
  cursor: pointer;
}
.detail__chips .chip:hover {
  background: var(--accent);
  color: #000;
}

.detail__links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

/* ========== Detail drawer · 個別動漫留言 ========== */
.detail__comments {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.anime-comment__count {
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-faint);
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}
.detail__comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 320px;
  overflow-y: auto;
}
.anime-comment {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.anime-comment__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.anime-comment__name { color: var(--accent); font-weight: 700; font-size: 13px; }
.anime-comment__time { color: var(--fg-faint); font-size: 11px; margin-left: auto; }
.anime-comment__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}
.anime-comment__empty {
  color: var(--fg-faint);
  font-size: 12px;
  text-align: center;
  padding: 12px 0;
}
.anime-comment__banner {
  background: var(--bg-elev-2);
  border-left: 3px solid var(--review);
  color: var(--fg-muted);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 4px;
  line-height: 1.5;
}

.anime-comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.anime-comment-form input[type="text"],
.anime-comment-form textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}
.anime-comment-form input[type="text"]:focus,
.anime-comment-form textarea:focus { border-color: var(--accent); }
.anime-comment-form textarea { resize: vertical; min-height: 70px; }
.anime-comment-form__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.anime-comment-form__count {
  font-size: 11px;
  color: var(--fg-faint);
  flex: 1;
}
.anime-comment-form .submit-btn {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
  padding: 8px 18px;
}
.anime-comment-form .submit-btn:disabled {
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  border-color: var(--border);
  cursor: not-allowed;
}
.anime-comment-form__note {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: var(--bg-elev-2);
  border-left: 2px solid var(--accent);
  font-size: 10px;
  color: var(--fg-muted);
  border-radius: 4px;
  line-height: 1.5;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  top: max(70px, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: rgba(93,210,255,0.95);
  color: #000;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: bold;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(93,210,255,0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }

/* ========== Recommends page (留言) ========== */
.recommend-form {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 16px 12px 14px;
}
.recommend-form h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--accent);
}
.recommend-form .form-row {
  display: block;
  margin-bottom: 12px;
  position: relative;
}
.recommend-form .form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.recommend-form input[type="text"],
.recommend-form textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.recommend-form input[type="text"]:focus,
.recommend-form textarea:focus { border-color: var(--accent); }
.recommend-form textarea { resize: vertical; min-height: 90px; }
.recommend-form .form-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg-faint);
  text-align: right;
}

/* chip-input：picks 顯示為 inline chip + 後接 input */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 42px;
  cursor: text;
  transition: border-color 0.15s;
}
.chip-input:focus-within { border-color: var(--accent); }
.chip-input input[type="text"] {
  flex: 1;
  min-width: 120px;
  background: transparent;
  border: none;
  padding: 4px 2px;
  color: var(--fg);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.chip-input input[type="text"]:disabled { color: var(--fg-faint); }

.chip-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 4px 3px 10px;
  font-size: 12px;
  max-width: 100%;
}
.chip-pill.matched { border-color: var(--accent); }
.chip-pill.unmatched { border-color: var(--fg-faint); opacity: 0.85; }
.chip-pill__title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.chip-pill__tag {
  font-size: 10px;
  color: var(--fg-faint);
  padding: 0 4px;
  white-space: nowrap;
}
.chip-pill.matched .chip-pill__tag { color: var(--accent); }
.chip-pill__remove {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip-pill__remove:hover { background: var(--bg-elev-2); color: var(--review); }

.recommend-form .autocomplete-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: absolute;
  width: 100%;
  z-index: 20;
  box-shadow: var(--shadow-md);
}
.recommend-form .autocomplete-list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.recommend-form .autocomplete-list li:hover { background: var(--bg-elev); }
.recommend-form .autocomplete-list .ac-meta { color: var(--fg-faint); font-size: 12px; }

.recommend-form .form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.recommend-form .submit-btn {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
  padding: 10px 22px;
}
.recommend-form .submit-btn:disabled {
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  border-color: var(--border);
  cursor: not-allowed;
}
.recommend-form .form-error { color: var(--review); font-size: 12px; flex: 1; }
.recommend-form .privacy-note {
  margin: 12px 0 0;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border-left: 2px solid var(--accent);
  font-size: 11px;
  color: var(--fg-muted);
  border-radius: 4px;
  line-height: 1.5;
}

.comments-list { padding: 12px; padding-bottom: 80px; }
.comments-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.comments-header h2 { margin: 0; font-size: 16px; }
.comments-header .count { color: var(--fg-faint); font-size: 12px; }

.comment-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.comment-name { color: var(--accent); font-size: 14px; font-weight: 700; }
.comment-arrow { color: var(--fg-faint); font-size: 12px; }
.comment-picks {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
}
.comment-pick { white-space: nowrap; }
.comment-pick:not(:last-child)::after {
  content: "、";
  color: var(--fg-faint);
  margin-left: 2px;
}
.comment-anime {
  color: var(--star);
  font-weight: 600;
  text-decoration: none;
}
.comment-anime:hover { text-decoration: underline; }
.comment-anime.no-link { pointer-events: none; color: var(--fg-muted); cursor: default; }
.comment-tag {
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.comment-time { color: var(--fg-faint); font-size: 11px; margin-left: auto; }
.comment-body {
  margin: 0;
  color: var(--fg);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-footer { text-align: center; margin-top: 16px; }
.comments-footer .all-loaded { color: var(--fg-faint); font-size: 12px; margin: 12px 0; }

/* ========== Comment 1-層回覆 thread ========== */
.comment-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.reply-toggle {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.12s, color 0.12s;
}
.reply-toggle:hover { background: var(--bg-elev-2); color: var(--accent); }
.reply-toggle.has-replies {
  color: var(--accent);
  background: rgba(93,210,255,0.08);
}
.reply-toggle.has-replies:hover { background: rgba(93,210,255,0.15); }
.reply-toggle__count { color: var(--fg-faint); font-size: 11px; }
.reply-toggle.has-replies .reply-toggle__count { color: var(--accent); font-weight: 600; }

.comment-thread {
  margin-top: 8px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--border);
}
.reply-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.reply-item {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.reply-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
  font-size: 11px;
}
.reply-name { color: var(--accent); font-weight: 700; font-size: 12px; }
.reply-time { color: var(--fg-faint); font-size: 11px; margin-left: auto; }
.reply-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}
.reply-empty {
  color: var(--fg-faint);
  font-size: 11px;
  text-align: center;
  padding: 8px 0;
}

.reply-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reply-form input[type="text"],
.reply-form textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  box-sizing: border-box;
}
.reply-form input[type="text"]:focus,
.reply-form textarea:focus { border-color: var(--accent); }
.reply-form textarea { resize: vertical; min-height: 50px; }
.reply-form__row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply-form__count { font-size: 11px; color: var(--fg-faint); flex: 1; }
.reply-form .submit-btn {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
  padding: 6px 14px;
  font-size: 12px;
}
.reply-form .submit-btn:disabled {
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  border-color: var(--border);
  cursor: not-allowed;
}

@media (min-width: 600px) {
  .recommend-form { padding: 20px 16px; }
  .recommend-form h2 { font-size: 18px; }
  .comments-list { padding: 16px; }
}

@media (min-width: 900px) {
  .recommend-form { padding: 24px; }
  .comments-list { padding: 24px; max-width: 880px; margin: 0 auto; }
  .recommend-form > form, .recommend-form > h2, .recommend-form > .banner {
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
  }
  .recommend-form > h2 { padding-left: 0; }
}

/* ========== Tablet (≥600px) ========== */
@media (min-width: 600px) {
  .header__title { font-size: 18px; }
  .header__title small { display: inline; }
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    padding: 16px;
  }
  .recommend-cards {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .card .title { font-size: 14px; }
}

/* ========== Desktop (≥900px) — drawer becomes side panel ========== */
@media (min-width: 900px) {
  .header { padding: 10px 24px; }
  .header__title { font-size: 22px; }
  .header__row2 { margin-top: 10px; }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    padding: 20px;
    transition: padding-right 0.3s ease;
  }
  .cards.with-detail { padding-right: 420px; }

  .drawer-backdrop { display: none; }
  .drawer {
    top: var(--header-h-desktop);
    bottom: 0;
    left: auto;
    right: 0;
    width: 400px;
    height: auto;
    max-height: none;
    border-radius: 0;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.30, 1);
  }
  .drawer.open { transform: translateX(0); }
  .drawer__handle { display: none; }

  .detail__cover { max-height: 320px; }
  .card .icon {
    width: 28px; height: 28px;
    min-width: 28px; min-height: 28px;
    line-height: 26px;
  }
}

/* ========== Wide desktop (≥1200px) ========== */
@media (min-width: 1200px) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 24px;
  }
  .cards.with-detail { padding-right: 440px; }
  .drawer { width: 420px; }
}
