:root {
  /* Surface & Background */
  --bg-primary: #f8fafc;        /* Slate 50 */
  --bg-surface: #ffffff;        /* Pure White */
  --bg-card-hover: #f1f5f9;     /* Slate 100 */
  --bg-input: #ffffff;          /* White Inputs */
  --border-color: #e2e8f0;      /* Slate 200 */
  --border-hover: #cbd5e1;      /* Slate 300 */
  --border-focus: #0284c7;      /* Keenetic Blue (Sky 600) */

  /* Typography */
  --text-primary: #0f172a;      /* Slate 900 (High contrast) */
  --text-secondary: #334155;    /* Slate 700 */
  --text-muted: #64748b;        /* Slate 500 */

  /* Keenetic Blue Accents */
  --accent-primary: #0284c7;    /* Sky 600 */
  --accent-hover: #0369a1;      /* Sky 700 */
  --accent-subtle: #f0f9ff;     /* Sky 50 */
  --accent-border: #bae6fd;     /* Sky 200 */

  /* Status Accents */
  --accent-success: #16a34a;    /* Green 600 */
  --accent-success-subtle: #dcfce7;
  --accent-warning: #d97706;    /* Amber 600 */
  --accent-warning-subtle: #fef3c7;
  --accent-danger: #dc2626;     /* Red 600 */
  --accent-danger-subtle: #fee2e2;
  --accent-violet: #7c3aed;     /* Violet 600 */
  --accent-violet-subtle: #f5f3ff;

  /* Shadows */
  --shadow-sm: 0 1px 3px 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-sticky: 0 -4px 16px rgba(0, 0, 0, 0.08);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Native System Fonts */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --touch-min: 44px;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

body.modal-open {
  overflow: hidden;
}

.app-container {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Structural Layout Synchronization */
.header,
.header-content,
.nav-tabs,
.tab-view,
.main-grid,
.analyzer-grid,
.card,
.content-card,
.footer {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}


/* Header */
.header {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2rem;
  background: var(--accent-subtle);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-border);
  line-height: 1;
}

h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  display: inline-block;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  flex: 1;
}

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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.hint-inline {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 6px;
}

.divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* Inputs, Clearable Container & Controls */
.input-clearable {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.input-clearable input {
  padding-right: 36px;
}

.btn-clear-input {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: none;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  z-index: 2;
  user-select: none;
}

.btn-clear-input:hover {
  background: #cbd5e1;
  color: #0f172a;
}

input[type="text"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease-in-out;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

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

.btn-lg {
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: #334155;
  color: #ffffff;
  border-color: #334155;
}
.btn-secondary:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.btn-outline {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-subtle);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.btn-text:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.btn:disabled,
.btn[disabled],
.btn.btn-disabled-network {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
  pointer-events: auto !important;
  box-shadow: none;
  transform: none !important;
}

.v2fly-link {
  color: var(--accent-primary);
  text-decoration: underline;
  transition: color 0.15s ease-in-out;
}
.v2fly-link:hover {
  color: var(--accent-hover);
}

/* Reverse Domain Search */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.search-results {
  margin-top: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.search-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}

.matches-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
}

.match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  gap: 8px;
}

