  :root {
    --maxw: 1200px;
    --pad: 18px;
    --border: #dbe3ee;
    --muted: #556070;
    --bg: #f6f8fb;
    --panel: #fff;
    --shadow: 0 1px 0 rgba(0,0,0,.04);
    --accent: #3d6fb6;
    --accent-weak: #e7f0fb;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans JP","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif;
    line-height: 1.65;
    color: #111;
    background: var(--bg);
  }
  a { color: inherit; text-decoration: none; }
  a:hover { text-decoration: underline; }

  header { background: #fff; border-bottom: 1px solid var(--border); }
  .wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: var(--pad);
    /* iOS Safari safe-area (notch) handling: prevents subtle left/right offset on some devices */
    padding-left: max(var(--pad), env(safe-area-inset-left));
    padding-right: max(var(--pad), env(safe-area-inset-right));
  }

  .toprow { display:flex; align-items:center; justify-content:space-between; gap: 12px; flex-wrap: wrap; }
  .brand { display:flex; align-items: center; gap: 12px; min-width: 0; }
  .brand h1 { font-size: 28px; margin: 0; font-weight: 800; letter-spacing: .02em; line-height: 1.1; }
  .brand a { text-decoration: none; }
  .brand a:hover { text-decoration: none; }
  .brand .sub { font-size: 12px; color: var(--muted); }

  form.site-search { display:flex; align-items:center; gap: 8px; flex: 1; justify-content: flex-end; }
  .site-search input[type="text"] {
    width: min(440px, 55vw);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font-size: 13px;
  }
  .site-search button {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-category-nav { display: none; }

  @media (max-width: 980px) {
    .mobile-category-nav {
      display: block;
      margin-top: 12px;
      border: 1px solid #c7d9f7;
      border-radius: 12px;
      background: #fff;
      overflow: hidden;
    }
    .mobile-category-nav > summary {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 48px;
      padding: 11px 13px;
      color: #214d8f;
      background: var(--accent-weak);
      cursor: pointer;
      font-size: 14px;
      font-weight: 700;
      list-style: none;
    }
    .mobile-category-nav > summary::-webkit-details-marker,
    .mobile-category-more > summary::-webkit-details-marker { display: none; }
    .mobile-category-nav > summary::after {
      content: '＋';
      margin-left: 2px;
      font-size: 18px;
      line-height: 1;
    }
    .mobile-category-nav[open] > summary::after { content: '−'; }
    .mobile-category-title { flex: 1; }
    .mobile-category-summary-hint {
      color: var(--muted);
      font-size: 11px;
      font-weight: 500;
    }
    .mobile-category-body { padding: 12px; }
    .mobile-category-label {
      margin: 0 0 8px;
      color: var(--muted);
      font-size: 12px;
    }
    .mobile-category-list {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .mobile-category-link {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
      min-width: 0;
      min-height: 44px;
      padding: 9px 10px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #fff;
      font-size: 13px;
    }
    .mobile-category-link:hover { text-decoration: none; border-color: #a9c2ee; }
    .mobile-category-link.active { border-color: var(--accent); }
    .mobile-category-link .name {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .mobile-category-link .catcount {
      min-width: 34px;
      padding-right: 6px;
      padding-left: 6px;
      flex: 0 0 auto;
    }
    .mobile-category-more { margin-top: 10px; }
    .mobile-category-more > summary {
      min-height: 44px;
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #f8fafc;
      color: #2d5aa6;
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
      list-style: none;
      text-align: center;
    }
    .mobile-category-more[open] > summary { margin-bottom: 8px; }
  }

  main { padding: var(--pad) 0 28px; }

  .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: var(--pad);
    box-shadow: var(--shadow);
  }

  .content { display: grid; gap: 20px; align-items: start; }
  /* Allow grid items to shrink below responsive AdSense's intrinsic width. */
  .content > * { min-width: 0; }
  .content.has-sidebar.has-aside { grid-template-columns: 260px minmax(0, 1fr) 320px; }
  .content.has-sidebar:not(.has-aside) { grid-template-columns: 260px minmax(0, 1fr); }
  .content:not(.has-sidebar).has-aside { grid-template-columns: minmax(0, 1fr) 320px; }
  .content:not(.has-sidebar):not(.has-aside) { grid-template-columns: minmax(0, 1fr); }

  @media (max-width: 980px) {
    .content.has-sidebar.has-aside { grid-template-columns: 1fr; }
    .content.has-sidebar:not(.has-aside) { grid-template-columns: 1fr; }
    .content:not(.has-sidebar).has-aside { grid-template-columns: 1fr; }
    .sidebar { order: 2; }
    .aside { order: 3; }
  }

  /* Item page: show right-column info in main on mobile (same order as desktop aside) */
  .aside-mobile { display: none; }
  @media (max-width: 980px) {
    .aside-mobile { display: block; }
    .aside { display: none; }
  }

  /* AdSense: collapse empty slots to avoid mysterious whitespace (e.g., no-fill) */
  ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

  .sidebar .side-title,
  .aside .side-title { font-size: 13px; color: #222; margin: 0 0 10px; display:flex; align-items:center; gap: 6px; }

  .english-quiz-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #cfc5ef;
    border-radius: 12px;
    color: #30215d;
    background: linear-gradient(135deg, #f8f5ff 0%, #eee9ff 100%);
    box-shadow: 0 2px 8px rgba(63, 45, 125, .1);
    line-height: 1.35;
    text-decoration: none;
  }
  .english-quiz-card:hover {
    border-color: #8f7ad6;
    box-shadow: 0 3px 12px rgba(63, 45, 125, .16);
    text-decoration: none;
  }
  .english-quiz-card__icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 9px;
    background: #fff3b5;
    font-size: 18px;
  }
  .english-quiz-card__copy { min-width: 0; flex: 1; }
  .english-quiz-card__copy strong { display: block; font-size: 13px; }
  .english-quiz-card__copy small {
    display: block;
    margin-top: 1px;
    color: #655a82;
    font-size: 10px;
  }
  .english-quiz-card__arrow {
    flex: 0 0 auto;
    color: #7663ba;
    font-size: 22px;
    line-height: 1;
  }
  .english-quiz-card--desktop { margin-bottom: 14px; }
  .english-quiz-card--mobile { display: none; }

  @media (max-width: 980px) {
    .english-quiz-card--desktop { display: none; }
    .english-quiz-card--mobile { display: flex; }
    .english-quiz-card--mobile .english-quiz-card__copy strong { font-size: 14px; }
    .english-quiz-card--mobile .english-quiz-card__copy small { font-size: 11px; }
  }

  .catlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
  .catlist a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    min-height: 44px;
  }
  .catlist a:hover { text-decoration: none; border-color: #c7d4e5; }
  .catlist a.active {
    border-color: var(--accent);
  }
  .catlabel { display:flex; align-items:center; gap: 8px; min-width: 0; overflow: hidden; flex: 1 1 auto; }
  .catlabel span.name { display:block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .catcount {
    font-size: 11px;
    color: #2f4f7a;
    background: #eaf1fb;
    border: 1px solid #c9d9f2;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 40px;
    text-align: center;
  }

  .grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  @media (max-width: 920px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  @media (max-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

  .recommendation-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }
  .recommendation-heading { margin: 0; font-size: 16px; line-height: 1.35; }
  .recommendation-lead { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
  .recommendation-shuffle {
    min-height: 44px;
    padding: 9px 13px;
    border: 1px solid #a9c2ee;
    border-radius: 12px;
    color: #214d8f;
    background: var(--accent-weak);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }
  .recommendation-shuffle:hover { border-color: var(--accent); }
  .recommendation-shuffle:disabled { cursor: wait; opacity: .7; }
  .recommendation-grid .card img {
    aspect-ratio: 1.414 / 1;
    object-fit: contain;
  }
  .recommendation-ad {
    margin: 24px 0;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-width: 0;
    text-align: center;
  }
  .recommendation-ad-label {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .08em;
  }
  .recommendation-ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
  .recommendation-ad + .recommendation-grid,
  .recommendation-grid + .recommendation-grid { margin-top: 16px; }
  .recommendation-footer { margin-top: 18px; text-align: center; }
  .recommendation-status {
    min-height: 1.65em;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
  }

  @media (max-width: 640px) {
    .recommendation-toolbar { align-items: stretch; flex-direction: column; }
    .recommendation-toolbar .recommendation-shuffle { width: 100%; }
  }

  .card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
  .card img { width: 100%; height: auto; display: block; background: #f2f2f2; }
  .card .meta { padding: 12px; }
  .card .title { font-size: 13px; margin: 0 0 4px; font-weight: 600; }
  .card .small { font-size: 12px; color: var(--muted); }

  .section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
  }
  .section-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
  }
  .section-head .small {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
  }
  .related-block {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
  .tag {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: #fff;
  }
  .tag--cat { background: #eef4ff; border-color: #c7d9f7; color: #2d5aa6; }
  .tag--lang { background: #e9f6fb; border-color: #b7e3f4; color: #1d6c86; }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 3px 9px;
    border: 1px solid #c7d9f7;
    border-radius: 999px;
    color: #2d5aa6;
    background: #eef4ff;
  }
  a.badge { text-decoration: none; }
  a.badge:hover { text-decoration: none; border-color: #a9c2ee; }

  .kvs { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; margin: 12px 0 0; }
  @media (max-width: 640px) { .kvs { grid-template-columns: 1fr; } }
  .kvs dt { font-weight: 700; color: #222; }
  .kvs dd { margin: 0; color: #222; }

  .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font-size: 13px;
  }
  .btn:hover { text-decoration: none; border-color: #cfcfcf; }
  .btn-dl {
    font-size: 22px;
    padding: 14px 14px;
    font-weight: 700;
    line-height: 1.1;
  }
  .btn-pdf { border-color: #d93025; }
  .btn-jpg { border-color: #1a73e8; }
  .btn-pdf:hover { border-color: #d93025; }
  .btn-jpg:hover { border-color: #1a73e8; }

  .heroimg { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background:#fff; }
  .heroimg img { width: 100%; height: auto; display:block; background:#f2f2f2; }

  .box { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background:#fff; }
  .box h3 { margin: 0 0 8px; font-size: 13px; }
  .box p { margin: 0; color: #222; font-size: 13px; }
  .aside { font-size: 15px; }
  .aside .box h3 { font-size: 15px; }
  .aside .box p { font-size: 15px; }
  .aside .btn { font-size: 14px; }
  .aside .btn.btn-dl { font-size: 22px; }

  .box + .box { margin-top: 14px; }

  .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  @media (max-width: 920px) { .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

  .filter-strip {
    margin: 0 0 14px;
  }
  .filter-strip__label {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
  .filter-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: #2d5aa6;
    font-size: 12px;
    font-weight: 700;
  }
  .filter-chip span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }
  .filter-chip:hover,
  .filter-chip.active {
    border-color: #a9c2ee;
    background: var(--accent-weak);
    text-decoration: none;
  }
  .category-status,
  .search-status {
    min-height: 1.65em;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
  }

  .local-search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
  }
  .local-search-form input[type="search"] {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
  }
  .local-search-form button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid #a9c2ee;
    border-radius: 12px;
    color: #214d8f;
    background: var(--accent-weak);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }
  .local-search-suggestions {
    margin: 0 0 12px;
  }

  .pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
  .pager a { flex: 1; text-align: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
  .pager .spacer { flex: 1; }

  footer { color: var(--muted); font-size: 12px; padding: 24px 0; text-align: center; }

  @media (max-width: 640px) {
    .toprow { flex-direction: column; align-items: stretch; }
    .brand { width: 100%; }
    form.site-search { width: 100%; justify-content: space-between; }
    .site-search input[type="text"] { width: 100%; flex: 1; }
    .site-search button { flex: 0 0 auto; }
  }
