    * {
      box-sizing: border-box;
    }
    body {
      margin: 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
      background: radial-gradient(circle at top, var(--pb-bg-1) 0, var(--pb-bg-2) 45%, var(--pb-bg-3) 100%);
      color: var(--pb-text);
      height: 100vh;
      display: flex;
    }
    .app-root {
      display: flex;
      width: 100%;
      height: 100%;
    }
    .left-panel {
      flex: 0 0 58%;
      border-right: 1px solid rgba(148, 163, 184, 0.4);
      padding: 1.5rem 1.75rem;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    .right-panel {
      flex: 0 0 42%;
      padding: 1.5rem 1.75rem;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    h1, h2, h3 {
      margin: 0;
      font-weight: 650;
      letter-spacing: 0.03em;
    }
    h1 {
      font-size: 1.6rem;
    }
    h2 {
      font-size: 1.05rem;
      text-transform: uppercase;
    }
    .subtitle {
      margin-top: 0.35rem;
      font-size: 0.8rem;
      color: var(--pb-muted);
    }
    .panel-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 1rem;
      margin-bottom: 1rem;
          position: relative;
      z-index: 5;
    }
    .panel-header-right {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: flex-start;
      gap: 0.5rem;
      row-gap: 0.5rem;
    }
    
/* --- Header wrap + no-underlap fix (desktop + narrow desktop) ---------
   Prevents long control rows (tab group / toggles / action buttons)
   from spilling underneath the right panel when the window is narrower. */
.left-panel, .right-panel{ min-width: 0; } /* allow flex children to shrink instead of overflowing */
.panel-header{ flex-wrap: wrap; }
.panel-header > *{ min-width: 0; } /* allow title block to shrink instead of forcing overlap */
.panel-header > div:first-child{
  min-width: 260px;
  flex: 1 1 360px;
}
.panel-header-right{
  flex: 1 1 360px;
  max-width: 100%;
}
@media (max-width: 1400px){
  .panel-header-right{ justify-content: flex-start; }
}

.mode-toggle {
      display: inline-flex;
      padding: 0.15rem;
      border-radius: 999px;
      background: rgba(15, 23, 42, 0.9);
      border: 1px solid rgba(148, 163, 184, 0.6);
      font-size: 0.7rem;
    }
    .mode-toggle button {
      border: none;
      background: transparent;
      color: #cbd5f5;
      padding: 0.15rem 0.5rem;
      border-radius: 999px;
      cursor: pointer;
    }
    .mode-toggle button.active {
      background: linear-gradient(135deg, var(--neonA), var(--neonB));
      color: #0b1120;
    }
    
    .feature-row{
      display:flex;
      flex-wrap:wrap;
      gap:0.5rem;
      margin-top:0.35rem;
      margin-bottom:0.15rem;
    }
    .feature-toggle{
      display:inline-flex;
      align-items:center;
      gap:0.35rem;
      font-size:0.75rem;
      color:#cbd5f5;
      padding:0.15rem 0.6rem;
      border-radius:999px;
      border:1px solid rgba(148, 163, 184, 0.6);
      background: rgba(15, 23, 42, 0.9);
      cursor:pointer;
      user-select:none;
      white-space:nowrap;
    }
    .feature-toggle input{ accent-color: var(--neonA); }

.animal-toggle, .folklore-toggle, .rites-toggle, .food-toggle {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      font-size: 0.75rem;
      color: #cbd5f5;
      padding: 0.15rem 0.6rem;
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.6);
      background: rgba(15, 23, 42, 0.9);
      cursor: pointer;
      user-select: none;
    }
    .animal-toggle input,
    .folklore-toggle input,
    .rites-toggle input,
    .food-toggle input {
      accent-color: var(--neonA);
    }
    .btn {
  border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.9);
      padding: 0.35rem 0.9rem;
      font-size: 0.8rem;
      background: radial-gradient(circle at top left, rgba(96, 165, 250, 0.35), rgba(15, 23, 42, 0.95));
      color: #e5e7eb;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      white-space: nowrap;
    }
    .btn:hover {
      border-color: var(--neonA);
      box-shadow: 0 0 0 1px rgba(255, 154, 61, 0.28);
    }
    .search-row {
      margin-top: 0.75rem;
    }
    .search-input {
      width: 100%;
      padding: 0.45rem 0.75rem;
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.6);
      background: rgba(15, 23, 42, 0.85);
      color: #e5e7eb;
      font-size: 0.8rem;
    }
    .search-input::placeholder {
      color: #6b7280;
    }
    .tag-scroll {
      flex: 1 1 auto;
      overflow-y: auto;
      padding-right: 0.75rem;
      margin-top: 0.5rem;
    }
    .category-section {
      margin-bottom: 1.1rem;
      padding-bottom: 0.7rem;
      border-bottom: 1px dashed rgba(55, 65, 81, 0.7);
    }
    .category-section.collapsed .tags-row,
    .category-section.collapsed .custom-tag-box {
      display: none;
    }
    .category-section.collapsed .category-header {
      margin-bottom: 0;
    }
    .category-header {
      display: block;
      margin-bottom: 0.45rem;
    }
    .category-title-row {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 0.45rem;
      flex: 1 1 auto;
      min-width: 0;
    }
    .category-title-left {
      display: flex;
      align-items: baseline;
      gap: 0.5rem;
      min-width: 0;
      flex: 1 1 auto;
    }
    .category-hint {
      flex: 1 1 auto;
      min-width: 0;
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: #6b7280;
    }
    .category-controls {
      display: flex;
      gap: 0.35rem;
      flex-wrap: wrap;
      width: 100%;
    }
    .mini-btn {
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.6);
      padding: 0.25rem 0.75rem;
      font-size: 0.78rem;
      background: rgba(15, 23, 42, 0.9);
      color: #d1d5db;
      cursor: pointer;
      white-space: nowrap;
      transition: transform .06s ease, border-color .12s ease, background .12s ease, color .12s ease;
    }
    .mini-btn.toggle-on {
      background: linear-gradient(135deg, var(--neonA), var(--neonB));
      color: #0b1120;
      border-color: var(--neonA);
    }

    .mini-btn:hover {
      border-color: var(--neonA);
      border-color: var(--neonA);
    }
    .tags-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
      margin-top: 0.3rem;
    }


