@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@400;700;800&family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Cairo:wght@400;600;700;800;900&family=Tajawal:wght@400;500;700;800&display=swap');

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-block-end: var(--space-4);
  list-style: none;
}

.breadcrumbs a {
  color: var(--text-muted);
  min-height: var(--min-touch-size);
  display: inline-flex;
  align-items: center;
}

.breadcrumbs a:hover {
  color: var(--text-main);
}

.breadcrumbs-separator {
  color: var(--text-subtle);
}

/* Tool Hero Liquid Glass Section */
.tool-hero-glass {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  margin-block-end: var(--space-8);
  padding: var(--space-6) var(--space-7);
  background: rgba(14, 22, 40, 0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
}

.tool-hero-content {
  flex: 1;
  min-width: 0;
}

.tool-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-block-end: var(--space-2);
  color: var(--text-main);
  line-height: 1.25;
}

.tool-hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 780px;
  margin-block-end: var(--space-4);
}

.tool-hero-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.tool-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.tool-badge-pill.primary {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tool-badge-pill.subtle {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-hero-art {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-hero-art img {
  width: 148px;
  height: 148px;
  max-width: 95%;
  max-height: 95%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.45));
}

@media (max-width: 640px) {
  .tool-hero-glass {
    flex-direction: column-reverse;
    text-align: center;
    padding: var(--space-5);
  }

  .tool-hero-badges {
    justify-content: center;
  }

  .tool-hero-art img {
    width: 90px;
    height: 90px;
    aspect-ratio: 1 / 1;
  }
}

/* Batch image workspaces — space reserved to prevent Cumulative Layout Shift (CLS) */
.image-batch-shell {
  min-width: 0;
  min-height: 520px;
}

.tool-workspace:has(.image-batch-shell) {
  min-height: 575px;
}

@media (max-width: 640px) {
  .image-batch-shell {
    min-height: 570px;
  }
  .tool-workspace:has(.image-batch-shell) {
    min-height: 610px;
  }
}

.image-batch-tool { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.batch-file-input { display: none !important; }
.batch-dropzone,
.dropzone {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 260px;
  padding: clamp(40px, 6vw, 62px) 24px;
  color: var(--text-main);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.08), rgba(255, 255, 255, 0.025)), var(--bg-glass);
  border: 1px dashed var(--brand-primary-border);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s ease;
  user-select: none;
}

[data-theme="light"] .batch-dropzone,
[data-theme="light"] .dropzone {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(230, 242, 255, 0.64));
  border-color: rgba(96, 165, 250, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 28px rgba(37, 99, 235, 0.07);
}

.batch-dropzone:hover,
.batch-dropzone.is-dragging,
.batch-dropzone.dragover,
.dropzone:hover,
.dropzone.dragover,
.dropzone.is-dragging {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
  transform: scale(1.006);
}

.dropzone-icon {
  width: 52px;
  height: 52px;
  color: var(--brand-primary);
  margin-block-end: 18px;
  transition: transform .2s ease;
  flex-shrink: 0;
}

.dropzone:hover .dropzone-icon,
.batch-dropzone:hover .dropzone-icon {
  transform: translateY(-3px);
}

.batch-dropzone strong,
.dropzone-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-block-end: 10px;
  line-height: 1.4;
}

.batch-dropzone small,
.dropzone-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-block-end: 20px;
  max-width: 580px;
}

.dropzone-content-default > :last-child,
.dropzone-subtitle:last-child,
.batch-dropzone small:last-child {
  margin-block-end: 0;
}

.dropzone-browse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 24px;
  border-radius: 9999px;
  background-color: var(--brand-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--brand-primary-light);
  transition: all 0.18s ease;
  pointer-events: auto;
  margin-block-start: 6px;
}

.dropzone-browse-btn:hover {
  background-color: var(--brand-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--brand-primary-light);
}

.batch-drop-icon { display: none; }
/* Modern Batch Image Settings Panel */
.batch-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  margin-block-end: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .03);
}

.batch-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block-end: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.batch-panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.batch-title-icon-box {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  flex-shrink: 0;
}

.batch-title-text-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-panel-title {
  margin: 0;
  color: var(--text-main);
  font-size: .96rem;
  font-weight: 800;
  line-height: 1.2;
}

.batch-panel-desc {
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.2;
}

.batch-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding-inline: 15px;
  font-size: .82rem;
  font-weight: 700;
  border-radius: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--brand-primary);
  cursor: pointer;
  transition: all .15s ease;
  flex-shrink: 0;
}

.batch-apply-btn:hover {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
}

.batch-apply-btn[hidden] {
  display: none !important;
}

.batch-settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.batch-sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--bg-subtle, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 650;
  transition: all 0.2s ease;
  user-select: none;
}

.batch-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.batch-sync-indicator.is-updating {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #059669;
}

.batch-sync-indicator.is-updating .batch-sync-dot {
  transform: scale(1.3);
  background: #059669;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
}

.batch-sync-indicator.has-custom {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #d97706;
}

.batch-sync-indicator.has-custom .batch-sync-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

/* Card level sync badge */
.batch-card-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.batch-card-sync-pill.is-synced {
  color: #059669;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.22);
}

.batch-card-sync-pill.is-custom {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
}

.batch-card-reset-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 6px;
}

.batch-card-reset-sync-btn:hover {
  background: var(--brand-primary);
  color: #ffffff;
}

.batch-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 768px) {
  .batch-settings-grid {
    grid-template-columns: 1fr;
  }
}

.batch-setting {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  color: var(--text-main);
  font-size: .82rem;
  font-weight: 650;
}

.batch-setting-full {
  grid-column: 1 / -1;
}

.batch-setting-label {
  color: var(--text-main);
  font-size: .82rem;
  font-weight: 700;
  display: block;
}

.batch-setting-hint {
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 500;
}

/* 1. Segmented Control Pills */
.batch-setting-segmented {
  gap: 8px;
}

.batch-segmented-track {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle, rgba(0, 0, 0, .04));
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.batch-segmented-track::-webkit-scrollbar {
  display: none;
}

.batch-segment-pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: 700 .9rem/1.2 var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all .15s ease;
}

.batch-segment-pill svg {
  flex-shrink: 0;
}

.batch-segment-pill:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, .04);
}

.batch-segment-pill.is-active {
  color: var(--brand-primary);
  background: var(--bg-surface);
  border-color: var(--border-medium);
  font-weight: 750;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

/* 2. Modern Toggle Switch Card */
.batch-setting-switch {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  min-height: 48px;
  box-sizing: border-box;
  transition: border-color .15s ease, background-color .15s ease;
}

.batch-setting-switch:hover {
  border-color: var(--border-medium);
  background: var(--bg-card);
}

.batch-switch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-switch-title {
  color: var(--text-main);
  font-size: .84rem;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 6px;
}

.batch-switch-hint {
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 500;
}

.batch-switch-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  direction: ltr !important;
}

.batch-switch-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.batch-switch-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-subtle, #cbd5e1);
  border-radius: 99px;
  transition: background-color .2s ease;
  pointer-events: none;
}

.batch-switch-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s ease;
}

.batch-switch-toggle input:checked + .batch-switch-slider {
  background: var(--brand-primary);
}

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

/* 3. Range Slider Card */
.batch-setting-range {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  min-height: 48px;
  box-sizing: border-box;
}

.batch-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.batch-range-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--brand-primary-light);
  color: #60a5fa;
  font: 750 .76rem/1 var(--font-mono);
  border: 1px solid var(--brand-primary-border);
}

[data-theme="light"] .batch-range-badge {
  color: #1d4ed8;
}

.batch-setting-range input[type="range"] {
  direction: ltr !important;
  box-sizing: border-box;
  width: 100%;
  height: 6px;
  margin: 6px 0 2px;
  padding: 0;
  background: var(--bg-subtle, #cbd5e1);
  border-radius: 99px;
  appearance: none;
  cursor: pointer;
  accent-color: var(--brand-primary);
  border: none;
}

.batch-setting-range input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  cursor: pointer;
}

/* 4. Styled Input with Suffix */
.batch-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.batch-input-wrap input {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 9px 42px 9px 12px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  font: inherit;
}

[dir="rtl"] .batch-input-wrap input {
  padding: 9px 12px 9px 42px;
}

.batch-input-suffix {
  position: absolute;
  right: 12px;
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  font-family: var(--font-mono);
}

[dir="rtl"] .batch-input-suffix {
  right: auto;
  left: 12px;
}

/* 5. Custom Select with SVG Arrow */
.batch-select-wrap {
  position: relative;
  width: 100%;
}

.batch-select-wrap select {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 9px 44px 9px 16px;
  color: var(--text-main);
  background-color: var(--bg-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

[dir="rtl"] .batch-select-wrap select {
  padding: 9px 16px 9px 44px;
  background-position: left 14px center;
}

.batch-setting input:focus,
.batch-setting select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}

/* Dedicated Queue Controls Bar */
.batch-queue-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 10px 14px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 16px; margin-block-end: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .03); }
.batch-queue-header.is-empty { display: none; }
.batch-queue-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.batch-queue-badge { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 99px; background: var(--brand-primary-light); color: #60a5fa; font: 750 .8rem/1 var(--font-mono); border: 1px solid var(--brand-primary-border); }
[data-theme="light"] .batch-queue-badge { color: #1d4ed8; }
.batch-queue-status { color: var(--text-muted); font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-queue-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.batch-run-all-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding-inline: 18px; font-size: .86rem; font-weight: 750; border-radius: 12px; }
.batch-zip-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding-inline: 16px; font-size: .84rem; font-weight: 650; border-radius: 12px; }
.batch-zip-btn[hidden] { display: none !important; }
.batch-clear-btn { min-height: 40px; padding-inline: 12px; font-size: .8rem; border-radius: 12px; color: var(--text-muted); }
.batch-queue-actions button:disabled { opacity: .46; cursor: not-allowed; }

/* Compact Queue Cards */
.batch-queue-list { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 2px 2px 6px; }

.batch-card { display: grid; gap: 0; min-width: 0; padding: 9px 12px; color: var(--text-main); background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 16px; box-shadow: 0 2px 10px rgba(0, 0, 0, .03); transition: border-color .15s ease, background-color .15s ease; }
.batch-card:hover { border-color: var(--border-medium); }
.batch-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.batch-thumb-wrap { position: relative; flex: 0 0 50px; width: 50px; height: 50px; border-radius: 12px; overflow: hidden; background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.batch-thumb-wrap.can-compare { cursor: pointer; }
.batch-thumb-wrap.can-compare:hover::after { content: ""; position: absolute; inset: 0; background: rgba(59, 130, 246, .2); }
.batch-thumbnail { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch-card-body { display: grid; gap: 3px; flex: 1; min-width: 0; }
.batch-card-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.batch-file-name { overflow: hidden; color: var(--text-main); font-size: .86rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.batch-card-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .8rem; }
.batch-stat-old { color: var(--text-subtle); text-decoration: line-through; font-family: var(--font-mono); font-size: .78rem; opacity: .85; }
.batch-stat-arrow { color: var(--text-subtle); font-size: .72rem; }
.batch-stat-new { color: var(--text-main); font-weight: 750; font-family: var(--font-mono); font-size: .82rem; }
.batch-stat-orig { color: var(--text-muted); font-family: var(--font-mono); font-size: .8rem; }
.batch-status-tag { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 99px; font-size: .72rem; font-weight: 650; background: var(--bg-subtle); color: var(--text-subtle); }
.batch-saving-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font: 750 .74rem/1.2 var(--font-mono); }
.batch-saving-badge.saving-good { background: rgba(16, 185, 129, .14); color: #10b981; border: 1px solid rgba(16, 185, 129, .28); }
.batch-saving-badge.saving-neutral { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.batch-saving-badge.saving-larger { background: rgba(245, 158, 11, .14); color: #f59e0b; border: 1px solid rgba(245, 158, 11, .28); }
.batch-stat-dim { color: var(--text-subtle); font-size: .74rem; font-family: var(--font-mono); }
.batch-error-text { color: #ef4444; font-size: .78rem; font-weight: 600; }
.batch-progress-text { color: var(--brand-primary); font-size: .78rem; font-weight: 600; }

.batch-card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.batch-btn-compare { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding-inline: 12px; font-size: .8rem; font-weight: 650; border-radius: 10px; cursor: pointer; }
.batch-btn-download { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding-inline: 13px; font-size: .8rem; font-weight: 700; border-radius: 10px; text-decoration: none; }
.batch-btn-process { min-height: 36px; padding-inline: 13px; font-size: .8rem; border-radius: 10px; cursor: pointer; }
.batch-icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); color: var(--text-muted); cursor: pointer; font-size: 1.1rem; transition: background .15s ease, color .15s ease; }
.batch-icon-button:hover { color: var(--text-main); background: var(--bg-elevated); }
.batch-icon-button.is-active { background: var(--brand-primary-light); color: var(--brand-primary); border-color: var(--brand-primary-border); }
.batch-icon-button:disabled, .batch-card-actions button:disabled { opacity: .46; cursor: not-allowed; }

.batch-card-progress { width: 100%; height: 2px; margin-top: 6px; overflow: hidden; border-radius: 99px; background: transparent; }
.batch-card[data-status="working"] .batch-card-progress { background: var(--bg-subtle); }
.batch-progress-bar { width: 100%; height: 2px; display: block; appearance: none; border: 0; }
.batch-progress-bar::-webkit-progress-bar { background: var(--bg-subtle); }
.batch-progress-bar::-webkit-progress-value { background: linear-gradient(90deg, var(--brand-primary), #60a5fa); border-radius: 99px; }
.batch-progress-bar::-moz-progress-bar { background: linear-gradient(90deg, var(--brand-primary), #60a5fa); border-radius: 99px; }

.batch-item-custom-panel { padding-top: 10px; margin-top: 8px; border-top: 1px solid var(--border-subtle); }
.batch-item-custom-panel[hidden] { display: none !important; }

/* Comparison Modal Dialog (Native <dialog>) */
.batch-compare-dialog { border: 1px solid var(--border-glass); border-radius: 24px; background: var(--bg-surface); color: var(--text-main); box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .7); padding: 0; width: min(94vw, 860px); max-height: 92vh; overflow-y: auto; margin: auto; }
.batch-compare-dialog::backdrop { background: rgba(6, 9, 19, .75); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.compare-modal-box { display: grid; grid-template-rows: auto auto 1fr auto auto; min-width: 0; }
.compare-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); }
.compare-title-wrap { display: grid; gap: 2px; min-width: 0; }
.compare-modal-title { margin: 0; font-size: .98rem; font-weight: 750; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-modal-meta { color: var(--text-muted); font-size: .78rem; font-family: var(--font-mono); }
.compare-modal-close { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); color: var(--text-muted); cursor: pointer; transition: color .15s ease, background-color .15s ease; }
.compare-modal-close:hover { color: var(--text-main); background: var(--bg-elevated); }

.compare-stats-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border-subtle); }
.compare-stat-pill { display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.compare-stat-pill.stat-before { text-align: start; }
.compare-stat-pill.stat-after { text-align: end; }
.compare-stat-label { color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.compare-stat-size { color: var(--text-main); font-size: 1.15rem; font-weight: 800; font-family: var(--font-mono); }
.compare-stat-diff { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.compare-diff-badge { display: inline-block; padding: 3px 11px; border-radius: 99px; font-weight: 800; font-size: .84rem; font-family: var(--font-mono); }
.compare-diff-badge.saving-good { background: rgba(16, 185, 129, .15); color: #10b981; border: 1px solid rgba(16, 185, 129, .3); }
.compare-diff-badge.saving-neutral { background: var(--bg-subtle); color: var(--text-muted); }
.compare-diff-badge.saving-larger { background: rgba(245, 158, 11, .15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, .3); }
.compare-diff-saving { color: var(--text-muted); font-size: .74rem; font-family: var(--font-mono); }

.compare-stage { position: relative; width: 100%; height: clamp(260px, 48vh, 480px); background: linear-gradient(45deg, rgba(128,128,128,.06) 25%, transparent 25%), linear-gradient(-45deg, rgba(128,128,128,.06) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(128,128,128,.06) 75%), linear-gradient(-45deg, transparent 75%, rgba(128,128,128,.06) 75%), var(--bg-canvas); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px; overflow: hidden; user-select: none; touch-action: none; }
.compare-layer { position: absolute; inset: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.compare-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.compare-layer-after { z-index: 1; }
.compare-layer-before { z-index: 2; clip-path: polygon(0 0, var(--compare-pos, 50%) 0, var(--compare-pos, 50%) 100%, 0 100%); }
.compare-badge-corner { position: absolute; top: 12px; padding: 4px 9px; border-radius: 8px; font-size: .74rem; font-weight: 700; background: rgba(6, 9, 19, .72); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .15); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); pointer-events: none; font-family: var(--font-mono); }
.badge-before { left: 12px; }
.badge-after { right: 12px; }
.compare-divider { position: absolute; top: 0; bottom: 0; left: var(--compare-pos, 50%); width: 2px; background: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, .5); transform: translateX(-50%); pointer-events: none; z-index: 3; }
.compare-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #0f172a; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; gap: 1px; }
.compare-range-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; z-index: 4; touch-action: none; }
.compare-stage-hint { margin: 0; padding: 7px 16px; text-align: center; color: var(--text-muted); font-size: .75rem; background: var(--bg-card); border-top: 1px solid var(--border-subtle); }
.compare-modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border-subtle); background: var(--bg-surface); }
.compare-footer-download { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; }
/* Extracted Details Drawer (for OCR & Metadata tools) */
.batch-details-drawer { margin-top: 8px; border-top: 1px solid var(--border-subtle); padding-top: 6px; }
.batch-details-summary { color: var(--brand-primary); cursor: pointer; font-size: .8rem; font-weight: 700; user-select: none; }
.batch-drawer-body { display: grid; gap: 8px; margin-top: 6px; }
.batch-drawer-pre { max-height: 220px; margin: 0; padding: 10px 12px; overflow: auto; color: var(--text-muted); background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 12px; font: .76rem/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.batch-btn-copy { justify-self: start; min-height: 32px; padding-inline: 12px; font-size: .78rem; border-radius: 8px; }

/* Batch Queue & Comparison Modal Mobile Responsiveness */
@media (max-width: 640px) {
  .batch-queue-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .batch-queue-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .batch-queue-actions > button { flex: 1; min-height: 44px; justify-content: center; }
  .batch-card-main { flex-wrap: wrap; gap: 10px; }
  .batch-card-body { min-width: calc(100% - 66px); }
  .batch-card-actions { width: 100%; justify-content: stretch; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border-subtle); }
  .batch-card-actions > .batch-btn-compare,
  .batch-card-actions > .batch-btn-download,
  .batch-card-actions > .batch-btn-process { flex: 1; min-height: 42px; justify-content: center; }
  .batch-card-actions > .batch-icon-button { min-width: 42px; min-height: 42px; }
  .compare-modal-header, .compare-stats-header, .compare-modal-footer { padding-inline: 14px; }
  .compare-stage { height: 320px; }
}
@media (max-width: 480px) {
  .batch-thumb-wrap { flex: 0 0 44px; width: 44px; height: 44px; }
  .compare-stat-size { font-size: .98rem; }
  .compare-diff-badge { font-size: .76rem; }
}

/* Compact Dropzone when items exist in queue (all image tools) */
.batch-dropzone.is-compact,
.dropzone.is-compact {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  min-height: 52px !important;
  max-height: 60px !important;
  padding: 8px 18px !important;
  border-radius: 14px !important;
  border-style: dashed !important;
  border-width: 1.5px !important;
  gap: 14px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
  cursor: pointer;
  margin-block-end: 4px;
}

.batch-dropzone.is-compact .dropzone-icon,
.dropzone.is-compact .dropzone-icon {
  width: 22px !important;
  height: 22px !important;
  margin-block-end: 0 !important;
  flex-shrink: 0;
}

.batch-dropzone.is-compact .dropzone-content-default,
.dropzone.is-compact .dropzone-content-default {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 0;
  flex: 1;
  text-align: start !important;
}

[dir="rtl"] .batch-dropzone.is-compact .dropzone-content-default,
[dir="rtl"] .dropzone.is-compact .dropzone-content-default {
  text-align: right !important;
}

.batch-dropzone.is-compact strong,
.dropzone.is-compact strong,
.batch-dropzone.is-compact .dropzone-title,
.dropzone.is-compact .dropzone-title {
  font-size: 0.86rem !important;
  font-weight: 750 !important;
  margin-block-end: 0 !important;
  color: var(--text-main) !important;
  white-space: nowrap;
}

.batch-dropzone.is-compact small,
.dropzone.is-compact small,
.batch-dropzone.is-compact .dropzone-subtitle,
.dropzone.is-compact .dropzone-subtitle {
  font-size: 0.76rem !important;
  margin-block-end: 0 !important;
  color: var(--text-muted) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .batch-dropzone.is-compact,
  .dropzone.is-compact {
    min-height: 44px !important;
    max-height: 50px !important;
    padding: 6px 12px !important;
  }
  .batch-dropzone.is-compact small,
  .dropzone.is-compact small,
  .batch-dropzone.is-compact .dropzone-subtitle,
  .dropzone.is-compact .dropzone-subtitle {
    display: none !important;
  }
}

/* Universal Smart Live Interactive Preview Stage */
.batch-live-stage,
.cropper-live-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  margin-block-end: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .03);
}

.batch-live-stage[hidden],
.cropper-live-stage[hidden] {
  display: none !important;
}

.batch-stage-header,
.cropper-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.batch-stage-title-wrap,
.cropper-stage-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.batch-stage-title,
.cropper-stage-title {
  margin: 0;
  color: var(--text-main);
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.3;
}

.batch-stage-hint,
.cropper-stage-hint {
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
}

.batch-stat-badge,
.cropper-stat-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  font: 700 .76rem/1.3 var(--font-mono);
}

.batch-canvas-wrapper,
.cropper-canvas-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  max-height: 520px;
  padding: 12px;
  background: linear-gradient(45deg, rgba(128,128,128,.06) 25%, transparent 25%),
              linear-gradient(-45deg, rgba(128,128,128,.06) 25%, transparent 25%),
              linear-gradient(45deg, transparent 75%, rgba(128,128,128,.06) 75%),
              linear-gradient(-45deg, transparent 75%, rgba(128,128,128,.06) 75%),
              var(--bg-canvas);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.batch-canvas-wrapper.is-dragging,
.cropper-canvas-wrapper.is-dragging {
  cursor: grabbing;
}

.batch-canvas,
.cropper-canvas {
  display: block;
  max-width: 100%;
  max-height: 480px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

.batch-image-switcher,
.cropper-image-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 4px 10px;
  scrollbar-width: thin;
}

.batch-thumb-chip,
.cropper-thumb-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 2px;
  background: var(--bg-card);
  border: 2px solid var(--border-medium);
  border-radius: 12px;
  cursor: pointer;
  transition: all .18s ease;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
}

.batch-thumb-chip:hover,
.cropper-thumb-chip:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .08);
}

.batch-thumb-chip.is-active,
.cropper-thumb-chip.is-active {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-light), 0 4px 14px rgba(59, 130, 246, 0.28);
  transform: scale(1.06);
}

.batch-chip-img,
.cropper-chip-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  pointer-events: none;
}

.batch-chip-name,
.cropper-chip-name {
  display: none;
}

/* Palette Tool Specifics */
.palette-queue-list { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 2px 2px 6px; }
.palette-thumb-wrap { flex-basis: 76px; width: 76px; height: 52px; }
.palette-canvas { width: 100%; height: 100%; object-fit: contain; cursor: crosshair; }
.palette-swatches { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border-subtle); }
.palette-chip { display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 3px 9px 3px 5px; color: var(--text-main); background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 99px; cursor: pointer; font: 650 .75rem/1.2 var(--font-mono); transition: transform .12s ease, border-color .12s ease; }
.palette-chip:hover { transform: translateY(-1px); border-color: var(--brand-primary); }
.palette-chip::before { width: 20px; height: 20px; content: ""; background: var(--sample-color); border: 1px solid rgba(15, 23, 42, .12); border-radius: 50%; }