.match-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.badge-match {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-exact {
  background: var(--accent-success-subtle);
  color: var(--accent-success);
  border: 1px solid #bbf7d0;
}

.badge-parent {
  background: var(--accent-warning-subtle);
  color: var(--accent-warning);
  border: 1px solid #fde68a;
}

.badge-wildcard {
  background: var(--accent-violet-subtle);
  color: var(--accent-violet);
  border: 1px solid #ddd6fe;
}

.badge-category {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-keyword {
  background: rgba(99, 102, 241, 0.15);
  color: #4f46e5;
  border: 1px solid #c7d2fe;
}

/* Presets Bar & Scroll */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.presets-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.presets-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.presets-scroll::-webkit-scrollbar {
  display: none;
}

.preset-chip {
  white-space: nowrap;
  scroll-snap-align: start;
  flex-shrink: 0;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.preset-chip:hover {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.chip-clear {
  background: var(--accent-danger-subtle);
  border-color: #fca5a5;
  color: var(--accent-danger);
}
.chip-clear:hover {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: #ffffff;
}

/* Catalog section */
.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.selection-counter {
  font-size: 0.85rem;
  color: var(--accent-primary);
  background: var(--accent-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-border);
  font-weight: 500;
}

.filter-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-controls select {
  max-width: 170px;
  flex-shrink: 0;
}

.categories-list {
  flex: 1;
  min-height: 380px;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.category-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.category-row.selected {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
}

.category-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.category-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-samples {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
}

.cat-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.badge-count {
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  flex-shrink: 0;
}

/* Rules Accordion */
.rules-accordion {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.rules-accordion[open] {
  border-color: var(--border-hover);
}

.accordion-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.accordion-summary:hover {
  background: var(--bg-card-hover);
}

.accordion-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.rules-accordion[open] .accordion-icon {
  transform: rotate(180deg);
}

.custom-rules-panel {
  padding: 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Optimization Options Box */
.options-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent-primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Stats Box */
.stats-box {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-item.highlight .stat-value {
  color: var(--accent-primary);
}

/* Export Actions */
.export-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

/* Preview Modal & Backdrop */
.preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 2000;
  animation: fadeIn 0.2s ease-out;
}

.preview-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 760px;
  max-height: 82vh;
  z-index: 2001;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popIn 0.22s ease-out;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.preview-code {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: #0f172a;
  color: #38bdf8;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
  max-height: 440px;
}

/* Mobile Sticky Action Bar (Hidden by default on desktop) */
.mobile-sticky-bar {
  display: none;
}

/* Footer */
.footer {
  margin-top: 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hidden {
  display: none !important;
}

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Mobile Responsive Optimization (<= 768px) */
@media (max-width: 768px) {
  .app-container {
    width: 100%;
    max-width: 100%;
    padding: 14px 12px calc(84px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }

  .header {
    padding: 14px 16px;
    margin-bottom: 16px;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .brand {
    gap: 10px;
  }

  h1 {
    font-size: 1.25rem;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    gap: 16px;
  }

  .analyzer-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    gap: 16px;
  }

  .card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 16px 14px;
    border-radius: var(--radius-md);
    box-sizing: border-box;
  }

  .search-bar {
    width: 100%;
    min-width: 0;
  }

  .export-actions .btn,
  .analyzer-submit-row .btn {
    width: 100%;
    white-space: normal;
    word-break: break-word;
    text-align: center;
  }

  /* Touch Targets (>= 44px) */
  .btn {
    min-height: var(--touch-min);
  }

  .btn-sm {
    min-height: 38px;
  }

  .category-row {
    min-height: 48px;
    padding: 10px 12px;
  }

  .cat-checkbox {
    width: 22px;
    height: 22px;
  }

  .preset-chip {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 0.82rem;
  }

  .btn-clear-input {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
    right: 6px;
  }

  .filter-controls {
    flex-direction: column;
    gap: 8px;
  }

  .filter-controls select {
    max-width: 100%;
    min-height: var(--touch-min);
  }

  .stats-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 12px;
  }

  /* Sticky Mobile Bar */
  .mobile-sticky-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-sticky);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .sticky-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .sticky-counter-badge {
    background: var(--accent-subtle);
    color: var(--accent-primary);
    border: 1px solid var(--accent-border);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 700;
  }

  .sticky-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Bottom Sheet Preview Modal on Mobile */
  .preview-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideUp 0.25s ease-out;
  }

  .preview-code {
    max-height: 55vh;
  }
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  min-height: var(--touch-min);
}

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

.nav-tab.active {
  background: var(--accent-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.tab-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.tab-view {
  display: block;
}

.tab-view.hidden {
  display: none !important;
}

/* Analyzer Grid & Components */
.analyzer-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drop-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  outline: none;
}

.drop-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.drop-main {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drop-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.hidden-file-input {
  display: none !important;
}

.file-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  color: var(--accent-primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.file-info-badge .file-name {
  font-family: var(--font-mono);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info-badge.hidden {
  display: none !important;
}

.analyzer-submit-row {
  margin-top: 18px;
  display: flex;
}

/* Audit Results */
.audit-summary-header {
  margin-bottom: 16px;
}

.text-accent {
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.stat-alert {
  background: var(--accent-warning-subtle) !important;
  border-color: var(--accent-warning) !important;
}

.stat-alert .stat-value {
  color: var(--accent-warning) !important;
}

.audit-table-wrapper {
  margin-top: 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.audit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
}

.audit-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.audit-list {
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.audit-item {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 14px;
  background: var(--bg-surface);
  transition: background 0.15s;
}

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

.audit-item:hover {
  background: var(--bg-primary);
}

.audit-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.audit-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.audit-cat-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.audit-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audit-counts {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-up-to-date {
  background: var(--accent-success-subtle);
  color: var(--accent-success);
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.badge-outdated {
  background: var(--accent-warning-subtle);
  color: var(--accent-warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.badge-custom {
  background: var(--accent-violet-subtle);
  color: var(--accent-violet);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.audit-diff-details {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  word-break: break-all;
}

.diff-missing-title {
  color: var(--accent-warning);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Additional Additions Box */
.analyzer-additions-box {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.section-subheading {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.add-cat-row {
  position: relative;
}

.add-cat-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 4px;
}

.add-cat-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
}

.add-cat-option:last-child {
  border-bottom: none;
}

.add-cat-option:hover {
  background: var(--accent-subtle);
  color: var(--accent-primary);
}

.added-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Banner Notification Styles */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.45;
}

.banner-info {
  background: var(--accent-subtle);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.banner-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}

.banner-text strong {
  display: block;
  margin-bottom: 2px;
}

/* Audit Block Separation */
.audit-block {
  border-radius: var(--radius-md);
}

/* Target Filename Customization Box */
.target-filename-box {
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.target-filename-input-wrap {
  margin-top: 8px;
}

.input-target-filename {
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-primary);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-target-filename:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.added-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  color: var(--accent-primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
}

.added-chip-remove {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-muted);
}

.added-chip-remove:hover {
  color: var(--accent-danger);
}

/* Mobile <= 480px and iOS Safari zoom fixes */
@media (max-width: 480px) {
  .header {
    padding: 12px 14px;
  }

  .brand {
    gap: 8px;
  }

  .logo-icon {
    font-size: 1.5rem;
    padding: 6px;
  }

  h1 {
    font-size: 1.15rem;
  }

  .subtitle {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .status-badge {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .nav-tabs {
    gap: 6px;
  }

  .nav-tab {
    flex: 1 1 50%;
    padding: 8px 10px;
    font-size: 0.82rem;
    justify-content: center;
  }

  /* Protect against iOS Safari auto-zoom by ensuring font-size >= 16px */
  input[type="text"],
  textarea,
  select {
    font-size: 16px !important;
  }

  .btn-lg {
    font-size: 0.92rem;
    padding: 12px 16px;
  }

  .stats-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 8px;
  }
}