.pack-separator {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.35rem 0 0.15rem;
  opacity: 0.82;
  user-select: none;
  pointer-events: none;
}
.pack-separator::before,
.pack-separator::after {
  content: "";
  height: 1px;
  flex: 1 1 auto;
  background: linear-gradient(90deg, rgba(148,163,184,0.04), rgba(148,163,184,0.30), rgba(148,163,184,0.04));
}
.pack-separator span {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(203, 213, 245, 0.80);
  padding: 0.16rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.22);
  background: rgba(15, 23, 42, 0.40);
  backdrop-filter: blur(6px);
}

    
    .tags-title{
      margin: 0.35rem 0.35rem 0.25rem 0.35rem;
      font-size: 0.72rem;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      opacity: 0.70;
    }
.tag {
      display: inline-flex;
      align-items: flex-start;
      max-width: 100%;
      padding: 0.36rem 0.75rem;
      border-radius: 999px;
      border: 1px solid rgba(75, 85, 99, 0.9);
      background: rgba(15, 23, 42, 0.9);
      font-size: 0.82rem;
      cursor: pointer;
      gap: 0.35rem;
    }
    .tag.selected {
      border-color: var(--neonA);
      background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.3), rgba(15, 23, 42, 0.95));
      box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
    }
    .tag .label {
      flex: 1 1 auto;
      min-width: 0;
      white-space: normal;
      overflow: visible;
      text-overflow: clip;
      word-break: break-word;
      line-height: 1.15;
    }
    .tag .x {
      margin-left: 0;
      font-size: 0.7rem;
      opacity: 0.7;
      white-space: nowrap;
      align-self: flex-start;
    }
    .tag.random-gen {
      border-style: dashed;
      border-color: rgba(96, 165, 250, 0.8);
      background: rgba(15, 23, 42, 0.85);
    }

    .right-panel h2 {
      margin-bottom: 0.2rem;
    }
    .field-group {
      margin-bottom: 0.55rem;
      font-size: 0.8rem;
    }
    .field-label {
      font-size: 0.78rem;
      color: var(--pb-muted);
      margin-bottom: 0.1rem;
    }
    select, textarea, input[type="text"] {
      width: 100%;
      font-size: 0.8rem;
      background: rgba(15, 23, 42, 0.9);
      color: #e5e7eb;
      border-radius: 0.5rem;
      border: 1px solid rgba(148, 163, 184, 0.7);
      padding: 0.35rem 0.5rem;
    }
    select {
      height: 1.9rem;
    }
    textarea {
      resize: vertical;
      min-height: 5rem;
    }
    .chars-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      margin-top: 0.4rem;
      margin-bottom: 0.25rem;
    }
    .char-list {
      border-radius: 0.5rem;
      border: 1px solid rgba(55, 65, 81, 0.8);
      background: rgba(15, 23, 42, 0.9);
      padding: 0.35rem 0.4rem;
      max-height: 7.5rem;
      overflow-y: auto;
      font-size: 0.78rem;
    }
    .char-row {
      display: grid;
      grid-template-columns: minmax(0, 1.2fr) minmax(0, 2.2fr) auto;
      gap: 0.25rem;
      align-items: flex-start;
      margin-bottom: 0.3rem;
    }
    
    .char-name-wrap {
      display: flex;
      flex-direction: column;
      gap: 0.22rem;
      min-width: 0;
    }
    .char-name-wrap input {
      width: 100%;
    }
    .char-remove-btn {
      width: 100%;
      border-radius: 0.75rem;
      border: 1px solid rgba(148, 163, 184, 0.55);
      padding: 0.20rem 0.65rem;
      font-size: 0.78rem;
      background: rgba(15, 23, 42, 0.78);
      color: #e5e7eb;
      cursor: pointer;
      white-space: nowrap;
      text-align: center;
    }
    .char-remove-btn:hover {
      background: rgba(15, 23, 42, 0.90);
    }