/* QR design studio */
.qr-generator-pro { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); align-items: start; gap: 16px; }
.qr-generator-pro [hidden] { display: none !important; }
.qr-config-panel, .qr-result-panel { display: grid; gap: 16px; min-width: 0; padding: clamp(16px, 2.4vw, 24px); background: color-mix(in srgb, var(--bg-surface) 90%, var(--brand-primary-light)); border: 1px solid var(--border-subtle); border-radius: 22px; box-shadow: 0 14px 40px rgba(31, 52, 92, .06); }
.qr-section-heading h2, .qr-result-head h2 { margin: 3px 0 4px; color: var(--text-main); font-size: 1.15rem; }
.qr-section-heading p, .qr-note { margin: 0; color: var(--text-muted); font-size: .82rem; line-height: 1.6; }
.qr-eyebrow { color: var(--brand-primary); font: 750 .68rem/1.3 var(--font-mono); letter-spacing: .08em; }
.qr-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qr-preset-btn { display: grid; gap: 5px; min-width: 0; padding: 12px; color: var(--text-main); text-align: start; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 15px; cursor: pointer; transition: border-color .16s ease, transform .16s ease; }
.qr-preset-btn:hover { border-color: var(--brand-primary); transform: translateY(-1px); }
.qr-preset-btn > span { display: grid; place-items: center; width: 30px; height: 30px; color: var(--brand-primary); background: var(--brand-primary-light); border-radius: 10px; font-size: 1.1rem; }
.qr-preset-btn strong { font-size: .79rem; }
.qr-preset-btn small { color: var(--text-muted); font-size: .7rem; line-height: 1.45; }
.qr-field { display: grid; gap: 7px; min-width: 0; color: var(--text-main); font-size: .82rem; font-weight: 650; }
.qr-field input, .qr-field select { box-sizing: border-box; width: 100%; min-width: 0; min-height: 43px; padding: 9px 12px; color: var(--text-main); background: var(--bg-surface); border: 1px solid var(--border-medium); border-radius: 12px; font: 500 .88rem/1.45 var(--font-system); }
.qr-field-grid, .qr-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.qr-options-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qr-wide { grid-column: 1 / -1; }
.qr-check { display: flex; align-items: center; gap: 9px; min-height: 40px; color: var(--text-main); font-size: .82rem; }
.qr-check input { width: 17px; height: 17px; accent-color: var(--brand-primary); }
.qr-brand-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 12px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 14px; }
.qr-logo-picker { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 12px; overflow: hidden; cursor: pointer; font-size: .79rem; }
.qr-logo-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#qr-logo-name { color: var(--text-muted); font-size: .78rem; overflow-wrap: anywhere; }
.qr-brand-row .btn-tertiary { min-height: 34px; padding-inline: 8px; font-size: .76rem; }
.qr-brand-row small { flex-basis: 100%; color: var(--text-muted); font-size: .73rem; }
.qr-color-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 9px 12px; color: var(--text-main); background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px; font-size: .79rem; font-weight: 650; }
.qr-color-field input { width: 39px; height: 34px; padding: 3px; background: var(--bg-surface); border: 1px solid var(--border-medium); border-radius: 9px; cursor: pointer; }
.qr-result-panel { position: sticky; top: 18px; }
.qr-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qr-secure-badge { flex: 0 0 auto; padding: 7px 10px; color: #16815a; background: rgba(22, 163, 104, .09); border-radius: 99px; font-size: .7rem; font-weight: 700; }
.qr-preview-box { display: flex; justify-content: center; align-items: center; width: fit-content; max-width: 100%; min-height: 0; height: auto; padding: 10px; margin-inline: auto; background: #fff; border: 1px solid var(--border-subtle); border-radius: 16px; box-shadow: 0 4px 18px rgba(0, 0, 0, .05); }
.qr-output { display: flex; justify-content: center; align-items: center; width: auto; }
.qr-canvas-preview { display: block; width: 220px; max-width: 100%; aspect-ratio: 1; height: auto; object-fit: contain; image-rendering: pixelated; }
.qr-download-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; width: 100%; }
.qr-download-row > button { flex: 1 1 120px; }
.qr-note { padding-top: 12px; border-top: 1px solid var(--border-subtle); text-align: center; }
.qr-camera-result { width: 100%; min-height: 86px; padding: 12px; color: var(--text-main); background: var(--bg-surface); border: 1px solid var(--border-medium); border-radius: 13px; resize: vertical; }

@media (max-width: 760px) {
  .qr-generator-pro { grid-template-columns: minmax(0, 1fr); }
  .qr-result-panel { position: static; }
}
@media (max-width: 640px) {
  .batch-settings-panel { padding: 14px; border-radius: 17px; }
  .batch-queue-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .batch-queue-actions { width: 100%; justify-content: flex-start; }
  .batch-run-all-btn, .batch-zip-btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .batch-card-main { flex-wrap: wrap; gap: 10px; }
  .batch-card-body { flex-basis: calc(100% - 64px); }
  .batch-card-actions { width: 100%; justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--border-subtle); }
  .batch-btn-compare, .batch-btn-download, .batch-btn-process { min-height: 40px; }
  .compare-stats-header { padding: 10px 14px; gap: 8px; }
  .compare-stat-pill { min-width: 70px; }
  .compare-stat-size { font-size: 1rem; }
  .compare-diff-badge { font-size: .78rem; padding: 2px 8px; }
  .compare-stage { height: clamp(200px, 36vh, 280px); }
  .compare-modal-footer { padding: 10px 14px; flex-direction: column; align-items: stretch; }
  .compare-modal-footer button, .compare-modal-footer a { justify-content: center; min-height: 44px; }
}
@media (max-width: 560px) {
  .qr-preset-grid { grid-template-columns: minmax(0, 1fr); }
  .qr-preset-btn { grid-template-columns: auto 1fr; align-items: center; column-gap: 9px; }
  .qr-preset-btn > span { grid-row: span 2; }
  .qr-preset-btn small { grid-column: 2; }
  .qr-options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qr-preview-box { min-height: 0; }
}

/* Tool Workspace */
.tool-workspace {
  position: relative;
  z-index: 25;
  min-height: 260px;
  background: rgba(14, 22, 40, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-block-end: var(--space-6);
}

.tool-feature-grid {
  position: relative;
  z-index: 1;
}

@media (max-width: 480px) {
  .tool-workspace {
    padding: var(--space-4);
  }
}

/* Liquid Glass Form Inputs & Textareas */
.glass-textarea,
textarea.search-input,
.tool-workspace textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px 20px;
  background: rgba(8, 13, 25, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  font-family: var(--font-system);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text-main);
  resize: vertical;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.glass-textarea:focus,
textarea.search-input:focus,
.tool-workspace textarea:focus {
  outline: none;
  background: rgba(14, 22, 42, 0.9);
  border-color: #3b82f6;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Inputs across workspaces */
.tool-workspace input[type="text"],
.tool-workspace input[type="number"],
.tool-workspace input[type="date"],
.tool-workspace select {
  height: 48px;
  padding: 0 16px;
  background: rgba(8, 13, 25, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  font-family: var(--font-system);
  font-size: 0.95rem;
  color: var(--text-main);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
}

.tool-workspace input[type="text"]:focus,
.tool-workspace input[type="number"]:focus,
.tool-workspace input[type="date"]:focus,
.tool-workspace select:focus {
  outline: none;
  background: rgba(14, 22, 42, 0.9);
  border-color: #3b82f6;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Common Interactive Area */
.interactive-area {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(20, 30, 52, 0.6);
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  user-select: none;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.interactive-area.active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
}

/* Primary Action Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-touch-size);
  padding-inline: var(--space-6);
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-pill);
  border: none;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-touch-size);
  padding-inline: var(--space-5);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-pill);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Results Display */
.results-box {
  margin-block-start: var(--space-5);
  padding: 16px 20px;
  background: rgba(10, 16, 32, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-4);
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  transition: all 0.2s ease;
}

.stat-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: #38bdf8;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-block-start: 4px;
}

/* Light Theme Variants for Tool Pages */
[data-theme="light"] .tool-hero-glass {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .tool-workspace {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .glass-textarea,
[data-theme="light"] textarea.search-input,
[data-theme="light"] .tool-workspace textarea {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-main);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .glass-textarea:focus,
[data-theme="light"] textarea.search-input:focus,
[data-theme="light"] .tool-workspace textarea:focus {
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.04), 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="light"] .tool-workspace input[type="text"],
[data-theme="light"] .tool-workspace input[type="number"],
[data-theme="light"] .tool-workspace input[type="date"],
[data-theme="light"] .tool-workspace select {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-main);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .tool-workspace input[type="text"]:focus,
[data-theme="light"] .tool-workspace input[type="number"]:focus,
[data-theme="light"] .tool-workspace input[type="date"]:focus,
[data-theme="light"] .tool-workspace select:focus {
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.04), 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="light"] .interactive-area {
  background-color: rgba(240, 244, 250, 0.7);
  border-color: rgba(15, 23, 42, 0.14);
}

[data-theme="light"] .results-box {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .stat-item {
  background: rgba(240, 244, 250, 0.8);
  border-color: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .stat-value {
  color: var(--brand-primary);
}

[data-theme="light"] .btn-secondary {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-main);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.2);
}

[data-theme="light"] .tool-badge-pill.primary {
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
}

[data-theme="light"] .tool-badge-pill.subtle {
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.1);
}

/* Tool Instructions & FAQ */
.tool-info-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin-block-end: var(--space-6);
}

.tool-info-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-block-end: var(--space-3);
  color: var(--text-main);
}

.tool-info-content {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.tool-info-content p {
  margin-block-end: var(--space-3);
}

.tool-info-content ul {
  padding-inline-start: var(--space-5);
  margin-block-end: var(--space-3);
}

/* =======================================================
   Modern Glass Kazakan Native Store Promo Banner
   ======================================================= */
.promo-card {
  display: none; /* Activated only when geo-validated via JS */
  margin-block: var(--space-8);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Dark Mode Appearance (Default) */
[data-theme="dark"] .promo-card,
.promo-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92) 0%, rgba(30, 58, 138, 0.32) 100%);
  border: 1px solid rgba(59, 130, 246, 0.28);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 16px 36px -10px rgba(15, 23, 42, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

/* Light Mode Appearance */
[data-theme="light"] .promo-card {
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.94) 0%, rgba(219, 234, 254, 0.78) 100%);
  border: 1px solid rgba(59, 130, 246, 0.22);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 16px 36px -10px rgba(37, 99, 235, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.75) inset;
}

.promo-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 20px 42px -10px rgba(37, 99, 235, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

/* Ambient Radial Accent */
.promo-card::before {
  content: '';
  position: absolute;
  top: -35%;
  inset-inline-end: -8%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle Top Rim Highlight */
.promo-card::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.5), transparent);
  pointer-events: none;
}

.promo-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: 24px 32px;
  position: relative;
  z-index: 1;
}

.promo-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.promo-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.promo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brand-primary);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.26);
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1;
}

.promo-badge-icon {
  display: inline-block;
  flex-shrink: 0;
}

.promo-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.24);
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1;
}

.promo-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.promo-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

[data-theme="dark"] .promo-title,
.promo-title {
  color: #ffffff;
}

[data-theme="light"] .promo-title {
  color: var(--text-main);
}

.promo-desc {
  font-size: 0.925rem;
  line-height: 1.6;
  margin: 0;
  max-width: 600px;
  transition: color 0.2s ease;
}

[data-theme="dark"] .promo-desc,
.promo-desc {
  color: #94a3b8;
}

[data-theme="light"] .promo-desc {
  color: var(--text-muted);
}

.promo-footer-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.promo-card .promo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  font-size: 0.935rem;
  font-weight: 700;
  color: #ffffff !important;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, background 0.2s ease;
}

[dir="rtl"] .promo-card .promo-btn::after {
  content: '←';
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.2s ease;
}

[dir="ltr"] .promo-card .promo-btn::after {
  content: '→';
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.2s ease;
}

.promo-card .promo-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}

[dir="rtl"] .promo-card .promo-btn:hover::after {
  transform: translateX(-4px);
}

[dir="ltr"] .promo-card .promo-btn:hover::after {
  transform: translateX(4px);
}

.promo-card .promo-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.promo-card .promo-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

.promo-trust-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  font-weight: 600;
  transition: color 0.2s ease;
}

[data-theme="dark"] .promo-trust-note,
.promo-trust-note {
  color: #cbd5e1;
}

[data-theme="light"] .promo-trust-note {
  color: var(--text-muted);
}

.promo-trust-note svg {
  color: #3b82f6;
  flex-shrink: 0;
}

.promo-media-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-mascot-img {
  max-height: 155px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.35));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.promo-card:hover .promo-mascot-img {
  transform: translateY(-3px) scale(1.05);
}

/* Mobile & Small Screens Responsiveness */
@media (max-width: 768px) {
  .promo-card {
    border-radius: 20px;
    margin-block: var(--space-6);
  }

  .promo-inner {
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
    padding: 22px 18px;
    gap: 16px;
  }

  .promo-header-row {
    justify-content: center;
  }

  .promo-title {
    font-size: 1.15rem;
  }

  .promo-desc {
    font-size: 0.875rem;
  }

  .promo-footer-row {
    justify-content: center;
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .promo-card .promo-btn {
    width: 100%;
  }

  .promo-mascot-img {
    max-height: 120px;
  }
}

/* =======================================================
   Specialized Tool Component Styles (Phase 2)
   ======================================================= */

/* 1. Reaction Time Box */
.reaction-box {
  min-height: 280px;
  width: 100%;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.1s ease;
  padding: var(--space-6);
  text-align: center;
}
.reaction-box.idle {
  background-color: var(--bg-subtle);
  border: 2px dashed var(--border-medium);
}
.reaction-box.waiting {
  background-color: #dc2626;
  color: #ffffff;
}
.reaction-box.ready {
  background-color: #16a34a;
  color: #ffffff;
}
.reaction-box.early {
  background-color: #2563eb;
  color: #ffffff;
}

/* 2. Typing Speed Tests (English & Arabic) */
.typing-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
}
.typing-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.typing-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.typing-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.typing-select {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease;
}
.typing-select:focus-visible {
  border-color: var(--brand-primary);
}

/* Collapsible Folded Custom Text Drawer */
.typing-custom-drawer {
  background: var(--surface-glass, var(--bg-card));
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-block-end: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.typing-custom-drawer[hidden] {
  display: none !important;
}
.typing-custom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block-end: var(--space-2);
}
.typing-custom-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.typing-custom-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.typing-custom-close-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}
.typing-custom-textarea {
  width: 100%;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  background: var(--bg-surface, var(--bg-card));
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease;
}
.typing-custom-textarea:focus-visible {
  border-color: var(--brand-primary);
}
.typing-custom-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-block-start: var(--space-3);
}

/* Arena: Sentence strictly on top, input strictly below */
.typing-arena {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
}
.typing-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  font-size: 1.25rem;
  line-height: 2;
  user-select: none;
  max-height: 220px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.typing-input-field {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  font-size: 1.15rem;
  padding: 12px 16px;
  border: 1.5px solid var(--border-medium);
  background-color: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.typing-input-field:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.typing-char {
  position: relative;
  transition: color 0.05s ease;
}
.typing-char.correct {
  color: #10b981;
}
.typing-char.incorrect {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.15);
  border-radius: 2px;
}
.typing-char.current {
  border-inline-start: 2px solid var(--brand-primary);
  animation: blink 1s infinite;
}
@keyframes blink {
  0%, 100% { border-color: var(--brand-primary); }
  50% { border-color: transparent; }
}

/* 3. Keyboard Tester Visualizer */
.keyboard-wrapper {
  overflow-x: auto;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  padding-block: 8px 16px;
  display: flex;
  width: 100%;
  box-sizing: border-box;
}
.keyboard-grid {
  --key-unit: 44px;
  --key-height: 44px;
  --kb-gap: 6px;
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  direction: ltr !important;
  user-select: none;
  margin: auto;
  box-sizing: border-box;
  padding-bottom: 4px;
}

.kb-cluster-main {
  display: flex;
  flex-direction: column;
  gap: var(--kb-gap);
  width: calc(15 * var(--key-unit) + 14 * var(--kb-gap));
  flex-shrink: 0;
}

.kb-cluster-main .keyboard-row {
  display: flex;
  gap: var(--kb-gap);
  width: 100%;
  height: var(--key-height);
}

.kb-cluster-nav {
  display: grid;
  grid-template-columns: repeat(3, var(--key-unit));
  grid-template-rows: repeat(6, var(--key-height));
  gap: var(--kb-gap);
  width: calc(3 * var(--key-unit) + 2 * var(--kb-gap));
  flex-shrink: 0;
}

.kb-cluster-numpad {
  display: grid;
  grid-template-columns: repeat(4, var(--key-unit));
  grid-template-rows: repeat(6, var(--key-height));
  gap: var(--kb-gap);
  width: calc(4 * var(--key-unit) + 3 * var(--kb-gap));
  flex-shrink: 0;
}

.key-cap {
  height: 100%;
  box-sizing: border-box;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: 0 2px 0 var(--border-medium);
  transition: background-color 0.1s ease, transform 0.05s ease, border-color 0.1s ease;
  user-select: none;
  cursor: default;
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-cluster-main .key-cap {
  min-width: 0;
}

.key-spacer {
  height: 100%;
  min-width: 0;
  visibility: hidden;
  pointer-events: none;
}

.key-cap.pressed {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary-hover);
  transform: translateY(2px);
  box-shadow: none;
}

.key-cap.tested {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}

#kb-app .results-box {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  margin-block-start: 20px;
}

#kb-app .stat-item {
  min-height: 80px;
  overflow: hidden;
}

#kb-app .stat-value {
  font-size: 1.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

#kb-rollover-count {
  white-space: nowrap;
  font-size: 1.35rem;
  unicode-bidi: plaintext;
}

#kb-last-key {
  white-space: nowrap;
  font-size: 1.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 768px) {
  .keyboard-grid {
    --key-unit: 34px;
    --key-height: 38px;
    --kb-gap: 4px;
    gap: 10px;
  }
  .key-cap {
    font-size: 0.65rem;
    padding: 1px 2px;
  }
}

/* 4. Mouse Tester */
.mouse-visualizer {
  width: 220px;
  height: 320px;
  margin-inline: auto;
  position: relative;
  border: 2px solid var(--border-medium);
  border-radius: 90px 90px 70px 70px;
  background-color: var(--bg-surface);
  margin-block: var(--space-4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.mouse-btn {
  position: absolute;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: background-color 0.1s ease, color 0.1s ease;
}
.mouse-btn.active {
  background-color: var(--brand-primary);
  color: #ffffff;
}
.mouse-btn-left {
  top: 0;
  inset-inline-start: 0;
  width: 108px;
  height: 120px;
  border-start-start-radius: 88px;
}
.mouse-btn-right {
  top: 0;
  inset-inline-end: 0;
  width: 108px;
  height: 120px;
  border-start-end-radius: 88px;
}
.mouse-btn-middle {
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 54px;
  border-radius: var(--radius-full);
  z-index: 5;
}
.mouse-btn-side {
  width: 14px;
  height: 48px;
  inset-inline-start: -16px;
  border-radius: 4px;
}
.mouse-btn-side-1 { top: 140px; }
.mouse-btn-side-2 { top: 196px; }

/* 5. Gamepad / Controller Visualizer */
.gamepad-container {
  max-width: 500px;
  margin-inline: auto;
}
.stick-drift-meter {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-medium);
  position: relative;
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stick-crosshair {
  position: absolute;
  width: 100%;
  height: 1px;
  background-color: var(--border-subtle);
}
.stick-crosshair.vert {
  width: 1px;
  height: 100%;
}
.stick-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background-color: var(--brand-primary);
  position: absolute;
  transform: translate(-50%, -50%);
  transition: background-color 0.05s ease;
}

/* 5.1 Microphone & Speaker Test */
.audio-visualizer-canvas {
  width: 100%;
  height: 160px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  display: block;
}
.speaker-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.rec-pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background-color: #ef4444;
  margin-inline-end: 6px;
  animation: pulseRec 1.2s infinite ease-in-out;
  vertical-align: middle;
}
@keyframes pulseRec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.75); }
}

/* 6. Universal File Input Hiding & Dropzone Integration */
input[type="file"],
.dropzone input[type="file"],
.hidden-file-input {
  display: none !important;
  opacity: 0 !important;
  position: absolute !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  visibility: hidden !important;
  z-index: -9999 !important;
}

.dropzone {
  min-height: 260px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(40px, 6vw, 62px) 24px;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  text-align: center;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}

[data-theme="dark"] .dropzone {
  background-color: rgba(15, 23, 42, 0.55);
  border-color: rgba(255, 255, 255, 0.15);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-primary);
  background-color: var(--brand-primary-light);
  transform: scale(1.008);
}

/* Modern Dropzone States: Loading, Progress Bar & Error */
.dropzone-content-default {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.dropzone-loading-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
  pointer-events: none;
}

.dropzone-loading-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: dropzone-spin 0.75s linear infinite;
}

@keyframes dropzone-spin {
  to { transform: rotate(360deg); }
}

.dropzone-loading-filename {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone-progress-wrap {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .dropzone-progress-wrap {
  background: rgba(255, 255, 255, 0.08);
}

.dropzone-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 99px;
  transition: width 0.18s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.45);
}

.dropzone-loading-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dropzone-loading-pct {
  font-weight: 700;
  font-family: var(--font-mono);
  color: #2563eb;
}

.dropzone-loading-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

.dropzone-error-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
}

.dropzone-error-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
}

.dropzone-error-msg {
  font-size: 0.88rem;
  color: #ef4444;
  text-align: center;
  margin: 0;
  line-height: 1.5;
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-block: var(--space-5);
}
.preview-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
}
.preview-card img {
  max-height: 180px;
  margin-inline: auto;
  border-radius: var(--radius-sm);
  margin-block-end: var(--space-3);
  object-fit: contain;
}

/* =======================================================
   Specialized Tool Component Styles (Phase 3)
   ======================================================= */

/* 7. Screen Color Test */
.screen-color-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  cursor: pointer;
  user-select: none;
}
.screen-color-overlay.active {
  display: block;
}
.screen-color-tip {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.875rem;
  pointer-events: none;
  font-family: var(--font-system);
}

/* 8. Touchscreen Test */
.touch-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 420px;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.touch-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Touchscreen Fullscreen Styles & Floating HUD */
.touch-canvas-wrapper:fullscreen,
.touch-canvas-wrapper:-webkit-full-screen,
.touch-canvas-wrapper.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border: none !important;
  border-radius: 0 !important;
  z-index: 999999 !important;
  background-color: #0b0f19 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.touch-fs-hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 14px;
  background-color: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  z-index: 1000000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  user-select: none;
  max-width: 95vw;
}

.touch-fs-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.touch-fs-badge small {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.touch-fs-sep {
  color: rgba(255, 255, 255, 0.3);
}

.touch-fs-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.touch-fs-actions button {
  padding: 4px 10px;
  font-size: 0.75rem;
  min-height: 30px;
}

/* 9. Microphone & Speaker Visualizer */
.audio-visualizer-canvas {
  width: 100%;
  height: 120px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  display: block;
  margin-block: var(--space-4);
}
.speaker-channels-grid {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-block: var(--space-4);
  flex-wrap: wrap;
}

/* 10. Gaming Cropper Presets */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
  margin-block: var(--space-4);
}
.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-btn:hover, .preset-btn.active {
  background-color: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}
.preset-btn span.dims {
  font-size: 0.6875rem;
  opacity: 0.8;
}

/* 11. PDF Tool Page Grid & Item Cards */
.file-list-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block: var(--space-4);
}
.file-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-subtle);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

/* 12. QR Code Generator & Preview */
.qr-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  margin-block: var(--space-4);
  min-height: 260px;
}
.qr-preview-box svg, .qr-preview-box canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 13. SVG Sanitizer Code & Preview Diffs */
.svg-diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-block: var(--space-4);
}
@media (max-width: 768px) {
  .svg-diff-grid {
    grid-template-columns: 1fr;
  }
}
.svg-preview-pane {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  min-height: 200px;
}
.svg-preview-pane-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-block-end: var(--space-2);
}
.svg-canvas-render {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-height: 250px;
}
.svg-canvas-render svg {
  max-width: 100%;
  max-height: 200px;
  height: auto;
}

/* 14. Professional DAW Audio Waveform Trimmer */
.audio-trimmer-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: clamp(14px, 2vw, 20px);
  margin-block: var(--space-4);
  user-select: none;
}

.audio-trimmer-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-block-end: var(--space-4);
  direction: ltr !important;
}

.audio-ruler-track {
  position: relative;
  height: 32px;
  background: color-mix(in srgb, var(--bg-surface) 75%, var(--brand-primary-light));
  border: 1px solid var(--border-subtle);
  border-radius: 12px 12px 0 0;
  overflow: visible;
  direction: ltr !important;
}

.audio-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  cursor: ew-resize;
  touch-action: none;
  z-index: 10;
  outline: none;
}

.audio-marker-head {
  position: absolute;
  top: 3px;
  left: 0;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  min-height: 26px;
  min-width: 48px;
  background: #2563eb;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  font: 750 0.72rem/1 var(--font-mono);
  white-space: nowrap;
  pointer-events: auto;
  cursor: ew-resize;
  transition: transform 0.12s ease, background-color 0.12s ease;
  unicode-bidi: plaintext;
}

.audio-marker-head::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #2563eb;
}

.audio-marker:hover .audio-marker-head,
.audio-marker.is-dragging .audio-marker-head,
.audio-marker:focus-visible .audio-marker-head {
  background: #1d4ed8;
  transform: translateX(-50%) scale(1.08);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

.audio-canvas-wrap {
  position: relative;
  width: 100%;
  height: 124px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-top: 0;
  direction: ltr !important;
}

.audio-timeline-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

.audio-selection-box {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(37, 99, 235, 0.2);
  border-left: 2px solid #2563eb;
  border-right: 2px solid #2563eb;
  box-shadow: inset 0 0 16px rgba(37, 99, 235, 0.22);
  pointer-events: auto;
  cursor: grab;
  z-index: 5;
  touch-action: none;
}

.audio-selection-box.is-dragging {
  cursor: grabbing;
  background: rgba(37, 99, 235, 0.28);
}

.audio-selection-handle-l,
.audio-selection-handle-r {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  cursor: ew-resize;
  touch-action: none;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-selection-handle-l {
  left: -12px;
}

.audio-selection-handle-r {
  right: -12px;
}

.audio-selection-handle-l::after,
.audio-selection-handle-r::after {
  content: '';
  display: block;
  width: 6px;
  height: 36px;
  background-color: #2563eb;
  border: 1.5px solid #ffffff;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.audio-selection-handle-l:hover::after,
.audio-selection-handle-r:hover::after,
.audio-selection-handle-l.is-dragging::after,
.audio-selection-handle-r.is-dragging::after {
  background-color: #1d4ed8;
  transform: scale(1.18);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

/* Audio Trimmer Live Real-time Playhead Indicator */
.audio-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  pointer-events: none;
  z-index: 35;
  direction: ltr !important;
}
.audio-playhead-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.85), 0 0 2px #ffffff;
  transform: translateX(-50%);
}
.audio-playhead-badge {
  position: absolute;
  top: 8px;
  left: 0;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid #38bdf8;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  color: #38bdf8;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: transform 0.05s linear;
}
.audio-playhead-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  animation: playhead-pulse 0.9s infinite alternate;
}
@keyframes playhead-pulse {
  0% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.25); box-shadow: 0 0 10px #38bdf8; }
}

