/* ===== 無料文庫 — Modern Redesign ===== */

:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-hover: #222228;
  --border: #2a2a35;
  --glass: rgba(14, 14, 16, 0.82);
  --text: #f0f0f2;
  --text-sub: #a0a0ab;
  --text-muted: #b0b0bc;
  --accent: #818cf8;
  --accent-2: #06b6d4;
  --grad: linear-gradient(135deg, #6366f1, #06b6d4);
  --glow: rgba(99, 102, 241, 0.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html, body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: 'Noto Sans JP', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* App shell */
.app {
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-width 0.2s;
}

/* ===== Header: Ad ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.banner-slot {
  width: 100%;
  aspect-ratio: 320 / 100;
  background: linear-gradient(135deg, #1a1a22 0%, #12121a 100%);
}
.banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Footer: Controls ===== */
.site-footer {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 6px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  position: relative;
}
.footer-title-row {
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.footer-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.footer-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Back button */
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  position: absolute;
  left: 12px;
  transition: all 0.15s;
}
.back-btn:hover {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px var(--glow);
}

/* Search input */
.footer-search {
  width: 60%;
  max-width: 280px;
  height: 44px;
  padding: 0 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s;
}
.footer-search::placeholder { color: var(--text-muted); }
.footer-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glow);
  background: rgba(255,255,255,0.06);
}

/* ===== Main ===== */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

/* ===== Unified Item Card ===== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 8px;
}

.item-card {
  display: flex;
  height: 128px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}
.item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 0 16px var(--glow);
}

/* Left: thumbnail + overlay */
.item-thumb {
  position: relative;
  width: 50%;
  flex-shrink: 0;
}
.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.item-thumb-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
}
.item-thumb-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.item-thumb-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

/* Rank / chapter number badge */
.item-rank {
  position: absolute;
  top: 0; left: 0;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom-right-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.5px;
  z-index: 2;
}

/* Right: synopsis */
.item-synopsis {
  width: 50%;
  padding: 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-sub);
  overflow: hidden;
}

/* Empty */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 17px;
}

/* ===== Responsive: Tablet (768px+) ===== */
@media (min-width: 768px) {
  .app { max-width: 960px; }
  .item-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0 16px;
  }
  .item-card { width: calc(50% - 8px); }
  .site-header { display: none; }
  .footer-search { max-width: 400px; }
  .footer-row { padding: 4px 24px; }
  .back-btn { left: 24px; }
}

/* ===== Responsive: Desktop (1025px+) ===== */
@media (min-width: 1025px) {
  .app { max-width: 1200px; }
  .item-list { gap: 20px; padding: 0 20px; }
  .item-card { width: calc(33.333% - 14px); }
  .footer-search { max-width: 480px; }
  .footer-row { padding: 4px 32px; }
  .back-btn { left: 32px; }
}
