 @import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  :root {
    --bg-dark: #0A0C10;
    --card-bg: #13161F;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --text-primary: #F0F3FA;
    --text-muted: #868E9E;
    --accent-blue: #009ef6;
    --accent-cyan: #00D4FF;
    --modal-white: #FFFFFF;
    --modal-gray-bg: #F8F9FE;
    --modal-border: #EFF2F9;
    --toast-bg: #1E2638;
    --error-red: #ef4444;
  }

/* MODAL */
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
  }

  .overlay.active {
    display: flex;
  }

  .modal-window {
    background: var(--modal-white);
    border-radius: 2rem;
    width: calc(100% - 2rem);
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
  }

  @keyframes modalPop {
    from { opacity: 0; transform: scale(0.96) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
  }

  .modal-screen {
    display: none;
    padding: 1.8rem 1.8rem 2.2rem;
  }

  .modal-screen.active-screen {
    display: block;
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.6rem;
  }

  .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.3px;
  }

  .modal-close, .modal-back-btn {
    background: #F1F5F9;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    transition: all 0.2s;
  }

  .modal-close:hover, .modal-back-btn:hover {
    background: #E2E8F0;
    color: #0F172A;
  }

  /* Terms box */
  .terms-container {
    background: var(--modal-gray-bg);
    border-radius: 1.2rem;
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.8rem;
    border: 1px solid transparent;
    transition: none;
    min-height: 70px;
  }

  .terms-container.accepted-terms {
    border-color: transparent;
    background: var(--modal-gray-bg);
  }

  .checkbox-custom {
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid #CBD5E1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.1s;
  }

  .checkbox-custom.checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
  }

  .checkbox-custom.checked::after {
    content: '✓';
    font-size: 13px;
    color: white;
    font-weight: bold;
  }

  .terms-text {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.45;
    flex: 1;
  }

  .terms-text a {
    color: var(--accent-blue);
    text-decoration: none;
  }

  .terms-text a:hover {
    text-decoration: underline;
  }

  .wallet-section-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    color: #1E293B;
    font-family: 'Syne', sans-serif;
  }

  /* Search Bar */
  .wallet-search-bar {
    margin-bottom: 1rem;
    padding: 8px 12px;
    border: 1px solid #E9EEF5;
    border-radius: 12px;
    background: white;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .wallet-search-bar input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    font-family: inherit;
  }

  .wallet-search-bar svg {
    opacity: 0.5;
    flex-shrink: 0;
  }

  .wallets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
    margin-bottom: 1.3rem;
  }

  .wallets-grid.expanded {
    grid-template-columns: 1fr;
    max-height: 400px;
    overflow-y: auto;
  }

  @media (max-width: 480px) {
    .wallets-grid {
      grid-template-columns: 1fr;
    }
    .wallets-grid.expanded {
      grid-template-columns: 1fr;
    }
  }

  .wallet-item {
    background: var(--modal-gray-bg);
    border: 1px solid #E9EEF5;
    border-radius: 1rem;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    cursor: pointer;
    transition: all 0.18s;
    position: relative;
  }

  .wallet-item.disabled-wallet {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.1);
  }

  .wallet-item:not(.disabled-wallet):hover {
    background: #EEF4FF;
    border-color: rgba(0, 158, 246, 0.4);
    transform: translateY(-1px);
  }

  .wallet-icon-bg {
    width: 42px;
    height: 42px;
    background: #EFF3F8;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
  }

  .wallet-icon-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
  }

  .browser-wallet-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .browser-wallet-icon svg {
    width: 100%;
    height: 100%;
  }

  .wallet-name {
    font-weight: 300;
    font-size: 0.9rem;
    color: #0F172A;
  }

  .more-wallets {
    text-align: center;
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid #E9EEF5;
    font-size: 0.85rem;
    color: var(--accent-blue);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .more-wallets img {
    width: 17px;
    height: 17px;
  }

  /* LOADER STYLES */
  .cwl-wallet-selected {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    min-height: 450px;
  }

  .cwl-top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 22px;
  }

  .cwl-top-bar p {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-blue);
    transition: color 0.2s ease;
    margin: 0;
  }

  .cwl-top-bar p:hover {
    color: #007acc;
  }

  .cwl-wallet-loader {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cwl-wallet-loader img {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    object-fit: cover;
    z-index: 2;
    background: #fff;
  }

  .cwl-loader-svg {
    position: absolute;
    width: 90px;
    height: 90px;
    transform: rotate(-90deg);
  }

  .cwl-loader-rect {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 60 300;
    animation: cwlMoveStroke 1.6s linear infinite;
  }

  @keyframes cwlMoveStroke {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -360; }
  }

  .cwl-loading-text {
    font-size: 14px;
    color: #6b7280;
  }

  .cwl-loading-text span.cwl-dots::after {
    content: '';
    display: inline-block;
    width: 1ch;
    text-align: left;
    animation: cwlLoadingDots 1s steps(3, end) infinite;
  }

  @keyframes cwlLoadingDots {
    0%,20%{content:''}
    40%{content:'.'}
    60%{content:'..'}
    80%,100%{content:'...'}
  }

  /* Connection Failed Screen */
  .cwl-wallet-failed {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 450px;
    position: relative;
  }

  .cwl-failure-img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: #fff5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    color: #ef4444;
    margin-bottom: 20px;
    border: 2px solid #fca5a5;
    animation: cwlPulseRed 1.5s infinite ease-in-out;
  }

  @keyframes cwlPulseRed {
    0%,100%{transform:scale(1);opacity:1}
    50%{transform:scale(1.05);opacity:0.75}
  }

  .cwl-failure-text {
    font-weight: 600;
    color: #ef4444;
    margin-bottom: 12px;
  }

  .cwl-error-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(239,68,68,0.2);
    border-radius: 2px;
    margin-top: 18px;
    overflow: hidden;
  }

  .cwl-error-progress-fill {
    height: 100%;
    width: 100%;
    background: #ef4444;
    border-radius: 2px;
    animation: cwlShrinkBar 2s linear forwards;
    transform-origin: left;
  }

  @keyframes cwlShrinkBar {
    from{transform:scaleX(1)}
    to{transform:scaleX(0)}
  }

  /* Restore Wallet Screen */
  .cwl-restore-wallet {
    overflow-y: auto;
  }

  .cwl-option {
    cursor: pointer;
    font-weight: 600;
    margin: 0;
    transition: color 0.2s;
  }

  .cwl-option.cwl-selected {
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 2px;
  }

  .cwl-textarea {
    font-family: inherit;
    font-size: 14px;
    resize: none;
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #cfd5e3;
    outline: none;
    background: #fff;
    color: #1f2937;
  }

  /* Failed Notification - Slides from TOP of the webpage */
  .cwl-failed-notification {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 14px 22px;
    border-radius: 10px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    font-size: 14px;
    z-index: 99999;
    font-family: 'DM Sans', system-ui, sans-serif;
    transition: top 0.3s ease-in-out;
    pointer-events: none;
    white-space: nowrap;
  }

  .cwl-failed-notification.show {
    top: 20px;
  }

  /* Loading Overlay */
  #cwl-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  #cwl-loading-overlay.cwl-show {
    opacity: 1;
    pointer-events: all;
  }

  #cwl-loading-overlay .cwl-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cwlSpin 1s linear infinite;
  }

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

  /* Toast */
  #cwl-toast {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #1f2937;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 99999;
    transition: top 0.4s ease;
    font-size: 15px;
    font-weight: 500;
    font-family: 'DM Sans', system-ui, sans-serif;
  }

  #cwl-toast.cwl-show {
    top: 20px;
  }

  #cwl-toast .cwl-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fee;
    color: #ef4444;
    font-size: 18px;
    font-weight: bold;
  }

  /* All Wallets Grid */
  .all-wallets-view {
    height: 100%;
  }

  .all-wallets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }

  .search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F1F3F7;
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 16px;
  }

  .search-row input {
    background: none;
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    font-family: inherit;
  }

  .wallets-grid-all {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
  }

  .wallet-card {
    background: #F8F9FB;
    border-radius: 16px;
    padding: 14px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid transparent;
  }

  .wallet-card:hover {
    background: #EEF2FF;
    border-color: rgba(0, 158, 246, 0.3);
    transform: translateY(-2px);
  }

  .wallet-card-img {
    width: 56px;
    height: 56px;
    background: #EFF3F8;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .wallet-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
  }

  .wallet-card p {
    margin: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: #374151;
    text-align: center;
  }

  #cwl-proceed-btn {
    background: var(--accent-blue) !important;
  }

  #cwl-proceed-btn:hover {
    background: #007acc !important;
  }

  /* Mobile specific adjustments */
  @media (max-width: 600px) {
    .cwl-failed-notification {
      padding: 12px 18px;
      font-size: 13px;
      white-space: nowrap;
    }
    
    .cwl-failed-notification.show {
      top: 15px;
    }
  }