[data-theme="light"] .audio-playhead-line {
  background: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.65);
}
[data-theme="light"] .audio-playhead-badge {
  background: rgba(255, 255, 255, 0.94);
  border-color: #0284c7;
  color: #0284c7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .audio-playhead-dot {
  background-color: #0284c7;
  box-shadow: 0 0 6px #0284c7;
}

.time-inputs-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block: var(--space-3);
  flex-wrap: wrap;
}
.time-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-width: 160px;
}
.time-input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.time-input-group input[type="number"], .time-input-group input[type="text"] {
  min-height: 42px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
}

/* Shared iPhone-style system for every tool page */
.container.tool-page,
.tool-page {
  width: 100%;
  max-width: var(--container-tool, 1380px);
  margin-inline: auto;
  min-width: 0;
  padding-block: clamp(20px, 3.5vw, 44px);
  padding-inline: clamp(16px, 2.5vw, 36px);
}

@media (min-width: 1440px) {
  .container.tool-page,
  .tool-page {
    max-width: 1440px;
  }
}

@media (min-width: 1680px) {
  .container.tool-page,
  .tool-page {
    max-width: 1540px;
  }
}

.tool-page > nav {
  margin-block-end: 18px;
}

.tool-page .breadcrumbs-glass {
  max-width: 100%;
  min-height: 38px;
  padding: 7px 14px;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-color: var(--border-glass);
}

.tool-page .breadcrumbs-glass::-webkit-scrollbar {
  display: none;
}

.tool-hero-glass {
  align-items: center;
  min-height: 196px;
  padding: clamp(20px, 3.5vw, 34px);
  margin-block-end: 20px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(56, 189, 248, 0.035)), rgba(14, 22, 40, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  box-shadow: var(--glass-shadow);
}

[data-theme="light"] .tool-hero-glass {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(236, 246, 255, 0.68));
  border-color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 38px -18px rgba(37, 99, 235, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.tool-hero-title {
  margin-block-end: 6px;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.2;
}

.tool-hero-desc {
  margin-block-end: 16px;
  font-size: 0.98rem;
}

.tool-hero-art {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  border-radius: 32px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.16), rgba(255, 255, 255, 0.035));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 14px 32px rgba(0, 0, 0, 0.14);
}

[data-theme="light"] .tool-hero-art {
  background: linear-gradient(145deg, rgba(219, 234, 254, 0.82), rgba(255, 255, 255, 0.78));
  border-color: rgba(59, 130, 246, 0.18);
  box-shadow: inset 0 1px 0 #fff, 0 14px 32px rgba(37, 99, 235, 0.14);
}

.tool-hero-art img {
  width: 148px;
  height: 148px;
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.22));
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-hero-art:hover img {
  transform: scale(1.04);
}

.tool-workspace {
  min-width: 0;
  padding: clamp(18px, 3.2vw, 30px);
  margin-block-end: 20px;
  background: linear-gradient(145deg, rgba(22, 34, 60, 0.66), rgba(10, 16, 30, 0.76));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  box-shadow: var(--glass-shadow);
}

[data-theme="light"] .tool-workspace {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(241, 247, 255, 0.7));
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 44px -22px rgba(37, 99, 235, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.tool-workspace input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]) {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  color: var(--text-main);
  background: rgba(8, 13, 25, 0.58);
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.06);
  font: 500 0.95rem/1.4 var(--font-system);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.tool-workspace select:not(.kz-native-select-hidden) {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 44px 0 16px;
  color: var(--text-main);
  background-color: rgba(8, 13, 25, 0.58);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.06);
  font: 500 0.95rem/1.4 var(--font-system);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

[dir="rtl"] .tool-workspace select:not(.kz-native-select-hidden) {
  padding: 0 16px 0 44px;
  background-position: left 14px center;
}

[data-theme="light"] .tool-workspace input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(100, 116, 139, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 10px rgba(15, 23, 42, 0.035);
}

[data-theme="light"] .tool-workspace select:not(.kz-native-select-hidden) {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.78);
  border-color: rgba(100, 116, 139, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 10px rgba(15, 23, 42, 0.035);
}

.tool-workspace textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 164px;
  padding: 15px 16px;
  color: var(--text-main);
  background: rgba(8, 13, 25, 0.58);
  border: 1px solid var(--border-medium);
  border-radius: 17px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 3px 10px rgba(0, 0, 0, 0.06);
  font: 400 1rem/1.7 var(--font-system);
  resize: vertical;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

[data-theme="light"] .tool-workspace textarea {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(100, 116, 139, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 10px rgba(15, 23, 42, 0.035);
}

.tool-workspace input::placeholder,
.tool-workspace textarea::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

.tool-workspace input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):focus,
.tool-workspace select:focus,
.tool-workspace textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--brand-primary-light), 0 5px 18px rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .tool-workspace input,
[data-theme="dark"] .tool-workspace textarea,
[data-theme="dark"] .tool-workspace select {
  color-scheme: dark;
}

[data-theme="light"] .tool-workspace input,
[data-theme="light"] .tool-workspace textarea,
[data-theme="light"] .tool-workspace select {
  color-scheme: light;
}

.tool-workspace input[type="checkbox"],
.tool-workspace input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-primary);
  vertical-align: middle;
}

.tool-workspace input[type="range"] {
  width: 100%;
  accent-color: var(--brand-primary);
  direction: ltr !important;
}

.tool-workspace input[type="color"] {
  width: 48px;
  height: 48px;
  padding: 4px;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  background: var(--bg-glass);
}

.tool-workspace label {
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
}

.tool-workspace .btn-primary,
.tool-workspace .btn-secondary,
.tool-workspace .dropzone-browse-btn,
.promo-btn {
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-family: var(--font-system);
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.tool-workspace .btn-primary,
.tool-workspace .dropzone-browse-btn,
.promo-btn {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.tool-workspace .btn-secondary {
  color: var(--text-main);
  background: var(--bg-glass);
  border: 1px solid var(--border-medium);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tool-workspace .btn-secondary:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
  border-color: var(--border-medium);
}

.tool-workspace .btn-primary:hover,
.tool-workspace .btn-secondary:hover,
.tool-workspace .dropzone-browse-btn:hover,
.promo-btn:hover {
  transform: translateY(-1px);
}

.tool-workspace button:focus-visible,
.tool-workspace a:focus-visible,
.promo-btn:focus-visible {
  outline: 3px solid var(--brand-primary-border);
  outline-offset: 3px;
}

.tool-workspace button:disabled,
.tool-workspace input:disabled,
.tool-workspace select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.interactive-area,
.dropzone {
  color: var(--text-main);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.08), rgba(255, 255, 255, 0.025)), var(--bg-glass);
  border: 1px solid var(--border-medium);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .interactive-area,
[data-theme="light"] .dropzone {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(230, 242, 255, 0.64));
  border-color: rgba(96, 165, 250, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 28px rgba(37, 99, 235, 0.07);
}

.dropzone {
  min-height: 260px;
  padding: clamp(40px, 6vw, 62px) 24px;
  border: 1px dashed var(--brand-primary-border);
}

.results-box {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 138px), 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .results-box {
  background: rgba(228, 239, 255, 0.54);
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.stat-item {
  min-width: 0;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .stat-item {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.045), inset 0 1px 0 #fff;
}

.stat-value {
  max-width: 100%;
  color: var(--brand-primary);
  font-size: clamp(1.25rem, 3.8vw, 1.8rem);
  overflow-wrap: anywhere;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.45;
  text-transform: none;
}

.age-calculator {
  width: 100%;
  max-width: 680px;
  margin-inline: auto;
}

.age-date-field {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin-inline: auto;
  margin-block-end: 22px;
}

.age-date-field label {
  font-size: 0.9rem;
  font-weight: 700;
}

.age-date-input {
  text-align: center;
  font-weight: 650;
}

.age-results {
  display: none;
}

.age-summary-panel {
  margin-block-end: 16px;
  padding: clamp(16px, 3vw, 24px);
  text-align: center;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.09), rgba(255, 255, 255, 0.025)), var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .age-summary-panel {
  background: linear-gradient(145deg, rgba(232, 243, 255, 0.78), rgba(255, 255, 255, 0.68));
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 #fff, 0 8px 20px rgba(37, 99, 235, 0.05);
}

.age-summary-title {
  margin-block-end: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.age-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.age-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}

[data-theme="light"] .age-summary-item {
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(255, 255, 255, 0.9);
}

.age-summary-value {
  color: var(--brand-primary);
  font: 800 clamp(1.5rem, 5vw, 2.25rem)/1.1 var(--font-mono);
}

.age-summary-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.age-results-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-block-end: 0;
}

.stat-value-text {
  font-family: var(--font-system);
  font-size: 1rem;
  line-height: 1.35;
}

.file-list-item,
.preview-card,
.qr-preview-box,
.audio-trimmer-wrapper,
.svg-preview-pane {
  background: var(--bg-glass);
  border-color: var(--border-glass);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .file-list-item,
[data-theme="light"] .preview-card,
[data-theme="light"] .qr-preview-box,
[data-theme="light"] .audio-trimmer-wrapper,
[data-theme="light"] .svg-preview-pane {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(255, 255, 255, 0.88);
}

.tool-disclosures {
  gap: 10px;
  margin-block-start: 18px;
}

/* Accordion inherits rich liquid glass styling from glass.css */

@media (max-width: 640px) {
  .tool-page {
    padding-block: 18px 28px;
  }

  .tool-page > nav {
    margin-block-end: 12px;
  }

  .tool-hero-glass {
    flex-direction: column-reverse;
    min-height: 0;
    gap: 12px;
    padding: 18px;
    text-align: center;
  }

  .tool-hero-art {
    width: 112px;
    height: 112px;
    border-radius: 24px;
    padding: 4px;
  }

  .tool-hero-art img {
    width: 102px;
    height: 102px;
    max-width: 95%;
    max-height: 95%;
  }

  .tool-hero-title {
    font-size: clamp(1.55rem, 6vw, 2rem);
  }

  .tool-hero-desc {
    margin-inline: auto;
    font-size: 0.9rem;
  }

  .tool-hero-badges {
    justify-content: center;
  }

  .tool-workspace {
    padding: 16px;
    border-radius: 22px;
  }

  .age-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dropzone {
    min-height: 200px;
  }

  .time-input-group {
    flex: 1 1 150px;
    min-width: 0;
  }
}

/* ==========================================================================
   Top 100 Global Leaderboard & Hall of Fame (Modern Minimalist Component)
   ========================================================================== */

.kz-leaderboard-panel {
  margin-top: var(--space-8, 32px);
  margin-bottom: var(--space-8, 32px);
  background: var(--bg-surface, #121827);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-6, 24px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: border-color var(--transition-fast, 0.2s ease);
}

[data-theme="light"] .kz-leaderboard-panel {
  background: var(--bg-surface, #ffffff);
  border-color: var(--border-medium, rgba(0, 0, 0, 0.08));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

/* Header */
.kz-lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4, 16px);
  padding-bottom: var(--space-5, 20px);
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  margin-bottom: var(--space-5, 20px);
  flex-wrap: wrap;
}

[data-theme="light"] .kz-lb-header {
  border-bottom-color: var(--border-subtle, rgba(0, 0, 0, 0.06));
}

.kz-lb-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.kz-lb-trophy-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md, 10px);
  background: rgba(234, 179, 8, 0.12);
  color: #eab308;
  flex-shrink: 0;
}

[data-theme="light"] .kz-lb-trophy-badge {
  background: rgba(217, 119, 6, 0.12);
  color: #d97706;
}

.kz-lb-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main, #f8fafc);
  line-height: 1.3;
}

[data-theme="light"] .kz-lb-title {
  color: var(--text-main, #0f172a);
}

.kz-lb-subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
}

.kz-lb-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.kz-lb-live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.kz-lb-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: kz-pulse 2s infinite ease-in-out;
}

@keyframes kz-pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}


/* Table */
.kz-lb-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-4, 16px);
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.04));
}

[data-theme="light"] .kz-lb-table-wrap {
  border-color: var(--border-subtle, rgba(0, 0, 0, 0.04));
}

.kz-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: start;
}

.kz-lb-table th {
  padding: 12px 16px;
  background: var(--bg-subtle, rgba(255, 255, 255, 0.03));
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-medium, rgba(255, 255, 255, 0.08));
}

