:root {
    --bg: #0b0e11;
    --bg-card: #151a21;
    --bg-hover: #1c232d;
    --border: #2a3340;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --danger: #ef4444;
    --accent: #a78bfa;
    --radius: 12px;
    --font: 'Inter', system-ui, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 32px;
    padding: 0 8px;
}

.logo-icon {
    font-size: 1.6rem;
}

.logo .fun {
    color: var(--primary);
}

.nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
}

.stat-box {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.disclaimer {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
}

/* Main */
.main {
    flex: 1;
    margin-left: 220px;
    padding: 24px 32px;
    max-width: 1400px;
}

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

.search-form {
    display: flex;
    flex: 1;
    max-width: 420px;
}

.search-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 0 14px;
    cursor: pointer;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-lg {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
}

.btn-buy {
    background: var(--primary);
    color: #000;
    flex: 1;
}

.btn-sell {
    background: var(--danger);
    color: #fff;
    flex: 1;
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.filter-chip:hover,
.filter-chip.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

/* Content grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.section-title {
    font-size: 1.25rem;
    margin-bottom: 16px;
    font-weight: 700;
}

/* Coin grid */
.coin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.coin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: all 0.15s;
    display: flex;
    gap: 12px;
}

.coin-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    background: var(--bg-hover);
}

.coin-img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
}

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

.placeholder-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #22c55e33, #a78bfa33);
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary);
}

.placeholder-img.large {
    width: 80px;
    height: 80px;
    font-size: 1.5rem;
    border-radius: 50%;
}

.coin-info {
    flex: 1;
    min-width: 0;
}

.coin-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ticker {
    font-weight: 700;
    font-size: 0.95rem;
}

.badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.badge.graduated {
    background: #22c55e33;
    color: var(--primary);
}

.badge.buy {
    background: #22c55e33;
    color: var(--primary);
}

.badge.sell {
    background: #ef444433;
    color: var(--danger);
}

.coin-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coin-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.price {
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 4px;
    color: var(--primary);
}

/* Activity */
.activity-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    height: fit-content;
    position: sticky;
    top: 24px;
}

.activity-panel h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.activity-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-msg {
    margin-bottom: 2px;
}

.activity-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

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

.small {
    font-size: 0.8rem;
}

/* Create page */
.create-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    max-width: 900px;
}

.create-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.create-intro {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.create-form .form-group {
    margin-bottom: 16px;
}

.create-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.create-form input,
.create-form textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.create-form input:focus,
.create-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.create-form small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.create-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    height: fit-content;
}

.create-info h3 {
    margin-bottom: 12px;
}

.create-info ul {
    list-style: none;
}

