/* Global */
html, body { height: auto; min-height: 100%; overflow-y: auto !important; overflow-x: hidden; }
body { overflow-y: auto !important; }
.hidden { display: none !important; }
.topbar { display:flex; gap:8px; }
/* Main Layout */
main { 
  display:block; 
  width: 1240px;
  max-width: 90%; 
  margin: 0 auto; 
  overflow-y: visible; 
  height: auto; 
  padding-top: 60px; /* Compensation for fixed header */
  padding-bottom: 40px;
}
textarea { width: 100%; height: 40vh; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* Header & Nav */
.site-topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  height: 60px; /* Increased height */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg-titlebar);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.site-logo img { width: 32px; height: 32px; }
.site-title { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; color: var(--fg); margin-right: 24px; }
.site-nav { display: flex; gap: 4px; height: 100%; }
.topnav-item { 
  background: transparent; 
  border: none; 
  color: var(--muted); 
  padding: 0 16px; /* Increased padding */
  cursor: pointer; 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  height: 100%; /* Full height */
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
  text-decoration: none;
  border-radius: 0;
}
.topnav-item:hover { background: rgba(255,255,255,0.05); }
.topnav-item i { font-size: 18px; }

/* Active state with square background indicator */
.topnav-item.active { background: rgba(255,255,255,0.08); }
.topnav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
}

.site-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }

/* About / Hero */
.about-hero { display:flex; flex-direction: column; align-items:center; justify-content:center; gap:24px; padding:60px 20px; text-align: center; }
.about-logo { width: 120px; height: 120px; }
.about-title .name { font-size:48px; font-weight:700; margin-bottom: 16px; color: var(--fg); }
.about-title .tagline { font-size: 20px; color: var(--muted); max-width: 600px; margin: 0 auto; line-height: 1.6; }
.hero-btn.primary { background: var(--accent); color: #fff; border: none; font-size: 14px; padding: 8px 16px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; transition: all 0.2s; }
.hero-btn.primary:hover { background: var(--accent); filter: brightness(1.1); transform: translateY(-2px); }
.hero-btn.secondary { background: var(--btn-secondary-bg); color: var(--fg); border: 1px solid var(--border); }
.hero-btn.secondary:hover { background: var(--hover); transform: translateY(-2px); }
.hero-stats { margin-top: 16px; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Features */
.features { display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap:24px; padding:40px 20px; max-width: 1200px; margin: 0 auto; }
.feature-card { padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-secondary); }
.feature-card i { color: var(--accent); font-size: 32px; margin-bottom: 16px; display: block; }
.feature-card .field-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--fg); }
.feature-card .field-desc { color: var(--muted); line-height: 1.5; }

/* Download Section */
.download-section { text-align: center; padding: 20px; margin-bottom: 40px; }
.download-btn { padding: 16px 48px; font-size: 20px; border-radius: 50px; display: inline-flex; align-items: center; gap: 12px; box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3); }
.version-info { margin-top: 16px; color: var(--muted); font-size: 14px; }
.version-info span { margin: 0 8px; }

/* Item Page Specific */
.download-nav-btn {
  display: none; /* Deprecated */
}

/* Modal */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg-modal); color: var(--fg); padding: 32px; border-radius: 16px; width: 90%; max-width: 520px; box-shadow: 0 12px 24px rgba(0,0,0,0.35); border: 1px solid var(--border); }
.modal-header, .download-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.download-title { font-size: 24px; font-weight: 600; color: var(--fg); margin: 0; line-height: 1.2; }
.download-subtitle { font-size: 13px; color: var(--muted); margin-top: 6px; display: block; font-weight: normal; }
.modal-close { cursor: pointer; padding: 8px; border-radius: 50%; transition: background 0.2s; color: var(--muted); margin-top: -8px; margin-right: -8px; }
.modal-close:hover { background: var(--hover); color: var(--fg); }
.platform-options { display: grid; gap: 16px; }
.platform-btn { display: flex; align-items: center; padding: 20px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; text-align: left; background: transparent; width: 100%; transition: all 0.2s; }
.platform-btn:hover { border-color: var(--accent); background: var(--active); }
.platform-btn i { font-size: 32px; margin-right: 16px; }
.platform-info { flex: 1; }
.platform-name { font-weight: 600; font-size: 18px; display: block; margin-bottom: 4px; color: var(--fg); }
.platform-meta { font-size: 13px; color: var(--muted); }