[data-theme="light"] .kz-lb-table th {
  background: var(--bg-subtle, #f8fafc);
  color: var(--text-muted, #64748b);
  border-bottom-color: var(--border-medium, #e2e8f0);
}

.kz-lb-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.04));
  color: var(--text-main, #f8fafc);
  vertical-align: middle;
}

[data-theme="light"] .kz-lb-table td {
  border-bottom-color: var(--border-subtle, rgba(0, 0, 0, 0.04));
  color: var(--text-main, #0f172a);
}

.kz-lb-row {
  transition: background-color var(--transition-fast, 0.15s ease);
}

.kz-lb-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .kz-lb-row:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Podium Ranks */
.kz-lb-row.rank-gold {
  background: rgba(234, 179, 8, 0.06);
}

.kz-lb-row.rank-gold:hover {
  background: rgba(234, 179, 8, 0.1);
}

.kz-lb-row.rank-silver {
  background: rgba(148, 163, 184, 0.05);
}

.kz-lb-row.rank-silver:hover {
  background: rgba(148, 163, 184, 0.08);
}

.kz-lb-row.rank-bronze {
  background: rgba(217, 119, 6, 0.05);
}

.kz-lb-row.rank-bronze:hover {
  background: rgba(217, 119, 6, 0.08);
}

.kz-lb-row.highlight-new-entry {
  animation: kz-row-flash 2.5s ease-out;
}

@keyframes kz-row-flash {
  0% { background: rgba(34, 197, 94, 0.28); }
  50% { background: rgba(34, 197, 94, 0.14); }
  100% { background: transparent; }
}

/* Rank Badges */
.kz-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-sm, 8px);
  font-weight: 800;
  font-size: 0.88rem;
  background: var(--bg-subtle, rgba(255, 255, 255, 0.06));
  color: var(--text-muted, #94a3b8);
}

[data-theme="light"] .kz-rank-badge {
  background: var(--bg-subtle, #f1f5f9);
  color: var(--text-muted, #64748b);
}

.rank-gold .kz-rank-badge {
  background: #eab308;
  color: #000000;
  font-weight: 900;
}

.rank-silver .kz-rank-badge {
  background: #cbd5e1;
  color: #0f172a;
  font-weight: 900;
}

.rank-bronze .kz-rank-badge {
  background: #d97706;
  color: #ffffff;
  font-weight: 900;
}

/* Player Cell */
.kz-player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kz-flag {
  font-size: 1.15rem;
  line-height: 1;
}

.kz-player-name {
  font-weight: 700;
  color: var(--text-main, #f8fafc);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

[data-theme="light"] .kz-player-name {
  color: var(--text-main, #0f172a);
}

.kz-device-icon {
  opacity: 0.55;
  font-size: 0.85rem;
  line-height: 1;
}

/* Score Values */
.kz-col-score {
  white-space: nowrap;
}

.kz-score-val {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--brand-primary, #6366f1);
}

.kz-score-unit {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
  margin-inline-start: 4px;
  font-weight: 600;
}

/* Secondary Metric Pill */
.kz-metric-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-subtle, rgba(255, 255, 255, 0.06));
  color: var(--text-muted, #cbd5e1);
  font-size: 0.82rem;
  font-weight: 600;
}

[data-theme="light"] .kz-metric-pill {
  background: var(--bg-subtle, #f1f5f9);
  color: var(--text-muted, #475569);
}

.kz-date-cell {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
}

/* Loading & Empty States */
.kz-lb-loading-cell,
.kz-lb-empty-cell {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted, #94a3b8);
}

.kz-lb-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--brand-primary, #6366f1);
  border-radius: 50%;
  animation: kz-spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

[data-theme="light"] .kz-lb-spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--brand-primary, #6366f1);
}

@keyframes kz-spin {
  to { transform: rotate(360deg); }
}

/* Pagination (Strictly 20 per page) */
.kz-lb-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4, 16px);
  padding-top: var(--space-4, 16px);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  flex-wrap: wrap;
}

[data-theme="light"] .kz-lb-pagination {
  border-top-color: var(--border-subtle, rgba(0, 0, 0, 0.06));
}

.kz-lb-page-info {
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 600;
}

.kz-lb-page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kz-lb-page-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-subtle, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.1));
  color: var(--text-main, #f8fafc);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-theme="light"] .kz-lb-page-btn {
  background: var(--bg-subtle, #f1f5f9);
  border-color: var(--border-medium, #cbd5e1);
  color: var(--text-main, #334155);
}

.kz-lb-page-btn:hover:not(:disabled) {
  background: var(--brand-primary, #6366f1);
  color: #ffffff;
  border-color: var(--brand-primary, #6366f1);
}

.kz-lb-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.kz-lb-pages-list {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kz-lb-page-num {
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-subtle, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-main, #f8fafc);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

[data-theme="light"] .kz-lb-page-num {
  background: var(--bg-subtle, #f8fafc);
  border-color: var(--border-subtle, #e2e8f0);
  color: var(--text-main, #334155);
}

.kz-lb-page-num:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .kz-lb-page-num:hover:not(.active) {
  background: #e2e8f0;
}

.kz-lb-page-num.active {
  background: var(--brand-primary, #6366f1);
  color: #ffffff;
  border-color: var(--brand-primary, #6366f1);
}

/* Record Qualified Score Dialog */
.kz-record-dialog {
  border: none;
  background: transparent;
  padding: 0;
  margin: auto;
  max-width: 480px;
  width: 92vw;
}

.kz-record-dialog::backdrop {
  background: rgba(10, 15, 28, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.kz-record-card {
  background: var(--bg-surface, #121827);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-6, 24px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: kz-dialog-appear 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .kz-record-card {
  background: var(--bg-surface, #ffffff);
  border-color: var(--border-medium, rgba(0, 0, 0, 0.12));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

@keyframes kz-dialog-appear {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.kz-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4, 16px);
}

.kz-dialog-header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.kz-rec-trophy {
  font-size: 1.8rem;
  line-height: 1;
}

.kz-dialog-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main, #f8fafc);
}

[data-theme="light"] .kz-dialog-title {
  color: var(--text-main, #0f172a);
}

.kz-dialog-desc {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
}

.kz-dialog-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  border-radius: var(--radius-sm, 6px);
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kz-dialog-close-btn:hover {
  background: var(--bg-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-main, #f8fafc);
}

/* Score Highlight Box */
.kz-rec-score-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4, 16px);
  background: var(--bg-subtle, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 10px);
  margin-bottom: var(--space-5, 20px);
}

[data-theme="light"] .kz-rec-score-box {
  background: var(--bg-subtle, #f8fafc);
  border-color: var(--border-medium, #e2e8f0);
}

.kz-rec-score-label {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 600;
}

.kz-rec-score-num {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brand-primary, #6366f1);
  margin-inline-end: 4px;
}

.kz-rec-score-unit {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
}

.kz-rec-proj-badge {
  padding: 6px 12px;
  border-radius: var(--radius-sm, 8px);
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  font-size: 0.82rem;
  font-weight: 800;
}

/* Form */
.kz-rec-form-group {
  margin-bottom: var(--space-4, 16px);
}

.kz-rec-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main, #f8fafc);
  margin-bottom: 6px;
}

[data-theme="light"] .kz-rec-label {
  color: var(--text-main, #0f172a);
}

.kz-rec-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-subtle, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.12));
  color: var(--text-main, #f8fafc);
  font-size: 0.95rem;
  font-weight: 600;
  box-sizing: border-box;
  transition: border-color var(--transition-fast, 0.15s ease);
}

[data-theme="light"] .kz-rec-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.kz-rec-input:focus {
  outline: none;
  border-color: var(--brand-primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.kz-rec-input-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 6px;
}

.kz-rec-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm, 6px);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: var(--space-4, 16px);
  line-height: 1.4;
}

/* Actions */
.kz-rec-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3, 12px);
  margin-top: var(--space-5, 20px);
}

.kz-btn-rec-cancel {
  min-height: 48px;
  padding: 10px 18px;
  border-radius: var(--radius-sm, 8px);
  background: transparent;
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.12));
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
}

[data-theme="light"] .kz-btn-rec-cancel {
  border-color: #cbd5e1;
  color: #64748b;
}

.kz-btn-rec-cancel:hover {
  background: var(--bg-subtle, rgba(255, 255, 255, 0.05));
  color: var(--text-main, #f8fafc);
}

.kz-btn-rec-submit {
  min-height: 48px;
  padding: 10px 22px;
  border-radius: var(--radius-sm, 8px);
  background: var(--brand-primary, #6366f1);
  border: 1px solid var(--brand-primary, #6366f1);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
}

.kz-btn-rec-submit:hover:not(:disabled) {
  background: var(--brand-hover, #4f46e5);
}

.kz-btn-rec-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .kz-leaderboard-panel {
    padding: var(--space-4, 16px);
    margin-top: var(--space-5, 20px);
  }

  .kz-lb-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .kz-lb-table th,
  .kz-lb-table td {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .kz-col-date {
    display: none;
  }

  .kz-player-name {
    max-width: 130px;
  }

  .kz-lb-pagination {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .kz-lb-page-nav {
    width: 100%;
    justify-content: center;
  }

  .kz-lb-page-btn,
  .kz-lb-page-num {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .kz-player-name {
    max-width: 100px;
  }

  .kz-lb-page-num {
    min-width: 40px;
    min-height: 40px;
    padding: 0 8px;
  }
}


/* Refined text editor and accessible date picker */
.word-counter-app {
  width: 100%;
}

.word-counter-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: 10px;
}

.word-counter-editor-header label {
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 700;
}

.word-counter-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: var(--text-muted);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.word-counter-live > span {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  background: #3b82f6;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.tool-workspace textarea.word-counter-input {
  min-height: 176px;
  max-height: min(60vh, 520px);
  padding: 17px 18px;
  color: var(--text-main);
  background: radial-gradient(ellipse at 100% 0%, rgba(59, 130, 246, 0.09), transparent 48%), rgba(8, 13, 25, 0.58);
  border-radius: 20px;
  font-size: 1rem;
  line-height: 1.75;
  text-align: start;
  caret-color: var(--brand-primary);
  resize: vertical;
  scrollbar-color: rgba(100, 116, 139, 0.55) transparent;
}

.tool-workspace textarea.word-counter-input::placeholder {
  color: var(--text-subtle);
  opacity: 0.88;
}

.tool-workspace textarea.word-counter-input:focus {
  background: radial-gradient(ellipse at 100% 0%, rgba(59, 130, 246, 0.13), transparent 50%), rgba(12, 20, 37, 0.84);
  border-color: rgba(59, 130, 246, 0.68);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14), 0 12px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .tool-workspace textarea.word-counter-input {
  background: radial-gradient(ellipse at 100% 0%, rgba(59, 130, 246, 0.07), transparent 50%), rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 #fff, 0 5px 18px rgba(15, 23, 42, 0.045);
}

[data-theme="light"] .tool-workspace textarea.word-counter-input:focus {
  background: radial-gradient(ellipse at 100% 0%, rgba(59, 130, 246, 0.09), transparent 52%), #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), 0 10px 24px rgba(15, 23, 42, 0.07);
}

.age-date-field {
  position: relative;
  z-index: 2;
}

.age-date-field > label {
  color: var(--text-main);
  text-align: start;
}

.age-date-picker {
  position: relative;
  z-index: 50;
  width: 100%;
}

.age-date-trigger {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 0 17px;
  color: var(--text-main);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.09), transparent 68%), rgba(8, 13, 25, 0.58);
  border: 1px solid var(--border-medium);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 5px 16px rgba(0, 0, 0, 0.08);
  font: 600 0.98rem/1.4 var(--font-system);
  text-align: start;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.age-date-trigger:hover {
  border-color: rgba(59, 130, 246, 0.48);
  transform: translateY(-1px);
}

.age-date-trigger:focus-visible,
.age-calendar-nav:focus-visible,
.age-calendar-day:focus-visible,
.age-calendar-this-month:focus-visible,
.age-calendar-footer-btn:focus-visible,
.age-calendar-select:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.32);
  outline-offset: 2px;
}

.age-date-trigger-icon {
  width: 21px;
  height: 21px;
  color: var(--brand-primary);
}

.age-date-trigger-value {
  overflow: hidden;
  color: var(--text-main);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age-date-trigger-value.is-placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.age-date-trigger-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 160ms ease;
}

.age-date-trigger[aria-expanded="true"] .age-date-trigger-chevron {
  transform: rotate(180deg);
}

[data-theme="light"] .age-date-trigger {
  background: linear-gradient(145deg, rgba(219, 234, 254, 0.68), transparent 70%), rgba(255, 255, 255, 0.9);
  border-color: rgba(100, 116, 139, 0.2);
  box-shadow: inset 0 1px 0 #fff, 0 6px 18px rgba(37, 99, 235, 0.06);
}

.age-calendar-popover[hidden] {
  display: none !important;
}

.age-calendar-popover {
  position: absolute;
  z-index: 100;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  margin-inline: auto;
  width: min(370px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 16px;
  color: var(--text-main);
  background: rgba(10, 16, 30, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(28px) saturate(145%);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  animation: age-calendar-in 150ms ease-out both;
}

[data-theme="light"] .age-calendar-popover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(100, 116, 139, 0.22);
  box-shadow: 0 24px 64px rgba(30, 64, 110, 0.18), inset 0 1px 0 #fff;
}

@keyframes age-calendar-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.age-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-end: 14px;
}

.age-calendar-selects {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.age-calendar-select {
  box-sizing: border-box;
  appearance: auto;
  -webkit-appearance: menulist;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 6px 8px;
  cursor: pointer;
  text-align: center;
  min-height: 38px;
  transition: border-color .15s ease, background-color .15s ease;
}

.age-calendar-select:hover {
  border-color: var(--brand-primary);
}

.age-calendar-select-month {
  flex: 1.3;
  min-width: 0;
}

.age-calendar-select-year {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
}

[data-theme="light"] .age-calendar-select {
  background: #fff;
  border-color: rgba(100, 116, 139, 0.25);
  color: var(--text-main);
}

.age-calendar-month {
  margin: 0;
  color: var(--text-main);
  font-size: 0.98rem;
  font-weight: 750;
  text-align: center;
}

.age-calendar-nav {
  display: grid;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--text-main);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.age-calendar-nav:hover:not(:disabled) {
  color: #fff;
  background: var(--brand-primary);
}

.age-calendar-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.age-calendar-nav svg {
  width: 18px;
  height: 18px;
}

.age-calendar-weekdays,
.age-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.age-calendar-weekdays {
  margin-block-end: 5px;
}

.age-calendar-weekdays > span {
  display: grid;
  min-height: 32px;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.age-calendar-day,
.age-calendar-empty {
  display: grid;
  min-width: 0;
  min-height: 38px;
  place-items: center;
  border-radius: 12px;
}

.age-calendar-day {
  color: var(--text-main);
  background: transparent;
  border: 1px solid transparent;
  font: 600 0.88rem/1 var(--font-system);
  cursor: pointer;
  transition: color 130ms ease, background-color 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.age-calendar-day:hover:not(:disabled) {
  color: #fff;
  background: rgba(59, 130, 246, 0.72);
  transform: scale(1.04);
}

.age-calendar-day.is-today {
  color: var(--brand-primary);
  border-color: rgba(59, 130, 246, 0.36);
}

.age-calendar-day.is-selected,
.age-calendar-day.is-selected:hover {
  color: #fff;
  background: linear-gradient(145deg, #4f8fff, #2563eb);
  border-color: transparent;
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.3);
}

.age-calendar-day:disabled {
  color: var(--text-subtle);
  opacity: 0.35;
  cursor: not-allowed;
}

.age-calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-start: 12px;
  padding-block-start: 11px;
  border-block-start: 1px solid rgba(148, 163, 184, 0.14);
}

.age-calendar-footer-btn,
.age-calendar-this-month {
  padding: 6px 14px;
  min-height: 36px;
  color: var(--brand-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.age-calendar-footer-btn:hover,
.age-calendar-this-month:hover {
  background: var(--brand-primary-light);
}

.age-calendar-footer-btn.btn-clear {
  color: var(--text-muted);
}

.age-calendar-footer-btn.btn-clear:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

@media (max-width: 480px) {
  .word-counter-editor-header {
    align-items: flex-start;
  }

  .tool-workspace textarea.word-counter-input {
    min-height: 160px;
    padding: 15px;
  }

  .age-calendar-popover {
    padding: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .age-calendar-popover {
    animation: none;
  }
}

/* Shared native-feeling workspaces for the expanded tool catalog */
.extra-tool {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.extra-tool [hidden] { display: none !important; }

.extra-tool > label,
.extra-tool .control-row > label,
.extra-two-col > label,
.extra-two-col > div {
  display: flex;
  flex: 1 1 190px;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 650;
}

.extra-tool textarea,
.extra-tool input[type="text"],
.extra-tool input[type="number"],
.extra-tool input:not([type]),
.extra-tool select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 14px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  font: 500 0.94rem/1.55 var(--font-system);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.extra-tool textarea {
  min-height: 132px;
  resize: vertical;
  font-family: var(--font-system);
}

.extra-tool textarea[dir="ltr"],
.extra-tool input[dir="ltr"] {
  font-family: var(--font-mono);
}

.extra-tool textarea:focus-visible,
.extra-tool input:focus-visible,
.extra-tool select:focus-visible,
.extra-tool button:focus-visible,
.extra-tool a:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.32);
  outline-offset: 2px;
}

.extra-tool input[type="color"] {
  width: 56px;
  height: 46px;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 13px;
  cursor: pointer;
}

.extra-tool input[type="range"] {
  min-height: 32px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  direction: ltr !important;
}

.extra-tool input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-primary);
}

.extra-tool input[type="file"] {
  display: none !important;
}

.control-row {
  display: flex;
  align-items: end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.control-row > label {
  flex: 1 1 140px;
}

.control-row > button,
.control-row > a,
.control-row > .file-button {
  flex: 0 0 auto;
}

.extra-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.extra-status {
  display: block;
  min-height: 1.35em;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.extra-status[data-kind="success"] { color: #16a34a; }
.extra-status[data-kind="warning"] { color: #d97706; }
.extra-status[data-kind="error"] { color: #dc2626; }

.extra-hint,
.field-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-touch-size);
  padding: 0 18px;
  overflow: hidden;
  cursor: pointer;
}

.extra-file-list {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.extra-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 13px;
  overflow-wrap: anywhere;
  color: var(--text-main);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  font-size: 0.86rem;
}

.extra-file-item > span { min-width: 0; }
.extra-file-item .btn-secondary { min-height: 38px; padding-inline: 13px; }
.extra-file-item button:disabled { opacity: 0.45; }

.color-swatch {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border-medium);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 24px rgba(15, 23, 42, 0.12);
}

.color-value {
  padding: 0;
  color: var(--text-main);
  background: transparent;
  border: 0;
  font: 700 1rem/1.5 var(--font-mono);
  cursor: pointer;
}

.color-copy { width: 100%; cursor: pointer; }
.color-picker-stage { display: grid; gap: 12px; justify-items: start; }
.color-picker-stage canvas { display: block; max-width: 100%; max-height: 65vh; object-fit: contain; border: 1px solid var(--border-medium); border-radius: 16px; cursor: crosshair; }
.color-picker-stage .color-swatch { width: 74px; min-height: 54px; }

.qr-preview-box { display: grid; min-height: 240px; place-items: center; padding: 20px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 20px; }
.qr-output img { display: block; width: min(100%, 280px); height: auto; image-rendering: pixelated; }
.scanner-video { width: min(100%, 620px); max-height: 55vh; margin-inline: auto; background: #050810; border-radius: 18px; }
.ocr-preview { display: block; max-width: min(100%, 480px); max-height: 320px; margin-inline: auto; object-fit: contain; border-radius: 16px; }
.ocr-progress-wrap { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem; }
.ocr-progress-wrap progress { width: min(100%, 420px); accent-color: var(--brand-primary); }
.pdf-preview { display: block; max-width: min(100%, 480px); height: auto; margin: 14px auto; border: 1px solid var(--border-subtle); border-radius: 12px; }
/* ==========================================================================
   Markdown Editor & Previewer 2.0 (Full-Screen, Wide Mode & Extended GFM)
   ========================================================================== */

.markdown-editor-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Wide Screen Mode */
.tool-page.is-wide {
  max-width: min(100vw - 32px, 1720px) !important;
  width: 100% !important;
}

/* True Fullscreen Overlay Mode & Document Isolation */
html.is-mp-fullscreen,
body.is-mp-fullscreen {
  overflow: hidden !important;
  height: 100vh !important;
  width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.is-mp-fullscreen .site-header,
body.is-mp-fullscreen nav[aria-label="Breadcrumb"],
body.is-mp-fullscreen .breadcrumbs-glass,
body.is-mp-fullscreen .tool-hero-glass,
body.is-mp-fullscreen .tool-feature-grid,
body.is-mp-fullscreen .site-footer {
  display: none !important;
}

body.is-mp-fullscreen .container,
body.is-mp-fullscreen .tool-page {
  max-width: none !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.is-mp-fullscreen .tool-workspace {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transform: none !important;
  filter: none !important;
  background: var(--bg-main, #0b0f19) !important;
  z-index: 9999999 !important;
  overflow: hidden !important;
}

.markdown-editor-shell.mp-fullscreen-mode,
#markdown-preview-app:fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000000 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  background: var(--bg-surface, #0f172a) !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

.markdown-editor-shell.mp-fullscreen-mode .mp-workspace-body,
#markdown-preview-app:fullscreen .mp-workspace-body {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
}

.markdown-editor-shell.mp-fullscreen-mode .mp-pane,
#markdown-preview-app:fullscreen .mp-pane {
  height: 100% !important;
  min-height: 0 !important;
}

.markdown-editor-shell.mp-fullscreen-mode .markdown-preview,
#markdown-preview-app:fullscreen .markdown-preview {
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
}

/* Header Action Bar */
.mp-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow-sm);
}

.mp-view-toggles {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  gap: 2px;
}

.mp-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 32px;
}

.mp-view-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.mp-view-btn.is-active {
  background: var(--brand-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mp-top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.mp-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 36px;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.mp-file-upload-label {
  cursor: pointer;
}

/* Formatting Toolbar */
.mp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
}

.mp-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.mp-group-end {
  margin-inline-start: auto;
}

.mp-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin-inline: 4px;
}

.mp-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.825rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mp-tb-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
  color: var(--brand-primary);
}

.mp-tb-btn:active {
  transform: scale(0.96);
}

.mp-tb-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.mp-tb-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}

/* Alerts Dropdown */
.mp-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.mp-dropdown-menu {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  margin-top: 6px;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow-lg);
  padding: 4px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-dropdown-menu[hidden] {
  display: none !important;
}

.mp-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: start;
  width: 100%;
}

.mp-dropdown-item:hover {
  background: var(--bg-subtle);
  color: var(--brand-primary);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-dot.note { background: #3b82f6; }
.badge-dot.tip { background: #10b981; }
.badge-dot.important { background: #8b5cf6; }
.badge-dot.warning { background: #f59e0b; }
.badge-dot.caution { background: #ef4444; }

/* Workspace Dual Split Panels */
.mp-workspace-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  height: clamp(620px, 72vh, 880px);
  min-height: 520px;
  transition: all 0.2s ease;
}

.markdown-editor-shell.view-editor .mp-workspace-body {
  grid-template-columns: 1fr;
}
.markdown-editor-shell.view-editor .mp-pane-preview {
  display: none !important;
}

/* User requirement: In Editor screen only, hide the collapse button completely */
.markdown-editor-shell.view-editor .mp-pane-collapse-btn {
  display: none !important;
}
.markdown-editor-shell.view-editor .mp-pane-editor {
  width: 100% !important;
  max-width: 100% !important;
}
.markdown-editor-shell.view-editor .mp-editor-inner {
  width: 100% !important;
  height: 100% !important;
}

.markdown-editor-shell.view-preview .mp-workspace-body {
  grid-template-columns: 1fr;
}
.markdown-editor-shell.view-preview .mp-pane-editor {
  display: none !important;
}

/* Collapsible Editor Layout & Toggle */
.markdown-editor-shell.editor-collapsed .mp-workspace-body {
  grid-template-columns: 44px 1fr !important;
}

[dir="rtl"] .markdown-editor-shell.editor-collapsed .mp-workspace-body {
  grid-template-columns: 44px 1fr !important;
}

.markdown-editor-shell.editor-collapsed .mp-toolbar {
  display: none !important;
}

.mp-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--glass-shadow-sm);
  min-height: 0;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Editor Pane: Horizontal Layout on Desktop (Editor Inner + Full-height Collapse Rail) */
.mp-pane-editor {
  position: relative;
  display: flex;
  flex-direction: row;
  min-width: 0;
  height: 100%;
}

.mp-editor-inner {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mp-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
}

.mp-pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 700;
}

.mp-pane-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-hint-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Collapse Rail Button: Spans Full Height of Editor on Desktop */
.mp-pane-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  width: 24px;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border: none;
  border-inline-start: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
}

.mp-pane-collapse-btn:hover,
.mp-pane-collapse-btn:focus-visible {
  background: var(--bg-surface);
  color: var(--brand-primary);
  outline: none;
}

.mp-collapse-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.mp-collapse-text {
  display: none;
}

.mp-collapse-arrow {
  display: block;
  flex-shrink: 0;
  color: currentColor;
  stroke: currentColor;
  stroke-width: 3px;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Arrow orientation: Desktop RTL editor collapses rightward */
[dir="rtl"] .mp-collapse-arrow {
  transform: scaleX(-1);
}

/* Collapsed state (Desktop horizontal split) */
.mp-pane-editor.is-collapsed {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  flex: 0 0 44px !important;
  padding: 0 !important;
  cursor: pointer;
  user-select: none;
  background: var(--bg-surface) !important;
  border-color: var(--border-medium);
}

.mp-pane-editor.is-collapsed:hover {
  border-color: var(--brand-primary);
  background: var(--bg-subtle) !important;
}

.mp-pane-editor.is-collapsed .mp-editor-inner {
  display: none !important;
}

.mp-pane-editor.is-collapsed .mp-pane-collapse-btn {
  width: 100% !important;
  height: 100% !important;
  flex: 1 1 100% !important;
  border-inline-start: none !important;
  background: transparent !important;
}

.mp-pane-editor.is-collapsed .mp-collapse-text {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  color: var(--text-main);
}

.mp-pane-editor.is-collapsed:hover .mp-collapse-text {
  color: var(--brand-primary);
}

.mp-pane-editor.is-collapsed .mp-collapse-arrow {
  transform: rotate(180deg) !important;
}

[dir="rtl"] .mp-pane-editor.is-collapsed .mp-collapse-arrow {
  transform: scaleX(-1) rotate(180deg) !important;
}

.mp-sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}
.mp-sync-toggle input {
  cursor: pointer;
  accent-color: var(--brand-primary);
}

.mp-editor-wrap {
  flex: 1 1 0;
  display: flex;
  min-height: 0;
}

#mp-input {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: none;
  outline: none;
  padding: 18px 20px;
  font-family: var(--font-mono, monospace);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  background: transparent;
  tab-size: 2;
  box-sizing: border-box;
}

/* Enhanced Preview Pane Styling */
.mp-pane-preview {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.mp-pane-preview .mp-pane-header {
  width: 100% !important;
  flex: 0 0 auto !important;
}

.markdown-preview {
  flex: 1 1 0;
  height: 100%;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto;
  padding: 22px 28px;
  color: var(--text-main);
  background: var(--bg-surface);
  line-height: 1.8;
  font-size: 1rem;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

.markdown-preview > *:last-child {
  margin-bottom: 0 !important;
}

.markdown-preview h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
  margin-block: 0.8em 0.5em;
}

.markdown-preview h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 750;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-block: 1em 0.5em;
}

.markdown-preview h3 {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  font-weight: 700;
  margin-block: 0.9em 0.4em;
}

.markdown-preview h4, .markdown-preview h5, .markdown-preview h6 {
  margin-block: 0.8em 0.3em;
  font-weight: 650;
}

.markdown-preview p {
  margin-block: 0.6em 0.8em;
}

.markdown-preview hr {
  height: 1px;
  border: none;
  background: var(--border-medium);
  margin-block: 24px;
}

.markdown-preview blockquote {
  margin-block: 14px;
  padding: 10px 18px;
  color: var(--text-muted);
  border-inline-start: 4px solid var(--brand-primary);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.markdown-preview ul, .markdown-preview ol {
  padding-inline-start: 24px;
  margin-block: 8px 14px;
}

.markdown-preview li {
  margin-block: 4px;
}

/* GitHub Callout Alerts */
.md-alert {
  margin-block: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border-inline-start: 4px solid var(--border-medium);
  background: var(--bg-subtle);
}

.md-alert-note {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.md-alert-tip {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.md-alert-important {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}
.md-alert-warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.md-alert-caution {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.md-alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.md-alert-note .md-alert-header { color: #3b82f6; }
.md-alert-tip .md-alert-header { color: #10b981; }
.md-alert-important .md-alert-header { color: #8b5cf6; }
.md-alert-warning .md-alert-header { color: #f59e0b; }
.md-alert-caution .md-alert-header { color: #ef4444; }

.md-alert-title {
  font-size: 0.9rem;
  font-weight: 750;
  text-transform: capitalize;
}

.md-alert-body {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.6;
}
.md-alert-body p:first-child { margin-top: 0; }
.md-alert-body p:last-child { margin-bottom: 0; }

/* Code Blocks & Cards */
.md-code-card {
  margin-block: 16px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: #0d1117;
  overflow: hidden;
}

.md-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.md-code-lang {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #8b949e;
  text-transform: uppercase;
}

.md-code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 0.75rem;
  color: #c9d1d9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.md-code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.md-code-card pre {
  margin: 0;
  padding: 14px 16px;
  background: transparent;
  direction: ltr;
  text-align: start;
  overflow-x: auto;
  color: #e6edf3;
  font-family: var(--font-mono, monospace);
  font-size: 0.9rem;
  line-height: 1.55;
}

.markdown-preview :not(pre) > code {
  padding: 2px 6px;
  font-family: var(--font-mono, monospace);
  font-size: 0.88em;
  color: var(--brand-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

/* Rich Tables */
.markdown-preview table {
  display: table;
  width: 100%;
  margin-block: 16px;
  border-collapse: collapse;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-medium);
}

.markdown-preview thead {
  background: var(--bg-subtle);
}

.markdown-preview th {
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}

.markdown-preview td {
  padding: 9px 14px;
  border: 1px solid var(--border-medium);
}

.markdown-preview tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Task Checklists */
.markdown-preview input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--brand-primary);
  margin-inline-end: 8px;
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.markdown-preview li:has(input[type="checkbox"]) {
  list-style: none;
  margin-inline-start: -16px;
}

/* Highlights & Kbd */
.markdown-preview mark, .markdown-preview .md-highlight {
  background: #fde047;
  color: #1f2937;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 500;
}

.markdown-preview kbd {
  display: inline-block;
  padding: 3px 6px;
  font-family: var(--font-mono, monospace);
  font-size: 0.8em;
  line-height: 1;
  color: var(--text-main);
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Status Bar */
.mp-statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mp-stats-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.mp-stat-sep {
  opacity: 0.4;
}

.mp-autosave-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--status-success, #10b981);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  .markdown-preview, .markdown-preview * {
    visibility: visible;
  }
  .markdown-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: auto;
    overflow: visible;
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .mp-workspace-body {
    grid-template-columns: 1fr;
    height: auto;
  }
  .mp-pane {
    height: 480px;
  }
  .mp-action-label {
    display: none;
  }
  .mp-group-end {
    margin-inline-start: 0;
  }

  /* In mobile vertical layout: editor is stacked vertically, so collapse button is full width (horizontal rail) */
  .mp-pane-editor {
    flex-direction: column !important;
  }

  .mp-pane-editor .mp-pane-collapse-btn {
    width: 100% !important;
    height: 38px !important;
    min-height: 38px !important;
    flex: 0 0 38px !important;
    border-inline-start: none !important;
    border-top: 1px solid var(--border-subtle) !important;
  }

  .mp-pane-collapse-btn .mp-collapse-indicator {
    flex-direction: row !important;
    gap: 8px !important;
  }

  .mp-pane-collapse-btn .mp-collapse-text {
    display: inline-block !important;
    writing-mode: horizontal-tb !important;
    transform: none !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
  }

  .mp-collapse-arrow {
    transform: rotate(90deg) !important;
  }

  [dir="rtl"] .mp-collapse-arrow {
    transform: rotate(90deg) !important;
  }

  /* Vertical collapse on mobile (Editor folds UPWARDS) */
  .markdown-editor-shell.editor-collapsed .mp-workspace-body {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
  }

  .mp-pane-editor.is-collapsed {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    cursor: pointer;
  }

  .mp-pane-editor.is-collapsed .mp-editor-inner {
    display: none !important;
  }

  .mp-pane-editor.is-collapsed .mp-pane-collapse-btn {
    height: 44px !important;
    border-top: none !important;
  }

  .mp-pane-editor.is-collapsed .mp-collapse-arrow {
    transform: rotate(-90deg) !important;
  }

  [dir="rtl"] .mp-pane-editor.is-collapsed .mp-collapse-arrow {
    transform: rotate(-90deg) !important;
  }

  .markdown-editor-shell.mp-fullscreen-mode .mp-workspace-body {
    height: 100% !important;
    flex: 1 1 0 !important;
  }

  .markdown-editor-shell.mp-fullscreen-mode .mp-pane-preview {
    height: 100% !important;
    flex: 1 1 0 !important;
  }
}
.diff-output { min-height: 72px; max-height: 420px; overflow: auto; padding: 15px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: 16px; direction: auto; }
.diff-add { color: #166534; background: rgba(34, 197, 94, 0.19); }
.diff-remove { color: #991b1b; background: rgba(239, 68, 68, 0.18); text-decoration: line-through; }
.unit-result { padding: 20px; color: var(--brand-primary); background: var(--brand-primary-light); border: 1px solid var(--brand-primary-border); border-radius: 18px; font: 750 clamp(1.25rem, 3vw, 2rem)/1.4 var(--font-mono); overflow-wrap: anywhere; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check-grid label { display: flex; align-items: center; gap: 9px; min-height: 42px; color: var(--text-main); font-size: 0.9rem; }
.extra-tool meter { width: min(100%, 400px); height: 14px; accent-color: var(--brand-primary); }

@media (max-width: 640px) {
  .extra-two-col { grid-template-columns: minmax(0, 1fr); }
  .control-row > label { flex-basis: 100%; }
  .control-row > button, .control-row > a, .control-row > .file-button { flex: 1 1 132px; }
  .check-grid { grid-template-columns: minmax(0, 1fr); }
  .extra-tool textarea { min-height: 120px; }
}

/* Keep the QR result visible beside the controls and compact on all screens. */
.extra-tool.qr-generator-pro {
  display: grid !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  grid-template-columns: minmax(0, 1.2fr) minmax(290px, 360px) !important;
  grid-template-areas: "config result" !important;
  align-items: start;
  gap: clamp(14px, 1.8vw, 22px);
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-config-panel {
  grid-area: config;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(14px, 1.8vw, 20px);
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--brand-primary-light));
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}
.extra-tool.qr-generator-pro .qr-result-panel {
  grid-area: result;
  width: 100%;
  box-sizing: border-box;
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: clamp(14px, 1.8vw, 20px);
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--brand-primary-light));
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}
.extra-tool.qr-generator-pro .qr-result-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.extra-tool.qr-generator-pro .qr-section-heading {
  text-align: center;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-section-heading h2 {
  margin: 4px 0 2px;
  font-size: 1.12rem;
}
.extra-tool.qr-generator-pro .qr-section-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.extra-tool.qr-generator-pro .qr-preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 0 !important;
  height: auto;
  padding: 8px !important;
  margin-inline: auto;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-output {
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
  height: auto;
}
.extra-tool.qr-generator-pro .qr-output img,
.extra-tool.qr-generator-pro .qr-canvas-preview {
  width: 210px;
  max-width: 100%;
  aspect-ratio: 1;
  height: auto;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
}
.extra-tool.qr-generator-pro .extra-status {
  text-align: center;
  width: 100%;
  margin: 0;
  font-size: 0.82rem;
}
.extra-tool.qr-generator-pro .qr-download-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-download-row button {
  min-height: 42px;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 650;
  justify-content: center;
}
.extra-tool.qr-generator-pro .qr-note {
  text-align: center;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
  font-size: 0.77rem;
  line-height: 1.45;
}
.extra-tool.qr-generator-pro .qr-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
  min-height: 72px;
  padding: 8px 6px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease;
}
.extra-tool.qr-generator-pro .qr-preset-btn:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}
.extra-tool.qr-generator-pro .qr-preset-btn > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-inline: auto;
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border-radius: 8px;
  font-size: 1rem;
}
.extra-tool.qr-generator-pro .qr-preset-btn strong {
  font-size: .78rem;
  text-align: center;
}
.extra-tool.qr-generator-pro .qr-preset-btn small {
  color: var(--text-muted);
  font-size: .68rem;
  line-height: 1.3;
  text-align: center;
}
.extra-tool.qr-generator-pro .qr-field { gap: 6px; }
.extra-tool.qr-generator-pro .qr-field input,
.extra-tool.qr-generator-pro .qr-field select { min-height: 42px; }

/* Advanced settings always visible */
.extra-tool.qr-generator-pro .qr-advanced-settings {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
  width: 100%;
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-advanced-heading {
  text-align: center;
  padding-bottom: 2px;
}
.extra-tool.qr-generator-pro .qr-advanced-heading h3 {
  margin: 0;
  color: var(--text-main);
  font-size: .88rem;
  font-weight: 700;
}
.extra-tool.qr-generator-pro .qr-advanced-content {
  display: grid;
  gap: 12px;
  padding: 0;
  width: 100%;
}

/* Dots style card selector */
.extra-tool.qr-generator-pro .qr-style-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-style-fieldset legend,
.extra-tool.qr-generator-pro .qr-field-label {
  float: none;
  padding: 0;
  color: var(--text-main);
  font-size: .82rem;
  font-weight: 650;
  text-align: center;
}
.extra-tool.qr-generator-pro .qr-style-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-style-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 68px;
  padding: 8px 6px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  box-sizing: border-box;
  transition: border-color .16s ease, transform .16s ease, background-color .16s ease;
}
.extra-tool.qr-generator-pro .qr-style-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}
.extra-tool.qr-generator-pro .qr-style-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}
.extra-tool.qr-generator-pro .qr-style-card:has(input:checked) {
  border-color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary) 12%, var(--bg-surface));
  box-shadow: 0 0 0 1px var(--brand-primary);
}
.extra-tool.qr-generator-pro .qr-style-preview {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary) 10%, var(--bg-surface));
  border-radius: 8px;
  transition: background-color .15s ease, color .15s ease;
}
.extra-tool.qr-generator-pro .qr-style-card:has(input:checked) .qr-style-preview {
  background: var(--brand-primary);
  color: #ffffff;
}
.extra-tool.qr-generator-pro .qr-style-title {
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}

.extra-tool.qr-generator-pro .qr-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

/* Brand row & remove logo button with overflow protection */
.extra-tool.qr-generator-pro .qr-brand-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-brand-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
.extra-tool.qr-generator-pro .qr-logo-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  overflow: hidden;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 650;
}
.extra-tool.qr-generator-pro .qr-logo-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.extra-tool.qr-generator-pro #qr-logo-name {
  color: var(--text-muted);
  font-size: .78rem;
  overflow-wrap: anywhere;
  max-width: 160px;
  text-align: center;
}
.extra-tool.qr-generator-pro .qr-btn-remove-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  border: 1.5px solid rgba(220, 38, 38, 0.4);
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .16s ease;
}
.extra-tool.qr-generator-pro .qr-btn-remove-logo:hover {
  background: rgba(220, 38, 38, 0.16);
  border-color: #dc2626;
  color: #b91c1c;
  transform: translateY(-1px);
}
.extra-tool.qr-generator-pro .qr-btn-remove-logo:active {
  transform: translateY(0);
}
.extra-tool.qr-generator-pro .qr-btn-remove-logo[hidden] {
  display: none !important;
}
.extra-tool.qr-generator-pro .qr-brand-row small,
.extra-tool.qr-generator-pro #qr-logo-hint {
  display: block;
  width: 100%;
  box-sizing: border-box;
  color: var(--text-muted);
  font-size: .74rem;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: break-word;
  flex-basis: auto;
}
.extra-tool.qr-generator-pro #qr-correction:disabled {
  opacity: 0.7;
  background-color: var(--bg-subtle);
  cursor: not-allowed;
}

.extra-tool.qr-generator-pro .qr-colors-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 6px 10px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  font-size: .78rem;
  font-weight: 650;
  box-sizing: border-box;
}
.extra-tool.qr-generator-pro .qr-color-field input[type="color"] {
  width: 38px;
  height: 32px;
  padding: 2px;
  border-radius: 8px;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .extra-tool.qr-generator-pro {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "result" "config" !important;
    gap: 16px;
  }
  .extra-tool.qr-generator-pro .qr-result-panel {
    position: static !important;
    top: auto;
  }
}
@media (max-width: 560px) {
  .extra-tool.qr-generator-pro .qr-preset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .extra-tool.qr-generator-pro .qr-preset-btn {
    padding: 6px 4px;
    min-height: 64px;
  }
  .extra-tool.qr-generator-pro .qr-preset-btn small {
    display: none;
  }
  .extra-tool.qr-generator-pro .qr-preset-btn > span {
    width: 24px;
    height: 24px;
  }
  .extra-tool.qr-generator-pro .qr-style-selector {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .extra-tool.qr-generator-pro .qr-style-card {
    padding: 6px 4px;
    min-height: 64px;
  }
  .extra-tool.qr-generator-pro .qr-style-title {
    font-size: .7rem;
  }
  .extra-tool.qr-generator-pro .qr-options-grid {
    grid-template-columns: 1fr;
  }
  .extra-tool.qr-generator-pro .qr-colors-grid {
    grid-template-columns: 1fr;
  }
  .extra-tool.qr-generator-pro .qr-download-row {
    grid-template-columns: 1fr;
  }
  .extra-tool.qr-generator-pro .qr-secure-badge {
    white-space: nowrap;
  }
}

/* ==========================================================================
   14. PDF Studio — Modern Compact Workspace, Visual Action Cards & Live Preview
   ========================================================================== */

.pdf-studio {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.pdf-controls-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

/* Header bar */
.pdf-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.pdf-meta-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pdf-badge-secure {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--status-success);
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.pdf-main-filename {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-doc-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-stat-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Visual Action Cards Grid */
.pdf-action-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  width: 100%;
}

@media (max-width: 768px) {
  .pdf-action-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .pdf-action-cards {
    grid-template-columns: 1fr;
  }
}

.pdf-action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  text-align: start;
  transition: all 0.16s ease;
  min-height: 72px;
}

.pdf-action-card:hover {
  border-color: var(--brand-primary-border);
  color: var(--text-main);
  transform: translateY(-1px);
}

.pdf-action-card.active {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary);
  color: var(--text-main);
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.pdf-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  color: var(--brand-primary);
  border: 1px solid var(--border-subtle);
}

.pdf-action-card.active .pdf-action-icon {
  background: var(--brand-primary);
  color: var(--text-on-primary);
  border-color: var(--brand-primary);
}

.pdf-action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pdf-action-text strong {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.pdf-action-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Rotation Bar */
.pdf-rotation-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.pdf-rotation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pdf-rot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  min-height: 32px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pdf-rot-btn:hover {
  color: var(--text-main);
  border-color: var(--brand-primary);
}

.pdf-rot-btn.active {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 700;
}

/* Collapsible Pages Accordion */
.pdf-accordion {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.18s ease;
}

.pdf-accordion[open] {
  border-color: var(--border-medium);
}

.pdf-accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-subtle);
  transition: background 0.16s ease;
  list-style: none;
}

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

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

.pdf-accordion-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.pdf-accordion-title svg {
  color: var(--brand-primary);
  flex-shrink: 0;
}

.pdf-accordion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.pdf-accordion-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-block-start: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

/* Compact Smart Selector Toolbar */
.pdf-selector-card.compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.pdf-presets-toolbar.compact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-presets-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.pdf-preset-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.btn-xs {
  min-height: 28px !important;
  padding: 2px 10px !important;
  font-size: 0.78rem !important;
  border-radius: var(--radius-pill) !important;
}

.pdf-preset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pdf-preset-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.pdf-range-row.compact {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 10px 16px !important;
  padding: 6px 12px !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-sm) !important;
}

.pdf-range-picker {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
}

.pdf-range-inputs {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
}

.pdf-range-label {
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: var(--text-muted) !important;
  white-space: nowrap !important;
}

.pdf-sub-label {
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
  white-space: nowrap !important;
}

/* Force override of .extra-tool input[type="number"] */
.extra-tool .pdf-range-row input.pdf-num-input,
.extra-tool input[type="number"].pdf-num-input,
.pdf-range-picker .pdf-num-input,
.pdf-num-input {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 2px 6px !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  text-align: center !important;
  background: var(--bg-subtle) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-medium) !important;
  border-radius: var(--radius-xs) !important;
  box-shadow: none !important;
  flex: 0 0 58px !important;
  margin: 0 !important;
}

.pdf-range-apply-btn {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 0 12px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  border-radius: var(--radius-xs) !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.pdf-text-range {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 1 1 200px !important;
  min-width: 180px !important;
}

/* Force override of .extra-tool input[type="text"] */
.extra-tool .pdf-range-row input.pdf-text-input,
.extra-tool input[type="text"].pdf-text-input,
.pdf-text-range .pdf-text-input,
.pdf-text-input {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 2px 10px !important;
  font-size: 0.82rem !important;
  background: var(--bg-subtle) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-medium) !important;
  border-radius: var(--radius-xs) !important;
  box-shadow: none !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 120px !important;
  margin: 0 !important;
}

.pdf-mode-hint.compact {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0;
  padding: 2px 8px;
  border-inline-start: 2px solid var(--brand-primary);
}

.pdf-selection-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
}

/* Scrollable Centered Thumbnails Section */
.pdf-grid-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pdf-grid-scroll-box {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
}

.pdf-thumbnails-grid.centered {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  align-items: flex-start !important;
  gap: 8px;
  padding: 2px;
  margin: 0 auto;
}

/* Page Card — Tight & Snug without extra margins */
.pdf-page-card {
  display: flex;
  flex-direction: column;
  width: 110px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  position: relative;
  box-sizing: border-box;
}

.pdf-page-card:hover {
  border-color: var(--brand-primary-border);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pdf-page-card:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.pdf-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: var(--bg-subtle);
  border-block-end: 1px solid var(--border-subtle);
  gap: 4px;
}

.pdf-check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pdf-card-check {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  margin: 0;
}

.pdf-page-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

.pdf-page-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  display: none;
}

.pdf-page-status-badge.badge-extract {
  display: inline-block;
  background: rgba(16, 185, 129, 0.16);
  color: var(--status-success);
}

.pdf-page-status-badge.badge-remove {
  display: inline-block;
  background: rgba(239, 68, 68, 0.16);
  color: var(--status-error);
}

.pdf-page-status-badge.badge-keep {
  display: inline-block;
  background: rgba(16, 185, 129, 0.12);
  color: var(--status-success);
}

.pdf-page-status-badge.badge-rotate {
  display: inline-block;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.pdf-card-rotate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.pdf-card-rotate-btn:hover {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.pdf-card-rotate-btn[hidden] {
  display: none !important;
}

/* Card States */
.pdf-page-card.is-selected {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.pdf-page-card.is-unselected {
  opacity: 0.42;
  filter: grayscale(0.4);
}

.pdf-page-card.is-removed {
  border-color: var(--status-error);
  box-shadow: 0 0 0 1px var(--status-error);
  background: rgba(239, 68, 68, 0.05);
}

.pdf-page-card.is-removed .pdf-card-thumb-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.22);
  pointer-events: none;
}

.pdf-page-card.is-kept {
  border-color: var(--status-success);
}

/* Snug thumbnail container centered */
.pdf-card-thumb-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: #ffffff;
  box-sizing: border-box;
}

.pdf-card-loading-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: pdf-shimmer 1.5s infinite;
}

@keyframes pdf-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.pdf-card-canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

/* Live Result Viewer Panel — Always Visible & Fixed Top-Clipping */
.pdf-result-viewer-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.pdf-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-block-end: var(--space-2);
  border-block-end: 1px solid var(--border-subtle);
}