.char-desc-wrap {
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
      min-width: 0;
    }
    .char-controls {
      display: inline-flex;
      align-items: center;
      justify-content: flex-end;
      gap: 0.25rem;
      margin-top: 0.05rem;
    }
    .char-autogen-toggle {
      display: inline-flex;
      align-items: center;
      gap: 0.3rem;
      font-size: 0.70rem;
      color: #cbd5f5;
      padding: 0.10rem 0.55rem;
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.55);
      background: rgba(255, 255, 255, 1);
      cursor: pointer;
      user-select: none;
      width: fit-content;
      white-space: nowrap;
      line-height: 1;
      height: 1.35rem;
    }
    .char-autogen-toggle input {
      accent-color: var(--neonA);
    }

    .char-autogen-toggle span {
      white-space: nowrap;
    }


    .dialogue-notes-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 0.5rem;
      margin-top: 0.25rem;
    }
    .dialogue-notes-grid.multiple {
      grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    }
    .dialogue-col-label {
      font-size: 0.72rem;
      color: var(--pb-muted);
      margin-bottom: 0.15rem;
    }
    .dialogue-notes-grid textarea {
      width: 100%;
      min-height: 4.5rem;
      resize: vertical;
      border-radius: 0.5rem;
      border: 1px solid rgba(55, 65, 81, 0.8);
      background: rgba(15, 23, 42, 0.95);
      color: #e5e7eb;
      font-size: 0.78rem;
      padding: 0.4rem 0.5rem;
    }

    .char-row input {
      width: 100%;
      font-size: 0.75rem;
      padding: 0.25rem 0.35rem;
      border-radius: 0.4rem;
      border: 1px solid rgba(55, 65, 81, 0.8);
      background: rgba(15, 23, 42, 0.95);
      color: #e5e7eb;
    }
    .char-row select {
      width: auto;
      height: 1.7rem;
      font-size: 0.7rem;
      padding: 0.1rem 0.3rem;
    }
    .char-row button {
      border-radius: 999px;
      border: 1px solid rgba(148, 163, 184, 0.7);
      background: transparent;
      color: var(--pb-muted);
      cursor: pointer;
      font-size: 0.75rem;
      padding: 0.1rem 0.4rem;
    }
    .outputs {
      margin-top: 0.75rem;
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      overflow: hidden;
    }
    .output-block {
      flex: 1 1 0;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }
    .output-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 0.78rem;
      color: var(--pb-muted);
    }
    .output-header span {
      text-transform: uppercase;
      letter-spacing: 0.12em;
    }
    .output-textarea {
      flex: 1 1 auto;
      width: 100%;
      resize: none;
      min-height: 4.2rem;
    }
    .footer-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 0.4rem;
      font-size: 0.7rem;
      color: #6b7280;
    }
    .muted {
      color: #6b7280;
      font-size: 0.72rem;
    }
  
