:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #e2e8f0;
  --border-focus: #3b82f6;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --primary-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);

  --accent: #10b981;
  --accent-subtle: #ecfdf5;
  --accent-text: #059669;

  --amber: #f59e0b;
  --amber-subtle: #fffbeb;
  --amber-text: #d97706;

  --danger: #ef4444;
  --danger-subtle: #fef2f2;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --topbar-height: 56px;
  --tabbar-height: 60px;
}

[data-theme="dark"] {
  --bg: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --bg-subtle: #1a2234;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --border: #1e293b;
  --border-focus: #60a5fa;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: rgba(59, 130, 246, 0.12);
  --primary-gradient: linear-gradient(135deg, #172554 0%, #1d4ed8 100%);

  --accent: #34d399;
  --accent-subtle: rgba(52, 211, 153, 0.12);
  --accent-text: #34d399;

  --amber: #fbbf24;
  --amber-subtle: rgba(251, 191, 36, 0.12);
  --amber-text: #fbbf24;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
#app {
  max-width: 768px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: calc(var(--tabbar-height) + 24px + env(safe-area-inset-bottom));
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s, border-color 0.2s;
}

[data-theme="dark"] .topbar {
  background: rgba(17, 24, 39, 0.85);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.logo {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.brand-text-col {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brandtxt {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.badge-free {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-top: 2px;
  width: fit-content;
}

.spacer {
  flex: 1;
}

.iconbtn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.iconbtn svg {
  width: 18px;
  height: 18px;
}

.iconbtn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--primary);
}

.user-pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.user-avatar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Prototype Quick Bar */
.proto-quick-bar {
  background: linear-gradient(90deg, #1e293b, #0f172a);
  color: #f8fafc;
  padding: 7px 16px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.proto-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.proto-tag {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 11px;
}

.proto-desc {
  flex: 1;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proto-actions {
  display: flex;
  gap: 6px;
}

.btn-micro {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.12s;
}

.btn-micro:hover {
  background: rgba(255, 255, 255, 0.24);
}

.btn-micro.primary {
  background: var(--primary);
  border-color: var(--primary);
}

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

/* Main View */
.view {
  flex: 1;
  padding: 16px;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Bottom Tabbar - Clean Line SVG Icons Only */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  max-width: 768px;
  margin: 0 auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.tab-item {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  transition: color 0.15s ease;
}

.tab-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.9;
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.tab-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.tab-item.active {
  color: var(--primary);
}

.tab-item.active .tab-icon {
  transform: translateY(-1px);
}

.tab-item.active .tab-label {
  font-weight: 700;
}

.tab-item.active .tab-dot {
  background: var(--primary);
  transform: scale(1.2);
}

.tab-item:active {
  transform: scale(0.96);
}

/* Hero Card */
.hero {
  background: var(--primary-gradient);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.hero h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.hero p {
  margin: 4px 0 0;
  opacity: 0.9;
  font-size: 13.5px;
  line-height: 1.5;
}

.user-status-tag {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.user-status-tag .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
}

.progress-box {
  margin-top: 18px;
  background: rgba(0, 0, 0, 0.15);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #34d399, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
  opacity: 0.95;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 4px 10px;
}

.section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.section-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   AD PLACEMENT CARDS (Clean, Standard Mobile Ads with Switch Support)
   ========================================================================== */
.ad-slot-wrapper {
  margin: 14px 0;
  animation: fadeIn 0.3s ease;
}

.ad-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
  overflow: hidden;
}

.ad-card:hover {
  border-color: var(--amber);
  box-shadow: var(--shadow-md);
}

.ad-card-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04), rgba(245, 158, 11, 0.04));
  border-left: 4px solid var(--amber);
}

.ad-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ad-sponsor-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ad-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--amber-text);
  background: var(--amber-subtle);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.3px;
}

.ad-advertiser {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.ad-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  line-height: 1;
}

.ad-dismiss-btn:hover {
  color: var(--text-main);
}

.ad-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ad-card-text {
  flex: 1;
  min-width: 0;
}

.ad-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 2px;
}

.ad-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.ad-cta-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
  text-decoration: none;
}

.ad-cta-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Chapter List */
.chlist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.chitem:active {
  transform: scale(0.99);
}

.chitem .no {
  flex: 0 0 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13.5px;
  border: 1px solid var(--border);
}

.chitem .tx {
  flex: 1;
  min-width: 0;
}