.pdf-viewer-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pdf-viewer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.pdf-viewer-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pdf-page-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 85px;
  text-align: center;
}

.pdf-page-indicator strong {
  color: var(--text-main);
}

.pdf-viewer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pdf-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
}

.pdf-canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 320px;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  position: relative;
  scrollbar-width: thin;
}

.pdf-main-canvas {
  display: block;
  margin: 0 auto !important;
  max-width: 100%;
  max-height: 62vh;
  width: auto !important;
  height: auto !important;
  background: #ffffff;
  border-radius: var(--radius-xs);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.pdf-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(14, 22, 40, 0.82);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 10;
}

.pdf-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
}

@keyframes pdf-spin {
  to { transform: rotate(360deg); }
}

.pdf-viewer-footer {
  text-align: center;
}

/* Merge Block */
.pdf-merge-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pdf-merge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pdf-merge-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.pdf-merge-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.pdf-merge-file-card:hover {
  border-color: var(--border-medium);
}

.pdf-merge-file-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pdf-merge-cover-canvas {
  width: 40px;
  height: 52px;
  object-fit: cover;
  background: #ffffff;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pdf-merge-file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pdf-merge-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-merge-file-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pdf-merge-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pdf-order-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-xs);
}

.pdf-remove-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-xs);
  color: var(--status-error);
}

.pdf-remove-file-btn:hover {
  background: rgba(239, 68, 68, 0.12);
}

@media (max-width: 768px) {
  .pdf-action-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pdf-viewer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .pdf-viewer-nav {
    justify-content: center;
  }
  .pdf-viewer-actions {
    justify-content: stretch;
  }
  .pdf-viewer-actions button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .pdf-action-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .pdf-action-card {
    padding: 8px 10px;
    min-height: 64px;
  }
  .pdf-action-text strong {
    font-size: 0.8rem;
  }
  .pdf-action-text small {
    display: none;
  }
  .pdf-page-card {
    width: 105px;
  }
}

/* ==========================================================================
   Large Screen Ergonomics & Productivity Layouts (min-width: 1024px / 1280px)
   ========================================================================== */

@media (min-width: 1024px) {
  /* 1. Tool Hero Enhancement */
  .tool-hero-glass {
    min-height: 210px;
    padding: clamp(24px, 3vw, 38px) clamp(28px, 3.5vw, 48px);
    gap: 36px;
  }

  .tool-hero-title {
    font-size: clamp(2.1rem, 3.2vw, 2.75rem);
  }

  .tool-hero-desc {
    font-size: 1.02rem;
    line-height: 1.65;
  }

  .tool-hero-art {
    width: 172px;
    height: 172px;
  }

  .tool-hero-art img {
    width: 156px;
    height: 156px;
  }

  /* 2. Workspace Breathing Room */
  .tool-workspace {
    padding: clamp(24px, 2.8vw, 38px);
    margin-block-end: 28px;
  }

  /* 3. Image Batch Workspaces */
  .batch-dropzone {
    min-height: 260px;
    padding: clamp(40px, 6vw, 62px) 28px;
    gap: 12px;
  }

  .batch-drop-icon {
    width: 50px;
    height: 50px;
    font-size: 1.65rem;
  }

  .batch-dropzone strong {
    font-size: 1.08rem;
  }

  .batch-settings-panel {
    padding: 20px 24px;
    border-radius: 20px;
  }

  .batch-settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 195px), 1fr));
    gap: 14px 18px;
  }

  .batch-queue-header {
    padding: 12px 18px;
    border-radius: 18px;
  }

  .batch-card {
    padding: 12px 16px;
  }

  .batch-thumb-wrap {
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
  }

  /* Large Comparison Stage */
  .batch-compare-dialog {
    width: min(94vw, 1200px);
  }

  .compare-stage {
    height: clamp(340px, 56vh, 600px);
  }

  /* 4. Text, Diff & Code Editors */
  .extra-two-col {
    gap: 22px;
  }

  .extra-two-col textarea {
    min-height: 380px;
    font-size: 0.95rem;
    line-height: 1.6;
  }

  #td-left, #td-right {
    min-height: 340px;
  }

  .diff-output {
    max-height: 620px;
  }


  /* JSON Studio Side-by-Side */
  #json-formatter-app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    row-gap: 14px;
    align-items: start;
  }
  #json-formatter-app > label:first-of-type { grid-column: 1; grid-row: 1; }
  #json-formatter-app > label:last-of-type { grid-column: 2; grid-row: 1; }
  #json-formatter-app > .control-row:first-of-type { grid-column: 1; grid-row: 2; }
  #json-formatter-app > .control-row:last-of-type { grid-column: 2; grid-row: 2; }
  #jf-input, #jf-output { min-height: 420px; font-family: var(--font-mono); }

  /* CSV-JSON Studio Side-by-Side */
  #csv-json-converter-app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    row-gap: 14px;
    align-items: start;
  }
  #csv-json-converter-app > .control-row:first-of-type { grid-column: 1 / -1; grid-row: 1; }
  #csv-json-converter-app > label:first-of-type { grid-column: 1; grid-row: 2; }
  #csv-json-converter-app > label:last-of-type { grid-column: 2; grid-row: 2; }
  #csv-json-converter-app > .control-row:last-of-type { grid-column: 2; grid-row: 3; }
  #cj-input, #cj-output { min-height: 380px; font-family: var(--font-mono); }

  /* Word Counter */
  #wc-input {
    min-height: 280px;
    font-size: 1.05rem;
    line-height: 1.7;
    padding: 20px 24px;
  }
  .word-counter-app .results-box {
    gap: 14px;
    margin-block-start: 18px;
  }
  .word-counter-app .stat-item {
    padding: 16px 14px;
  }
  .word-counter-app .stat-value {
    font-size: 2.1rem;
  }

  /* 5. Hardware Testers */
  #kb-app .results-box {
    max-width: 1080px;
    margin-inline: auto;
    margin-block-start: 24px;
  }

  .gamepad-container {
    max-width: 640px;
  }
  .stick-drift-meter {
    width: 160px;
    height: 160px;
  }

  /* Audio Trimmer */
  .audio-trimmer-wrapper {
    padding: 26px 30px;
    border-radius: 22px;
  }
  .audio-trimmer-stage {
    margin-block-end: 20px;
  }
  .audio-ruler-track {
    height: 36px;
  }

  /* PDF Organizer Grid */
  .pdf-thumbnails-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 16px;
  }

  /* Age Calculator */
  .age-calculator {
    max-width: 880px;
  }
  .age-summary-grid {
    gap: 14px;
  }
  .age-summary-item {
    padding: 16px 12px;
  }
  .age-results-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
  }

  /* QR Generator Pro */
  .qr-generator-pro {
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    gap: 22px;
  }
  .qr-config-panel, .qr-result-panel {
    padding: 24px 26px;
  }
  .qr-canvas-preview {
    width: 250px;
  }

  /* Trust Pills & Accordions */
  .tool-feature-grid {
    gap: var(--space-4);
    margin-block-start: var(--space-8);
    margin-block-end: var(--space-8);
  }
  .tool-feature-pill {
    padding: 16px 20px;
  }
  .glass-accordion-header {
    padding: 18px 24px;
  }
  .glass-accordion-body {
    padding: 0 24px 22px;
    max-width: 960px;
  }
}

/* Enhanced 2-column queue for multi-image batch on screens >= 1280px */
@media (min-width: 1280px) {
  .batch-queue-list:has(.batch-card:nth-child(2)) {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .pdf-thumbnails-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
  }

  .keyboard-grid {
    max-width: 1180px;
    gap: 9px;
  }
  .keyboard-row {
    gap: 9px;
  }
  .key-cap {
    height: 56px;
    min-width: 48px;
    font-size: 0.9rem;
  }

  .qr-canvas-preview {
    width: 270px;
  }
}

/* =======================================================
   15. Advanced Client-Side PDF Editor Studio (.pe-studio)
   ======================================================= */
.pe-studio {
  width: 100%;
  margin: 0 auto;
}

.pe-workspace-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  position: relative;
  transition: all 0.2s ease;
}

.pe-workspace-wrapper.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  z-index: 99999 !important;
  background: var(--bg-surface) !important;
}

.pe-workspace-wrapper.is-fullscreen .pe-studio-layout {
  flex: 1;
  height: 100% !important;
  max-height: none !important;
}

/* Top Navigation Bar */
.pe-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg-surface) 85%, var(--brand-primary-light));
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-wrap: wrap;
}

.pe-doc-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.pe-badge-secure {
  font-size: 0.75rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pe-filename {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.pe-stat-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

.pe-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pe-action-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

.pe-action-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pe-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  padding-inline: 16px;
  background: #2563eb;
  color: #ffffff;
}

.pe-docx-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  padding-inline: 14px;
  background: var(--bg-surface);
  color: var(--brand-primary);
  border: 1.5px solid var(--border-medium);
  transition: all 0.15s ease;
}

.pe-docx-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--brand-primary);
}

/* Word-Style Tabbed Ribbon */
.pe-tools-ribbon {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-medium);
}

.pe-ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 14px 0;
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--brand-primary-light));
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.pe-ribbon-tabs::-webkit-scrollbar {
  display: none;
}

.pe-ribbon-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.pe-ribbon-tab:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.04);
}

.pe-ribbon-tab.active {
  color: var(--brand-primary);
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  border-bottom-color: var(--bg-surface);
  margin-bottom: -1px;
  z-index: 2;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}

.pe-selected-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(37, 99, 235, 0.08);
  border-bottom: 1px solid rgba(37, 99, 235, 0.25);
  font-size: 0.82rem;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.pe-ribbon-content {
  background: var(--bg-surface);
  min-height: 58px;
  display: flex;
  align-items: stretch;
  position: relative;
}

.pe-ribbon-pane {
  display: flex;
  align-items: stretch;
  gap: 10px;
  row-gap: 8px;
  padding: 8px 14px;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
  overflow: visible;
}

.pe-ribbon-pane[hidden] {
  display: none !important;
}

.pe-ribbon-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding-inline: 4px;
  flex-shrink: 0;
}

.pe-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.pe-group-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
  user-select: none;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.pe-ribbon-divider {
  width: 1px;
  background: var(--border-subtle);
  align-self: stretch;
  margin-inline: 4px;
  flex-shrink: 0;
}

.pe-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.pe-tool-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.pe-tool-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

.pe-tool-btn svg {
  flex-shrink: 0;
}

.pe-tool-btn.file-button {
  cursor: pointer;
}

.pe-tool-btn.btn-danger-soft {
  color: #ef4444;
}

.pe-tool-btn.btn-danger-soft:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

.pe-text-block.is-dragging {
  opacity: 0.85;
  outline: 2px dashed #2563eb !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25) !important;
  cursor: grabbing !important;
  z-index: 99 !important;
}

.pe-options-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.pe-sub-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.pe-sub-select {
  height: 32px !important;
  min-height: 32px !important;
  padding: 2px 8px !important;
  font-size: 0.8rem !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-medium) !important;
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  width: auto !important;
  min-width: 90px;
}

/* Ribbon Integration for Custom Selects */
.pe-tools-ribbon .kz-select-wrapper {
  width: 155px !important;
  max-width: 155px !important;
  min-width: 130px !important;
  height: 32px !important;
  display: inline-flex !important;
  vertical-align: middle;
}

.pe-tools-ribbon .kz-select-trigger {
  height: 32px !important;
  min-height: 32px !important;
  padding: 4px 8px !important;
  font-size: 0.8rem !important;
  border-radius: 6px !important;
  background: var(--bg-surface) !important;
  border-color: var(--border-medium) !important;
}

.pe-tools-ribbon .kz-select-trigger .kz-select-value {
  font-size: 0.8rem !important;
}

.pe-color-picker {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 1px;
  cursor: pointer;
  background: var(--bg-surface);
}

.pe-mini-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.12s ease;
}

.pe-mini-toggle.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.pe-size-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
}

.pe-size-btn[data-size="2"] { font-size: 0.6rem; }
.pe-size-btn[data-size="4"] { font-size: 0.85rem; }
.pe-size-btn[data-size="8"] { font-size: 1.15rem; }

.pe-size-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.pe-color-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--chip-color);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  padding: 0;
}

.pe-color-chip.active, .pe-color-chip:hover {
  transform: scale(1.18);
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.pe-redact-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
}

.pe-redact-btn.active {
  background: var(--text-main);
  color: var(--bg-surface);
}

.pe-hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
}

/* Studio Layout: Sidebar + Canvas Stage */
.pe-studio-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: clamp(520px, 80vh, 920px);
  position: relative;
  overflow: hidden;
  background: #0f172a;
}

[data-theme="light"] .pe-studio-layout {
  background: #e2e8f0;
}

/* Pages Sidebar */
.pe-pages-sidebar {
  width: 190px;
  min-width: 170px;
  max-width: 210px;
  height: 100% !important;
  max-height: 100% !important;
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-medium);
  display: flex;
  flex-direction: column;
  flex-shrink: 0 !important;
  z-index: 15;
  position: relative !important;
  overflow: hidden;
}

.pe-pages-sidebar.is-collapsed {
  display: none !important;
}

.pe-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  flex-shrink: 0;
}

.pe-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1;
}

.pe-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.pe-thumbnails-scroll {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: calc(100% - 46px);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.pe-thumbnail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
  background: var(--bg-subtle);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pe-thumbnail-item:hover {
  border-color: var(--border-medium);
  background: color-mix(in srgb, var(--bg-subtle) 70%, var(--brand-primary-light));
}

.pe-thumbnail-item.active {
  border-color: #2563eb;
  background: color-mix(in srgb, var(--bg-subtle) 40%, var(--brand-primary-light));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.pe-thumbnail-canvas {
  width: 100%;
  max-width: 140px;
  height: auto;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  display: block;
}

.pe-thumbnail-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Viewport & Canvas Stage */
.pe-viewport-container {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 32px 28px 64px;
  position: relative;
  scrollbar-width: thin;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .pe-viewport-container {
    padding: 16px 12px 48px;
  }
}

.pe-canvas-stage {
  position: relative;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  background: #ffffff;
  overflow: hidden;
  user-select: none;
  transform-origin: top center;
  transition: none;
  margin: 0 auto;
  flex-shrink: 0;
}

.pe-base-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

.pe-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.pe-interactive-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 14;
  overflow: hidden;
}

/* Full pointer events when drawing or manipulating shapes */
#pdf-editor-app[data-active-tool="draw"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="highlight"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="shape"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="redact"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="snip-object"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="eraser"] .pe-interactive-overlay {
  pointer-events: auto !important;
}