/* --- FUTUREMODE THEME OVERRIDES (non-destructive) --------------------- */
:root{
  --bg0:#0b2f1a;
  --bg1:#072314;
  --panel: rgba(8, 30, 18, 0.62);
  --panel2: rgba(10, 38, 22, 0.55);
  --stroke: rgba(255,255,255,0.20);
  --stroke2: rgba(255,154,61,0.45);
  --text: #ffffff;
  --muted: rgba(255,255,255,0.70);
  --neonA:#ff9a3d;
  --neonB:#ffd1a3;
  --neonC:#86efac;
  --shadow: 0 18px 60px rgba(0,0,0,0.55);
  --glow: 0 0 0 1px rgba(255,154,61,0.18), 0 0 22px rgba(255,209,163,0.14);
}

body{
  background:
    radial-gradient(1200px 800px at 15% 10%, rgba(255,255,255,0.22), transparent 55%),
    radial-gradient(1000px 700px at 85% 20%, rgba(255,154,61,0.14), transparent 60%),
    radial-gradient(900px 700px at 55% 90%, rgba(255,209,163,0.10), transparent 65%),
    radial-gradient(circle at top, rgba(255,255,255,0.78) 0, #0b2f1a 46%, #03170b 100%);
  color: var(--text);
  overflow: hidden;
}

/* Ambient HUD layer */
.fx-bg{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.fx-bg::before{
  content:"";
  position:absolute;
  inset:-2px;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.02), rgba(0,0,0,0.04)),
    repeating-linear-gradient(to right, rgba(200,16,46,0.08) 0 1px, transparent 1px 58px),
    repeating-linear-gradient(to bottom, rgba(200,16,46,0.07) 0 1px, transparent 1px 58px);
  opacity: 0.34;
  mask-image: radial-gradient(circle at 55% 45%, rgba(0,0,0,1), rgba(0,0,0,0.15) 55%, rgba(0,0,0,0) 75%);
  animation: gridDrift 18s linear infinite;
}
.fx-bg::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.028) 0 1px, transparent 1px 4px);
  opacity: 0.12;
  mix-blend-mode: overlay;
  animation: scan 6.5s linear infinite;
}
@keyframes gridDrift{
  from{ transform: translate3d(0,0,0); }
  to{ transform: translate3d(-120px,-60px,0); }
}
@keyframes scan{
  0%{ transform: translateY(-12px); }
  100%{ transform: translateY(12px); }
}

/* Put the app above FX */

/* Language banner (mobile) */
.lang-banner{
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(10px);
  background: rgba(2, 6, 23, 0.75);
}

.app-root{ position: relative; z-index: 1; }

/* Glass panels */
.left-panel, .right-panel{
  background: linear-gradient(180deg, var(--panel), rgba(2,6,23,0.35));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}
.left-panel{
  border-right: 1px solid rgba(148,163,184,0.22);
}
.right-panel{
  border-left: 1px solid rgba(148,163,184,0.16);
}