.chitem .tx b {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chitem-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chitem-tag {
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-size: 11px;
}

.chitem-status {
  font-size: 11px;
  font-weight: 600;
}

.chitem-status.read {
  color: var(--accent-text);
}

.chitem .ar {
  color: var(--text-subtle);
  display: flex;
  align-items: center;
}

.chitem .ar svg {
  width: 18px;
  height: 18px;
}

/* Chapter Detail / Article View */
.ch-head {
  margin-bottom: 12px;
}

.ch-head h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 8px 0 4px;
  line-height: 1.35;
  color: var(--text-main);
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 2px 9px;
  border-radius: var(--radius-full);
}

.article {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  line-height: 1.75;
}

.article h3 {
  font-size: 16.5px;
  font-weight: 800;
  margin: 22px 0 10px;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
  line-height: 1.4;
  color: var(--text-main);
}

.article h4 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 16px 0 6px;
  color: var(--primary);
}

.article p {
  margin: 12px 0;
  color: var(--text-secondary);
}

.article ul, .article ol {
  margin: 10px 0;
  padding-left: 22px;
  color: var(--text-secondary);
}

.article li {
  margin: 6px 0;
}

.article strong {
  color: var(--text-main);
  font-weight: 700;
}

.article code {
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #db2777;
}

.article pre {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--border);
}

.article pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.article blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--primary);
  background: var(--primary-subtle);
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: normal;
}

.article hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}

.article th, .article td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.article th {
  background: var(--bg-subtle);
  font-weight: 700;
}

.article a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.navrow {
  display: flex;
  gap: 10px;
  margin: 16px 0 6px;
}

.navrow button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
}

.navrow button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.navrow button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Plan View */
.plan-header-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.plan-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.plan-nums {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.plan-pct-badge {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-subtle);
  color: var(--accent-text);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.plan-filter-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.plan-filter-tab {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.plan-filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.week:hover {
  border-color: var(--border-focus);
}

.week.done {
  background: var(--accent-subtle);
  border-color: rgba(16, 185, 129, 0.3);
}

.check {
  flex: 0 0 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 2px;
  color: transparent;
  transition: all 0.15s ease;
}

.check svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.week.done .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.week .body {
  flex: 1;
  min-width: 0;
}

.week .wk {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.week .wk b {
  font-size: 13.5px;
  color: var(--primary);
}

.week .phase {
  font-size: 11px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.week .hrs {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: auto;
}

.week .task {
  font-size: 14px;
  margin: 5px 0 6px;
  line-height: 1.45;
  color: var(--text-main);
}

.week.done .task {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(16, 185, 129, 0.7);
}

.week .links a {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.week .links a:hover {
  text-decoration: underline;
}

/* Glossary View */
.search-box {
  position: sticky;
  top: 56px;
  z-index: 20;
  padding: 4px 0 10px;
  background: var(--bg);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon-inside {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 11px 14px 11px 38px;
  font-size: 14.5px;
  color: var(--text-main);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}

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

.seg-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.seg-pills button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.seg-pills button.on {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.gitem {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 9px;
  box-shadow: var(--shadow-sm);
}

.gitem .t {
  font-weight: 800;
  font-size: 15px;
  color: var(--text-main);
}

.gitem .d {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.gitem .a {
  font-size: 12.5px;
  color: var(--accent-text);
  background: var(--accent-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  line-height: 1.4;
}

/* ==========================================================================
   ADMIN MANAGEMENT BACKEND VIEW (Switch Controls, Users, Analytics, Prototype)
   ========================================================================== */
.admin-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.admin-header {
  margin-bottom: 14px;
}

.admin-header h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px;
}

.admin-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.admin-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.admin-nav-btn.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary);
}

/* iOS Style Switch */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: var(--border);
  border-radius: 9999px;
  transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.switch-input:checked + .switch-slider {
  background-color: var(--accent);
}

.switch-input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch-text {
  font-size: 12.5px;
  font-weight: 700;
}

/* Ad Admin List */
.admin-ad-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-subtle);
}

.admin-ad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-ad-title-col {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-ad-key {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.admin-ad-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.admin-ad-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* User Admin Table */
.user-table-wrap {
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.user-table th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
}

.user-cell-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

/* Stats Overview Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stat-box-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  margin: 4px 0 2px;
}

.stat-box-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==========================================================================
   PROTOTYPE & SPECIFICATION VIEWS
   ========================================================================== */
.proto-spec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.proto-spec-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 10px;
  color: var(--primary);
}

.proto-diagram {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

/* Modals */
.modal-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* Form Controls */
.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  padding: 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.15s;
}

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

.btn-secondary {
  width: 100%;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

/* Toast Message */
.toast-msg {
  position: fixed;
  bottom: calc(var(--tabbar-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 120;
  pointer-events: none;
  animation: fadeIn 0.2s ease;
}
