:root {
      --ink:      #89847f;
      --ink-mid:  #5a5650;
      --ink-soft: #e3dfddc4;
      --paper:    #faf8f4;
      --paper-2:  #f2ede5;
      --paper-3:  #e8e0d4;
      --accent:   #ece3ddbc;
      --accent-l: #ece8e5;
      --border:   rgba(30, 27, 24, 0.482);
      --border-2: rgba(187, 127, 67, 0.22);
      --radius:   10px;
      --radius-l: 16px;
    }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { scroll-behavior: smooth; }

    body {
      font-family: 'Noto Sans JP', sans-serif;
      background: var(--paper);
      background-color: rgb(85, 75, 63);
      color: var(--ink);
      min-height: 100vh;
      line-height: 1.7;
    }

    /* ── HEADER ── */
    .site-header {
      padding: 3rem 2.5rem 2rem;
      height:350px;
      max-width: 1140px;
      margin: 0 auto;
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 1rem;
      border-bottom: 1px solid var(--border);
      background-image: url('headerback.jpg');
      background-size: cover;
      background-position: center;
    }

    .site-title {
      font-size: 70px;
        font-family: 'Shippori Mincho', serif;
    font-weight: 700;
      letter-spacing: 0.08em;
      line-height: 1.2;
      color:rgba(255, 245, 238, 0.677);

    }

  

    .site-title span {
      display: block;
      font-size: 20px;
      font-family: 'Noto Sans JP', sans-serif;
      font-weight: 300;
      letter-spacing: 0.25em;
      color: var(--ink-soft);
      margin-bottom: 6px;
      text-transform: uppercase;
      color:rgba(255, 245, 238, 0.8);
    }

  
    .header-stats {
      display: flex;
      gap: 2rem;
      align-items: flex-end;
      flex-shrink: 0;
    }

    .stat-block { text-align: right; }

    .stat-block .num {
      font-family: 'Shippori Mincho', serif;
      font-size: 32px;
      font-weight: 700;
      color: var(--accent);
      line-height: 1;
    }

    .stat-block .lbl {
      font-size: 10px;
      color: var(--ink-soft);
      letter-spacing: 0.15em;
      margin-top: 2px;
    }

    /* ── CONTROLS ── */
    .controls-bar {
      max-width: 1140px;
      margin: 0 auto;
      padding: 1rem 2.5rem;
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      border-bottom: 1px solid var(--border);
      background: var(--paper);
      background-color: rgba(65, 59, 53, 0.568);
      position: sticky;
      top: 0;
      z-index: 10;
    }

    .filter-group {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }

    .filter-label {
      font-size: 10px;
      letter-spacing: 0.2em;
      color: rgba(255, 255, 255, 0.738);
      text-transform: uppercase;
      white-space: nowrap;
    }

    .pill {
      background: transparent;
      border: 1px solid var(--border-2);
      border-radius: 20px;
      padding: 4px 13px;
      font-size: 12px;
      font-family: 'Noto Sans JP', sans-serif;
      color: var(--ink-mid);
      cursor: pointer;
      transition: all 0.18s;
      white-space: nowrap;
      line-height: 1.6;
    }

    .pill:hover { border-color: var(--accent-l); color: var(--accent); }

    .pill.active {
      background: var(--ink);
      border-color: var(--ink);
      color: var(--paper);
    }

    .divider {
      width: 1px;
      height: 22px;
      background: var(--border-2);
      flex-shrink: 0;
    }

    .right-controls {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }

    .sort-select {
      background: transparent;
      border: 1px solid var(--border-2);
      border-radius: var(--radius);
      padding: 5px 10px;
      font-size: 12px;
      font-family: 'Noto Sans JP', sans-serif;
      color: var(--ink);
      cursor: pointer;
      outline: none;
    }

    .sort-select:focus { border-color: var(--accent-l); }

    .view-toggle {
      display: flex;
      border: 1px solid var(--border-2);
      border-radius: var(--radius);
      overflow: hidden;
    }

    .view-btn {
      background: transparent;
      border: none;
      padding: 5px 11px;
      cursor: pointer;
      color: var(--ink-soft);
      font-size: 15px;
      transition: all 0.15s;
      line-height: 1;
    }

    .view-btn:hover { background: var(--paper-2); color: var(--ink); }
    .view-btn.active { background: var(--ink); color: var(--paper); }

    /* ── MAIN ── */
    .main {
      max-width: 1140px;
      margin: 0 auto;
      padding: 2rem 2.5rem 5rem;
    }

    /* ── STATE MESSAGES ── */
    .state-msg {
      text-align: center;
      padding: 5rem 2rem;
      color: var(--ink-soft);
    }

    .spinner {
      width: 30px; height: 30px;
      border: 2px solid var(--border-2);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.75s linear infinite;
      margin: 0 auto 1rem;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    .state-msg p { font-size: 14px; line-height: 2; }

    .state-msg code {
      background: var(--paper-2);
      border: 1px solid var(--border-2);
      border-radius: 4px;
      padding: 1px 6px;
      font-size: 12px;
    }

    /* ── RESULT INFO ── */
    .result-info {
      font-size: 12px;
      color: var(--ink-soft);
      margin-bottom: 1.25rem;
      letter-spacing: 0.04em;
    }

    .result-info strong { color: var(--ink); }

    /* ────────────────────────────────────
       GRID VIEW
    ──────────────────────────────────── */
    .grid-view {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
      gap: 18px;
    }

    .book-card {
      background: #fff;
      border: 1px solid var(--border);
      border-radius: var(--radius-l);
      overflow: hidden;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
      animation: fadeUp 0.28s ease both;
    }

    .book-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 10px 28px rgba(26,23,20,0.09);
      border-color: var(--border-2);
    }

    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(10px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .book-cover {
      
      height:240px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      overflow: hidden;
    }

    .book-cover img {
      width: 80%;
      height: 100%;
      object-fit: cover;
    }

    .book-cover .cover-fallback {
      font-size: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
    }

    .cover-spine {
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 6px;
    }

    .book-body {
      padding: 11px 13px 13px;
      border-top: 1px solid var(--border);
    }

    .book-title {
      font-family: 'Shippori Mincho', serif;
      font-size: 13px;
      font-weight: 500;
      line-height: 1.55;
      margin-bottom: 3px;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .book-author {
      font-size: 11px;
      color: var(--ink-soft);
      margin-bottom: 8px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .book-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 4px;
    }

    .genre-badge {
      font-size: 10px;
      padding: 2px 8px;
      border-radius: 10px;
      white-space: nowrap;
      max-width: 100px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .year-pill {
      font-size: 10px;
      color: var(--ink-soft);
      white-space: nowrap;
    }

    .card-links {
      display: flex;
      gap: 6px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px solid var(--border);
    }

    .ext-link {
      font-size: 10px;
      color: var(--ink-soft);
      text-decoration: none;
      border: 1px solid var(--border-2);
      border-radius: 6px;
      padding: 2px 8px;
      transition: all 0.15s;
      white-space: nowrap;
    }

    .ext-link:hover { color: var(--accent); border-color: var(--accent-l); }

    /* ────────────────────────────────────
       LIST VIEW
    ──────────────────────────────────── */
    .list-view {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .book-row {
      background: #fff;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 12px 16px;
      display: grid;
      grid-template-columns: 48px 1fr auto;
      align-items: center;
      gap: 14px;
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
      animation: fadeUp 0.22s ease both;
    }

    .book-row:hover {
      border-color: var(--border-2);
      background: var(--paper-2);
    }

    .row-thumb {
      width: 48px;
      height: 64px;
      border-radius: 4px;
      overflow: hidden;
      flex-shrink: 0;
      position: relative;
    }

    .row-thumb img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .row-thumb-fallback {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
    }

    .row-thumb-spine {
      position: absolute;
      left: 0; top: 0; bottom: 0;
      width: 4px;
    }

    .row-main { min-width: 0; }

    .row-title {
      font-family: 'Shippori Mincho', serif;
      font-size: 15px;
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .row-sub {
      font-size: 12px;
      color: var(--ink-soft);
      margin-top: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .row-comment {
      font-size: 11px;
      color: var(--ink-mid);
      margin-top: 4px;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .row-right {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 5px;
      flex-shrink: 0;
    }

    .year-tag {
      font-size: 11px;
      color: var(--ink-soft);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 1px 7px;
    }

    .row-links {
      display: flex;
      gap: 5px;
    }

    footer{
      margin-right: 100px;
      margin-left: 100px;
      margin-bottom: 80px;
    }

    footer p {
      font-family: 'Noto Sans JP',sans-serif;
      font-size: 14px;
      color:rgba(255, 245, 238, 0.677);
    
    }

    footer h4{
      font-family: 'Shippori Mincho', serif;
      font-size: 20px;
      color:rgba(255, 245, 238, 0.677);
    }

    .footer-contents{
      display: flex;
      justify-content: space-between;
    }

    li{
      list-style: none;
      margin-bottom: 10px;
      
    }

    .footer-left a{
      text-decoration: none;
      color:rgba(255, 245, 238, 0.677);
      font-family: 'Noto Sans JP',sans-serif;
      font-size: 14px;
      padding: 10px;
      border-radius: 10px;
    }

    .mylink:hover{ background: var(--paper-2); color: var(--ink); }
    .view-btn.active { background: var(--ink); color: var(--paper); }

    

    .copyright{
      text-align: center;
    }

    .aff{
      margin-right: 100px;
      margin-left: 100px;
      margin-bottom: 30px;
      padding-top: 30px;
    }

    .aff-contents{
      display: flex;
      justify-content: space-around;
    }

    .top-affiliate{
      margin-top: 30px;
    }
    .bottom-affiliate{
      
    }

    .rakuten{
      margin-left: 1px;
      margin-right: 1px;
    }

    /* ── EMPTY ── */
    .empty-state {
      text-align: center;
      padding: 4rem 2rem;
      color: var(--ink-soft);
      font-size: 14px;
    }

    /* ── MODAL ── */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(26,23,20,0.45);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 100;
      padding: 1.5rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }

    .modal-overlay.open {
      opacity: 1;
      pointer-events: all;
    }

    .modal {
      background: var(--paper);
      border-radius: var(--radius-l);
      max-width: 500px;
      width: 100%;
      overflow: hidden;
      transform: translateY(12px);
      transition: transform 0.2s;
    }

    .modal-overlay.open .modal { transform: translateY(0); }

    .modal-cover {
      height: 200px;
      overflow: hidden;
      position: relative;
    }

    .modal-cover img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .modal-cover-fallback {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 60px;
    }

    .modal-body {
      padding: 1.5rem;
    }

    .modal-genre {
      font-size: 11px;
      padding: 3px 10px;
      border-radius: 12px;
      display: inline-block;
      margin-bottom: 10px;
    }

    .modal-title {
      font-family: 'Shippori Mincho', serif;
      font-size: 20px;
      font-weight: 700;
      line-height: 1.4;
      margin-bottom: 4px;
    }

    .modal-author {
      font-size: 13px;
      color: var(--ink-soft);
      margin-bottom: 14px;
    }

    .modal-comment {
      font-size: 13px;
      color: var(--ink-mid);
      line-height: 1.8;
      padding: 12px 14px;
      background: var(--paper-2);
      border-radius: var(--radius);
      border-left: 3px solid var(--accent-l);
      margin-bottom: 14px;
    }

    .modal-comment-label {
      font-size: 10px;
      letter-spacing: 0.15em;
      color: var(--ink-soft);
      text-transform: uppercase;
      margin-bottom: 4px;
    }

    .modal-meta {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 14px;
    }

    .meta-chip {
      font-size: 12px;
      color: var(--ink-mid);
      border: 1px solid var(--border-2);
      border-radius: 8px;
      padding: 3px 10px;
    }

    .modal-footer {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      padding-top: 14px;
      border-top: 1px solid var(--border);
    }

    .modal-link {
      flex: 1;
      text-align: center;
      padding: 9px 12px;
      border: 1px solid var(--border-2);
      border-radius: var(--radius);
      font-size: 13px;
      color: var(--ink);
      text-decoration: none;
      transition: all 0.15s;
    }

    .modal-link:hover {
      background: var(--ink);
      color: var(--paper);
      border-color: var(--ink);
    }

    .modal-close {
      position: absolute;
      top: 12px;
      right: 12px;
      background: rgba(26,23,20,0.45);
      border: none;
      border-radius: 50%;
      width: 30px; height: 30px;
      color: #fff;
      font-size: 16px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }

    .hidden { display: none !important; }

    /* ── SETUP GUIDE ── */
    .setup-guide {
      max-width: 1140px;
      margin: 0 auto;
      padding: 1.5rem 2.5rem 3rem;
      border-top: 1px solid var(--border);
    }

    .setup-guide summary {
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      color: var(--ink-mid);
      letter-spacing: 0.05em;
      list-style: none;
    }

    .setup-guide summary::-webkit-details-marker { display: none; }

    .setup-guide-body {
      margin-top: 1rem;
      padding: 1.5rem;
      background: var(--paper-2);
      border-radius: var(--radius);
      font-size: 13px;
      color: var(--ink-mid);
      line-height: 2;
    }

    .setup-guide-body pre {
      background: #fff;
      border: 1px solid var(--border-2);
      border-radius: 6px;
      padding: 12px 14px;
      font-size: 12px;
      overflow-x: auto;
      margin: 6px 0 1rem;
      white-space: pre;
    }

    .setup-guide-body ol {
      padding-left: 1.4rem;
      margin: 4px 0 1rem;
    }

    .setup-guide-body strong { color: var(--ink); }

  /* ── RESPONSIVE ── */

/* タブレット・スマホ共通（〜1024px）*/
@media screen and (max-width: 1024px) {

  /* アフィリエイトバナーを縦並び */
  .aff-contents {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  /* バナー内の固定幅500pxを上書き */
  .aff-contents > div,
  .aff-contents > table {
    width: 100% !important;
    max-width: 500px;
    box-sizing: border-box;
  }

  /* aff全体の横余白を縮める */
  .aff {
    margin-left: 16px;
    margin-right: 16px;
  }

  /* コントロールバーを折り返し */
  .controls-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    gap: 8px;
  }

  .right-controls {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  /* ヘッダー調整 */
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 2rem 1.25rem 1.5rem;
    height: auto;
    min-height: 200px;
  }

  /* グリッドを少し小さく */
  .grid-view {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 12px;
  }

  .main {
    padding: 1.5rem 1.25rem 4rem;
  }
}

/* スマホ専用（〜600px）*/
@media screen and (max-width: 600px) {

  .site-header {
    padding: 1.5rem 1rem;
    height: auto;
  }

  .site-title {
    font-size: 42px;
  }

  .controls-bar {
    padding: 0.75rem 0.75rem;
  }

  /* フィルターのpillが小さすぎないように */
  .filter-group {
    width: 100%;
  }

  .grid-view {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }

  .book-row {
    grid-template-columns: 40px 1fr auto;
  }

  .main {
    padding: 1rem 0.75rem 3rem;
  }

  /* アフィリエイトの余白をさらに縮める */
  .aff {
    margin-left: 8px;
    margin-right: 8px;
    padding-top: 16px;
  }

  /* フッター縦並び */
  footer {
    margin-left: 16px;
    margin-right: 16px;
    margin-bottom: 40px;
  }

  .footer-contents {
    flex-direction: column;
    gap: 16px;
  }

  /* Rakutenテーブルも幅100%に */
  .rakuten,
  .rakuten > tbody,
  .rakuten > tbody > tr,
  .rakuten > tbody > tr > td {
    display: block !important;
    width: 100% !important;
  }

  .rakuten div[style] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}