/* Softer typography + holo suffix */
h1{
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.holo-suffix{
  font-weight: 700;
  font-size: 0.78em;
  margin-left: 0.35rem;
  color: rgba(226,232,240,0.75);
  text-shadow: 0 0 12px rgba(22,155,98,0.22);
}
.subtitle{
  color: var(--muted);
}

/* Inputs: neon focus rings */
.search-input, select, textarea, input[type="text"]{
  border-color: rgba(148,163,184,0.38);
  background: linear-gradient(180deg, rgba(9,15,32,0.72), rgba(6,10,24,0.92));
}
.search-input:focus, select:focus, textarea:focus, input[type="text"]:focus{
  outline: none;
  border-color: rgba(22,155,98,0.75);
  box-shadow: 0 0 0 3px rgba(22,155,98,0.16), 0 0 18px rgba(99,102,241,0.14);
}

/* Buttons: holographic sheen */
.btn, .mini-btn, .mode-toggle, .animal-toggle{
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.btn{
  position: relative;
  overflow: hidden;
  border-color: rgba(148,163,184,0.45);
  background:
    radial-gradient(circle at 20% 20%, rgba(22,155,98,0.22), transparent 45%),
    radial-gradient(circle at 80% 30%, rgba(99,102,241,0.22), transparent 55%),
    rgba(15, 23, 42, 0.82);
  box-shadow: var(--glow);
}
.btn::after{
  content:"";
  position:absolute;
  inset:-2px;
  background: linear-gradient(120deg, transparent 0 35%, rgba(255,255,255,0.12) 45%, transparent 55% 100%);
  transform: translateX(-60%);
  opacity: 0;
  transition: opacity .18s ease;
}
.btn:hover{
  border-color: rgba(22,155,98,0.75);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(22,155,98,0.28), 0 0 28px rgba(22,155,98,0.16), 0 0 34px rgba(99,102,241,0.14);
}
.btn:hover::after{
  opacity: 1;
  animation: sheen 1.05s ease both;
}
@keyframes sheen{
  from{ transform: translateX(-60%); }
  to{ transform: translateX(60%); }
}

.mode-toggle{
  background: rgba(6, 10, 24, 0.62);
  border-color: rgba(148,163,184,0.45);
}
.mode-toggle button{
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mode-toggle button.active{
  box-shadow: 0 0 0 1px rgba(56,189,248,0.25), 0 0 18px rgba(99,102,241,0.18);
}

.mini-btn{
  background: rgba(6,10,24,0.72);
  border-color: rgba(148,163,184,0.38);
}
.mini-btn:hover{
  transform: translateY(-1px);
  border-color: rgba(22,155,98,0.75);
  box-shadow: 0 0 0 1px rgba(22,155,98,0.16);
}
.mini-btn.toggle-on{
  box-shadow: 0 0 0 1px rgba(56,189,248,0.24), 0 0 18px rgba(99,102,241,0.16);
}

/* Sections: subtle circuitry */
.category-section{
  position: relative;
  padding: 0.9rem 0.85rem 0.75rem;
  border: 1px solid rgba(148,163,184,0.16);
  border-radius: 14px;
  background:
    radial-gradient(420px 220px at 18% 0%, rgba(56,189,248,0.10), transparent 60%),
    radial-gradient(420px 220px at 88% 0%, rgba(99,102,241,0.10), transparent 60%),
    rgba(2,6,23,0.28);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.28);
}
.category-section::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: 14px;
  background:
    linear-gradient(90deg, transparent 0 40%, rgba(56,189,248,0.08) 50%, transparent 60% 100%);
  opacity: 0;
  pointer-events:none;
}
.category-section:hover::after{
  opacity: 1;
  animation: sectionSweep 1.15s ease both;
}
@keyframes sectionSweep{
  from{ transform: translateX(-18%); }
  to{ transform: translateX(18%); }
}

.category-hint{
  color: rgba(226,232,240,0.52);
}

/* Tags: neon chips */
.tag{
  border-color: rgba(148,163,184,0.30);
  background:
    radial-gradient(circle at 20% 20%, rgba(56,189,248,0.10), transparent 45%),
    rgba(6,10,24,0.72);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tag:hover{
  transform: translateY(-1px);
  border-color: rgba(56,189,248,0.65);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.18);
}
.tag.selected{
  border-color: rgba(56,189,248,0.92);
  background:
    radial-gradient(circle at 20% 20%, rgba(56,189,248,0.18), rgba(15, 23, 42, 0.75) 55%),
    linear-gradient(135deg, rgba(56,189,248,0.10), rgba(99,102,241,0.10));
  box-shadow: 0 0 0 1px rgba(56,189,248,0.30), 0 0 22px rgba(99,102,241,0.16);
}

/* Scrollbars */
.tag-scroll::-webkit-scrollbar, .char-list::-webkit-scrollbar, textarea::-webkit-scrollbar{
  width: 10px;
}
.tag-scroll::-webkit-scrollbar-track, .char-list::-webkit-scrollbar-track, textarea::-webkit-scrollbar-track{
  background: rgba(2,6,23,0.45);
  border-radius: 999px;
}
.tag-scroll::-webkit-scrollbar-thumb, .char-list::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg, rgba(56,189,248,0.50), rgba(99,102,241,0.45));
  border-radius: 999px;
  border: 2px solid rgba(2,6,23,0.55);
}

/* Small detail polish */
.output-header span{
  color: rgba(226,232,240,0.70);
}
.footer-row{
  color: rgba(226,232,240,0.46);
}

  