/* Annotation Elements */
.pe-annotation {
  position: absolute;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
  touch-action: none;
  pointer-events: auto !important;
}

.pe-annotation.selected {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.pe-annotation.selected::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  background: #2563eb;
  border: 2px solid #ffffff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  pointer-events: auto;
}

.pe-annotation-text {
  outline: none;
  padding: 4px 6px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
  min-width: 40px;
  cursor: text;
}

.pe-annotation-text:focus {
  outline: 1.5px dashed #2563eb;
  background: rgba(37, 99, 235, 0.05);
}

.pe-annotation-image img,
.pe-annotation-shape svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.pe-annotation-redact {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Bottom Control Bar */
.pe-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-medium);
  gap: 12px;
  flex-wrap: wrap;
  z-index: 30;
}

.pe-page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pe-nav-btn {
  padding: 4px 10px;
  min-height: 32px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pe-page-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pe-page-num-input {
  width: 46px !important;
  height: 30px !important;
  min-height: 30px !important;
  text-align: center;
  padding: 0 !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-medium) !important;
  font-size: 0.82rem !important;
}

.pe-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pe-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  min-height: 32px;
  font-size: 0.78rem;
}

.pe-page-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pe-page-actions .btn-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.pe-page-actions .btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.pe-zoom-stepper {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  overflow: hidden;
  height: 32px;
}

.pe-zoom-btn {
  background: transparent;
  border: none;
  width: 28px;
  height: 100%;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pe-zoom-btn:hover {
  background: var(--bg-surface);
}

.pe-zoom-label {
  min-width: 50px;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  padding: 0 4px;
}

/* Signature & Stamp Dialog */
.pe-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: transparent;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.pe-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.pe-dialog-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pe-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.pe-dialog-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-main);
}

.pe-dialog-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.pe-tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.pe-tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: var(--bg-surface);
}

.pe-tab-pane {
  padding: 18px;
}

.pe-sig-pad-box {
  position: relative;
  border: 2px dashed var(--border-medium);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.pe-sig-canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
  cursor: crosshair;
}

.pe-sig-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #94a3b8;
  pointer-events: none;
  user-select: none;
}

.pe-sig-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.pe-sig-colors {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pe-sig-type-preview {
  margin-top: 14px;
  padding: 24px;
  text-align: center;
  background: #f8fafc;
  color: #1e293b;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 1.8rem;
  font-family: 'Amiri', cursive, serif;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pe-dialog-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-subtle);
}

@media (max-width: 768px) {
  .pe-pages-sidebar {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    background: var(--bg-surface);
  }
  .pe-top-bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .pe-filename {
    max-width: 150px;
    font-size: 0.86rem;
  }
  .pe-top-actions {
    gap: 6px;
  }
  .pe-export-btn, .pe-docx-btn {
    padding-inline: 10px;
    font-size: 0.78rem;
    min-height: 36px;
  }
  .pe-primary-tools,
  .pe-context-bar {
    padding-inline: 10px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .pe-tool-btn {
    min-height: 42px;
    padding: 6px 10px;
  }
  .pe-bottom-bar {
    padding: 8px 12px;
    gap: 8px;
    justify-content: center;
  }
  .pe-page-actions {
    width: 100%;
    justify-content: center;
    margin-top: 2px;
  }
}

@media (max-width: 480px) {
  .pe-top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .pe-doc-info {
    justify-content: space-between;
  }
  .pe-filename {
    max-width: 160px;
  }
  .pe-mode-switcher {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .pe-mode-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.75rem;
  }
  .pe-top-actions {
    width: 100%;
    justify-content: space-between;
  }
  .pe-top-actions button {
    flex: 1;
    min-width: 0;
    padding: 6px 4px;
    text-align: center;
  }
  .pe-action-icon-btn {
    flex: 0 0 36px !important;
  }
  .pe-view-btn {
    padding: 4px 6px;
    font-size: 0.74rem;
  }
  .pe-page-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  .pe-zoom-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* =======================================================
   16. In-Place Text Editing & Word-Like Toolbar
   ======================================================= */

/* Highlighted Text Edit Action Button */
.pe-tool-btn.pe-tool-highlighted {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.3);
  color: #2563eb;
  font-weight: 700;
}

.pe-tool-btn.pe-tool-highlighted:hover {
  background: rgba(37, 99, 235, 0.16);
  border-color: #2563eb;
}

.pe-tool-btn.pe-tool-highlighted.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

/* Number Stepper for Font Size */
.pe-number-stepper {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  height: 32px;
  overflow: hidden;
}

.pe-step-btn {
  width: 24px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.1s ease;
}

.pe-step-btn:hover {
  background: var(--bg-subtle);
}

.pe-size-input {
  width: 44px !important;
  height: 100% !important;
  min-height: 100% !important;
  border: none !important;
  padding: 0 !important;
  text-align: center !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  font-family: var(--font-mono) !important;
  background: transparent !important;
  color: var(--text-main) !important;
}

.pe-tool-separator {
  width: 1px;
  height: 22px;
  background: var(--border-medium);
  margin-inline: 4px;
  flex-shrink: 0;
}

/* In-Place Text Detection Layer */
.pe-text-detection-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
}

.pe-text-block {
  position: absolute;
  box-sizing: border-box;
  cursor: text;
  pointer-events: auto;
  line-height: 1.15;
  user-select: none;
  color: transparent; /* CRITICAL: Prevent duplicate text! Crisp canvas text is shown */
  background: transparent;
  outline: none;
  outline-offset: 0;
  border-radius: 2px;
  transition: outline-color 0.12s ease, background-color 0.12s ease;
  white-space: pre;
  overflow: visible;
  padding: 0 2px;
  margin: 0;
}

#pdf-editor-app[data-active-tool="edit-text"] .pe-text-block:hover:not(.is-modified):not(.is-active-edit),
#pdf-editor-app[data-active-tool="select"] .pe-text-block:hover:not(.is-modified):not(.is-active-edit) {
  outline: 1.5px dashed rgba(37, 99, 235, 0.5) !important;
  background-color: rgba(37, 99, 235, 0.05);
  cursor: text !important;
}

/* Word Mode presentation: visually highlights unedited editable text blocks directly on top of the authentic document */
.pe-canvas-stage.is-word-mode .pe-text-block:not(.is-modified) {
  outline: 1px dashed rgba(37, 99, 235, 0.4) !important;
  background-color: rgba(37, 99, 235, 0.02);
}

.pe-canvas-stage.is-word-mode .pe-text-block:hover:not(.is-modified) {
  outline: 1.5px solid #2563eb !important;
  background-color: rgba(37, 99, 235, 0.08);
}

/* Smart Text Layer pointer events - allow both edit-text and select to edit and drag text */
#pdf-editor-app[data-active-tool="select"] .pe-text-block,
#pdf-editor-app[data-active-tool="edit-text"] .pe-text-block {
  pointer-events: auto !important;
  cursor: text !important;
}

#pdf-editor-app[data-active-tool]:not([data-active-tool="edit-text"]):not([data-active-tool="select"]):not([data-active-tool="eraser"]) .pe-text-block {
  pointer-events: none !important;
}

#pdf-editor-app[data-active-tool="eraser"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="eraser"] .pe-annotation {
  cursor: crosshair !important;
}

#pdf-editor-app[data-active-tool="snip-object"] .pe-interactive-overlay,
#pdf-editor-app[data-active-tool="select"] .pe-interactive-overlay {
  cursor: default;
}

.pe-text-block.is-active-edit {
  outline: 1.5px solid #2563eb !important;
  outline-offset: 1px !important;
  z-index: 50 !important;
  user-select: text !important;
  cursor: text !important;
  caret-color: #2563eb;
  border-radius: 2px;
  white-space: pre !important;
  word-break: normal !important;
  overflow: visible;
}

/* Modified text: completely clean, seamless, NO borders or outlines ever */
.pe-text-block.is-modified,
.pe-canvas-stage.is-word-mode .pe-text-block.is-modified,
.pe-text-block.is-modified:hover,
.pe-canvas-stage.is-word-mode .pe-text-block.is-modified:hover {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  z-index: 20;
}

.pe-text-block.is-deleted {
  background-color: #ffffff;
  outline: 1.5px dashed #ef4444 !important;
  opacity: 1 !important;
  z-index: 20;
}

/* Embedded Detected Image / Logo overlays */
.pe-detected-image {
  position: absolute;
  box-sizing: border-box;
  cursor: grab !important;
  pointer-events: auto !important;
  border: 1.5px dashed rgba(37, 99, 235, 0.35);
  background-color: rgba(37, 99, 235, 0.02);
  border-radius: 4px;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  z-index: 15;
}

.pe-detected-image:hover {
  border-color: #2563eb !important;
  background-color: rgba(37, 99, 235, 0.1) !important;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

.pe-detected-image:active,
.pe-detected-image.is-dragging {
  cursor: grabbing !important;
  border-color: #1d4ed8 !important;
  background-color: rgba(37, 99, 235, 0.15) !important;
}

.pe-detected-img-badge {
  position: absolute;
  top: -20px;
  inset-inline-start: 0;
  background-color: #2563eb;
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pe-detected-image:hover .pe-detected-img-badge {
  opacity: 1;
  transform: translateY(0);
}

/* Opacity Range Slider */
.pe-range-slider {
  width: 90px;
  accent-color: #2563eb;
  cursor: pointer;
  height: 6px;
}

/* Stamp Chips in Toolbar */
.pe-stamp-chip {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1.5px dashed;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  background: transparent;
}
.pe-stamp-chip:hover {
  transform: scale(1.05);
}
.pe-stamp-green { color: #059669; border-color: #059669; }
.pe-stamp-red { color: #dc2626; border-color: #dc2626; }
.pe-stamp-gray { color: #64748b; border-color: #64748b; }
.pe-stamp-blue { color: #2563eb; border-color: #2563eb; }
.pe-stamp-amber { color: #d97706; border-color: #d97706; }

/* Mark Chips in Toolbar */
.pe-mark-chip {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}
.pe-mark-chip.active, .pe-mark-chip:hover {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
}

/* Stamp Annotations on Stage */
.pe-annotation-stamp {
  border: 3px double;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 900;
  font-family: inherit;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  line-height: 1.15;
  transform: rotate(-3.5deg);
  transition: transform 0.12s ease;
}

.pe-annotation-stamp.selected {
  transform: rotate(0deg);
}

/* Form Mark Annotations on Stage */
.pe-annotation-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  user-select: none;
  line-height: 1;
}

/* Sticky Note Annotations on Stage */
.pe-annotation-note {
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.pe-note-pin {
  height: 18px;
  background: rgba(0, 0, 0, 0.08);
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
}
.pe-note-content {
  flex: 1;
  padding: 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  outline: none;
  cursor: text;
  color: #1e293b;
  overflow: auto;
}

/* Eraser Tool Styling */
.pe-studio[data-active-tool="eraser"] .pe-canvas-stage,
.pe-studio[data-active-tool="eraser"] .pe-annotation {
  cursor: crosshair !important;
}
.pe-studio[data-active-tool="eraser"] .pe-annotation:hover {
  outline: 2px dashed #ef4444 !important;
  opacity: 0.45 !important;
}

/* Mode Switcher */
.pe-mode-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: 24px;
  padding: 3px;
  gap: 3px;
}

.pe-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pe-mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.pe-mode-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

/* Word Document Flow Sheet */
.pe-doc-sheet {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  padding: 36px 44px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  max-width: 100%;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  scrollbar-width: thin;
  position: relative;
  transition: none;
}

.pe-doc-heading {
  margin: 0 0 16px 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e3a8a;
  text-align: center;
  outline: none;
  border: 1px dashed transparent;
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-word;
}

.pe-doc-heading:focus, .pe-doc-para:focus {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.04);
}

.pe-doc-para {
  margin: 0 0 12px 0;
  outline: none;
  border: 1px dashed transparent;
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-word;
}

/* Document Header & Footer Rows (Clean, borderless natural document flow) */
.pe-doc-header-row,
.pe-doc-footer-row,
.pe-doc-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin: 8px 0;
  gap: 16px;
  box-sizing: border-box;
}

.pe-doc-header-row {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.pe-doc-footer-row {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.pe-doc-flex-cell {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  outline: none;
  border: 1px dashed transparent;
  border-radius: 4px;
  word-break: break-word;
  white-space: pre-wrap;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.pe-doc-flex-cell:focus {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.04);
}

/* Word Document Table */
.pe-doc-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 14px 0;
  scrollbar-width: thin;
}

.pe-doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 2px solid #000000;
  margin: 0;
  background: #ffffff;
}

.pe-doc-table th {
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 6px;
  text-align: center;
  border: 1px solid #000000;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.pe-doc-table td {
  padding: 6px 8px;
  font-size: 0.92rem;
  border: 1px solid #000000;
  text-align: center;
  vertical-align: middle;
  outline: none;
  transition: background-color 0.12s ease, outline-color 0.12s ease;
  word-break: break-word;
  white-space: pre-wrap;
}

.pe-font-import-btn {
  font-weight: 600;
  padding: 4px 8px;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border-color, #cbd5e1);
  color: var(--text-color, #0f172a);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.78rem;
  transition: all 0.15s ease;
}

.pe-font-import-btn:hover {
  background: var(--brand-primary, #2563eb);
  color: #ffffff;
  border-color: var(--brand-primary, #2563eb);
}

.pe-doc-table td:focus {
  outline: 2px solid #2563eb !important;
  outline-offset: -1px;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.pe-doc-table tr.is-selected-row td {
  box-shadow: inset 0 0 0 2px #2563eb;
}

/* Table Controls in Toolbar */
.pe-table-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ==========================================================================
   Kazakan Tools — Modern iPhone Liquid Glass QR Scanner Studio
   ========================================================================== */

/* Strict hidden support so hidden elements never show */
.qr-hud-top[hidden],
.qr-hud-bottom[hidden],
.qr-reticle[hidden],
.qr-splash-overlay[hidden],
.qr-file-preview-card[hidden],
.qr-dropzone[hidden],
.qr-smart-card[hidden],
.qr-history-tray[hidden],
.qr-cam-switch-box[hidden],
.qr-video[hidden],
.qr-pane[hidden],
#qr-btn-torch[hidden] {
  display: none !important;
}

.qr-studio {
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5, 20px);
}

/* Mode Switcher: Uses shared .batch-segmented-track */
.qr-studio .qr-modes-nav {
  margin-inline: auto;
  align-self: center;
  max-width: 100%;
  margin-block-end: 14px;
}

/* Panes */
.qr-pane {
  display: none;
  width: 100%;
}

.qr-pane.is-active {
  display: block;
}

/* Viewfinder: Themed idle container */
.qr-viewfinder-box {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin-inline: auto;
  aspect-ratio: 16 / 10;
  min-height: 360px;
  max-height: 520px;
  background: color-mix(in srgb, var(--bg-surface) 92%, var(--brand-primary-light));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card, 22px);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

/* Active video streaming state */
.qr-viewfinder-box.is-streaming {
  background: #000000;
  border-color: var(--border-glass, rgba(255, 255, 255, 0.16));
}

.qr-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
}

/* Inactive Themed Camera Splash Overlay */
.qr-splash-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6, 24px);
  z-index: 5;
}

.qr-splash-icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  margin-block-end: var(--space-3, 12px);
}

.qr-splash-title {
  font-size: clamp(1.2rem, 3vw, 1.45rem);
  font-weight: 800;
  color: var(--text-main);
  margin-block-end: var(--space-2, 8px);
}

.qr-splash-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
  margin-block-end: var(--space-5, 20px);
}

.qr-start-cam-btn {
  min-height: var(--min-touch-size, 46px);
  padding: 0 28px;
  font-size: 0.98rem;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-pill, 9999px);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.qr-start-cam-btn:hover {
  transform: translateY(-1px);
}

.qr-privacy-tag {
  margin-top: var(--space-4, 16px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* Animated Target Reticle with Laser Beam */
.qr-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(260px, 72vw);
  height: min(260px, 72vw);
  pointer-events: none;
  z-index: 6;
}

.qr-corner {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: var(--brand-accent, #38bdf8);
  border-style: solid;
  border-width: 0;
}

.corner-tl {
  top: 0;
  left: 0;
  border-top-width: 3px;
  border-left-width: 3px;
  border-top-left-radius: 12px;
}

.corner-tr {
  top: 0;
  right: 0;
  border-top-width: 3px;
  border-right-width: 3px;
  border-top-right-radius: 12px;
}

.corner-bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-bottom-left-radius: 12px;
}

.corner-br {
  bottom: 0;
  right: 0;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-bottom-right-radius: 12px;
}

.qr-laser-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #38bdf8 20%, #38bdf8 80%, transparent);
  animation: qrLaserScan 2.4s ease-in-out infinite;
}

@keyframes qrLaserScan {
  0%, 100% {
    top: 10px;
    opacity: 0.9;
  }
  50% {
    top: calc(100% - 12px);
    opacity: 0.9;
  }
}

/* Live HUD Controls (Rendered strictly when camera is streaming) */
.qr-hud-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 10;
  pointer-events: auto;
}

.qr-cam-switch-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.qr-cam-flip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill, 9999px);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.qr-cam-flip-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(255, 255, 255, 0.35);
}

.qr-cam-dropdown {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.qr-hud-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qr-hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qr-hud-btn:hover {
  background: rgba(30, 41, 59, 0.95);
}

.qr-hud-icon-btn {
  padding: 0 10px;
}

.qr-hud-btn.is-active {
  color: var(--brand-accent, #38bdf8);
  border-color: var(--brand-accent, #38bdf8);
}

.qr-btn-stop {
  padding: 0 14px;
  gap: 6px;
  font-weight: 700;
  font-size: 0.84rem;
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.qr-btn-stop:hover {
  background: rgba(239, 68, 68, 0.45);
  color: #ffffff;
}

.qr-hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.84rem;
  color: #ffffff;
  white-space: nowrap;
  pointer-events: none;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
}

.qr-pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: qrPulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes qrPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.5;
  }
}

/* Smart Interactive Result Card */
.qr-smart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
  margin-top: var(--space-4, 16px);
}

.qr-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: var(--space-4, 16px);
  padding-block-end: var(--space-3, 12px);
  border-bottom: 1px solid var(--border-subtle);
}

.qr-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.qr-type-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
}

.qr-type-icon svg {
  width: 22px;
  height: 22px;
}

.qr-type-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.qr-format-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
}

/* Specialized Result Content Boxes */
.qr-url-box,
.qr-wifi-box,
.qr-contact-box,
.qr-text-box {
  background: color-mix(in srgb, var(--bg-surface) 88%, var(--brand-primary-light));
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-url-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qr-domain-badge {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
}

.qr-https-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--status-success);
}

.qr-url-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--brand-primary);
  word-break: break-all;
  text-decoration: none;
}

.qr-url-link:hover {
  text-decoration: underline;
}

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

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

.qr-info-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.qr-info-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.qr-pass-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px 10px;
}

.qr-pass-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono, monospace);
  font-size: 0.92rem;
  outline: none;
  width: 150px;
}

.qr-contact-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.qr-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-main);
}

.qr-contact-row a {
  color: var(--brand-primary);
  text-decoration: none;
}

.qr-contact-row a:hover {
  text-decoration: underline;
}

.qr-text-meta {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.qr-text-pre {
  margin: 0;
  font-family: var(--font-mono, monospace);
  font-size: 0.92rem;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Action Buttons */
.qr-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-4, 16px);
}

.qr-action-btn {
  min-height: var(--min-touch-size, 44px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-radius: var(--radius-pill, 9999px);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.qr-action-btn:hover {
  transform: translateY(-1px);
}

/* History Tray */
.qr-history-tray {
  margin-top: var(--space-4, 16px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--bg-surface);
  overflow: hidden;
}

.qr-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  min-height: var(--min-touch-size, 48px);
}

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

.qr-history-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.qr-history-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--brand-primary);
  color: var(--text-on-primary, #ffffff);
}

.qr-history-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.qr-history-tray[open] .qr-history-chevron {
  transform: rotate(180deg);
}

.qr-history-body {
  padding: 0 18px 16px 18px;
  border-top: 1px solid var(--border-subtle);
}

.qr-history-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg-surface) 90%, var(--brand-primary-light));
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.qr-hist-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-hist-icon svg {
  width: 18px;
  height: 18px;
}

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

