:root {
  --yb-green-900: #1b5b43;
  --yb-green-800: #217152;
  --yb-green-600: #2f8a64;
  --yb-cm-green: #007a5e;
  --yb-cm-red: #ce1126;
  --yb-cm-yellow: #fcd116;
  --yb-surface: rgba(255, 255, 255, 0.98);
  --yb-surface-muted: rgba(255, 255, 255, 0.92);
  --yb-border: #d7e0d8;
  --yb-border-strong: rgba(15, 44, 32, 0.22);
  --yb-shadow: 0 30px 70px rgba(2, 6, 23, 0.25);
  --yb-radius: 22px;
  --yb-text: #0b1b22;
  --yb-muted: #5b6b7a;
  --yb-navy-900: #244e82;
  --yb-grid-line: rgba(15, 23, 42, 0.03);
  --yb-font-body: "Public Sans", "Source Sans 3", "Noto Sans", "Liberation Sans", sans-serif;
  --yb-font-display: "Source Serif 4", "Libre Baskerville", "Noto Serif", "Georgia", serif;
}

#styleModal .modal-dialog.modal-fullscreen {
  padding: clamp(8px, 1.4vw, 16px);
}

.yb-style-modal {
  border: none;
  border-radius: var(--yb-radius);
  overflow: hidden;
  min-height: calc(100vh - clamp(16px, 2.8vw, 32px));
  background: var(--yb-surface);
  box-shadow: var(--yb-shadow);
  font-family: var(--yb-font-body);
  color: var(--yb-text);
  backdrop-filter: saturate(1.05);
}

.yb-style-modal__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.8rem;
  position: relative;
  border: none;
  padding: 0.9rem 1.15rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 45%),
    linear-gradient(135deg, var(--yb-green-900) 0%, var(--yb-green-800) 52%, var(--yb-green-600) 100%);
  color: rgba(255, 255, 255, 0.95);
}

.yb-style-modal__header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--yb-cm-green) 0%,
    var(--yb-cm-green) 33%,
    var(--yb-cm-red) 33%,
    var(--yb-cm-red) 66%,
    var(--yb-cm-yellow) 66%,
    var(--yb-cm-yellow) 100%
  );
  opacity: 0.8;
}

.yb-style-modal__icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 18px 30px rgba(2, 6, 23, 0.22);
  flex: 0 0 auto;
}

.yb-style-modal__icon i {
  font-size: 1.25rem;
}

.yb-style-modal__heading {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.yb-style-modal__title-wrap {
  min-width: 0;
}

.yb-style-modal__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding-right: 0.25rem;
}

.yb-style-header-btn {
  border-radius: 999px;
  font-weight: 750;
  padding: 0.4rem 0.85rem;
}

.yb-style-header-btn.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.92);
}

.yb-style-header-btn.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
}

.yb-style-modal__title {
  font-family: var(--yb-font-display);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  font-size: clamp(1rem, 0.8rem + 0.7vw, 1.35rem);
}

.yb-style-modal__subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.2rem;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.82);
}

.yb-style-modal__subtitle code {
  color: #e7fff2;
  background: rgba(6, 22, 16, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.05rem 0.35rem;
}

.yb-style-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.yb-style-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.82rem;
  font-weight: 700;
}

.yb-style-modal__close {
  margin-left: 0.15rem;
  opacity: 0.92;
}

.yb-style-modal__close:hover {
  opacity: 1;
}

.yb-style-modal__body {
  padding: 1.1rem 1.45rem 1.5rem;
  background:
    radial-gradient(1000px 600px at 12% 0%, rgba(24, 148, 115, 0.1), transparent 55%),
    radial-gradient(1000px 600px at 88% 0%, rgba(35, 75, 125, 0.08), transparent 60%),
    repeating-linear-gradient(0deg, var(--yb-grid-line) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, var(--yb-grid-line) 0 1px, transparent 1px 32px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 249, 0.96) 100%);
  overflow: auto;
}

.yb-style-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  width: fit-content;
  max-width: 100%;
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 44, 32, 0.14);
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.06);
  gap: 0.5rem;
}

.yb-style-tabs .nav-link {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.55rem 1rem;
  color: rgba(11, 27, 34, 0.78);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 44, 32, 0.18);
  transition: all 0.18s ease-in-out;
}

.yb-style-tabs .nav-link i {
  opacity: 0.9;
}

.yb-style-tabs .nav-link:hover {
  transform: translateY(-1px);
  border-color: rgba(27, 91, 67, 0.28);
}

.yb-style-tabs .nav-link.active {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(27, 91, 67, 0.32);
  color: var(--yb-green-900);
  box-shadow: 0 12px 25px rgba(2, 6, 23, 0.08);
}

#styleModalAlert {
  border-radius: 12px;
  border-width: 1px;
  box-shadow: 0 8px 16px rgba(2, 6, 23, 0.06);
}

.yb-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.yb-style-section {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(11, 27, 34, 0.12);
  border-radius: 18px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 8px 22px rgba(2, 6, 23, 0.06);
}

.yb-style-section--full {
  grid-column: 1 / -1;
  padding: 1.1rem 1.2rem 1.2rem;
}

.yb-style-section__title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--yb-font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(11, 27, 34, 0.9);
  margin-bottom: 0.9rem;
}

.yb-style-section__title i {
  color: var(--yb-green-800);
}

.yb-style-modal .form-label {
  color: rgba(11, 27, 34, 0.84);
  font-weight: 700;
  margin-bottom: 0.38rem;
}