/* --- Layout tweak: keep synthesize button clear & prominent --- */
.panel-header-right{
  flex-wrap: wrap;
  justify-content: flex-end;
}


#collapse-all-btn{
  flex: 1 1 100%;
  display: inline-flex;
  justify-content: center;
  text-align: center;
  margin-top: 0.25rem;
}
#random-all-btn{
  flex: 1 1 100%;
  justify-content: center;
  text-align: center;
  margin-top: 0.4rem;
}

/* Trio actions row (Copy / Clear / Slop) */
.tri-action-row{
  flex: 1 1 100%;
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  width: 100%;
}
.tri-action-row .tri-btn{
  flex: 1 1 0;
  display: inline-flex;
  justify-content: center;
  text-align: center;
}



/* =========================
   Responsive (mobile-first)
   ========================= */

:root{
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* Keep layout from over-stretching on ultra-wide monitors */
.app-root{
  max-width: 1600px;
  margin: 0 auto;
}

/* Make interactive targets friendlier */
button, .tag-pill, .tag-btn, .chip, select, input, textarea{
  touch-action: manipulation;
}

@media (max-width: 900px){
  .lang-banner{
    display: flex;
    position: sticky;
    top: 0;
    z-index: 60;
  }

  /* Allow page to scroll naturally on mobile browsers */
  body{
    height: auto;
    min-height: 100vh;
    display: block;
    /* Desktop theme uses `overflow: hidden` to keep split-pane scroll contained.
       On mobile we switch to normal document scrolling. */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .app-root{
    height: auto;
    min-height: 100vh;
    flex-direction: column;
    max-width: none;
    margin: 0;
  }
/* Stack panels full width */
  .left-panel, .right-panel{
    width: 100%;
    flex: none;
    padding: 1.0rem 0.95rem calc(1.2rem + var(--safe-bottom));
    overflow: visible;
    border-right: none;
  }
  .left-panel{
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  }
/* Header goes vertical; make room for small screens */
  .panel-header{
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .panel-header-right{
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  h1{
    font-size: 1.25rem;
    line-height: 1.25;
  }
  h2{
    font-size: 1.05rem;
  }
  .subtitle{
    font-size: 0.95rem;
  }

  /* Improve form sizing for thumbs */
  textarea, input[type="text"], select{
    font-size: 1rem;
    padding: 0.6rem 0.7rem;
    border-radius: 0.65rem;
  }
  select{ height: 2.35rem; }

  /* Avoid nested scroll traps */
  .tag-scroll{
    overflow: visible;
    padding-right: 0;
  }

  /* Buttons and pills: bigger hit areas */
  .mode-toggle{
    font-size: 0.85rem;
  }
  .mode-toggle button{
    padding: 0.45rem 0.7rem;
  }
  .tag-pill{
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
  }
  /* --- Mobile panel switcher: Tags / Output -------------------------------- */
  .lang-banner{
    justify-content: stretch;
  }
  .lang-banner-inner{
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .lang-label{
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.75rem;
    opacity: 0.95;
  }
  .mobile-tabs{
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }
  .mobile-tab{
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 42, 0.85);
    color: #d1d5db;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .06s ease, border-color .12s ease, background .12s ease, color .12s ease;
  }
  .mobile-tab:active{ transform: translateY(1px); }
  .mobile-tab:hover{ border-color: var(--neonA); }
  .mobile-tab.active{
    background: linear-gradient(135deg, var(--neonA), var(--neonB));
    color: #0b1120;
    border-color: var(--neonA);
  }

  /* Default to TAGS on mobile; switch to OUTPUT via .mobile-show-output */
  .app-root:not(.mobile-show-output) .right-panel{ display: none; }
  .app-root.mobile-show-output .left-panel{ display: none; }

}

/* Tablet: keep both panels visible but soften the split */
@media (min-width: 901px) and (max-width: 1200px){
  body{
    height: 100dvh;
  }
  .app-root{
    max-width: none;
  }
  .left-panel{ flex: 0 0 56%; }
  .right-panel{ flex: 0 0 44%; }
  h1{ font-size: 1.35rem; }
  textarea, input[type="text"], select{ font-size: 0.9rem; }
}

/* Small landscape phones / short viewports */
@media (max-height: 700px) and (max-width: 900px){
  .subtitle{ display: none; }
}


/* Module-injected categories (unified build prep) */
@keyframes pb3kFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.module-category {
  animation: pb3kFadeIn .22s ease-out both;
}


/* --- Module tab grouping (global tab subcategories) ------------------- */
#pb3k-tabgroup-toggle{
  margin-left: .25rem;
  flex: 1 1 100%;
  width: 100%;
  /* Wrap to multiple lines instead of forcing horizontal scrolling */
  overflow: visible;
}

/* Override base .mode-toggle so tabgroup can wrap and never hide buttons */
#pb3k-tabgroup-toggle.mode-toggle{
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  max-width: 100%;
  justify-content: flex-start;
  align-items: center;
  padding: .25rem;
}

#pb3k-tabgroup-toggle button{
  flex: 0 0 auto;
  white-space: nowrap;
}

.mini-btn .tab-title{
  display:inline-block;
}

.mini-btn .tab-group-badge{
  display:inline-block;
  margin-left: .4rem;
  padding: .05rem .35rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  font-size: .65em;
  opacity: .85;
  line-height: 1.1;
}


/* --- Category clusters (UI-only grouping) ---------------------------- */
.cluster-section .cluster-subcategory{
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.cluster-section .cluster-subcategory:first-of-type{
  margin-top: .4rem;
  padding-top: .4rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.cluster-subheader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:.6rem;
  margin-bottom:.35rem;
}
.cluster-subtitle{
  font-weight: 900;
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .92;
}
.cluster-subcontrols{
  display:flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: flex-end;
}


/* --- Step2: packs modal --- */
.pb3k-modal-backdrop{
  position:fixed; inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.55);
  z-index:9999;
  padding:16px;
}
.pb3k-modal-backdrop.show{ display:flex; }
.pb3k-modal{
  width:min(640px, 96vw);
  max-height:82vh;
  overflow:hidden;
  border-radius:16px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(18,18,18,0.92);
  box-shadow:0 20px 60px rgba(0,0,0,0.5);
  color:rgba(255,255,255,0.92);
}
.pb3k-modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.pb3k-modal-title{
  font-weight:800;
  letter-spacing:0.06em;
  text-transform:uppercase;
  font-size:13px;
}
.pb3k-modal-x{
  background:transparent;
  color:rgba(255,255,255,0.85);
  border:1px solid rgba(255,255,255,0.12);
  border-radius:10px;
  padding:6px 10px;
  cursor:pointer;
}
.pb3k-modal-body{
  padding:14px 16px;
  overflow:auto;
  max-height:60vh;
}
.pb3k-pack-row{
  display:flex;
  align-items:flex-start;
  gap:12px;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.07);
  background:rgba(255,255,255,0.03);
  margin-bottom:10px;
}
.pb3k-pack-name{ font-weight:700; }
.pb3k-pack-meta{ opacity:0.78; font-size:12px; margin-top:4px; line-height:1.3; }