.qr-hist-text {
  font-size: 0.88rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-hist-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.qr-history-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .qr-studio .qr-modes-nav {
    width: 100%;
  }

  .qr-viewfinder-box {
    aspect-ratio: 4 / 3;
    min-height: 320px;
  }

  .qr-hud-top {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .qr-cam-flip-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .qr-action-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   Color Studio & Converter Pro
   ========================================================================== */
.color-studio {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.cs-stage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cs-swatch-display {
  position: relative;
  height: 160px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
}

.cs-swatch-checker {
  position: absolute;
  inset: 0;
  background-image: repeating-conic-gradient(#cbd5e1 0% 25%, #ffffff 0% 50%);
  background-size: 16px 16px;
  z-index: 1;
}

[data-theme="dark"] .cs-swatch-checker {
  background-image: repeating-conic-gradient(#334155 0% 25%, #1e293b 0% 50%);
}

.cs-swatch-solid {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: background-color 0.15s ease;
}

.cs-swatch-info {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cs-color-name {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.cs-color-hex-tag {
  font-family: monospace;
  font-size: 0.85rem;
  opacity: 0.85;
  letter-spacing: 0.5px;
}

.cs-swatch-tools {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.cs-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.cs-tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.cs-tool-btn:active {
  transform: scale(0.96);
}

.cs-quick-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.cs-field-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.cs-picker-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  min-height: 44px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.cs-picker-trigger:hover {
  border-color: var(--border-strong);
}

.cs-picker-trigger input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.cs-picker-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border-subtle);
  flex-shrink: 0;
}

.cs-picker-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.cs-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  min-height: 44px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.cs-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(50, 109, 255, 0.15);
}

.cs-input-prefix {
  padding: 0 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 1rem;
}

.cs-text-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 0;
  outline: none;
  min-width: 0;
}

.cs-inline-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  margin-inline-end: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cs-inline-copy-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.cs-copy-all-btn {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
}

/* Channels Panel (RGB, HSL, CMYK) */
.cs-channels-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cs-tabs-header {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cs-tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cs-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.cs-tab-btn.active {
  background: var(--bg-canvas);
  color: var(--primary);
  border-color: var(--border-subtle);
}

.cs-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: var(--space-2);
}

.cs-slider-row {
  display: grid;
  grid-template-columns: 140px 1fr 80px;
  align-items: center;
  gap: 14px;
}

.cs-slider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.cs-ch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
}

.cs-ch-badge.red { background: #ef4444; }
.cs-ch-badge.green { background: #10b981; }
.cs-ch-badge.blue { background: #3b82f6; }
.cs-ch-badge.alpha { background: #64748b; }
.cs-ch-badge.hue { background: linear-gradient(135deg, #f43f5e, #eab308, #06b6d4); }
.cs-ch-badge.sat { background: #8b5cf6; }
.cs-ch-badge.light { background: #f59e0b; }

.cs-slider-track-wrap {
  width: 100%;
  display: flex;
  align-items: center;
}

.cs-range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: var(--track-bg, var(--bg-canvas));
  border: 1px solid var(--border-subtle);
  outline: none;
  cursor: pointer;
}

.cs-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.cs-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.cs-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.cs-range-h {
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%) !important;
}

.cs-num-input {
  width: 100%;
  height: 38px;
  text-align: center;
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-canvas);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease;
}

.cs-num-input:focus {
  border-color: var(--primary);
}

.cs-num-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cs-num-unit {
  position: absolute;
  inset-inline-end: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
  font-weight: 600;
}

.cs-cmyk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.cs-cmyk-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 6px;
}

.cs-cmyk-label {
  font-size: 0.82rem;
  font-weight: 700;
}

.cs-cmyk-label.c-cyan { color: #06b6d4; }
.cs-cmyk-label.c-magenta { color: #ec4899; }
.cs-cmyk-label.c-yellow { color: #eab308; }
.cs-cmyk-label.c-black { color: var(--text-main); }

.cs-cmyk-value {
  font-family: monospace;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Sections & Formats Grid */
.cs-formats-section,
.cs-harmonies-section,
.cs-shades-section,
.cs-contrast-section,
.cs-history-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cs-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.cs-formats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.cs-format-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.cs-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-card-format {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cs-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cs-copy-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.cs-card-code {
  font-family: monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
  background: var(--bg-canvas);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  user-select: all;
}

/* Harmonies Grid */
.cs-harmonies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.cs-harmony-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-harmony-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.cs-harmony-palette {
  display: flex;
  gap: 6px;
}

.cs-harmony-swatch {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cs-harmony-swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.cs-harmony-label {
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* Tints & Shades Ladder */
.cs-ladder-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.cs-ladder-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.cs-swatch-row {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.cs-ladder-swatch {
  flex: 1;
  min-width: 42px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
  position: relative;
  transition: transform 0.1s ease;
}

.cs-ladder-swatch:hover {
  transform: scale(1.06);
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cs-step-tag {
  font-size: 0.62rem;
  font-family: monospace;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* WCAG Contrast Section */
.cs-contrast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.cs-contrast-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.cs-contrast-preview {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.cs-contrast-sample-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.cs-contrast-sample-desc {
  font-size: 0.85rem;
  opacity: 0.9;
}

.cs-contrast-meta {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
}

.cs-contrast-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-contrast-target {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.cs-contrast-ratio {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.cs-contrast-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cs-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

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

[data-theme="dark"] .cs-badge.pass {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.cs-badge.fail {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .cs-badge.fail {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* History / Saved Palettes */
.cs-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cs-saved-palettes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.cs-saved-item {
  display: flex;
  align-items: center;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cs-saved-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.cs-saved-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0 8px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.cs-saved-del:hover {
  color: #ef4444;
}

.cs-history-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 8px;
  width: 100%;
  text-align: center;
}

/* Copy Animation Feedback */
button.copied {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
  transform: scale(1.02);
}

button.copied svg {
  stroke: #ffffff !important;
}

/* Responsiveness */
@media (max-width: 640px) {
  .cs-slider-row {
    grid-template-columns: 100px 1fr 65px;
    gap: 8px;
  }

  .cs-swatch-display {
    height: 140px;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
  }

  .cs-swatch-tools {
    justify-content: flex-end;
  }
}

/* Subtle Modern File Size & Count Advisory Pill */
.file-advisory-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-block-start: 10px;
  margin-inline: auto;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  color: #b45309;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: fit-content;
  box-sizing: border-box;
  animation: advisoryFadeSlide 0.22s ease-out;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-theme="dark"] .file-advisory-pill {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.26);
}

.file-advisory-pill[hidden] {
  display: none !important;
}

.file-advisory-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  color: currentColor;
}

.file-advisory-text {
  word-break: break-word;
}

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

/* URL Encoder & Studio */
.ue-inspector-card {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-subtle, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ue-params-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.ue-params-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ue-param-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.ue-empty-params {
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
  padding: 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}
.ue-utm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
@media (max-width: 640px) {
  .ue-param-row {
    grid-template-columns: 1fr;
  }
}

/* Text Diff Enhancements (Split & Unified) */
.diff-view-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.diff-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 120px;
  max-height: 520px;
  overflow: auto;
  padding: 15px;
  background: var(--bg-subtle, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  font-family: var(--font-mono, monospace);
  font-size: 0.88rem;
  line-height: 1.6;
}
.diff-split-col {
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-split-header {
  font-weight: 700;
  font-size: 0.85rem;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  color: var(--text-muted, #94a3b8);
}
.diff-line {
  display: block;
  padding: 1px 4px;
  border-radius: 4px;
}
.diff-line.diff-add {
  background: rgba(34, 197, 94, 0.18);
  color: #22c55e;
}
.diff-line.diff-remove {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
}
.diff-char-add {
  background: rgba(34, 197, 94, 0.35);
  font-weight: 600;
  border-radius: 2px;
}
.diff-char-remove {
  background: rgba(239, 68, 68, 0.35);
  text-decoration: line-through;
  border-radius: 2px;
}
@media (max-width: 640px) {
  .diff-split-container {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Kazakan Cognitive Test (IQ Test) Tool Styles
   Executive Assessment Dashboard, Minimalist, High-Contrast WCAG AAA
   ========================================================================== */

/* Outer Root & Stage */
.iq-test-root {
  width: 100%;
}

.iq-flow-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-inline: auto;
  max-width: 880px;
  width: 100%;
  color: var(--text-main);
}

/* Intro Header */
.iq-intro-header {
  text-align: center;
  margin-block-end: var(--space-6, 24px);
}
.iq-intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: var(--radius-pill, 9999px);
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.16));
  color: var(--brand-primary, #3b82f6);
  font-size: 0.84rem;
  font-weight: 700;
  margin-block-end: var(--space-3, 12px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .iq-intro-badge {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  color: #2563eb;
}
.iq-intro-badge.success {
  border-color: var(--status-success, #10b981);
  color: var(--status-success, #10b981);
  background: rgba(16, 185, 129, 0.1);
}
.iq-intro-title {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-block-end: var(--space-2, 8px);
  color: var(--text-main);
  line-height: 1.3;
}
.iq-intro-desc {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 680px;
  margin-inline: auto;
}

/* Info Pills Grid */
.iq-info-pills-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-block-end: var(--space-6, 24px);
}
.iq-info-pill {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-md, 16px);
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .iq-info-pill {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}
.iq-pill-val {
  font-size: 1.45rem;
  font-weight: 850;
  color: var(--brand-primary, #3b82f6);
  font-family: var(--font-system);
  line-height: 1.1;
}
.iq-pill-lbl {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Domains Strip */
.iq-domains-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-block-end: var(--space-6, 24px);
}
.iq-domain-item {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm, 10px);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .iq-domain-item {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}
.iq-domain-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.iq-domain-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Guidance Highlights Grid */
.iq-guidance-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-block-end: var(--space-6, 24px);
}
.iq-guide-card {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-md, 16px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .iq-guide-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}
.iq-guide-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--brand-primary, #3b82f6);
  flex-shrink: 0;
}
.iq-guide-text h4 {
  margin: 0 0 4px;
  font-size: 0.94rem;
  font-weight: 750;
  color: var(--text-main);
}
.iq-guide-text p {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Sample Accordion */
.iq-sample-accordion {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-md, 16px);
  margin-block-end: var(--space-6, 24px);
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .iq-sample-accordion {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}
.iq-sample-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--brand-primary, #3b82f6);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}
.iq-sample-summary:hover {
  background: rgba(59, 130, 246, 0.08);
}
.iq-sample-content {
  padding: 16px 20px 22px;
  border-block-start: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}
.iq-sample-q-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-block-end: 14px;
}
.iq-sample-stimulus {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px;
  background: var(--bg-subtle, #141e34);
  border-radius: var(--radius-sm, 12px);
  margin-block-end: 14px;
}
[data-theme="light"] .iq-sample-stimulus {
  background: #f1f5f9;
}
.iq-sample-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.iq-practice-feedback {
  margin-block-start: var(--space-3, 12px);
  padding: 12px 16px;
  border-radius: var(--radius-sm, 10px);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.5;
}
.iq-practice-feedback.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--status-success, #10b981);
  color: var(--status-success, #10b981);
}
.iq-practice-feedback.notice {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--status-warning, #f59e0b);
  color: var(--status-warning, #f59e0b);
}

/* Intro Footer */
.iq-intro-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3, 12px);
  margin-block-start: var(--space-4, 16px);
}
.iq-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 32px;
  min-height: 52px;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: var(--radius-pill, 9999px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.iq-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.45);
}
.iq-privacy-assure {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* Active Test Topbar */
.iq-test-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
  margin-block-end: var(--space-3, 12px);
}
.iq-domain-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill, 9999px);
  border: 1.5px solid var(--brand-primary, #3b82f6);
  background: var(--bg-surface, #0e1526);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 750;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .iq-domain-pill {
  background: #ffffff;
}
.iq-topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4, 16px);
}
.iq-q-counter {
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.iq-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-sm, 10px);
  background: var(--bg-surface, #0e1526);
  border: 1.5px solid var(--border-medium, rgba(255, 255, 255, 0.16));
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .iq-timer-box {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

/* Progress Track */
.iq-progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle, #141e34);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 999px;
  overflow: hidden;
  margin-block-end: var(--space-6, 24px);
}
[data-theme="light"] .iq-progress-track {
  background: #e2e8f0;
}
.iq-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary, #3b82f6), var(--brand-accent, #38bdf8));
  border-radius: 999px;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Question Stage */
.iq-question-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-5, 20px);
  min-height: 380px;
}
.iq-question-text {
  font-size: clamp(1.15rem, 2.5vw, 1.4rem);
  font-weight: 800;
  line-height: 1.5;
  color: var(--text-main);
  margin: 0;
}
.iq-stimulus-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(18px, 3vw, 28px);
  border-radius: var(--radius-lg, 20px);
  background: var(--bg-surface, #0e1526);
  border: 1.5px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  min-height: 160px;
}
[data-theme="light"] .iq-stimulus-container {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

/* Options Grid */
.iq-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-block-start: var(--space-3, 12px);
}
.iq-option-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  min-height: 64px;
  border-radius: var(--radius-md, 16px);
  background: var(--bg-surface, #0e1526);
  border: 1.5px solid var(--border-medium, rgba(255, 255, 255, 0.16));
  color: var(--text-main);
  cursor: pointer;
  text-align: start;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 650;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: border-color 0.12s ease, background-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
}
[data-theme="light"] .iq-option-btn {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}
.iq-option-btn:hover:not([disabled]) {
  background: var(--bg-elevated, #1a2744);
  border-color: var(--brand-primary, #3b82f6);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.2);
}
[data-theme="light"] .iq-option-btn:hover:not([disabled]) {
  background: #f8fafc;
  border-color: var(--brand-primary, #2563eb);
}
.iq-option-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #3b82f6);
  outline-offset: 2px;
}
.iq-option-btn:active:not([disabled]),
.iq-option-btn.selected {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--brand-primary, #3b82f6);
  box-shadow: 0 0 0 2px var(--brand-primary, #3b82f6);
}
.iq-opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-subtle, #141e34);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  font-size: 0.95rem;
  font-weight: 850;
  color: var(--brand-primary, #3b82f6);
  flex-shrink: 0;
  transition: all 0.12s ease;
}
[data-theme="light"] .iq-opt-letter {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #2563eb;
}
.iq-option-btn:hover .iq-opt-letter,
.iq-option-btn.selected .iq-opt-letter {
  background: var(--brand-primary, #3b82f6);
  border-color: var(--brand-primary, #3b82f6);
  color: #ffffff;
}
.iq-opt-content {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  color: var(--text-main);
}
[data-theme="light"] .iq-opt-content {
  color: #0f172a;
}
.iq-opt-content svg {
  max-height: 76px;
  max-width: 100%;
  height: auto;
  color: inherit;
}

/* Light mode high-contrast adaptive enforcement for SVG puzzles */
[data-theme="light"] .iq-opt-content svg [stroke="#f8fafc"],
[data-theme="light"] .iq-opt-content svg [stroke="white"],
[data-theme="light"] .iq-opt-content svg [stroke="#ffffff"],
[data-theme="light"] .iq-stimulus-container svg [stroke="#f8fafc"],
[data-theme="light"] .iq-stimulus-container svg [stroke="white"],
[data-theme="light"] .iq-stimulus-container svg [stroke="#ffffff"] {
  stroke: #0f172a !important;
}

[data-theme="light"] .iq-opt-content svg [fill="#f8fafc"],
[data-theme="light"] .iq-opt-content svg [fill="white"],
[data-theme="light"] .iq-opt-content svg [fill="#ffffff"],
[data-theme="light"] .iq-stimulus-container svg [fill="#f8fafc"],
[data-theme="light"] .iq-stimulus-container svg [fill="white"],
[data-theme="light"] .iq-stimulus-container svg [fill="#ffffff"] {
  fill: #0f172a !important;
}

[data-theme="light"] .iq-opt-content svg [stroke="#83C8F0"],
[data-theme="light"] .iq-stimulus-container svg [stroke="#83C8F0"] {
  stroke: #2563eb !important;
}

[data-theme="light"] .iq-opt-content svg [fill="#83C8F0"],
[data-theme="light"] .iq-stimulus-container svg [fill="#83C8F0"] {
  fill: #2563eb !important;
}

/* Common SVG Vector Board & Analogy */
.iq-svg-board,
.iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.65)"],
.iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.7)"],
.iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.9)"] {
  fill: var(--bg-subtle, #141e34);
  stroke: var(--border-medium, rgba(255, 255, 255, 0.16));
  stroke-width: 1.5;
}
[data-theme="light"] .iq-svg-board,
[data-theme="light"] .iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.65)"],
[data-theme="light"] .iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.7)"],
[data-theme="light"] .iq-stimulus-container svg rect[fill="rgba(14, 22, 40, 0.9)"] {
  fill: #f8fafc !important;
  stroke: #cbd5e1 !important;
}

.iq-svg-board-missing {
  fill: rgba(59, 130, 246, 0.12);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
}
[data-theme="light"] .iq-svg-board-missing {
  fill: rgba(37, 99, 235, 0.08);
  stroke: var(--brand-primary, #2563eb);
}

.iq-svg-text {
  fill: var(--text-main);
  font-family: var(--font-system);
}
[data-theme="light"] .iq-svg-text {
  fill: #0f172a !important;
}

.iq-svg-text-muted {
  fill: var(--text-muted);
  font-family: var(--font-system);
}
[data-theme="light"] .iq-svg-text-muted {
  fill: #64748b !important;
}

.iq-svg-analogy {
  max-width: 100%;
  height: auto;
  display: block;
}

/* SVG Vector Board & Cell Styles */
.iq-svg-matrix {
  max-width: 100%;
  height: auto;
  display: block;
}
.iq-svg-matrix .matrix-cell {
  fill: var(--bg-subtle, #141e34);
  stroke: var(--border-medium, rgba(255, 255, 255, 0.16));
  stroke-width: 1.5;
}
[data-theme="light"] .iq-svg-matrix .matrix-cell {
  fill: #f1f5f9;
  stroke: #cbd5e1;
}
.iq-svg-matrix .matrix-cell-missing {
  fill: rgba(59, 130, 246, 0.12);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
[data-theme="light"] .iq-svg-matrix .matrix-cell-missing {
  fill: rgba(37, 99, 235, 0.08);
  stroke: var(--brand-primary, #2563eb);
}
.iq-svg-matrix .matrix-q-mark {
  fill: var(--brand-primary, #3b82f6);
  font-family: var(--font-system);
  font-size: 32px;
  font-weight: 850;
}

.iq-svg-series .series-cell {
  fill: var(--bg-subtle, #141e34);
  stroke: var(--border-medium, rgba(255, 255, 255, 0.16));
  stroke-width: 1.5;
}
[data-theme="light"] .iq-svg-series .series-cell {
  fill: #f1f5f9;
  stroke: #cbd5e1;
}
.iq-svg-series .series-cell-missing {
  fill: rgba(59, 130, 246, 0.12);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 2;
  stroke-dasharray: 5 4;
}
[data-theme="light"] .iq-svg-series .series-cell-missing {
  fill: rgba(37, 99, 235, 0.08);
  stroke: var(--brand-primary, #2563eb);
}
.iq-svg-series .series-q-mark {
  fill: var(--brand-primary, #3b82f6);
  font-family: var(--font-system);
  font-size: 26px;
  font-weight: 850;
}

.iq-svg-net .net-cell {
  fill: var(--bg-subtle, #141e34);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 1.8;
}
[data-theme="light"] .iq-svg-net .net-cell {
  fill: #f1f5f9;
}

.iq-svg-isometric .cube-face-top {
  fill: rgba(59, 130, 246, 0.25);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 1.8;
}
.iq-svg-isometric .cube-face-left {
  fill: rgba(59, 130, 246, 0.45);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 1.8;
}
.iq-svg-isometric .cube-face-right {
  fill: rgba(30, 64, 175, 0.65);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 1.8;
}

.iq-svg-radar .radar-board {
  fill: var(--bg-surface, #0e1526);
  stroke: var(--border-medium, rgba(255, 255, 255, 0.14));
}
[data-theme="light"] .iq-svg-radar .radar-board {
  fill: #ffffff;
  stroke: rgba(15, 23, 42, 0.12);
}
.iq-svg-radar .radar-ring {
  stroke: var(--border-subtle, rgba(255, 255, 255, 0.12));
  stroke-width: 1;
}
[data-theme="light"] .iq-svg-radar .radar-ring {
  stroke: rgba(15, 23, 42, 0.1);
}
.iq-svg-radar .radar-spoke {
  stroke: var(--border-medium, rgba(255, 255, 255, 0.16));
  stroke-width: 1;
}
[data-theme="light"] .iq-svg-radar .radar-spoke {
  stroke: rgba(15, 23, 42, 0.14);
}
.iq-svg-radar .radar-label {
  fill: var(--text-muted);
  font-family: var(--font-system);
  font-size: 10px;
  font-weight: 700;
}
.iq-svg-radar .radar-area {
  fill: rgba(59, 130, 246, 0.25);
  stroke: var(--brand-primary, #3b82f6);
  stroke-width: 2.5;
}
.iq-svg-radar .radar-dot {
  fill: var(--brand-primary, #3b82f6);
  stroke: #ffffff;
  stroke-width: 1.5;
}

/* Footer & Status */
.iq-test-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block-start: var(--space-6, 24px);
  padding-block-start: var(--space-4, 16px);
  border-block-start: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}
.iq-calm-status {
  font-size: 0.9rem;
  color: var(--brand-primary, #3b82f6);
  font-weight: 700;
  min-height: 20px;
}
.iq-quit-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-xs, 6px);
  transition: color 0.12s ease;
}
.iq-quit-btn:hover {
  color: var(--text-main);
}

/* Results Card */
.iq-results-header {
  text-align: center;
  margin-block-end: var(--space-6, 24px);
}
.iq-results-title {
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  font-weight: 800;
  margin-block-end: var(--space-2, 8px);
  color: var(--text-main);
}
.iq-exploratory-disclaimer {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--status-warning, #f59e0b);
  border-radius: var(--radius-sm, 12px);
  padding: 10px 18px;
  font-size: 0.84rem;
  line-height: 1.5;
  margin-inline: auto;
  text-align: start;
}

/* Score Hero */
.iq-score-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-8, 32px);
  padding: var(--space-6, 24px);
  background: var(--bg-surface, #0e1526);
  border-radius: var(--radius-card, 22px);
  border: 1.5px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  margin-block-end: var(--space-8, 32px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .iq-score-hero {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}
.iq-main-meter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.iq-score-dial {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--brand-primary, #3b82f6);
  background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, var(--bg-surface, #0e1526) 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 28px rgba(59, 130, 246, 0.25);
}
.iq-dial-number {
  font-size: 3rem;
  font-weight: 850;
  line-height: 1;
  color: var(--text-main);
  font-family: var(--font-system);
}
.iq-dial-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-block-start: 4px;
}
.iq-dial-subtext {
  font-size: 0.9rem;
  font-weight: 750;
  color: var(--brand-primary, #3b82f6);
}

.iq-stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 12px;
  flex-grow: 1;
  max-width: 440px;
}
.iq-stat-card {
  background: var(--bg-subtle, #141e34);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 16px);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
[data-theme="light"] .iq-stat-card {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}
.iq-stat-card-val {
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--text-main);
  font-family: var(--font-system);
}
.iq-stat-card-lbl {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Domain Breakdown Section */
.iq-section-subheading {
  font-size: 1.2rem;
  font-weight: 800;
  margin-block-end: var(--space-4, 16px);
  color: var(--text-main);
}
.iq-radar-and-bars-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: var(--space-6, 24px);
  align-items: center;
  margin-block-end: var(--space-6, 24px);
}
.iq-radar-col {
  display: flex;
  justify-content: center;
}
.iq-bars-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.iq-domain-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.iq-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}
.iq-bar-title {
  color: var(--text-main);
}
.iq-bar-score {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.iq-bar-track {
  width: 100%;
  height: 9px;
  background: var(--bg-subtle, #141e34);
  border-radius: 999px;
  overflow: hidden;
}
[data-theme="light"] .iq-bar-track {
  background: #e2e8f0;
}
.iq-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Insights Section */
.iq-insights-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-block-end: var(--space-8, 32px);
}
.iq-insights-card {
  padding: 18px 22px;
  border-radius: var(--radius-md, 16px);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
}
.iq-insights-card.strength {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
}
.iq-insights-card.growth {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.35);
}
.iq-insight-title {
  font-size: 1rem;
  font-weight: 750;
  margin-block-end: 6px;
  color: var(--text-main);
}
.iq-insights-card p {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}

/* Human IQ Benchmarks & Smartest Minds Comparison */
.iq-benchmark-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-6, 24px);
  margin-block-end: var(--space-8, 32px);
}
.iq-benchmark-header {
  text-align: start;
}
.iq-benchmark-subtitle {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.iq-distribution-board {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-card, 20px);
  padding: 22px 24px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .iq-distribution-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}
.iq-distribution-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.iq-dist-tier {
  display: grid;
  grid-template-columns: minmax(210px, 260px) 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-radius: var(--radius-sm, 12px);
  background: var(--bg-subtle, #141e34);
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
}
[data-theme="light"] .iq-dist-tier {
  background: #f8fafc;
}
.iq-dist-tier.avg-tier {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}
[data-theme="light"] .iq-dist-tier.avg-tier {
  background: rgba(16, 185, 129, 0.08);
}
.iq-dist-tier.user-tier-highlight {
  border-color: var(--brand-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.2);
}
[data-theme="light"] .iq-dist-tier.user-tier-highlight {
  background: rgba(59, 130, 246, 0.08);
}
.iq-dist-tier-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.iq-dist-range-val {
  font-family: var(--font-mono, monospace);
  font-size: 1.05rem;
  font-weight: 850;
  color: var(--text-main);
  min-width: 68px;
}
.iq-avg-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(16, 185, 129, 0.2);
  color: var(--status-success, #10b981);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.iq-user-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(59, 130, 246, 0.25);
  color: var(--brand-primary, #3b82f6);
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.iq-dist-tier-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.iq-dist-tier-name {
  font-weight: 750;
  font-size: 0.88rem;
  color: var(--text-main);
}
.iq-dist-tier-pct {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}
.iq-dist-tier-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
[data-theme="light"] .iq-dist-tier-bar {
  background: #e2e8f0;
}
.iq-dist-tier-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Smartest Humans Comparison Block */
.iq-geniuses-block {
  margin-block-start: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 16px);
}
.iq-geniuses-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.iq-geniuses-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}
.iq-geniuses-note {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.iq-geniuses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.iq-genius-card {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-md, 16px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
[data-theme="light"] .iq-genius-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}
.iq-genius-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-primary, #3b82f6);
}
.iq-genius-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.iq-genius-score {
  font-family: var(--font-mono, monospace);
  font-size: 0.88rem;
  font-weight: 850;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  padding: 3px 10px;
  border-radius: var(--radius-xs, 6px);
  letter-spacing: 0.02em;
}
.iq-genius-field {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
}
.iq-genius-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}
.iq-genius-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Actions Footer */
.iq-results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.iq-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--min-touch-size, 48px);
  padding: 12px 22px;
  font-weight: 750;
  border-radius: var(--radius-pill, 9999px);
}

/* Review View */
.iq-review-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-block-end: var(--space-6, 24px);
}
.iq-review-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.iq-review-item {
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-md, 16px);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .iq-review-item {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}
.iq-review-item.item-correct {
  border-inline-start: 5px solid var(--status-success, #10b981);
}
.iq-review-item.item-wrong {
  border-inline-start: 5px solid var(--status-error, #ef4444);
}
.iq-review-item.item-unanswered {
  border-inline-start: 5px solid var(--border-medium, rgba(255, 255, 255, 0.2));
  opacity: 0.96;
}
[data-theme="light"] .iq-review-item.item-unanswered {
  border-inline-start-color: #94a3b8;
}
.iq-review-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.iq-review-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.iq-review-num {
  font-weight: 850;
  font-size: 1rem;
  color: var(--text-main);
}
.iq-domain-tag {
  padding: 3px 10px;
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.76rem;
  font-weight: 750;
}
.iq-review-badge {
  font-size: 0.83rem;
  font-weight: 750;
  padding: 4px 12px;
  border-radius: var(--radius-xs, 6px);
}
.iq-review-badge.correct {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-success, #10b981);
}
.iq-review-badge.wrong {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-error, #ef4444);
}
.iq-review-badge.unanswered {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted, #94a3b8);
}
[data-theme="light"] .iq-review-badge.unanswered {
  background: #f1f5f9;
  color: #64748b;
}
.iq-review-q-text {
  font-size: 1.08rem;
  font-weight: 750;
  color: var(--text-main);
  margin: 0;
}
.iq-review-stimulus {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: var(--bg-subtle, #141e34);
  border-radius: var(--radius-sm, 12px);
}
[data-theme="light"] .iq-review-stimulus {
  background: #f1f5f9;
}
.iq-review-choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.iq-review-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm, 12px);
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  font-size: 0.9rem;
  font-weight: 650;
}
[data-theme="light"] .iq-review-choice {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
}
.iq-review-choice.choice-right {
  border-color: var(--status-success, #10b981);
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-success, #10b981);
}
.iq-review-choice.choice-wrong {
  border-color: var(--status-error, #ef4444);
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-error, #ef4444);
}
.iq-user-picked-label {
  font-size: 0.75rem;
  font-weight: 750;
  margin-inline-start: auto;
}
.iq-review-explanation {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-sm, 12px);
  padding: 14px 18px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-main);
}
.iq-review-explanation p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

[data-theme="light"] .iq-review-stimulus svg [stroke="#f8fafc"],
[data-theme="light"] .iq-review-stimulus svg [stroke="white"],
[data-theme="light"] .iq-review-stimulus svg [stroke="#ffffff"] {
  stroke: #0f172a !important;
}
[data-theme="light"] .iq-review-stimulus svg [fill="#f8fafc"],
[data-theme="light"] .iq-review-stimulus svg [fill="white"],
[data-theme="light"] .iq-review-stimulus svg [fill="#ffffff"] {
  fill: #0f172a !important;
}
[data-theme="light"] .iq-review-stimulus svg [stroke="#83C8F0"] {
  stroke: #2563eb !important;
}
[data-theme="light"] .iq-review-stimulus svg [fill="#83C8F0"] {
  fill: #2563eb !important;
}

.iq-review-summary-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: var(--radius-sm, 12px);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}
.iq-review-summary-banner svg {
  color: var(--brand-primary, #3b82f6);
  flex-shrink: 0;
}

.iq-review-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-surface, #0e1526);
  border: 1px dashed var(--border-medium, rgba(255, 255, 255, 0.2));
  border-radius: var(--radius-md, 16px);
  gap: 14px;
}
[data-theme="light"] .iq-review-empty-state {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.16);
}
.iq-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.12);
  color: var(--brand-primary, #3b82f6);
  display: grid;
  place-items: center;
}
.iq-review-empty-state h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}
.iq-review-empty-state p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.55;
}

/* ==========================================================================
   Cognitive Benchmark Scale & Highest IQ Human Historical Comparisons
   ========================================================================== */

.iq-benchmark-section {
  margin-block-start: var(--space-6, 24px);
  padding: 24px 28px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-md, 16px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .iq-benchmark-section {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.iq-benchmark-header {
  margin-block-end: 20px;
}

.iq-benchmark-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 6px 0 0;
}

.iq-distribution-board {
  margin-block-end: 28px;
}

.iq-distribution-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.iq-dist-tier {
  display: grid;
  grid-template-columns: 210px 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm, 12px);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

[data-theme="light"] .iq-dist-tier {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}

.iq-dist-tier.avg-tier {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.06);
}

.iq-dist-tier.user-tier-highlight {
  border-color: var(--brand-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 1px var(--brand-primary, #3b82f6);
}

.iq-dist-tier-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.iq-dist-range-val {
  font-family: var(--font-system);
  font-weight: 850;
  font-size: 1rem;
  color: var(--text-main);
}

.iq-avg-pill {
  font-size: 0.72rem;
  font-weight: 750;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.iq-user-pill {
  font-size: 0.72rem;
  font-weight: 750;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.iq-dist-tier-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.iq-dist-tier-name {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text-main);
}

.iq-dist-tier-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.iq-dist-tier-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill, 9999px);
  overflow: hidden;
}

[data-theme="light"] .iq-dist-tier-bar {
  background: #e2e8f0;
}

.iq-dist-tier-fill {
  height: 100%;
  border-radius: var(--radius-pill, 9999px);
  transition: width 0.4s ease;
}

/* Smartest Humans Comparison Block */
.iq-geniuses-block {
  padding-block-start: 20px;
  border-block-start: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .iq-geniuses-block {
  border-block-start-color: rgba(15, 23, 42, 0.08);
}

.iq-geniuses-header {
  margin-block-end: 18px;
}

.iq-geniuses-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 6px;
}

.iq-geniuses-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.iq-geniuses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.iq-genius-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm, 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

[data-theme="light"] .iq-genius-card {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}

.iq-genius-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.35);
}

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

.iq-genius-score {
  font-family: var(--font-system);
  font-size: 0.85rem;
  font-weight: 850;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(139, 92, 246, 0.18);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

[data-theme="light"] .iq-genius-score {
  background: #ede9fe;
  color: #7c3aed;
  border-color: #ddd6fe;
}

.iq-genius-field {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.iq-genius-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.iq-genius-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* ==========================================================================
   Responsive Cognitive Stimulus Component Styles
   ========================================================================== */

/* Syllogism Board */
.iq-syllogism-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 580px;
  padding: 18px 22px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .iq-syllogism-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.iq-syllogism-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 0.98rem;
  line-height: 1.5;
}

.iq-premise-badge {
  font-size: 0.78rem;
  font-weight: 750;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 9999px);
  background: rgba(59, 130, 246, 0.12);
  color: var(--brand-primary, #3b82f6);
  white-space: nowrap;
}

.iq-premise-content {
  font-weight: 650;
  color: var(--text-main);
}

.iq-syllogism-conclusion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block-start: 10px;
  margin-block-start: 6px;
  border-block-start: 1px dashed var(--border-subtle, rgba(255, 255, 255, 0.12));
}

[data-theme="light"] .iq-syllogism-conclusion-row {
  border-block-start-color: rgba(15, 23, 42, 0.1);
}

.iq-conclusion-badge {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
}

.iq-conclusion-target {
  font-weight: 850;
  color: var(--brand-primary, #3b82f6);
  font-size: 1.1rem;
}

/* Analogy Board */
.iq-analogy-board {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 24px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 540px;
  width: 100%;
}

[data-theme="light"] .iq-analogy-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-analogy-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.iq-analogy-token {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-xs, 8px);
}

[data-theme="light"] .iq-analogy-token {
  background: #f1f5f9;
}

.iq-analogy-rel {
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
  font-size: 1.2rem;
}

.iq-analogy-sep {
  font-weight: 900;
  font-size: 1.4rem;
  color: #8b5cf6;
  padding-inline: 8px;
}

.iq-analogy-placeholder {
  font-size: 1.15rem;
  font-weight: 850;
  color: var(--brand-primary, #3b82f6);
  padding: 6px 14px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px dashed var(--brand-primary, #3b82f6);
  border-radius: var(--radius-xs, 8px);
}

/* 2x2 Rotation Stimulus */
.iq-rotation-stimulus {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 520px;
  width: 100%;
}

[data-theme="light"] .iq-rotation-stimulus {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-rotation-grid-wrap {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iq-grid-2x2-svg {
  width: 76px;
  height: 76px;
}

.iq-rotation-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iq-rotation-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
}

.iq-rotation-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Digit Sequence Board */
.iq-digit-sequence-board {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 480px;
  width: 100%;
}

[data-theme="light"] .iq-digit-sequence-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-digit-seq-value {
  font-family: var(--font-system);
  font-size: 1.8rem;
  font-weight: 850;
  color: var(--brand-primary, #3b82f6);
  letter-spacing: 0.06em;
}

/* Symbol Sequence Board */
.iq-symbol-sequence-board {
  display: flex;
  justify-content: center;
  padding: 16px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 480px;
  width: 100%;
}

[data-theme="light"] .iq-symbol-sequence-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-symbol-tokens-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.iq-symbol-token {
  font-size: 1.8rem;
  color: var(--brand-primary, #3b82f6);
}

/* Running Tally Board */
.iq-tally-board {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 520px;
  width: 100%;
}

[data-theme="light"] .iq-tally-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-tally-step {
  font-size: 0.95rem;
  font-weight: 750;
  padding: 6px 12px;
  border-radius: var(--radius-xs, 8px);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

[data-theme="light"] .iq-tally-step {
  background: #f1f5f9;
}

.iq-tally-step.start {
  color: var(--brand-primary, #3b82f6);
}

.iq-tally-step.op-plus {
  color: #10b981;
}

.iq-tally-step.op-minus {
  color: #f59e0b;
}

.iq-tally-arrow {
  color: var(--text-muted);
  font-weight: 700;
}

/* N-Back Board */
.iq-nback-board {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 520px;
  width: 100%;
}

[data-theme="light"] .iq-nback-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-nback-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-xs, 8px);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .iq-nback-step {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.1);
}

.iq-nback-step-num {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.iq-nback-step-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
}

.iq-nback-sep {
  color: var(--text-muted);
  font-weight: 700;
}

/* Code Substitution Board */
.iq-code-subst-board {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 520px;
  width: 100%;
}

[data-theme="light"] .iq-code-subst-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-code-key-row,
.iq-code-query-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.iq-code-key-label,
.iq-code-query-label {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--text-muted);
}

.iq-code-tokens {
  display: flex;
  gap: 8px;
}

.iq-code-token {
  font-size: 0.9rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-xs, 6px);
  background: rgba(59, 130, 246, 0.12);
  color: var(--brand-primary, #3b82f6);
}

.iq-code-query-symbols {
  display: flex;
  gap: 10px;
}

.iq-query-symbol {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-main);
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-xs, 6px);
}

[data-theme="light"] .iq-query-symbol {
  background: #f1f5f9;
}

/* String Comparison Board */
.iq-string-compare-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 440px;
  width: 100%;
}

[data-theme="light"] .iq-string-compare-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-str-row {
  font-family: var(--font-mono, monospace);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-main);
}

.iq-str-row.str-b {
  color: var(--brand-primary, #3b82f6);
}

.iq-str-divider {
  width: 100%;
  max-width: 260px;
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.12));
}

[data-theme="light"] .iq-str-divider {
  background: rgba(15, 23, 42, 0.1);
}

/* Balance Scale Board */
.iq-balance-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 22px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 520px;
  width: 100%;
}

[data-theme="light"] .iq-balance-board {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-balance-fact-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.95rem;
  color: var(--text-main);
}

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

.iq-balance-target-row {
  display: flex;
  justify-content: center;
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
  font-size: 1.05rem;
}

/* Clock Stimulus Board */
.iq-clock-stimulus {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 480px;
  width: 100%;
}

[data-theme="light"] .iq-clock-stimulus {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-clock-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text-main);
}

.iq-clock-query {
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
}

/* 3D Elevation Stimulus Board */
.iq-elevation-stimulus {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  background: var(--bg-surface, #0e1526);
  border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
  border-radius: var(--radius-sm, 14px);
  max-width: 480px;
  width: 100%;
}

[data-theme="light"] .iq-elevation-stimulus {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

.iq-elevation-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iq-elevation-tag {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--text-muted);
}

.iq-elevation-target {
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-primary, #3b82f6);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .iq-info-pills-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .iq-guidance-grid {
    grid-template-columns: 1fr;
  }
  .iq-radar-and-bars-grid {
    grid-template-columns: 1fr;
  }
  .iq-score-hero {
    flex-direction: column;
    text-align: center;
  }
  .iq-stats-summary-grid {
    width: 100%;
  }
  .iq-options-grid {
    grid-template-columns: 1fr;
  }
  .iq-dist-tier {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .iq-geniuses-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .iq-info-pills-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .iq-flow-card,
  .iq-option-btn,
  .iq-progress-bar,
  .iq-bar-fill {
    transition: none !important;
  }
}

/* ==========================================================================
   Aim Assist Training Lab (3D FPS Aim Trainer) Styles
   ========================================================================== */
.aim-workspace-app {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aim-lab-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  overflow: hidden;
  position: relative;
  box-shadow: var(--glass-shadow);
}

.aim-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-block-end: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.aim-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.aim-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aim-field-label {
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.aim-toolbar-select {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
}

.aim-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.aim-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  min-height: var(--min-touch-size);
  border-radius: var(--radius-sm);
}

.aim-icon-btn {
  min-width: var(--min-touch-size);
  min-height: var(--min-touch-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.aim-icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

/* 3D Viewport */
.aim-viewport {
  position: relative;
  width: 100%;
  height: 560px;
  min-height: 420px;
  max-height: 75vh;
  background: #060913;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.aim-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Tactical Crosshairs */
.aim-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
  color: #38bdf8;
}

.aim-crosshair.crosshair-cross {
  width: 18px;
  height: 18px;
}
.aim-crosshair.crosshair-cross::before,
.aim-crosshair.crosshair-cross::after {
  content: '';
  position: absolute;
  background: currentColor;
}
.aim-crosshair.crosshair-cross::before {
  top: 0;
  left: 8px;
  width: 2px;
  height: 18px;
}
.aim-crosshair.crosshair-cross::after {
  top: 8px;
  left: 0;
  width: 18px;
  height: 2px;
}

.aim-crosshair.crosshair-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.aim-crosshair.crosshair-circle_dot {
  width: 20px;
  height: 20px;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aim-crosshair.crosshair-circle_dot::after {
  content: '';
  width: 4px;
  height: 4px;
  background: currentColor;
  border-radius: 50%;
}

.aim-crosshair.crosshair-cross_gap {
  width: 22px;
  height: 22px;
  position: relative;
}
.aim-crosshair.crosshair-cross_gap::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10px;
  width: 2px;
  height: 6px;
  background: currentColor;
  box-shadow: 0 16px 0 currentColor;
}
.aim-crosshair.crosshair-cross_gap::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 0;
  width: 6px;
  height: 2px;
  background: currentColor;
  box-shadow: 16px 0 0 currentColor;
}

/* Top High-Visibility Esports Centered HUD Display */
.aim-hud-overlay {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: stretch;
  pointer-events: none;
  z-index: 15;
  gap: 14px;
  width: auto;
  max-width: calc(100% - 32px);
  direction: ltr;
}

.aim-hud-stat {
  background: rgba(10, 16, 32, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  border-radius: var(--radius-md, 12px);
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 105px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.aim-hud-stat.score {
  border-color: rgba(245, 158, 11, 0.75);
}
.aim-hud-stat.score .aim-hud-val {
  color: #fbbf24;
}

.aim-hud-stat.timer {
  border-color: rgba(56, 189, 248, 0.75);
}
.aim-hud-stat.timer .aim-hud-val {
  color: #38bdf8;
}

.aim-hud-stat.acc {
  border-color: rgba(16, 185, 129, 0.75);
}
.aim-hud-stat.acc .aim-hud-val {
  color: #34d399;
}

.aim-hud-stat.ammo {
  border-color: rgba(96, 165, 250, 0.75);
  min-width: 135px;
}
.aim-hud-stat.ammo .aim-hud-val {
  color: #60a5fa;
}

.aim-hud-label {
  font-size: 0.78rem;
  font-weight: 850;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-block-end: 2px;
  line-height: 1.2;
}

.aim-hud-val {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1.05;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.aim-hud-val.low-ammo {
  color: #ef4444 !important;
  animation: aim-ammo-pulse 0.5s infinite alternate;
}
.aim-hud-val.reloading {
  font-size: 1.15rem;
  color: #f59e0b !important;
}

@keyframes aim-ammo-pulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* Ammo Visual Pips Bar */
.aim-ammo-pips-strip {
  display: flex;
  gap: 2.5px;
  margin-block-start: 5px;
  max-width: 130px;
  flex-wrap: wrap;
  justify-content: center;
}

.aim-pip {
  width: 3.5px;
  height: 11px;
  border-radius: 1px;
  background: #60a5fa;
  transition: background-color 0.1s ease;
}
.aim-pip.empty {
  background: rgba(255, 255, 255, 0.15);
}

/* Tactical Hit Marker (X on crosshair) */
.aim-hit-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 14;
  opacity: 0;
  transition: opacity 0.04s ease;
}

.aim-hit-marker.active {
  opacity: 1;
}

.aim-hm-line {
  position: absolute;
  width: 7px;
  height: 2.5px;
  background: #ffffff;
  border-radius: 1px;
}
.aim-hit-marker.headshot .aim-hm-line {
  background: #facc15;
  box-shadow: 0 0 8px #facc15;
}

.aim-hm-line.tl { top: 2px; left: 2px; transform: rotate(45deg); }
.aim-hm-line.tr { top: 2px; right: 2px; transform: rotate(-45deg); }
.aim-hm-line.bl { bottom: 2px; left: 2px; transform: rotate(-45deg); }
.aim-hm-line.br { bottom: 2px; right: 2px; transform: rotate(45deg); }

/* Tactical ADS Vignette for Rifles / SMGs */
.aim-ads-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  background: radial-gradient(circle at center, transparent 48%, rgba(8, 14, 26, 0.55) 100%);
  transition: opacity 0.15s ease;
}

/* Heavy Sniper Fullscreen Optical Scope with Mil-Dots */
.aim-sniper-scope {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.03) 0%, transparent 28%, rgba(0, 0, 0, 0.96) 38%, #000000 58%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aim-sniper-reticle {
  position: relative;
  width: min(440px, 60vmin);
  height: min(440px, 60vmin);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aim-sniper-circle {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.9);
}

.aim-sniper-inner-ring {
  position: absolute;
  width: 50%;
  height: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.aim-sniper-cross-h {
  position: absolute;
  top: 50%;
  left: -200px;
  right: -200px;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.85);
  transform: translateY(-50%);
}

.aim-sniper-cross-v {
  position: absolute;
  left: 50%;
  top: -200px;
  bottom: -200px;
  width: 1.5px;
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(-50%);
}

.aim-sniper-center-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
  z-index: 2;
}

.aim-sniper-ticks {
  position: absolute;
  inset: 0;
}
.aim-scope-tick {
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
}
.aim-scope-tick.h1 { top: calc(50% - 4px); left: 35%; width: 1.5px; height: 8px; }
.aim-scope-tick.h2 { top: calc(50% - 4px); left: 20%; width: 1.5px; height: 8px; }
.aim-scope-tick.h3 { top: calc(50% - 4px); right: 35%; width: 1.5px; height: 8px; }
.aim-scope-tick.h4 { top: calc(50% - 4px); right: 20%; width: 1.5px; height: 8px; }
.aim-scope-tick.v1 { left: calc(50% - 4px); top: 35%; height: 1.5px; width: 8px; }
.aim-scope-tick.v2 { left: calc(50% - 4px); top: 20%; height: 1.5px; width: 8px; }
.aim-scope-tick.v3 { left: calc(50% - 4px); bottom: 35%; height: 1.5px; width: 8px; }
.aim-scope-tick.v4 { left: calc(50% - 4px); bottom: 20%; height: 1.5px; width: 8px; }

/* Center Game Viewport Hero Play Overlay */
.aim-viewport-hero {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 26, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 24;
  padding: var(--space-6);
  text-align: center;
  gap: var(--space-3);
}

.aim-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  font-size: 0.84rem;
  font-weight: 850;
}

.aim-hero-title {
  font-size: 2.25rem;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
}

.aim-hero-subtitle {
  font-size: 0.98rem;
  color: #e2e8f0;
  max-width: 560px;
  margin: 0;
  line-height: 1.6;
}

.aim-hero-weapon-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.aim-hero-weapon-label {
  font-size: 0.92rem;
  font-weight: 850;
  color: #f8fafc;
}

.aim-hero-weapon-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.aim-weapon-pill {
  padding: 9px 18px;
  border-radius: var(--radius-sm, 8px);
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(148, 163, 184, 0.45);
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.aim-weapon-pill:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.75);
  color: #ffffff;
  transform: translateY(-1px);
}

.aim-weapon-pill.active {
  background: rgba(14, 165, 233, 0.35);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.aim-hero-play-btn {
  margin-block-start: var(--space-3);
  padding: 16px 40px;
  font-size: 1.25rem;
  font-weight: 900;
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.45);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.aim-hero-play-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 16px 42px rgba(37, 99, 235, 0.65);
}

.aim-hero-controls-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-block-start: var(--space-3);
}

.aim-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 750;
  color: #f1f5f9;
  background: rgba(15, 23, 42, 0.82);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  padding: 6px 14px;
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.aim-legend-item b {
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.88rem;
  font-weight: 900;
}

/* Adaptive Difficulty HUD Toast */
.aim-adaptive-toast {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(59, 130, 246, 0.9);
  color: #ffffff;
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 750;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.aim-adaptive-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Countdown Prompt Overlay */
.aim-countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 19, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.aim-countdown-number {
  font-size: 5rem;
  font-weight: 900;
  color: var(--brand-primary);
  line-height: 1;
}

.aim-countdown-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-block-start: var(--space-2);
}

/* Quick Reaction Cue Prompt Banner */
.aim-reaction-prompt {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 14;
  pointer-events: none;
}

.aim-reaction-text {
  font-size: 1.75rem;
  font-weight: 900;
  padding: 8px 26px;
  border-radius: var(--radius-sm);
  letter-spacing: 1.5px;
  display: inline-block;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.aim-reaction-text.waiting {
  background: rgba(239, 68, 68, 0.88);
  color: #ffffff;
}

.aim-reaction-text.active {
  background: rgba(34, 197, 94, 0.92);
  color: #ffffff;
}

/* Pause Menu Modal */
.aim-pause-menu {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 19, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  z-index: 25;
}

.aim-pause-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.aim-pause-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 220px;
}

/* Mobile Virtual Touch Controls */
.aim-mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: var(--space-4);
}

.aim-touch-stick {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(14, 22, 40, 0.45);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.aim-touch-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-primary);
  position: absolute;
  top: calc(50% - 22px);
  left: calc(50% - 22px);
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.aim-touch-look {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 55%;
  pointer-events: auto;
  touch-action: none;
}

.aim-touch-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: auto;
  z-index: 16;
}

.aim-touch-btn {
  min-width: 56px;
  min-height: 56px;
  border-radius: 50%;
  background: rgba(14, 22, 40, 0.85);
  border: 1.5px solid var(--border-medium);
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.aim-touch-btn.fire-btn {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  min-width: 64px;
  min-height: 64px;
}

/* Dialog Modals */
.aim-dialog {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  margin: auto !important;
  border: none;
  border-radius: var(--radius-card);
  padding: 0;
  background: transparent;
  max-width: 680px;
  width: min(680px, 92vw);
  max-height: 88vh;
  max-height: 88dvh;
  overflow: visible;
  z-index: 1000;
}

.aim-dialog[open] {
  display: flex !important;
  flex-direction: column;
}

.aim-dialog::backdrop {
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.aim-dialog-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--glass-shadow-hover);
  width: 100%;
}

.aim-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.aim-dialog-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.aim-dialog-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  min-width: var(--min-touch-size);
  min-height: var(--min-touch-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.aim-dialog-close:hover {
  color: var(--text-main);
}

.aim-dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aim-settings-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin: 0;
  background: var(--bg-subtle);
}

.aim-group-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--brand-primary);
  padding: 0 6px;
}

.aim-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-3);
}

.aim-cm360-badge {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  color: var(--brand-primary);
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aim-checkbox-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-block-start: var(--space-3);
}

.aim-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-main);
  cursor: pointer;
  min-height: 36px;
}

.aim-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-block-start: var(--space-2);
}

/* Results & Coaching Styles */
.aim-tier-hero {
  text-align: center;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.aim-tier-pill {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.aim-score-display {
  margin: var(--space-2) 0;
}

.aim-score-number {
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--text-main);
  display: block;
  line-height: 1;
}

.aim-score-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.aim-best-badge {
  display: inline-block;
  margin-block-start: 6px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #f59e0b;
  font-size: 0.8rem;
  font-weight: 800;
}

.aim-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-2);
  margin-block-start: var(--space-3);
}

.aim-coaching-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-block-start: var(--space-3);
}

.aim-coaching-heading {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  margin-block-end: var(--space-3);
}

.aim-coaching-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.aim-coaching-col {
  background: var(--bg-subtle);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}

.aim-coaching-tag {
  font-size: 0.72rem;
  font-weight: 800;
  display: block;
  margin-block-end: 4px;
  text-transform: uppercase;
}

.aim-coaching-tag.positive {
  color: #10b981;
}

.aim-coaching-tag.critique {
  color: #f59e0b;
}

.aim-coaching-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.aim-advice-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-block-start: var(--space-3);
  border-inline-start: 3px solid var(--brand-primary);
}

.aim-advice-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.aim-advice-text {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.55;
  margin: 0;
}

.aim-fallback-card {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-main);
}

/* ==========================================================================
   Live Telemetry Dashboard & Quick Controls (Directly under 3D Viewport)
   ========================================================================== */

.aim-telemetry-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.aim-telemetry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  padding-block-end: var(--space-3);
}

.aim-telemetry-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.aim-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: var(--radius-pill);
}

.aim-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

/* 6-Card Live Telemetry Grid */
.aim-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-3);
}

