/* ==================================================
       THEMES & VARIABLES (SWISS DESIGN)
       ================================================== */
    :root, [data-theme="acid"] {
      --ink: #111111;
      --paper: #ffffff;
      --acid: #dfff00;
      --acid-hover: #cbef00;
      --line: #e6e6e6;
      --muted: #666666;
      --badge-bg: #f4f4f6;
      --wrap-cards: 1120px;
      --wrap-deck: 540px;
      --wrap-list: 640px;
      --wrap: var(--wrap-cards);
      --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    }

    [data-theme="dark"] {
      --ink: #f5f5f5;
      --paper: #0c0d10;
      --acid: #dfff00;
      --acid-hover: #cbef00;
      --line: #22252a;
      --muted: #8c9096;
      --badge-bg: #181a1e;
    }

    [data-theme="warm"] {
      --ink: #1c1917;
      --paper: #fbf8f3;
      --acid: #e11d48;
      --acid-hover: #be123c;
      --line: #e7e2d9;
      --muted: #78716c;
      --badge-bg: #f0ebe1;
    }

    *, *::before, *::after { box-sizing: border-box; }
    [hidden] { display: none !important; }
    html {
      color-scheme: light dark;
      -webkit-text-size-adjust: 100%;
      height: 100%;
    }
    body[data-view="deck"] {
      overscroll-behavior-y: none;
    }
    body[data-view="cards"] { --wrap: var(--wrap-cards); }
    body[data-view="deck"] { --wrap: var(--wrap-deck); }
    body[data-view="list"] { --wrap: var(--wrap-list); }

    body {
      margin: 0;
      min-height: 100%;
      background: var(--paper);
      color: var(--ink);
      font-family: Arial, Helvetica, -apple-system, sans-serif;
      -webkit-font-smoothing: antialiased;
      line-height: 1.35;
      display: flex;
      flex-direction: column;
      transition: background 0.2s ease, color 0.2s ease;
    }
    a { color: inherit; text-decoration: none; }
    button { font: inherit; }
    .wrap {
      width: min(var(--wrap), calc(100% - 24px));
      margin-inline: auto;
      transition: width 0.2s ease;
    }

    /* ==================================================
       HEADER & VIEW SWITCHER
       ================================================== */
    .header {
      position: sticky;
      top: 0;
      z-index: 50;
      background: var(--paper);
      border-bottom: 2px solid var(--ink);
    }
    .header-inner {
      height: 52px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .brand {
      font-size: 17px;
      font-weight: 900;
      letter-spacing: -0.06em;
      line-height: 1;
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }
    .brand-tag {
      background: var(--acid);
      color: #111;
      padding: 2px 6px;
      border-radius: 4px;
      font-weight: 900;
      font-size: 11px;
      letter-spacing: 0.04em;
    }
    .header-nav {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .view-switcher {
      display: inline-flex;
      align-items: center;
      background: var(--badge-bg);
      border: 1.5px solid var(--line);
      border-radius: 999px;
      padding: 2px;
      gap: 2px;
    }
    .view-btn {
      border: none;
      background: transparent;
      color: var(--muted);
      font-size: 12px;
      font-weight: 850;
      padding: 5px 11px;
      border-radius: 999px;
      cursor: pointer;
      transition: all 0.15s ease;
      touch-action: manipulation;
    }
    .view-btn.active {
      background: var(--ink);
      color: var(--paper);
    }
    .nav-link {
      font-size: 12.5px;
      font-weight: 800;
      letter-spacing: -0.02em;
    }
    .nav-link:hover { text-decoration: underline; }

    /* ==================================================
       MAIN WRAPPER
       ================================================== */
    .main {
      flex: 1;
      display: flex;
      flex-direction: column;
      padding-top: 10px;
      padding-bottom: 20px;
    }

    /* ==================================================
       DECK SECTION (TINDER-STYLE PHYSICAL CARDS)
       ================================================== */
    .deck-section {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      min-height: 0;
    }
    .deck-wrapper {
      position: relative;
      width: min(360px, calc(100vw - 28px));
      height: clamp(430px, 64vh, 510px);
      perspective: 1000px;
      margin: 0 auto;
    }
    .deck-stage {
      position: relative;
      width: 100%;
      height: 100%;
    }
    .deck-card {
      position: absolute;
      inset: 0;
      background: var(--paper);
      border: 2px solid var(--ink);
      border-radius: 20px;
      overflow: hidden;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
      display: flex;
      flex-direction: column;
      user-select: none;
      -webkit-user-select: none;
      touch-action: pan-y;
      cursor: grab;
      transform-origin: 50% 100%;
      will-change: transform, opacity;
    }
    .deck-card.is-dragging {
      cursor: grabbing;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
    }

    /* Card Cover Image */
    .card-cover {
      position: relative;
      width: 100%;
      height: 47%;
      background: #111;
      overflow: hidden;
      border-bottom: 2px solid var(--ink);
      flex-shrink: 0;
    }
    .cover-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      pointer-events: none;
    }
    .cover-fallback {
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #111111 0%, #1e2025 100%);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      color: #fff;
    }
    .fallback-tag {
      background: var(--acid);
      color: #111;
      font-size: 10px;
      font-weight: 900;
      padding: 3px 8px;
      border-radius: 4px;
      letter-spacing: 0.05em;
      text-transform: uppercase;
    }
    .fallback-title {
      font-size: 19px;
      font-weight: 900;
      letter-spacing: -0.04em;
      text-align: center;
      padding: 0 16px;
    }
    .cover-badge {
      position: absolute;
      top: 10px;
      left: 10px;
      background: var(--acid);
      color: #111;
      font-size: 10px;
      font-weight: 900;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      padding: 3px 8px;
      border-radius: 6px;
      border: 1px solid var(--ink);
      box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    }

    /* Card Content */
    .card-content {
      padding: 12px 16px 6px;
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .card-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 4px;
    }
    .card-num {
      font-family: var(--mono);
      font-size: 11px;
      font-weight: 850;
      color: var(--muted);
    }
    .card-category {
      font-size: 11px;
      font-weight: 850;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .deck-card-title {
      font-size: 19px;
      font-weight: 900;
      letter-spacing: -0.04em;
      margin: 0 0 6px 0;
      color: var(--ink);
      line-height: 1.2;
    }
    .deck-card-desc {
      font-size: 13px;
      line-height: 1.38;
      color: var(--muted);
      margin: 0;
      font-weight: 500;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    /* Card Actions */
    .deck-card-actions {
      display: flex;
      gap: 8px;
      padding: 12px 16px 14px;
      border-top: 1.5px solid var(--line);
      background: var(--paper);
      flex-shrink: 0;
    }
    .deck-btn-primary, .deck-btn-secondary {
      flex: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 12.5px;
      font-weight: 850;
      padding: 9px 12px;
      border-radius: 9px;
      text-align: center;
      touch-action: manipulation;
      min-height: 38px;
      transition: transform 0.12s, opacity 0.12s;
    }
    .deck-btn-primary {
      background: var(--acid);
      color: #111;
      border: 1.5px solid var(--ink);
    }
    .deck-btn-primary:active { transform: scale(0.97); }
    .deck-btn-secondary {
      background: var(--ink);
      color: var(--paper);
      border: 1.5px solid var(--ink);
    }
    .deck-btn-secondary:active { transform: scale(0.97); }

    /* Deck Bottom Controls */
    .deck-controls {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 16px;
      margin-top: 12px;
      width: min(360px, calc(100vw - 28px));
    }
    .deck-arrow-btn {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      border: 2px solid var(--ink);
      background: var(--paper);
      color: var(--ink);
      font-size: 19px;
      font-weight: 900;
      cursor: pointer;
      display: grid;
      place-items: center;
      transition: background 0.12s, transform 0.12s;
      box-shadow: 0 4px 10px rgba(0,0,0,0.06);
      touch-action: manipulation;
    }
    .deck-arrow-btn:active {
      transform: scale(0.92);
      background: var(--acid);
    }
    .deck-status {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
    }
    .deck-counter {
      font-family: var(--mono);
      font-size: 14px;
      font-weight: 900;
      color: var(--ink);
      letter-spacing: 0.05em;
    }
    .deck-hint {
      font-size: 10px;
      font-weight: 800;
      color: var(--muted);
      letter-spacing: 0.03em;
      text-transform: uppercase;
    }

    /* ==================================================
       CARDS / MASONRY SECTION (DEFAULT VIEW)
       ================================================== */
    .cards-section {
      width: 100%;
    }
    .cards-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 16px;
      width: 100%;
    }
    @media (min-width: 680px) {
      .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
      }
    }
    @media (min-width: 1040px) {
      .cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 22px;
      }
    }

    .masonry-card {
      background: var(--paper);
      border: 2px solid var(--ink);
      border-radius: 16px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
      transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    }
    @media (hover: hover) {
      .masonry-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
      }
    }
    .masonry-card .card-cover {
      position: relative;
      width: 100%;
      aspect-ratio: 16 / 9;
      height: auto;
      background: #111;
      overflow: hidden;
      border-bottom: 2px solid var(--ink);
      flex-shrink: 0;
    }
    .masonry-card .cover-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      transition: transform 0.35s ease;
    }
    @media (hover: hover) {
      .masonry-card:hover .cover-img {
        transform: scale(1.025);
      }
    }
    .masonry-card .card-content {
      padding: 14px 16px 12px;
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .masonry-card .card-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 5px;
    }
    .masonry-card-title {
      font-size: 18px;
      font-weight: 900;
      letter-spacing: -0.04em;
      margin: 0 0 6px 0;
      color: var(--ink);
      line-height: 1.25;
    }
    .masonry-card-desc {
      font-size: 13px;
      line-height: 1.4;
      color: var(--muted);
      margin: 0;
      font-weight: 500;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .masonry-card-actions {
      display: flex;
      gap: 8px;
      padding: 12px 16px 14px;
      border-top: 1.5px solid var(--line);
      background: var(--paper);
      flex-shrink: 0;
    }
    .card-btn-primary, .card-btn-secondary {
      flex: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 12.5px;
      font-weight: 850;
      padding: 9px 12px;
      border-radius: 9px;
      text-align: center;
      touch-action: manipulation;
      min-height: 40px;
      transition: transform 0.12s ease, opacity 0.12s ease;
    }
    .card-btn-primary {
      background: var(--acid);
      color: #111;
      border: 1.5px solid var(--ink);
    }
    .card-btn-primary:active { transform: scale(0.97); }
    .card-btn-secondary {
      background: var(--ink);
      color: var(--paper);
      border: 1.5px solid var(--ink);
    }
    .card-btn-secondary:active { transform: scale(0.97); }

    /* ==================================================
       LIST / COMPACT SECTION (ALTERNATIVE VIEW)
       ================================================== */
    .list-section {
      width: 100%;
    }
    .controls {
      display: grid;
      gap: 9px;
      margin-bottom: 12px;
    }
    .search-box {
      position: relative;
      display: flex;
      align-items: center;
    }
    .search-box input {
      width: 100%;
      height: 42px;
      padding: 9px 34px 9px 12px;
      border: 1.5px solid var(--ink);
      border-radius: 10px;
      font-size: 14px;
      font-weight: 600;
      color: var(--ink);
      background: var(--paper);
      -webkit-appearance: none;
    }
    .search-box input:focus {
      outline: none;
      box-shadow: 0 0 0 2.5px var(--acid);
    }
    .clear-btn {
      position: absolute;
      right: 8px;
      background: var(--line);
      border: none;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      font-size: 15px;
      cursor: pointer;
      display: grid;
      place-items: center;
      color: var(--ink);
    }
    .chips {
      display: flex;
      gap: 5px;
      overflow-x: auto;
      padding-bottom: 3px;
      scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
    }
    .chips::-webkit-scrollbar { display: none; }
    .chip {
      flex-shrink: 0;
      background: var(--badge-bg);
      border: 1px solid var(--line);
      color: var(--ink);
      padding: 6px 11px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 750;
      cursor: pointer;
      touch-action: manipulation;
    }
    .chip.active {
      background: var(--ink);
      border-color: var(--ink);
      color: var(--paper);
    }
    .list {
      display: grid;
      gap: 8px;
    }
    .card {
      border: 1.5px solid var(--line);
      border-radius: 12px;
      padding: 11px 13px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      background: var(--paper);
      transition: border-color 0.15s;
    }
    .card:hover { border-color: var(--ink); }
    .card-info { min-width: 0; flex: 1; }
    .card-title-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 2px;
    }
    .card-title {
      font-size: 15.5px;
      font-weight: 900;
      letter-spacing: -0.04em;
      margin: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      color: var(--ink);
    }
    .card-badge {
      font-size: 9px;
      font-weight: 850;
      text-transform: uppercase;
      background: var(--badge-bg);
      color: var(--muted);
      padding: 1px 5px;
      border-radius: 4px;
      flex-shrink: 0;
    }
    .card-desc {
      font-size: 12.5px;
      color: var(--muted);
      margin: 0;
      line-height: 1.3;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-weight: 500;
    }
    .card-actions {
      display: flex;
      align-items: center;
      gap: 5px;
      flex-shrink: 0;
    }
    .btn-demo, .btn-code {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 850;
      padding: 6px 10px;
      border-radius: 7px;
      min-height: 32px;
      touch-action: manipulation;
    }
    .btn-demo {
      background: var(--acid);
      color: #111;
      border: 1px solid var(--ink);
    }
    .btn-code {
      background: var(--ink);
      color: var(--paper);
      border: 1px solid var(--ink);
    }
    .empty {
      text-align: center;
      padding: 30px;
      color: var(--muted);
      font-size: 14px;
      font-weight: 600;
    }

    /* Footer */
    .footer {
      border-top: 1px solid var(--line);
      padding-block: 14px 20px;
      margin-top: auto;
    }
    .footer-links {
      display: flex;
      justify-content: center;
      gap: 16px;
      font-size: 12px;
      font-weight: 750;
      color: var(--muted);
      flex-wrap: wrap;
    }
    .footer-links a:hover { color: var(--ink); }

    @media (max-width: 440px) {
      .wrap { width: calc(100% - 16px); }
      .brand { font-size: 14.5px; gap: 4px; }
      .brand-tag { font-size: 9.5px; padding: 1px 4px; }
      .header-nav { gap: 6px; }
      .view-btn { padding: 4px 7px; font-size: 10.5px; }
      .masonry-card-title { font-size: 16.5px; }
      .masonry-card-desc { font-size: 12.5px; }
      .card-btn-primary, .card-btn-secondary { font-size: 11.5px; min-height: 38px; padding: 8px 10px; }
      .deck-card-title { font-size: 17.5px; }
      .deck-card-desc { font-size: 12.5px; }
      .deck-btn-primary, .deck-btn-secondary { font-size: 11.5px; padding: 8px 10px; }
    }

    /* ==================================================
       CONFIG MODAL DRAWER & WELCOME ONBOARDING
       ================================================== */
    .nav-btn-config {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      background: var(--badge-bg);
      border: 1.5px solid var(--line);
      border-radius: 999px;
      padding: 5px 9px;
      font-size: 11.5px;
      font-weight: 800;
      color: var(--ink);
      cursor: pointer;
      transition: all 0.15s ease;
      touch-action: manipulation;
    }
    .nav-btn-config:hover {
      border-color: var(--ink);
      background: var(--paper);
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.55);
      z-index: 100;
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }
    .modal-backdrop.open {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-drawer {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      max-width: 540px;
      margin: 0 auto;
      background: var(--paper);
      border: 2px solid var(--ink);
      border-bottom: none;
      border-radius: 20px 20px 0 0;
      padding: 22px 20px 32px;
      z-index: 101;
      transform: translateY(100%);
      transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      max-height: 86vh;
      overflow-y: auto;
    }
    .modal-backdrop.open .modal-drawer {
      transform: translateY(0);
    }
    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
    }
    .modal-title {
      font-size: 17px;
      font-weight: 900;
      margin: 0;
      letter-spacing: -0.04em;
    }
    .modal-close {
      background: var(--badge-bg);
      border: none;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      font-size: 18px;
      cursor: pointer;
      display: grid;
      place-items: center;
      color: var(--ink);
    }
    .modal-section {
      margin-bottom: 16px;
    }
    .modal-label {
      display: block;
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--muted);
      margin-bottom: 8px;
    }
    .input-row {
      display: flex;
      gap: 8px;
    }
    .input-row input {
      flex: 1;
      height: 40px;
      padding: 8px 12px;
      border: 1.5px solid var(--ink);
      border-radius: 8px;
      font-size: 14px;
      font-weight: 700;
      color: var(--ink);
      background: var(--paper);
    }
    .input-row input:focus {
      outline: none;
      box-shadow: 0 0 0 2px var(--acid);
    }
    .btn-apply {
      height: 40px;
      padding: 0 16px;
      background: var(--ink);
      color: var(--paper);
      border: 1.5px solid var(--ink);
      border-radius: 8px;
      font-size: 13px;
      font-weight: 850;
      cursor: pointer;
      touch-action: manipulation;
    }
    .btn-apply:active {
      transform: scale(0.96);
    }
    .pill-group {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
    }
    .pill-btn {
      background: var(--badge-bg);
      border: 1.5px solid var(--line);
      border-radius: 8px;
      padding: 7px 12px;
      font-size: 12px;
      font-weight: 800;
      color: var(--ink);
      cursor: pointer;
      transition: all 0.15s ease;
      touch-action: manipulation;
    }
    .pill-btn.selected {
      background: var(--ink);
      color: var(--paper);
      border-color: var(--ink);
    }
    .repo-manager-box {
      max-height: 180px;
      overflow-y: auto;
      border: 1.5px solid var(--line);
      border-radius: 10px;
      padding: 8px 12px;
      background: var(--paper);
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .repo-check-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      user-select: none;
    }
    .repo-check-item input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--ink);
      cursor: pointer;
    }
    .export-row {
      display: flex;
      gap: 8px;
    }
    .btn-export {
      flex: 1;
      height: 40px;
      background: var(--badge-bg);
      border: 1.5px solid var(--line);
      border-radius: 8px;
      font-size: 12px;
      font-weight: 850;
      color: var(--ink);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      touch-action: manipulation;
      transition: all 0.15s ease;
    }
    .btn-export:hover {
      border-color: var(--ink);
      background: var(--acid);
      color: #111;
    }

    /* Welcome / Setup Card in Deck */
    .welcome-card-box {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-top: 8px;
    }
    .welcome-input-row {
      display: flex;
      gap: 8px;
    }
    .welcome-input {
      flex: 1;
      height: 40px;
      padding: 8px 12px;
      border: 1.5px solid var(--ink);
      border-radius: 8px;
      font-size: 13.5px;
      font-weight: 700;
      color: var(--ink);
      background: var(--paper);
    }
    .welcome-input:focus {
      outline: none;
      box-shadow: 0 0 0 2px var(--acid);
    }
    .welcome-btn-submit {
      height: 40px;
      padding: 0 16px;
      background: var(--acid);
      color: #111;
      border: 1.5px solid var(--ink);
      border-radius: 8px;
      font-size: 13px;
      font-weight: 900;
      cursor: pointer;
      touch-action: manipulation;
      white-space: nowrap;
    }
    .welcome-presets {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }
    .welcome-preset-label {
      font-size: 11px;
      font-weight: 800;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .welcome-preset-btn {
      background: var(--badge-bg);
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 3px 9px;
      font-size: 11px;
      font-weight: 800;
      color: var(--ink);
      cursor: pointer;
      transition: all 0.12s;
    }
    .welcome-preset-btn:hover {
      background: var(--acid);
      color: #111;
      border-color: var(--ink);
    }