/* Changelog */
.changelog-section { max-width: 1200px; margin: 40px auto; padding: 0 20px; }
.changelog-list .item { padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-secondary); margin-bottom: 12px; }
.changelog-list .item .muted { color: var(--muted); }

.chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.store-tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.store-tabs .sub-item {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 24px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
  border-radius: 8px 8px 0 0;
}
.store-tabs .sub-item:hover { color: var(--fg); background: var(--hover); }
.store-tabs .sub-item.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--active); }
.store-tabs .sub-item i { margin-right: 6px; }

/* Showcase Card */
.showcase-card {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 16px;
  border: 1px solid var(--border);
  transition: transform 0.2s;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.showcase-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.showcase-icon-box {
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.showcase-icon { font-size: 32px; color: var(--fg); margin: 0; }

/* Markdown Styles */
.markdown-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--fg);
}
.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown-body p { margin-top: 0; margin-bottom: 16px; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 16px; }
.markdown-body code {
  padding: .2em .4em;
  margin: 0;
  font-size: 85%;
  background-color: var(--btn-secondary-bg);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
}
.markdown-body pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.markdown-body pre code { background-color: transparent; padding: 0; border: none; }
.markdown-body blockquote {
  padding: 0 1em;
  color: var(--muted);
  border-left: .25em solid var(--border);
  margin: 0 0 16px 0;
}
.markdown-body img { max-width: 100%; box-sizing: content-box; }
.markdown-body table { border-spacing: 0; border-collapse: collapse; margin-bottom: 16px; width: 100%; }
.markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid var(--border); }
.markdown-body table tr { background-color: var(--bg-secondary); border-top: 1px solid var(--border); }
.markdown-body table tr:nth-child(2n) { background-color: var(--bg); }

/* Mobile Responsive */
@media (max-width: 768px) {
  .site-title { display: none; }
  .site-logo { margin-right: 0; }
  .site-nav { margin-left: auto; gap: 4px; }
  
  .topnav-item { padding: 0 12px; }
  .topnav-item span { display: none; }
  .topnav-item i { font-size: 22px; margin: 0; }
  
  /* Reset active indicator to bottom */
  .topnav-item.active::after { bottom: 0; }
  
  #download-btn-top { padding: 8px; width: 40px; height: 40px; display:flex; align-items:center; justify-content:center; }
  #download-btn-top span { display: none; }
  #download-btn-top i { font-size: 20px; margin: 0; }
  
  .site-actions .btn { padding: 8px; }
  .site-actions .btn span { display: none; }
  .site-actions .btn i { margin: 0; font-size: 18px; }
  
  .store-panel { grid-template-columns: 1fr; }
  .store-left { display: none; }
  
  .store-tabs { flex-wrap: wrap; }
  .tabs-right { width: 100%; margin: 0 !important; margin-top: 8px !important; display:flex; }
  #market-search-input { flex: 1; }
  
  .about-title .name { font-size: 32px; }
  .about-title .tagline { font-size: 16px; }
  
  .features { grid-template-columns: 1fr; }
  
  /* Fix Home Hero Buttons Overlap */
  .about-hero .hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 280px;
  }
  .hero-btn { width: 100%; justify-content: center; }
  
  /* Fix Store Tabs Text */
  .store-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding-bottom: 4px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
  }
  .store-tabs .sub-item {
    flex-shrink: 0;
    padding: 10px 16px;
  }
  
  /* Fix Docs Sidebar */
  /* Mobile: Floating Sidebar */
  #client-docs-sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: -280px;
    width: 260px;
    background: var(--bg-modal);
    z-index: 1000;
    transition: left 0.3s ease;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 12px rgba(0,0,0,0.5);
  }
  #client-docs-sidebar.active { left: 0; }
  
  .docs-mobile-toggle {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: none;
    font-size: 24px;
  }
  
  /* Overlay */
  .docs-overlay {
    position: fixed;
    top: 60px; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .docs-overlay.active { opacity: 1; pointer-events: auto; }
  
  .docs-layout { flex-direction: row; height: auto; }
  .docs-list { max-height: none; }
  .docs-main { height: auto; min-height: 400px; }
  
}