:root {
  /* Default: Eye-friendly Light Mode */
  --bg-body: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f8fafc;
  --bg-hover: #eff4ff;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #059669;
  --success-soft: #d1fae5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-surface: #131c31;
  --bg-surface-alt: #1a2540;
  --bg-hover: #1e293b;
  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #23304d;
  --border-strong: #334155;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.18);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.18);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.18);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Top Navbar */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.top-nav-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.brand-text h1 span.tld {
  color: var(--primary);
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Top Menu Tabs */
.top-menu-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.top-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.top-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.top-menu-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Search Box */
.top-search {
  flex: 1;
  max-width: 390px;
  min-width: 220px;
  position: relative;
}

.top-search input {
  width: 100%;
  padding: 0.55rem 0.9rem 0.55rem 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.top-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.top-search .search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Right Controls */
.top-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pill-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}

.pill-btn:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s;
}

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

.btn-secondary {
  background: var(--bg-surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* 3-Column Workspace Layout */
.workspace-grid {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1240px) {
  .workspace-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .sidebar-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Sidebars */
.panel-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.45rem;
  padding-left: 0.4rem;
}

.sidebar-section-title:first-child {
  margin-top: 0;
}

.side-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.side-nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  transition: all 0.12s;
}

.side-nav-item:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

.side-nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.side-nav-item.sub-device {
  padding-left: 1.45rem;
  font-size: 0.82rem;
}

.nav-count {
  font-size: 0.73rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Center Header Banner */
.section-header-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-header-card h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.section-header-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* App Cards Grid (Boxes on Home Page) */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.1rem;
}

.app-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative;
}

.app-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.app-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}

.app-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.app-title-area {
  flex: 1;
  min-width: 0;
}

.app-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.app-title-row h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
}

.app-title-row h3:hover {
  color: var(--primary);
}

.version-pill {
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.version-count-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.app-subtitle {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Platform & Sub-Device Badges */
.platform-badges-area {
  margin: 0.55rem 0 0.9rem;
  padding: 0.65rem;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.platform-badges-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: block;
}

.platform-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.2rem 0.52rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
}

.platform-badge.plat-windows {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.08);
}

.platform-badge.plat-linux {
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.08);
}

.platform-badge.plat-android-phone,
.platform-badge.plat-android-tablet {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.09);
}

.platform-badge.plat-android-tv,
.platform-badge.plat-google-tv {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.1);
}

.platform-badge.plat-ios,
.platform-badge.plat-macos {
  border-color: rgba(100, 116, 139, 0.4);
  background: rgba(100, 116, 139, 0.1);
}

/* App Card Footer & Sentiment Bar */
.app-card-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.sentiment-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sent-pos {
  color: var(--success);
  background: var(--success-soft);
  padding: 0.14rem 0.48rem;
  border-radius: 6px;
  font-weight: 700;
}

.sent-neg {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 0.14rem 0.48rem;
  border-radius: 6px;
  font-weight: 700;
}

.app-card-actions {
  display: flex;
  gap: 0.5rem;
}

.app-card-actions button {
  flex: 1;
  justify-content: center;
}

/* Right Sidebar Feedback Stream */
.feedback-mini-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.feedback-mini-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.feedback-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.feedback-mini-app {
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
}

.feedback-mini-comment {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 0.25rem 0 0.4rem;
}

.feedback-mini-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Google AdSense Slot Component */
.ad-slot-box {
  border: 1px dashed var(--border-strong);
  background: var(--bg-surface-alt);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  text-align: center;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.ad-slot-box strong {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

/* App Detail & Version History View */
.detail-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.version-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.version-item {
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.version-item.latest {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.version-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.version-changelog {
  white-space: pre-line;
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-left: 0.2rem;
}

.version-platform-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border-color);
}

/* Forms & Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.form-group {
  margin-bottom: 0.9rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-size: 0.88rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.45rem;
  padding: 0.65rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
}

/* OAuth Social Buttons */
.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.oauth-btn {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: all 0.15s;
}

.oauth-btn:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}
