:root {
  --bg-obsidian: #060a12;
  --bg-surface: #0c1322;
  --bg-elevated: #121c31;
  --bg-hover: #17243e;
  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-cyan: rgba(56, 189, 248, 0.45);
  --cyan-primary: #38bdf8;
  --cyan-bright: #bae6fd;
  --cyan-glow: rgba(56, 189, 248, 0.22);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg-obsidian);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Microchip trace background matching Casper logo */
.circuit-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.14), transparent 55%),
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
}

.container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top Navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(6, 10, 18, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border-cyan);
  box-shadow: 0 0 18px var(--cyan-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #ffffff, var(--cyan-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.topbar-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pill-cyan {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan-bright);
  border: 1px solid var(--border-cyan);
}

.pill-muted {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Main Layout */
.main-content {
  padding-top: 32px;
  padding-bottom: 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.hero-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 24px;
}

.hero-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.hero-header p {
  color: var(--text-secondary);
  font-size: 0.96rem;
}

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(18, 28, 49, 0.65), rgba(12, 19, 34, 0.9));
  padding: 38px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover,
.dropzone.drag-over,
.dropzone:focus-visible {
  border-color: var(--cyan-primary);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 32px rgba(56, 189, 248, 0.16);
  outline: none;
}

.dropzone-icon img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border-cyan);
  box-shadow: 0 0 24px var(--cyan-glow);
}

.dropzone h2 {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.dropzone-hint {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

kbd {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.8rem;
  color: var(--cyan-bright);
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.quick-tags span {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* Controls Bar */
.controls-bar {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 1fr;
  gap: 20px;
  align-items: end;
}

@media (max-width: 960px) {
  .controls-bar {
    grid-template-columns: 1fr;
  }
}

.control-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

select {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--cyan-primary);
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--border-cyan);
  color: var(--text-primary);
}

.preset-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan-primary);
  color: var(--cyan-bright);
}

.lossless-lock {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lock-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
}

.lock-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Batch Toolbar */
.batch-toolbar {
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.batch-toolbar[hidden] {
  display: none;
}

.queue-summary {
  font-size: 0.95rem;
}

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

.batch-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.28);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(52, 211, 153, 0.14);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.4);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.22);
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-cyan);
}

/* Queue Cards */
.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.file-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.2s ease;
}

.file-card:hover {
  border-color: var(--border-cyan);
}

.file-card-top {
  display: flex;
  gap: 14px;
  align-items: center;
}

.thumb-box {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: repeating-conic-gradient(#121c31 0% 25%, #0c1322 0% 50%) 50% / 14px 14px;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-ext {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--cyan-bright);
  text-transform: uppercase;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-weight: 700;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-specs {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.status-line {
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-ready { color: var(--cyan-primary); }
.status-working { color: var(--warning); }
.status-done { color: var(--success); }
.status-error { color: var(--danger); }

.file-card-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.file-card-actions {
  display: flex;
  gap: 8px;
}

.file-card-actions .btn {
  flex: 1;
}

/* Formats Section */
.formats-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 26px;
}

.section-head {
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

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

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.cat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.cat-card h3 {
  font-size: 0.92rem;
  color: var(--cyan-bright);
  margin-bottom: 10px;
}

.ext-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ext-chip {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ext-chip:hover {
  border-color: var(--cyan-primary);
  color: var(--cyan-bright);
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  max-width: 780px;
  width: 92%;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-cyan);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

.modal::backdrop {
  background: rgba(3, 6, 12, 0.8);
  backdrop-filter: blur(6px);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px 22px;
  max-height: 70vh;
  overflow-y: auto;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

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

.spec-table th {
  color: var(--cyan-bright);
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 24px 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

.footer-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}


/* Extension Popularity Filter Tabs */
.section-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
}

.filter-tab {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab:hover {
  color: var(--text-primary);
}

.filter-tab.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--cyan-bright);
  box-shadow: inset 0 0 0 1px var(--border-cyan);
}

.ext-chip-rank {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-right: 4px;
  font-weight: 700;
}
