@layer reset, base, components;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
}

@layer base {
  :root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --panel-muted: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #3b82f6; /* Brighter blue for light mode */
    --accent-strong: #10b981; /* Stronger green */
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background-color: var(--bg);
  }

  body {
    min-height: 100vh;
    background: radial-gradient(1200px at 20% 20%, rgba(16, 185, 129, 0.05), transparent),
      radial-gradient(900px at 80% 0%, rgba(59, 130, 246, 0.05), transparent),
      var(--bg);
    color: var(--text);
    line-height: 1.5;
  }
}

@layer components {
  .page {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 20px 72px;
  }

  .backdrop {
    position: fixed;
    inset: 0;
    background: radial-gradient(1600px at 50% 0%, rgba(255, 255, 255, 0.03), transparent);
    pointer-events: none;
    z-index: -1;
  }

  .hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
  }

  .title-row {
    display: flex;
    align-items: center;
    gap: 18px;
  }

  .emblem {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
  }

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


  h1 {
    font-size: clamp(24px, 3.5vw, 32px);
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text) 30%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .lede {
    color: var(--muted);
    max-width: 620px;
    font-size: 17px;
  }

  .header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
  }

  .card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
  }

  .action-modules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
  }

  .module-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: transform 120ms ease, box-shadow 120ms ease;
  }

  .module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.1);
  }

  .module-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    display: grid;
    place-items: center;
    margin-bottom: 16px;
  }

  .module-card h3 {
    font-size: 20px;
    margin-bottom: 8px;
    font-weight: 600;
  }

  .module-card p {
    color: var(--muted);
    font-size: 15px;
    margin-bottom: 20px;
    flex-grow: 1;
  }

  .module-card button {
    width: 100%;
  }


  .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .label {
    text-transform: uppercase;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
  }

  h2 {
    font-size: 24px;
    letter-spacing: -0.01em;
  }

  .controls {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0 16px;
  }

  .metric-tile {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--bg);
  }

  .metric-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  button {
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 12px;
    padding: 12px 16px;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
    color: var(--text);
  }

  button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  .primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0a0f18;
    box-shadow: 0 10px 30px rgba(110, 168, 255, 0.25);
  }

  .primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(110, 168, 255, 0.35);
  }

  .ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
  }

  .ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.03);
  }

  .wide {
    width: 100%;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 12px;
    font-size: 16px;
  }

  .muted {
    color: var(--muted);
    margin-bottom: 6px;
  }

  .small {
    font-size: 13px;
  }

  .rpc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
  }

  .text-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font-weight: 600;
  }

  .text-btn.muted {
    color: var(--muted);
  }

  .text-btn:hover {
    text-decoration: underline;
  }

  code {
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    font-size: 13px;
    color: var(--text);
  }

  .status {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    word-break: break-word;
  }

  .status.info {
    border-color: rgba(110, 168, 255, 0.5);
    background: rgba(110, 168, 255, 0.08);
  }

  .status.success {
    border-color: #4caf93;
    background: #e2f7f0;
    color: #0f5132;
  }

  .status.error {
    border-color: rgba(255, 107, 107, 0.7);
    background: rgba(255, 107, 107, 0.12);
    color: #ffcfcf;
  }

  .how-it-works {
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  .how-it-works h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .how-it-works ul {
    list-style: disc;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.6;
    font-size: 14px;
  }

  .features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 18px 0 28px;
  }

  .feature-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    min-height: 120px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  }

  .feature-card h4 {
    font-size: 18px;
    margin-bottom: 6px;
  }

  .feature-card p {
    color: var(--muted);
    font-size: 14px;
  }

  .footer {
    color: var(--muted);
    font-size: 14px;
  }

  .footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
  }

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

  .hidden {
    display: none !important;
  }

  /* Modal Styles */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
  }

  .modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
  }

  .modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transform: translateY(10px);
    transition: transform 200ms ease;
  }

  .modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
  }

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

  .modal-header h3 {
    font-size: 20px;
    font-weight: 600;
  }

  .icon-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    display: grid;
    place-items: center;
  }

  .icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }

  .wallet-list {
    display: grid;
    gap: 12px;
  }

  .wallet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 120ms ease;
  }

  .wallet-option:hover {
    background: #eef2f6;
    border-color: #cbd5e1;
    transform: translateY(-1px);
  }

  .wallet-status {
    font-size: 12px;
    color: var(--muted);
    font-weight: normal;
    background: var(--panel-muted);
    padding: 2px 8px;
    border-radius: 99px;
  }

  .wallet-status.detected {
    color: var(--success);
    background: rgba(51, 204, 140, 0.12);
  }

  .wallet-status.missing {
    color: var(--error);
    background: rgba(255, 107, 107, 0.12);
  }
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    flex-direction: column;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-modules {
    grid-template-columns: 1fr;
  }
}
