
  :root {
    --bg: #f7faf8;
    --card-bg: #ffffff;
    --primary: #6b9e8a;
    --primary-light: #b5d4c7;
    --primary-dark: #4a7a66;
    --accent: #e8a87c;
    --text: #3d405b;
    --text-light: #8d8fa6;
    --border: #e4ece8;
    --shadow: 0 2px 12px rgba(61,64,91,0.06);
    --radius: 12px;
  }
  [data-theme="sakura"] {
    --bg: #fdf6f8;
    --card-bg: #ffffff;
    --primary: #d4899a;
    --primary-light: #f0c4cf;
    --primary-dark: #b8606e;
    --accent: #f2c078;
    --text: #5a3e44;
    --text-light: #a88a92;
    --border: #f0dde2;
    --shadow: 0 2px 12px rgba(180,100,120,0.06);
  }
  [data-theme="lavender"] {
    --bg: #f6f4fb;
    --card-bg: #ffffff;
    --primary: #9a8cbf;
    --primary-light: #cbc3e0;
    --primary-dark: #7263a3;
    --accent: #e0a0b0;
    --text: #3e3758;
    --text-light: #9189a8;
    --border: #e4dff0;
    --shadow: 0 2px 12px rgba(100,80,160,0.06);
  }
  [data-theme="ocean"] {
    --bg: #f3f8fb;
    --card-bg: #ffffff;
    --primary: #5b98b8;
    --primary-light: #b0d2e4;
    --primary-dark: #3a7494;
    --accent: #f0b87a;
    --text: #354555;
    --text-light: #8299ad;
    --border: #dce8f0;
    --shadow: 0 2px 12px rgba(60,100,140,0.06);
  }
  [data-theme="apricot"] {
    --bg: #fdf8f3;
    --card-bg: #ffffff;
    --primary: #d4a06a;
    --primary-light: #edcfac;
    --primary-dark: #b07a3e;
    --accent: #c07882;
    --text: #4a3e35;
    --text-light: #a89682;
    --border: #f0e4d6;
    --shadow: 0 2px 12px rgba(160,110,60,0.06);
  }
  [data-theme="night"] {
    --bg: #1a1b26;
    --card-bg: #24263a;
    --primary: #7aa2a0;
    --primary-light: #4a6260;
    --primary-dark: #a3cec5;
    --accent: #e0a07c;
    --text: #c0caf5;
    --text-light: #565f89;
    --border: #3b3e57;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
  }

  /* ---- header ---- */
  .header {
    text-align: left;
    line-height: 1.35;
  }
  .header h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--primary-dark);
    cursor: pointer;
    display: inline-block;
    user-select: none;
  }
  .header h1:hover { text-decoration: underline; }
  .header p {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
  }

  /* ---- settings bar ---- */
  .settings-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
  }
  .settings-btn {
    height: 29px;
    padding: 5px 12px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
  }
  .settings-btn:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
  }
  .settings-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .settings-btn .icon {
    font-size: 14px;
    line-height: 1;
  }

  /* ---- theme switcher ---- */
  .theme-picker {
    position: relative;
  }
  .theme-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,.12);
    z-index: 100;
    min-width: 130px;
  }
  .theme-dropdown.open { display: block; }
  .theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    border: none;
    background: none;
    width: 100%;
    font-size: 12px;
    color: var(--text);
    text-align: left;
  }
  .theme-option:hover {
    background: var(--primary-light);
    color: #fff;
  }
  .theme-option.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
  }
  .theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid rgba(0,0,0,.1);
  }

  /* ---- top row: mode switch + settings ---- */
  .top-row {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 20px 0;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
  }
  /* ---- mode switch ---- */
  .mode-bar {
    display: flex;
    gap: 12px;
  }
  .mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 7px 22px;
    border-radius: 20px;
    border: 1.5px solid var(--primary-light);
    background: transparent;
    color: var(--primary-dark);
    font-size: 13px;
    cursor: pointer;
    transition: all .25s;
    font-weight: 500;
  }
  .mode-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .mode-btn:hover:not(.active) {
    background: var(--primary-light);
    color: #fff;
  }

  /* ---- timeline ---- */
  .timeline-section {
    padding: 24px 0 0;
  }
  .timeline-wrap {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 60px;
  }
  .timeline-track {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 6px 4px 12px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
  }
  .timeline-track:active {
    cursor: grabbing;
  }
  .timeline-track::-webkit-scrollbar {
    height: 6px;
  }
  .timeline-track::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
  }
  .timeline-day {
    flex: 0 0 64px;
    text-align: center;
    padding: 8px 0 6px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    transition: all .2s;
  }
  .timeline-day:hover {
    border-color: var(--primary-light);
    transform: translateY(-1px);
  }
  .timeline-day.is-today .timeline-date::after {
    content: ' ·';
    color: var(--accent);
  }
  .timeline-day.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(107,158,138,.25);
  }
  .timeline-day.active .timeline-date,
  .timeline-day.active .timeline-dow {
    color: #fff;
  }
  .timeline-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .timeline-dow {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
  }
  .calendar-btn {
    position: absolute;
    top: 4px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1.5px solid var(--primary-light);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    z-index: 2;
  }
  .calendar-btn:hover {
    background: var(--primary-light);
    transform: scale(1.06);
  }
  .calendar-input {
    position: absolute;
    top: 4px;
    right: 16px;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border: none;
    opacity: 0;
    pointer-events: none;
  }

  /* ---- calendar popover (left of the 📅 button) ---- */
  .calendar-popover {
    position: absolute;
    top: 4px;
    right: calc(16px + 34px + 8px);
    width: 248px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 14px 40px rgba(20,30,50,.18);
    padding: 12px;
    z-index: 20;
    display: none;
  }
  .calendar-popover.open { display: block; }
  .cp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .cp-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }
  .cp-nav {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
  }
  .cp-nav:hover {
    background: var(--primary-light);
    color: #fff;
    border-color: var(--primary-light);
  }
  .cp-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .cp-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    border-radius: 9px;
    padding: 5px 8px;
    outline: none;
    transition: border-color .15s;
  }
  .cp-input::placeholder { color: var(--text-light); }
  .cp-input:focus { border-color: var(--primary); }
  .cp-today {
    flex: none;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 10px;
    transition: background .15s;
  }
  .cp-today:hover {
    background: var(--primary-light);
    color: #fff;
  }
  .cp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }
  .cp-dow {
    font-size: 10px;
    color: var(--text-light);
    text-align: center;
    padding: 4px 0;
  }
  .cp-d {
    text-align: center;
    font-size: 12px;
    line-height: 28px;
    height: 28px;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    transition: background .12s, color .12s;
  }
  .cp-d:hover { background: var(--primary-light); color: #fff; }
  .cp-d.dis { color: var(--border); cursor: default; pointer-events: none; }
  .cp-d.today { font-weight: 700; color: var(--accent); }
  .cp-d.sel {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
  }
  .cp-d.sel:hover { background: var(--primary-dark); color: #fff; }

  /* ---- expanding search pill (mode-bar) ---- */
  .search-pill {
    display: flex;
    align-items: center;
    position: relative;
  }
  .search-fields {
    display: flex;
    align-items: center;
    height: 34px;
    margin-left: 0;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width .3s ease, opacity .25s ease, margin-left .3s ease, padding .3s ease;
    border-radius: 20px;
    border: 1.5px solid var(--primary-light);
    background: var(--card-bg);
  }
  .search-pill.open .search-fields {
    max-width: 280px;
    opacity: 1;
    margin-left: 6px;
    padding: 0 6px 0 14px;
  }
  .search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    outline: none;
  }
  .search-input::placeholder {
    color: var(--text-light);
  }
  .search-submit {
    width: 28px;
    height: 28px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter .2s;
    padding: 0;
  }
  .search-submit:hover {
    filter: brightness(1.1);
  }
  .search-clear {
    width: 22px;
    height: 22px;
    flex: none;
    margin-right: 2px;
    border: none;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter .2s;
    padding: 0;
  }
  .search-clear:hover {
    background: #c04949;
    color: #fff;
  }

  /* ---- content area ---- */
  .content {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px 60px;
  }
  .content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 10px;
  }
  .content-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
  }
  .content-count {
    font-size: 12px;
    color: var(--text-light);
  }
  .sr-rank-btn {
    margin-left: auto;
    flex: none;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1.5px solid var(--primary-light);
    background: transparent;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
  }
  .sr-rank-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }

  /* ---- search rankings (top-20 番号) modal ---- */
  .sr-rank-box {
    max-width: 420px;
    padding: 16px 16px 6px;
  }
  .sr-rank-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-left: 4px;
    padding-right: 22px;
  }
  .sr-rank-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
  }
  .sr-rank-sub {
    font-size: 11px;
    color: var(--text-light);
  }
  .sr-rank-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 62vh;
    overflow-y: auto;
    padding-right: 4px;
  }
  .sr-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color .2s, background .2s;
  }
  .sr-rank-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
  }
  .sr-rank-no {
    width: 26px;
    flex: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
  }
  .sr-rank-item:nth-child(1) .sr-rank-no { color: #d4a017; }
  .sr-rank-item:nth-child(2) .sr-rank-no { color: #9aa0a6; }
  .sr-rank-item:nth-child(3) .sr-rank-no { color: #c98a5b; }
  .sr-rank-code {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.5px;
  }
  .sr-rank-count {
    flex: none;
    font-size: 11px;
    color: var(--text-light);
  }
  .sr-rank-empty {
    text-align: center;
    padding: 40px 12px;
    color: var(--text-light);
    font-size: 13px;
  }

  /* ---- cards grid ---- */
  .cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
  }
  /* ---- search results (detail layout, spans two grid cells) ---- */
  .search-result {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(190px, 250px) minmax(0, 1fr);
    gap: 24px;
    background:
      linear-gradient(180deg, rgba(127,127,127,0.035), transparent 150px),
      var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 18px;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  }
  .search-result:hover {
    transform: translateY(-2px);
    border-color: var(--primary-dark);
    box-shadow: 0 12px 30px rgba(80,90,120,0.14);
  }
  .sr-cover {
    align-self: start;
  }
  .sr-cover-img-wrap { position: relative; }
  .sr-cover-img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 14px;
    background: var(--border);
    display: block;
    cursor: zoom-in;
    transition: transform .22s ease;
    box-shadow: 0 4px 14px rgba(40,50,80,0.16);
  }
  .sr-cover:hover .sr-cover-img { transform: scale(1.02); }
  .sr-cover-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: calc(100% - 16px);
  }
  .sr-badge {
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .3px;
    color: #fff;
    backdrop-filter: blur(4px);
  }
  .sr-badge-code { background: rgba(25,35,55,0.58); }
  .sr-badge-maker { background: rgba(232,168,124,0.82); }
  .sr-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .sr-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }
  .sr-title {
    flex: 1;
    min-width: 0;
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--text);
    letter-spacing: .2px;
  }
  .sr-price-tag {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 800;
    color: var(--primary-dark);
    background: linear-gradient(135deg, rgba(107,158,138,0.16), rgba(107,158,138,0.05));
    border: 1px solid rgba(107,158,138,0.35);
    padding: 4px 11px;
    border-radius: 999px;
    white-space: nowrap;
    margin-top: 3px;
  }
  .sr-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  .sr-mchip {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(154,140,191,0.09);
    color: var(--text-light);
    border: 1px solid var(--border);
  }
  .sr-mchip.rate {
    color: #c9781a;
    background: rgba(240,180,90,0.14);
    border-color: rgba(240,180,90,0.42);
  }
  .sr-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    column-gap: 26px;
    row-gap: 6px;
    align-items: start;
    margin-top: 2px;
  }
  .sr-row {
    display: flex;
    font-size: 12.5px;
    line-height: 1.55;
    gap: 10px;
    min-width: 0;
  }
  .sr-label {
    flex: 0 0 88px;
    color: var(--text-light);
    flex-shrink: 0;
    font-weight: 600;
  }
  .sr-value {
    color: var(--text);
    word-break: break-word;
    min-width: 0;
  }
  .sr-chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 7px;
    margin: 1px 3px 1px 0;
    background: rgba(154,140,191,0.09);
    color: var(--primary-dark);
    border: 1px solid rgba(154,140,191,0.16);
  }
  .sr-desc {
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid var(--border);
    padding-left: 10px;
  }
  .sr-desc.expanded {
    -webkit-line-clamp: unset;
    color: var(--text);
  }
  .sr-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    margin-top: 2px;
  }
  .sr-thumbs img {
    width: 78px;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--border);
    cursor: zoom-in;
    transition: transform .16s ease, box-shadow .16s ease;
  }
  .sr-thumbs img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(40,50,80,0.18);
  }
  .card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    cursor: default;
  }
  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(61,64,91,0.1);
  }
  .card-img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: var(--border);
    display: block;
    cursor: zoom-in;
  }
  /* ---- gacha browse mode: blur covers + reveal effect ---- */
  body.browse-gacha .card {
    position: relative;
    cursor: pointer;
  }
  body.browse-gacha .card-img {
    filter: blur(26px) saturate(1.15);
    transform: scale(1.08);
    transition: filter .5s ease, transform .5s ease;
  }
  body.browse-gacha .card.revealed .card-img {
    animation: gachaFlip .8s ease forwards;
  }
  @keyframes gachaFlip {
    0%   { transform: perspective(800px) rotateY(0deg)   scale(1.08); filter: blur(26px) saturate(1.15); }
    30%  { transform: perspective(800px) rotateY(60deg)  scale(1.12); filter: blur(18px) saturate(1.3); }
    55%  { transform: perspective(800px) rotateY(110deg) scale(1.06); filter: blur(10px) saturate(1.2); }
    100% { transform: perspective(800px) rotateY(360deg) scale(1);    filter: none; }
  }
  body.browse-gacha .card.revealed::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 42%, rgba(255,235,160,.6) 50%, transparent 58%);
    animation: cardShine .8s ease forwards;
  }
  @keyframes cardShine {
    0%  { transform: translateX(-80%); opacity: 1; }
    70% { transform: translateX(80%);  opacity: 1; }
    100%{ transform: translateX(80%);  opacity: 0; }
  }
  .card-body {
    padding: 14px 16px 16px;
  }
  .card-rank {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(232,168,124,0.12);
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
  }
  .card-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
  }
  .card-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }
  .card-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: color .15s, transform .15s;
  }
  .card-id:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
  .card-id.copied { color: var(--primary); }
  .code-toast {
    position: fixed;
    left: 50%;
    bottom: 72px;
    transform: translateX(-50%);
    background: rgba(0,0,0,.82);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 9px 18px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 2000;
    opacity: 0;
    transition: opacity .2s;
  }
  .code-toast.show { opacity: 1; }
  .card-date {
    font-size: 11px;
    color: var(--text-light);
    background: rgba(232,168,124,0.12);
    padding: 2px 8px;
    border-radius: 8px;
  }
  .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--text-light);
  }
  .card-tag {
    background: rgba(124,154,146,0.08);
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
  }
  .card-tag.tag-genre {
    background: rgba(94,129,255,0.10);
    color: #8f9dff;
  }
  .card-tag.tag-label {
    background: rgba(255,157,94,0.10);
    color: #ffab80;
  }
  .card-price {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-top: 6px;
  }
  .card-price .original {
    text-decoration: line-through;
    color: var(--text-light);
    font-weight: 400;
    margin-left: 4px;
    font-size: 11px;
  }

  /* ---- pagination ---- */
  .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
  }
  .page-btn {
    padding: 6px 16px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
  }
  .page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary-dark);
  }
  .page-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
  }
  .page-info {
    font-size: 13px;
    color: var(--text-light);
    padding: 0 8px;
  }

  /* ---- favorites toolbar ---- */
  .fav-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
  }
  .fav-toolbar input[type="text"] {
    flex: 1 1 190px;
    min-width: 150px;
    padding: 7px 12px;
    border-radius: 9px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
  }
  .fav-toolbar input[type="text"]:focus { border-color: var(--primary); }
  .fav-tool-btn {
    padding: 6px 13px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
  }
  .fav-tool-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
  .fav-tool-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .fav-tool-btn.danger { color: #c04949; border-color: #e2b6b6; }
  .fav-tool-btn.danger:hover { border-color: #c04949; color: #c04949; }
  #fav-batch-del { display: none; }
  .fav-tool-btn.danger.show { display: inline-block; }
  .fav-tool-btn.danger:disabled { opacity: .45; cursor: not-allowed; }
  .fav-chk-all {
    display: none;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
  }
  .fav-toolbar.batch .fav-chk-all { display: inline-flex; }
  .fav-chk-all input { accent-color: var(--primary); }

  /* ---- favorites card overlay (checkbox + remove) ---- */
  .fav-card { position: relative; }
  .fav-card-tools {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
  }
  .fav-card-tools > * { pointer-events: auto; }
  .fav-chk {
    display: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    box-shadow: 0 1px 5px rgba(0,0,0,.18);
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .fav-chk input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
  .fav-toolbar.batch ~ .cards .fav-chk,
  .fav-toolbar.batch .fav-chk { display: flex; }
  .fav-del {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0,0,0,.25);
    transition: background .2s, transform .2s;
  }
  .fav-del:hover { background: #c04949; transform: scale(1.08); }

  /* ---- loading / empty ---- */
  .status-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 14px;
  }

  /* ---- footer / copyright ---- */
  .site-footer {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px 24px;
    font-size: 11px;
    color: var(--text-light);
    opacity: .8;
    user-select: none;
  }
  .site-note {
    text-align: center;
    margin: 0 0 8px;
    font-size: 11px;
    color: var(--text-light);
    opacity: .85;
  }
  .site-footer-row {
    text-align: right;
  }
  .site-footer a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
  }
  .site-footer a:hover {
    color: var(--primary-dark);
  }

  /* ---- fade in ---- */
  .fade-in {
    animation: fadeIn .35s ease;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ---- modal ---- */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn .2s ease;
  }
  .modal-overlay.open { display: flex; }
  .modal-box {
    position: relative;
    background: var(--card-bg);
    border-radius: 16px;
    overflow: visible;
    max-width: 960px;
    width: 92vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
  }
  .modal-img-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    overflow: hidden;
    border-radius: 16px 16px 0 0;
  }
  .modal-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
  }
  .modal-img-wrap { cursor: zoom-in; }
  .modal-loupe {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .85);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .12);
    background-repeat: no-repeat;
    background-position: 0 0;
    pointer-events: none;
    display: none;
    z-index: 6;
  }
  .modal-loupe.on { display: block; }
  .modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.85);
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .15s;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    z-index: 2;
  }
  .modal-arrow:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
  .modal-arrow.left  { left: 12px; }
  .modal-arrow.right { right: 12px; }
  .modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.85);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background .2s;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
  }
  .modal-close:hover { background: #fff; }
  .modal-footer {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 16px 16px;
  }
  .modal-counter {
    font-size: 13px;
    color: var(--text-light);
    min-width: 60px;
  }
  .modal-title {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .modal-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .modal-sub {
    font-size: 11px;
    color: var(--text-light);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }
  .modal-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(124,154,146,0.1);
    color: var(--primary-dark);
    white-space: nowrap;
  }

  /* ---- modal action buttons (magnet / play) ---- */
  .modal-footer {
    position: relative;
  }
  .action-bar {
    display: flex;
    gap: 8px;
    margin-left: auto;
  }
  .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--primary-light);
    background: var(--card-bg);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
  }
  .action-btn:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  .action-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
  }
  /* favorite heart button: fills with the active theme's primary color */
  .action-btn.fav-btn.active {
    background: transparent;
    color: var(--primary-dark);
    border-color: var(--primary-light);
    border-width: 1.5px;
  }
  .action-btn.fav-btn .action-ico {
    font-size: 13px;
    line-height: 1.2;
  }
  .action-btn.fav-btn.active .action-ico {
    color: var(--primary-dark);
  }
  .action-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
  }
  .action-ico {
    font-size: 12px;
    line-height: 1;
  }
  .action-ico.spin {
    display: inline-block;
    animation: spin .9s linear infinite;
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  .action-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: min(430px, calc(100vw - 40px));
    max-height: 55vh;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 14px 36px rgba(0,0,0,.18);
    z-index: 60;
    padding: 8px;
    display: none;
  }
  .action-popover.open {
    display: block;
  }
  .ap-status {
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
    padding: 18px 12px;
  }
  .ap-retry {
    display: block;
    margin: 0 auto 14px;
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg);
    border: 1px solid var(--primary);
    border-radius: 16px;
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  .ap-retry:hover { background: var(--primary); color: #fff; }
  .ap-tab.busy { opacity: .5; pointer-events: none; }
  .ap-status.ap-state-loading { color: var(--text-light); }
  .ap-group + .ap-group {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
  }
  .ap-head {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: .3px;
    margin-bottom: 6px;
    padding: 0 4px;
  }
  .ap-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.45;
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
  }
  .ap-row:hover {
    background: var(--primary-light);
  }
  a.ap-row:hover {
    color: var(--text);
  }
  .ap-magnet {
    cursor: pointer;
    flex-direction: column;
    align-items: stretch;
  }
  .ap-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
  }
  .ap-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
  }
  .ap-copy {
    flex-shrink: 0;
    padding: 2px 10px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    transition: background .2s;
  }
  .ap-copy.done {
    background: var(--primary-dark);
  }
  .ap-badge {
    flex-shrink: 0;
    font-size: 11px;
    border-radius: 8px;
    padding: 2px 8px;
    white-space: nowrap;
  }
  .ap-badge.ok   { background: rgba(124,180,146,.15); color: var(--primary-dark); }
  .ap-badge.no   { background: rgba(200,120,120,.12); color: var(--accent); }
  .ap-badge.warn { background: rgba(232,168,124,.15); color: var(--accent); }
  .ap-sub {
    font-size: 11px;
    color: var(--text-light);
    padding: 2px 4px 0;
  }

  /* ---- magnet tabs / tags / hint ---- */
  .ap-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .ap-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 9px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    transition: all .15s;
  }
  .ap-tab:hover {
    border-color: var(--primary-light);
    color: var(--primary-dark);
  }
  .ap-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
  }
  .ap-tab-cnt {
    font-size: 10px;
    opacity: .8;
  }
  .ap-pane { display: none; }
  .ap-pane.active { display: block; }
  .ap-tag-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
  }
  .ap-tag {
    display: inline-block;
    font-size: 10px;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(124,154,146,.1);
    color: var(--text-light);
  }
  .ap-tag.hd { background: rgba(124,180,146,.16); color: var(--primary-dark); }
  .ap-tag.co { background: rgba(91,152,184,.16); color: #3a7494; }
  .ap-tag.tx { background: rgba(232,168,124,.16); color: var(--accent); }
  .ap-hint {
    margin-top: 10px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(232,168,124,.12);
    color: var(--accent);
    font-size: 11px;
    line-height: 1.6;
  }
  .ap-disabled {
    opacity: .55;
    cursor: not-allowed;
  }

  /* ---- 18+ / NSFW gate ---- */
  body.gated > *:not(.gate-overlay) {
    display: none !important;
  }
  .gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(245,247,250,0.96);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(6px);
  }
  .gate-overlay.open {
    display: flex;
  }
  .gate-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(61,64,91,.15);
    max-width: 460px;
    width: 100%;
    padding: 36px 32px;
    text-align: center;
  }
  .gate-icon {
    font-size: 52px;
    line-height: 1;
    margin-bottom: 14px;
  }
  .gate-box h2 {
    font-size: 22px;
    color: var(--text);
    margin: 0 0 10px;
  }
  .gate-msg {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-light);
    margin: 0 0 18px;
  }
  .gate-conditions {
    text-align: left;
    margin: 0 0 24px;
    padding: 0 0 0 18px;
  }
  .gate-conditions li {
    font-size: 13px;
    color: var(--text);
    line-height: 1.8;
  }
  .gate-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .gate-btn {
    padding: 11px 20px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
  }
  .gate-btn.enter {
    background: var(--primary);
    color: #fff;
  }
  .gate-btn.enter:hover {
    background: var(--primary-dark);
  }
  .gate-btn.leave {
    background: transparent;
    color: var(--text-light);
    border: 1.5px solid var(--border);
  }
  .gate-btn.leave:hover {
    background: var(--border);
    color: var(--text);
  }
  .gate-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-light);
    cursor: pointer;
  }

  /* ================= responsive ================= */
  @media (max-width: 1200px) {
    .cards { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  }
  @media (max-width: 992px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
    .search-result { grid-template-columns: 150px 1fr; gap: 14px; padding: 14px; }
    .sr-title { font-size: 15px; }
    .sr-price-tag { font-size: 12px; padding: 2px 9px; }
    .sr-thumbs img { width: 64px; }
    .timeline-wrap { padding: 0 48px; }
  }
  @media (max-width: 700px) {
    .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .search-result { grid-template-columns: 104px 1fr; grid-column: 1 / -1; gap: 12px; padding: 10px 12px; border-radius: 14px; }
    .sr-label { flex-basis: 76px; }
    .sr-title { font-size: 14px; }
    .sr-head { flex-direction: column; align-items: stretch; gap: 6px; }
    .sr-price-tag { align-self: flex-start; margin-top: 0; }
    .sr-mchip { font-size: 10.5px; padding: 2px 7px; }
    .sr-info { gap: 8px; }
    .sr-thumbs img { width: 56px; border-radius: 6px; }
    .content {
      padding: 20px 14px calc(80px + env(safe-area-inset-bottom, 0px));
    }
.content-title { font-size: 15px; }
    .top-row { padding: 12px 14px 0; gap: 10px; }
    .header h1 { font-size: 18px; }
    .header p { font-size: 12px; }
    .mode-btn { padding: 6px 16px; font-size: 12px; }
    .timeline-wrap { padding: 0 14px; }
    .search-pill.open .search-fields { max-width: 190px; }
    .timeline-track { padding: 6px 2px 10px; }
    .timeline-day { flex-basis: 46px; }
    .timeline-date { font-size: 12px; }
    .calendar-btn { right: 6px; width: 30px; height: 30px; font-size: 14px; }
    .calendar-input { right: 6px; width: 30px; height: 30px; }
    .calendar-popover { right: calc(6px + 30px + 6px); }
    .card-body { padding: 10px 12px 12px; }
    .card-title { font-size: 13px; -webkit-line-clamp: 2; }
    .card-price { font-size: 11px; margin-top: 4px; }
    .pagination { flex-wrap: wrap; margin-top: 22px; }
    .modal-box { width: 96vw; max-height: 96vh; }
    .modal-arrow { width: 34px; height: 34px; font-size: 16px; }
    .modal-arrow.left  { left: 6px; }
    .modal-arrow.right { right: 6px; }
    .modal-close { top: 8px; right: 10px; width: 32px; height: 32px; }
    .modal-footer { padding: 10px 14px; flex-wrap: wrap; }
    .modal-badge { display: none; }
    .action-bar { width: 100%; justify-content: flex-end; margin-left: 0; }
    .action-btn { padding: 5px 10px; font-size: 11px; }
    .site-footer {
      padding: 0 14px calc(12px + env(safe-area-inset-bottom, 0px));
    }
  }
  @media (max-width: 380px) {
    .cards { grid-template-columns: repeat(1, 1fr); gap: 14px; }
    .settings-bar { gap: 5px; }
    .header h1 { font-size: 16px; letter-spacing: 0.5px; }
  }
  @media (max-height: 520px) {
    .modal-img { max-height: 72vh; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