.aim-live-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.aim-live-card:hover {
  border-color: var(--border-medium);
}

.aim-live-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.aim-live-num {
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.aim-live-card.hits .aim-live-num {
  color: #10b981;
}

.aim-live-card.misses .aim-live-num {
  color: #ef4444;
}

.aim-live-card.acc .aim-live-num {
  color: var(--brand-primary);
}

.aim-live-card.speed .aim-live-num {
  color: #8b5cf6;
}

.aim-live-card.streak .aim-live-num {
  color: #f97316;
}

.aim-live-card.headshot .aim-live-num {
  color: #eab308;
}

.aim-live-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-block-start: auto;
}

/* Accuracy Mini Bar */
.aim-acc-bar {
  width: 100%;
  height: 5px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-block-start: 4px;
}

.aim-acc-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
  transition: width 0.25s ease, background-color 0.25s ease;
}

/* Recent Shot Quality Feed */
.aim-shot-feed-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.aim-shot-feed-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.aim-shot-pills-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.aim-shot-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: aim-pill-enter 0.18s ease;
}

@keyframes aim-pill-enter {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.aim-shot-pill.hit {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
}

.aim-shot-pill.bullseye {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.45);
  color: #eab308;
}

.aim-shot-pill.miss {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.aim-shot-feed-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Quick Direct Target & Motion Controls */
.aim-quick-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-3);
  padding-block-start: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.aim-quick-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.aim-quick-label {
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aim-toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  user-select: none;
}

.aim-toggle-chip:hover {
  border-color: var(--brand-primary);
}

/* Responsive Rules */
@media (max-width: 1024px) {
  .aim-telemetry-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .aim-viewport {
    height: 480px;
  }
  .aim-hud-overlay {
    top: 8px;
    gap: 6px;
    width: 98%;
  }
  .aim-hud-stat {
    min-width: 0;
    flex: 1;
    padding: 6px 6px;
  }
  .aim-hud-label {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
  }
  .aim-hud-val {
    font-size: 1.35rem;
  }
  .aim-ammo-pips-strip {
    display: none;
  }
  .aim-hero-title {
    font-size: 1.6rem;
  }
  .aim-hero-play-btn {
    padding: 12px 24px;
    font-size: 1.05rem;
  }
  .aim-telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .aim-coaching-row {
    grid-template-columns: 1fr;
  }
  .aim-toolbar-group {
    width: 100%;
  }
  .aim-select-wrap {
    flex: 1;
    min-width: 130px;
  }
  .aim-dialog {
    width: 95vw;
    max-height: 92vh;
  }
}