.create-info li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.create-info li strong {
    color: var(--text);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-error {
    background: #ef444422;
    border: 1px solid var(--danger);
    color: #fca5a5;
}

.alert-success {
    background: #22c55e22;
    border: 1px solid var(--primary);
    color: #86efac;
}

/* Coin detail */
.coin-title-bar {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.ticker-lg {
    font-size: 1.4rem;
    font-weight: 800;
}

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

.coin-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

.coin-hero {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.coin-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

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

.coin-hero h1 {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.coin-desc {
    color: var(--text-muted);
    margin-bottom: 8px;
    max-width: 500px;
}

.meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.social-links a {
    display: inline-block;
    margin-right: 12px;
    color: var(--accent);
    font-size: 0.9rem;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
}

.stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat .stat-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.progress-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 24px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.progress-bar {
    height: 10px;
    background: var(--bg);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #86efac);
    border-radius: 5px;
    transition: width 0.3s;
}

.chart-placeholder {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 24px;
}

.chart-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.trades-section h3 {
    margin-bottom: 12px;
}

.trades-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.trades-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trades-table th,
.trades-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.trades-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 500;
}

.trades-table tr:last-child td {
    border-bottom: none;
}

/* Trade panel */
.trade-panel {
    position: sticky;
    top: 24px;
    height: fit-content;
}

.trade-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.trade-card h3 {
    margin-bottom: 4px;
}

.trade-form .form-group {
    margin-bottom: 14px;
}

.trade-form label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.trade-form input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 1rem;
}

.trade-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.trade-info {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.info-row span:last-child {
    color: var(--text);
    font-weight: 500;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state a {
    color: var(--primary);
}

/* Responsive */


/* ===== Solana Wallet UI ===== */
.wallet-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#network-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

#wallet-address {
  font-family: monospace;
  font-size: 0.85rem;
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

#wallet-balance {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

.btn-wallet {
  background: linear-gradient(135deg, #9945FF, #14F195);
  color: #000;
  font-weight: 700;
  border: none;
}

.btn-wallet:hover {
  opacity: 0.9;
}

.onchain-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #14F19522;
  color: #14F195;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.mint-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
  font-family: monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.mint-box a {
  color: var(--accent);
}

.network-warning {
  background: #f59e0b22;
  border: 1px solid #f59e0b;
  color: #fbbf24;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* Live ticker */
.ticker-bar {
  background: #0d1117;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  font-size: 0.8rem;
  color: var(--text-muted);
  height: 32px;
  display: flex;
  align-items: center;
}
.ticker-inner {
  display: flex;
  gap: 16px;
  padding: 0 24px;
  white-space: nowrap;
  animation: ticker-scroll 40s linear infinite;
}
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-30%); }
}
.live-dot {
  color: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* King of the Hill */
.koth-banner {
  display: block;
  background: linear-gradient(135deg, #1a1f2e 0%, #0f172a 50%, #1a2e1a 100%);
  border: 1px solid #22c55e55;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.koth-banner:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.koth-crown {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 10px;
}
.koth-body {
  display: flex;
  align-items: center;
  gap: 16px;
}
.koth-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
}
.koth-ticker {
  font-weight: 800;
  font-size: 1.1rem;
}
.koth-name {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.koth-stats {
  margin-left: auto;
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}
.koth-progress {
  margin-top: 12px;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.koth-progress > div {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  border-radius: 3px;
}

/* Mini progress on cards */
.mini-progress {
  margin-top: 8px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.mini-progress > div {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}

.app {
  /* account for ticker */
}
body {
  /* ticker is above app */
}

/* ========== Mobile-first phone optimization ========== */
.mobile-nav {
  display: none;
}

@media (max-width: 900px) {
  .ticker-bar {
    height: 28px;
    font-size: 0.7rem;
  }
  .ticker-inner {
    animation-duration: 25s;
    padding: 0 12px;
    gap: 12px;
  }

  /* Hide desktop sidebar; use bottom nav */
  .sidebar {
    display: none !important;
  }
  .main {
    margin-left: 0 !important;
    padding: 12px 12px 88px !important;
    max-width: 100%;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(21, 26, 33, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
  }
  .mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 10px;
    min-height: 48px;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav a span.icon {
    font-size: 1.25rem;
    line-height: 1;
  }
  .mobile-nav a.active,
  .mobile-nav a:active {
    color: var(--primary);
    background: #22c55e18;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .search-form {
    max-width: none;
    width: 100%;
  }
  .search-input {
    font-size: 16px; /* prevents iOS zoom */
    min-height: 44px;
  }
  .wallet-bar {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .wallet-bar .btn,
  .wallet-bar select {
    min-height: 40px;
    font-size: 0.85rem;
  }
  #wallet-connect, #wallet-disconnect {
    flex: 1;
    min-width: 120px;
  }
  .btn-primary {
    min-height: 44px;
  }

  .filters {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .filter-chip {
    flex-shrink: 0;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .content-grid,
  .coin-detail-grid,
  .create-container {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .coin-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }
  .coin-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    gap: 8px;
  }
  .coin-img {
    width: 44px;
    height: 44px;
  }
  .coin-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .activity-panel,
  .trade-panel {
    position: static !important;
  }
  .activity-panel {
    order: 2;
  }

  .koth-banner {
    padding: 12px 14px;
  }
  .koth-body {
    flex-wrap: wrap;
    gap: 10px;
  }
  .koth-stats {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }
  .stat {
    padding: 10px;
  }
  .stat .stat-value {
    font-size: 1rem;
  }

  .coin-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .coin-hero h1 {
    font-size: 1.4rem;
  }
  .trade-buttons {
    flex-direction: column;
  }
  .trade-buttons .btn {
    width: 100%;
    min-height: 48px;
  }
  .form-row {
    grid-template-columns: 1fr !important;
  }
  .create-form input,
  .create-form textarea,
  .trade-form input {
    font-size: 16px;
    min-height: 44px;
  }
  .btn-lg {
    min-height: 48px;
  }

  .coin-title-bar {
    flex-wrap: wrap;
  }
  .ticker-lg {
    font-size: 1.15rem;
  }

  .trades-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .trades-table table {
    min-width: 480px;
  }

  .section-title {
    font-size: 1.05rem;
  }
}

@media (max-width: 420px) {
  .coin-grid {
    grid-template-columns: 1fr !important;
  }
  .wallet-bar select {
    width: 100%;
  }
}

/* Touch feedback */
@media (hover: none) {
  .coin-card:active {
    border-color: var(--primary);
    transform: scale(0.98);
  }
  .btn:active {
    opacity: 0.85;
  }
}


/* Orbit brand */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}
.logo-text {
  background: linear-gradient(90deg, #e2e8f0, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo .fun { color: var(--primary); }

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
  border: none !important;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover {
  filter: brightness(1.08);
}

.live-dot { color: #a78bfa !important; }
.mini-progress > div {
  background: linear-gradient(90deg, #8b5cf6, #06b6d4) !important;
}
.koth-progress > div {
  background: linear-gradient(90deg, #8b5cf6, #06b6d4) !important;
}
.filter-chip.active {
  background: #8b5cf622 !important;
  border-color: #8b5cf6 !important;
  color: #c4b5fd !important;
}
.nav-item.active {
  color: #c4b5fd !important;
  background: #8b5cf618 !important;
}