.yb-style-modal .form-select,
.yb-style-modal .form-control:not(.form-control-color) {
  min-height: 42px;
  border-radius: 12px;
  border-color: rgba(11, 27, 34, 0.2);
}

.yb-style-modal .form-select:focus,
.yb-style-modal .form-control:focus {
  border-color: rgba(27, 91, 67, 0.4);
  box-shadow: 0 0 0 0.2rem rgba(47, 138, 100, 0.14);
}

.yb-style-range {
  accent-color: var(--yb-green-700, #15803d);
}

.yb-style-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.7);
}

.yb-style-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.7rem;
  border-radius: 14px;
  border: 1px solid var(--yb-border);
  background: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.65rem;
}

.yb-style-color-row:last-child {
  margin-bottom: 0;
}

.yb-style-color-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.yb-style-color-label {
  font-weight: 700;
  color: rgba(11, 27, 34, 0.82);
}

.yb-style-color-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* One captioned picker (background / text) inside a color row. */
.yb-style-color-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.yb-style-color-caption {
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  color: rgba(11, 27, 34, 0.62);
}

.yb-style-bold-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
}

.yb-style-bold-switch .form-check-label {
  font-size: 0.82rem;
  color: rgba(11, 27, 34, 0.62);
}

/* Live mini-preview of header / total rows / total columns / grand total. */
.yb-style-preview {
  border-radius: 14px;
  border: 1px dashed var(--yb-border);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.9rem;
  overflow-x: auto;
}

.yb-style-preview table {
  min-width: 320px;
  max-width: 560px;
  margin: 0 auto;
}

.yb-style-modal .form-control-color {
  width: 52px;
  min-width: 52px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(11, 27, 34, 0.2);
}

.yb-style-search {
  position: relative;
  min-width: min(320px, 100%);
}

.yb-style-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(15, 23, 42, 0.55);
}

.yb-style-search .form-control {
  padding-left: 2.25rem;
  border-radius: 999px;
  border-color: rgba(15, 44, 32, 0.2);
}

.yb-style-search .form-control:focus {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(34, 197, 94, 0.18);
}

.yb-style-accordion .accordion-item {
  border: 1px solid var(--yb-border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 0.65rem;
  background: rgba(255, 255, 255, 0.96);
}

.yb-style-accordion .accordion-item:last-child {
  margin-bottom: 0;
}

.yb-style-accordion .accordion-button {
  background: rgba(248, 250, 249, 0.96);
  font-weight: 800;
  color: rgba(11, 27, 34, 0.85);
  padding: 0.9rem 1rem;
}

.yb-style-target-badge {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.26rem 0.52rem;
  border: 1px solid transparent;
  color: rgba(11, 27, 34, 0.82);
}

.yb-style-target-badge--token {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(22, 163, 74, 0.35);
}

.yb-style-target-badge--static {
  background: rgba(100, 116, 139, 0.18);
  border-color: rgba(100, 116, 139, 0.3);
}

.yb-style-accordion .accordion-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(34, 197, 94, 0.16);
}

.yb-style-accordion .accordion-body {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.94);
}

.yb-style-accordion--targets {
  max-height: min(52vh, 560px);
  overflow: auto;
  padding-right: 0.25rem;
}

.yb-style-accordion--targets::-webkit-scrollbar {
  width: 8px;
}

.yb-style-accordion--targets::-webkit-scrollbar-thumb {
  background: rgba(11, 27, 34, 0.2);
  border-radius: 999px;
}

.yb-style-hint {
  border: 1px solid var(--yb-border-strong);
  background: rgba(238, 246, 241, 0.78);
  color: rgba(11, 27, 34, 0.82);
  border-radius: 16px;
}

.yb-style-modal__footer {
  border: none;
  padding: 1rem 1.4rem 1.3rem;
  background: rgba(20, 83, 45, 0.04);
  border-top: 1px solid var(--yb-border);
  gap: 0.65rem;
}

.yb-style-footer-btn {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.55rem 1.05rem;
}

.yb-style-apply-btn {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(20, 83, 45, 0.95);
}

.yb-style-apply-btn:hover {
  background: rgba(255, 255, 255, 0.98);
  color: rgba(20, 83, 45, 1);
}

.yb-style-modal__footer .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.92);
}

.yb-style-modal__footer .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
}

@media (max-width: 991.98px) {
  #styleModal .modal-dialog.modal-fullscreen {
    padding: 0;
  }

  .yb-style-modal {
    border-radius: 0;
    min-height: 100vh;
  }

  .yb-style-modal__header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "heading close"
      "actions actions";
  }

  .yb-style-modal__heading {
    grid-area: heading;
  }

  .yb-style-modal__actions {
    grid-area: actions;
    width: 100%;
  }

  .yb-style-modal__close {
    grid-area: close;
    justify-self: end;
  }

  .yb-style-grid {
    grid-template-columns: 1fr;
  }

  .yb-style-section--full {
    grid-column: auto;
  }
}

@media (max-width: 767.98px) {
  .yb-style-modal__header {
    padding: 0.85rem 0.9rem;
    gap: 0.7rem;
  }

  .yb-style-modal__actions {
    gap: 0.4rem;
  }

  .yb-style-header-btn {
    padding: 0.38rem 0.75rem;
  }

  .yb-style-modal__body {
    padding: 0.9rem 0.95rem 1.2rem;
  }

  .yb-style-tabs {
    width: 100%;
    justify-content: space-between;
    border-radius: 14px;
  }

  .yb-style-tabs .nav-link {
    padding: 0.5rem 0.75rem;
  }

  .yb-style-search {
    min-width: 100%;
  }

  .yb-style-accordion--targets {
    max-height: none;
  }
}