.pb3k-toggle{
  position:relative;
  display:inline-block;
  width:46px;
  height:26px;
  flex:0 0 auto;
  margin-top:2px;
}
.pb3k-toggle input{
  opacity:0;
  width:0;
  height:0;
}
.pb3k-toggle-slider{
  position:absolute;
  inset:0;
  cursor:pointer;
  background:rgba(255,255,255,0.08);
  border:1px solid rgba(255,255,255,0.10);
  border-radius:999px;
  transition:all .18s ease;
}
.pb3k-toggle-slider:before{
  content:"";
  position:absolute;
  height:20px;
  width:20px;
  left:3px;
  top:50%;
  transform:translateY(-50%);
  background:rgba(255,248,240,0.70);
  border-radius:999px;
  transition:all .18s ease;
  box-shadow:0 2px 8px rgba(0,0,0,0.35);
}
.pb3k-toggle input:checked + .pb3k-toggle-slider{
  background:rgba(155,13,31,0.25);
  border-color:rgba(155,13,31,0.35);
}
.pb3k-toggle input:checked + .pb3k-toggle-slider:before{
  left: calc(100% - 23px);
  background:rgba(255,248,240,0.92);
}
.pb3k-toggle input:focus + .pb3k-toggle-slider{
  outline:2px solid rgba(155,13,31,0.35);
  outline-offset:2px;
}
.pb3k-modal-footer{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:12px 16px;
  border-top:1px solid rgba(255,255,255,0.08);
}

