Spaces:
Pradeepccc
/
a
Running on Zero

someine commited on
Commit
cf10489
·
1 Parent(s): 4296095

fix(ui): harmonize gradio design with local studio interface (two-column master cards, clean accordions, segmented mode buttons, single presets row, and remove duplicate gallery)

Browse files
Files changed (1) hide show
  1. app.py +312 -251
app.py CHANGED
@@ -620,22 +620,17 @@ def apply_curated(choice_key: str, current_prompt: str):
620
  # Prompt Presets & Templates Manager
621
  # ============================================================
622
  PROMPT_PRESETS = [
623
- ("Real Anatomy", "photorealistic portrait, natural human anatomy, detailed skin pores, realistic body proportions, soft lighting"),
624
- ("Body Swap", BODY_PROMPT),
625
- ("Face Swap", FACE_PROMPT),
626
- ("Restore / Upscale", RESTORE_PROMPT),
627
- ("Studio Lighting", "Transform the image with balanced neutral exposure, professional studio lighting, high dynamic range"),
628
- ("Phone Photo Realism", "amateur phone camera photo, candid shot, natural lighting, authentic skin texture, imperfect framing, unedited"),
629
- ("Outfit & Fashion", "fashion photoshoot, detailed designer outfit, haute couture fabrics, crisp tailoring, editorial lighting"),
630
- ("Anime Consistency", "masterpiece, highly detailed anime illustration, vibrant colors, expressive eyes, crisp lineart"),
631
- ("Skin Retouch", "Retouch the face: smooth skin blemishes naturally while keeping fine skin pores and texture, brighten eyes"),
632
- ("85mm Portrait", "A photorealistic portrait, natural skin texture, soft daylight, 85mm lens, shallow depth of field"),
633
- ("Restore Old Photo", "Restore the old photo: remove scratches, dust, fading and grain and recover sharp, natural detail and color, keeping the same composition and people."),
634
  ]
635
 
636
  MAX_PRESETS = 100
637
- PRESET_STORAGE_KEY = "qwen_aio_presets_v2"
638
- DEFAULT_PRESETS = [{"label": l, "text": t, "favorite": False} for l, t in PROMPT_PRESETS]
639
 
640
 
641
  def normalize_presets(raw) -> list:
@@ -652,29 +647,25 @@ def normalize_presets(raw) -> list:
652
  if not label or not text or label in seen:
653
  continue
654
  seen.add(label)
655
- out.append({"label": label, "text": text, "favorite": bool(x.get("favorite", False))})
656
  if len(out) >= MAX_PRESETS:
657
  break
658
  return out
659
 
660
 
661
- def _chip(p: dict, handle: bool = True) -> str:
662
  label = _html.escape(p["label"], quote=True)
663
  text = _html.escape(p["text"], quote=True)
664
  tip = _html.escape(p["text"][:200], quote=True)
665
- fav_cls = "pp-fav is-on" if p["favorite"] else "pp-fav"
 
666
  star_svg = (
667
- '<svg class="pp-star-svg filled" width="13" height="13" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
668
- if p["favorite"]
669
- else '<svg class="pp-star-svg outline" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
670
- )
671
- grip = (
672
- '<span class="pp-handle" title="Drag to reorder"><svg class="pp-grip-svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="9" cy="12" r="1.5"/><circle cx="9" cy="5" r="1.5"/><circle cx="9" cy="19" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="15" cy="5" r="1.5"/><circle cx="15" cy="19" r="1.5"/></svg></span>'
673
- if handle
674
- else ""
675
  )
676
  return (
677
- f'<div class="pp-item" data-label="{label}" data-text="{text}">{grip}'
678
  f'<button type="button" class="pp-use" title="{tip}">{label}</button>'
679
  f'<button type="button" class="{fav_cls}" title="Toggle favorite">{star_svg}</button></div>'
680
  )
@@ -682,21 +673,9 @@ def _chip(p: dict, handle: bool = True) -> str:
682
 
683
  def render_presets_html(presets) -> str:
684
  presets = normalize_presets(presets)
685
- favs = [p for p in presets if p["favorite"]]
686
- sec_fav_icon = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
687
- sec_all_icon = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/></svg>'
688
- parts = ['<div class="pp-wrap">', f'<div class="pp-section">{sec_fav_icon}Favorites</div>']
689
- if favs:
690
- parts.append('<div class="pp-list">' + "".join(_chip(p, handle=False) for p in favs) + "</div>")
691
- else:
692
- parts.append('<div class="pp-empty">No favorites yet. Click the star on any template to pin it here.</div>')
693
- parts.append(f'<div class="pp-section">{sec_all_icon}All Templates <span class="pp-hint">(drag handle to reorder, click title to fill prompt)</span></div>')
694
- if presets:
695
- parts.append('<div class="pp-list pp-sortable">' + "".join(_chip(p) for p in presets) + "</div>")
696
- else:
697
- parts.append('<div class="pp-empty">No templates available. Save one below or import from JSON.</div>')
698
- parts.append("</div>")
699
- return "".join(parts)
700
 
701
 
702
  def apply_preset_cmd(cmd: str, presets) -> list:
@@ -989,19 +968,20 @@ def update_mode_ui(mode: str):
989
  # UI Theme & Assets
990
  # ============================================================
991
  THEME = gr.themes.Monochrome(
992
- radius_size="md",
993
  text_size="sm",
994
  font=[gr.themes.GoogleFont("Plus Jakarta Sans"), "system-ui", "-apple-system", "sans-serif"],
995
  font_mono=[gr.themes.GoogleFont("JetBrains Mono"), "ui-monospace", "monospace"],
996
  ).set(
997
- block_radius="8px",
998
- block_border_width="1px",
999
- block_border_color="*neutral_200",
1000
- block_border_color_dark="*neutral_800",
1001
- panel_border_width="1px",
1002
- panel_border_color="*neutral_200",
1003
- panel_border_color_dark="*neutral_800",
1004
- input_border_width="1px",
 
1005
  input_border_color="*neutral_200",
1006
  input_border_color_dark="*neutral_800",
1007
  button_primary_background_fill="*neutral_950",
@@ -1550,11 +1530,20 @@ HEAD_JS = """
1550
  'Custom Repo ID': 'wrench',
1551
 
1552
  // Accordions
 
 
 
1553
  'Prompt History': 'history',
1554
  'Prompt Templates & Presets': 'bookmark',
 
 
 
 
 
 
 
1555
  'Media Library': 'image',
1556
- 'Import / Export / Reset (JSON)': 'sliders',
1557
- 'Private Browser Gallery (Saved in your Browser)': 'hard-drive'
1558
  };
1559
 
1560
  var MODE_ICON_MAP = {
@@ -1667,6 +1656,19 @@ HEAD_JS = """
1667
  """
1668
 
1669
  CONTAINER_HEAD_CSS = """
 
 
 
 
 
 
 
 
 
 
 
 
 
1670
  <style>
1671
  /* Outer Canvas Layout: Center Gradio app on wide displays */
1672
  body, html {
@@ -1975,62 +1977,79 @@ div:has(.shadcn-header),
1975
  #left-controls, #right-preview {
1976
  display: flex !important;
1977
  flex-direction: column !important;
1978
- gap: 16px !important;
1979
- background: transparent !important;
1980
- border: none !important;
1981
- box-shadow: none !important;
1982
- padding: 0 !important;
1983
- box-sizing: border-box !important;
1984
- }
1985
-
1986
- /* SECTION CARDS: Distinct visible border, rounded corners, card background */
1987
- .section-card {
1988
- border: 1px solid var(--border) !important;
1989
- border-radius: var(--radius-lg) !important;
1990
  background-color: var(--card) !important;
1991
- padding: 18px 20px !important;
1992
- margin-bottom: 16px !important;
1993
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04) !important;
 
1994
  box-sizing: border-box !important;
1995
- transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
1996
  }
1997
- .section-card:hover {
1998
  border-color: var(--border-hover) !important;
1999
  }
2000
- .section-card .block {
 
 
 
 
 
2001
  background: transparent !important;
 
 
2002
  box-shadow: none !important;
2003
  padding: 0 !important;
2004
- margin: 4px 0 !important;
2005
  }
2006
 
2007
- /* Studio Section Headers & Dividers */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2008
  .studio-section-header {
2009
- display: flex;
2010
- flex-direction: column;
2011
- gap: 2px;
2012
- margin-bottom: 12px;
 
 
 
 
2013
  }
2014
  .studio-section-title {
2015
- font-size: 0.875rem;
2016
- font-weight: 600;
2017
- letter-spacing: -0.015em;
2018
- color: var(--foreground);
2019
- display: inline-flex;
2020
- align-items: center;
2021
- gap: 8px;
 
2022
  }
2023
  .studio-section-desc {
2024
- font-size: 0.75rem;
2025
- color: var(--muted-foreground);
2026
- }
2027
- .studio-divider {
2028
- border: none !important;
2029
- border-top: 1px solid var(--border) !important;
2030
- margin: 12px 0 !important;
2031
- height: 1px !important;
2032
- width: 100% !important;
2033
  }
 
2034
  .tab-helper {
2035
  font-size: 0.8125rem;
2036
  color: var(--muted-foreground);
@@ -2039,20 +2058,44 @@ div:has(.shadcn-header),
2039
  }
2040
 
2041
  /* Radio Group: Clean Segmented Controls with 8px radius */
2042
- .gr-radio {
 
 
2043
  display: grid !important;
2044
- grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
2045
  gap: 8px !important;
2046
  width: 100% !important;
2047
- margin-top: 6px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2048
  }
2049
- .gr-radio label {
 
 
 
 
 
2050
  border: 1px solid var(--border) !important;
2051
  border-radius: var(--radius) !important;
2052
- padding: 8px 12px !important;
2053
  background-color: var(--background) !important;
2054
  color: var(--foreground) !important;
2055
- font-size: 0.8125rem !important;
2056
  font-weight: 500 !important;
2057
  cursor: pointer !important;
2058
  transition: all 0.15s ease !important;
@@ -2062,19 +2105,47 @@ div:has(.shadcn-header),
2062
  gap: 6px !important;
2063
  text-align: center !important;
2064
  box-sizing: border-box !important;
 
2065
  }
2066
- .gr-radio label:hover {
 
2067
  background-color: var(--secondary) !important;
2068
  border-color: var(--border-hover) !important;
2069
  }
2070
- .gr-radio label.selected {
 
 
 
2071
  background-color: var(--primary) !important;
2072
  color: var(--primary-foreground) !important;
2073
  border-color: var(--primary) !important;
2074
  font-weight: 600 !important;
2075
  }
2076
- .gr-radio input[type="radio"] {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2077
  display: none !important;
 
 
 
 
 
 
 
 
2078
  }
2079
 
2080
  /* Inputs & Form Controls: 8px Radius, standard padding */
@@ -2492,32 +2563,35 @@ div:has(> .studio-field-label),
2492
  }
2493
  }
2494
 
2495
- /* Accordions: Card Accordion with clean 1px border */
2496
  .accordion, [data-testid="accordion"] {
2497
- border: 1px solid var(--border) !important;
2498
- border-radius: var(--radius-lg) !important;
2499
- background-color: var(--card) !important;
2500
- padding: 14px 18px !important;
2501
- margin: 12px 0 !important;
 
2502
  box-sizing: border-box !important;
2503
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04) !important;
2504
- transition: border-color 0.15s ease !important;
2505
- overflow: hidden !important;
2506
  width: 100% !important;
2507
  }
2508
- .accordion:hover, [data-testid="accordion"]:hover {
2509
- border-color: var(--border-hover) !important;
 
 
2510
  }
2511
  .accordion > .label-wrap,
2512
  .label-wrap,
2513
  summary,
2514
  .accordion-header {
2515
- padding: 4px 0 !important;
2516
  cursor: pointer !important;
2517
  background: transparent !important;
2518
  background-color: transparent !important;
2519
- font-size: 0.8125rem !important;
2520
  font-weight: 600 !important;
 
 
2521
  color: var(--foreground) !important;
2522
  display: flex !important;
2523
  align-items: center !important;
@@ -2529,7 +2603,7 @@ summary,
2529
  }
2530
  .accordion > .label-wrap:hover,
2531
  .label-wrap:hover {
2532
- opacity: 0.85 !important;
2533
  background: transparent !important;
2534
  }
2535
  .accordion > .label-wrap *,
@@ -2797,19 +2871,69 @@ button.tab-item.selected {
2797
  .pp-section { font-weight: 600; font-size: 0.8125rem; color: var(--foreground); display: flex; align-items: center; gap: 6px; }
2798
  .pp-hint { font-weight: 400; color: var(--muted-foreground); font-size: 0.75rem; }
2799
  .pp-empty { color: var(--muted-foreground); font-size: 0.8125rem; padding: 4px 0; font-style: italic; }
2800
- .pp-list { display: flex; flex-wrap: wrap; gap: 6px; }
2801
- .pp-item { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--secondary); color: var(--secondary-foreground); overflow: hidden; transition: all 0.15s ease; font-size: 0.75rem; }
2802
- .pp-item:hover { border-color: var(--foreground); background: var(--accent); }
2803
- .pp-handle { cursor: grab; padding: 4px 6px; opacity: 0.5; user-select: none; font-size: 0.75rem; }
2804
- .pp-handle:active { cursor: grabbing; }
2805
- .pp-use { border: none; background: transparent; cursor: pointer; padding: 4px 8px; font-size: 0.75rem; color: inherit; font-weight: 500; font-family: var(--font-sans); }
2806
- .pp-fav { border: none; background: transparent; cursor: pointer; padding: 4px 6px; font-size: 0.75rem; color: inherit; opacity: 0.5; transition: all 0.15s ease; }
2807
- .pp-fav:hover { opacity: 1; transform: scale(1.15); }
2808
- .pp-fav.is-on { color: #f59e0b; opacity: 1; }
2809
- .pp-star-svg { display: block; transition: transform 0.15s ease; }
2810
- .pp-fav:hover .pp-star-svg { transform: scale(1.15); }
2811
- .pp-fav.is-on .pp-star-svg { color: #f59e0b; fill: #f59e0b; }
2812
- .pp-fav:not(.is-on) .pp-star-svg { color: #71717a; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2813
  .pp-ghost { opacity: 0.35; }
2814
 
2815
  /* Private Browser Gallery (IndexedDB) */
@@ -2823,11 +2947,11 @@ button.tab-item.selected {
2823
  display: flex;
2824
  justify-content: space-between;
2825
  align-items: center;
2826
- padding: 8px 12px;
2827
  background: var(--secondary);
2828
  border: 1px solid var(--border);
2829
- border-radius: var(--radius-md);
2830
- font-size: 0.8125rem;
2831
  }
2832
  .idb-count {
2833
  font-weight: 500;
@@ -2835,24 +2959,26 @@ button.tab-item.selected {
2835
  display: flex;
2836
  align-items: center;
2837
  gap: 6px;
 
2838
  }
2839
  .idb-btn-danger, #idb-clear-btn {
2840
- background: #ef4444 !important;
2841
- color: #ffffff !important;
2842
- border: none !important;
2843
- border-radius: var(--radius-sm) !important;
2844
- padding: 6px 12px !important;
2845
  font-size: 0.75rem !important;
2846
- font-weight: 600 !important;
2847
  cursor: pointer !important;
2848
  display: inline-flex !important;
2849
  align-items: center !important;
2850
  gap: 6px !important;
2851
- transition: background-color 0.15s ease !important;
2852
  }
2853
  .idb-btn-danger:hover, #idb-clear-btn:hover {
2854
- background: #dc2626 !important;
2855
  color: #ffffff !important;
 
2856
  }
2857
  .idb-grid {
2858
  display: grid;
@@ -2864,6 +2990,29 @@ button.tab-item.selected {
2864
  }
2865
  .idb-empty {
2866
  grid-column: 1 / -1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2867
  text-align: center;
2868
  padding: 24px 12px;
2869
  color: var(--muted-foreground);
@@ -3124,17 +3273,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3124
  # LEFT COLUMN
3125
  with gr.Column(scale=6, elem_id="left-controls"):
3126
  # Section 1: Generation Mode
3127
- with gr.Group(elem_classes=["section-card"]):
3128
- gr.HTML("""
3129
- <div class="studio-section-header">
3130
- <span class="studio-section-title">
3131
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></svg>
3132
- Generation Mode
3133
- </span>
3134
- <span class="studio-section-desc">Select pipeline mode: Text to Image, Edit, Swap, or PNG</span>
3135
- </div>
3136
- """)
3137
-
3138
  mode_selector = gr.Radio(
3139
  choices=MODES,
3140
  value=MODES[0],
@@ -3143,17 +3282,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3143
  )
3144
 
3145
  # Section 2: Reference Images & Media Library (Hidden on Text to Image & Transparent PNG)
3146
- with gr.Column(visible=False, elem_id="reference-section", elem_classes=["section-card"]) as ref_section:
3147
- gr.HTML("""
3148
- <div class="studio-section-header">
3149
- <span class="studio-section-title">
3150
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>
3151
- Reference Images & Media Inputs
3152
- </span>
3153
- <span class="studio-section-desc">Upload reference inputs or select from the Media Library below</span>
3154
- </div>
3155
- """)
3156
-
3157
  with gr.Row():
3158
  ref_img_1 = gr.Image(
3159
  label="Reference Image 1 (Base / Target)",
@@ -3197,17 +3326,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3197
  clear_library_btn = gr.Button("Clear Library", size="sm", elem_classes=["action-btn", "btn-delete-template"])
3198
 
3199
  # Section 3: Prompt Description
3200
- with gr.Group(elem_classes=["section-card"]):
3201
- gr.HTML("""
3202
- <div class="studio-section-header">
3203
- <span class="studio-section-title">
3204
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>
3205
- Prompt Description
3206
- </span>
3207
- <span class="studio-section-desc">Describe your vision, character, scene, or requested edit</span>
3208
- </div>
3209
- """)
3210
-
3211
  prompt = gr.Textbox(
3212
  elem_id="prompt-box",
3213
  label="Prompt",
@@ -3218,7 +3337,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3218
  )
3219
 
3220
  # Section 4: Prompt History
3221
- with gr.Accordion("Prompt History", open=False, elem_id="prompt-history-accordion", elem_classes=["section-card"]):
3222
  prompt_history_state = gr.BrowserState([], storage_key="qwen_studio_prompt_history_v1")
3223
  history_html = gr.HTML(
3224
  '<div id="history-list-box" style="font-size: 12px; color: var(--muted-foreground); font-style: italic;">No prompt history yet. Prompts you generate will be saved here automatically.</div>',
@@ -3228,7 +3347,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3228
  clear_history_btn = gr.Button("Clear History", size="sm", elem_classes=["action-btn", "btn-delete-template"])
3229
 
3230
  # Section 5: Prompt Templates & Presets
3231
- with gr.Accordion("Prompt Templates & Presets", open=True, elem_classes=["section-card"]):
3232
  presets_state = gr.BrowserState(DEFAULT_PRESETS, storage_key=PRESET_STORAGE_KEY)
3233
  presets_html = gr.HTML(render_presets_html(DEFAULT_PRESETS), elem_id="pp-html")
3234
  pp_cmd = gr.Textbox(elem_id="pp-cmd", show_label=False, container=False, lines=1)
@@ -3268,17 +3387,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3268
  reset_btn = gr.Button("Reset to Default Templates", size="sm")
3269
 
3270
  # Section 6: LoRA Adapters & Acceleration
3271
- with gr.Group(elem_classes=["section-card"]):
3272
- gr.HTML("""
3273
- <div class="studio-section-header">
3274
- <span class="studio-section-title">
3275
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 12.5-9.17 4.16a2 2 0 0 1-1.66 0L2 12.5"/><path d="m22 17.5-9.17 4.16a2 2 0 0 1-1.66 0L2 17.5"/></svg>
3276
- LoRA Adapters & Acceleration
3277
- </span>
3278
- <span class="studio-section-desc">Curated presets & Hugging Face Hub integration</span>
3279
- </div>
3280
- """)
3281
-
3282
  with gr.Row():
3283
  lora_dropdown = gr.Dropdown(
3284
  label="LoRA Adapter",
@@ -3352,18 +3461,8 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3352
  with gr.Row():
3353
  custom_apply_btn = gr.Button("Apply Custom LoRA", variant="secondary")
3354
 
3355
- # Section 7: Generation Parameters & Execute
3356
- with gr.Group(elem_classes=["section-card"]):
3357
- gr.HTML("""
3358
- <div class="studio-section-header">
3359
- <span class="studio-section-title">
3360
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
3361
- Generation Parameters
3362
- </span>
3363
- <span class="studio-section-desc">Resolution, steps, and seed control</span>
3364
- </div>
3365
- """)
3366
-
3367
  with gr.Row():
3368
  aspect_ratio_dropdown = gr.Dropdown(
3369
  label="Aspect Ratio & Resolution",
@@ -3386,23 +3485,13 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3386
  seed_number = gr.Number(label="Seed", value=42, precision=0, scale=3)
3387
  randomize_seed_cb = gr.Checkbox(label="Randomize Seed", value=True, scale=1)
3388
 
3389
- # Section 8: Generate Button
3390
  run = gr.Button("Generate Image", variant="primary", size="lg", elem_id="generate-btn")
3391
 
3392
  # RIGHT COLUMN
3393
  with gr.Column(scale=6, elem_id="right-preview"):
3394
  # Section R1: Canvas & Result Viewport
3395
- with gr.Group(elem_classes=["section-card"]):
3396
- gr.HTML("""
3397
- <div class="studio-section-header">
3398
- <span class="studio-section-title">
3399
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>
3400
- Generated Result & Canvas
3401
- </span>
3402
- <span class="studio-section-desc">High-fidelity render viewport</span>
3403
- </div>
3404
- """)
3405
-
3406
  output_image = gr.Image(
3407
  label="Generated Result",
3408
  show_label=False,
@@ -3414,7 +3503,7 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3414
  )
3415
 
3416
  # Section R2: Download & Model Prompt
3417
- with gr.Group(elem_classes=["section-card"]):
3418
  download_file = gr.File(
3419
  label="Download High-Res Output",
3420
  interactive=False,
@@ -3424,51 +3513,13 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3424
  used_prompt = gr.Textbox(label="Prompt sent to the model", lines=2, interactive=False, elem_id="used-prompt")
3425
  idb_trigger = gr.Textbox(elem_id="idb-trigger", visible=False, container=False)
3426
 
3427
- with gr.Accordion("Private Browser Gallery (Saved in your Browser)", open=True, elem_classes=["section-card"]):
3428
- gr.Markdown(
3429
- "<span style='font-size:0.8125rem; opacity:0.8;'>"
3430
- "All generated images are automatically saved directly into your <strong>Browser Storage (IndexedDB)</strong>. "
3431
- "This is 100% private to your browser (uses 0 KB of Space storage). Hover to view, zoom, or download:</span>"
3432
- )
3433
- idb_gallery_html = gr.HTML("""
3434
- <div id="idb-gallery-wrap">
3435
- <div class="idb-toolbar">
3436
- <span id="idb-count-label" class="idb-count"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:6px;"><rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></svg>Browser Storage: 0 image(s) (100% Private)</span>
3437
- <button type="button" id="idb-clear-btn" class="idb-btn-danger"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>Clear Browser Storage</button>
3438
- </div>
3439
- <div id="idb-gallery-grid" class="idb-grid">
3440
- <div class="idb-empty">No images saved in your browser yet. Generated images will be saved automatically here.</div>
3441
- </div>
3442
- </div>
3443
- <!-- Lightbox Modal for Zoom & Inspection -->
3444
- <div id="idb-modal" class="idb-modal" style="display:none;">
3445
- <div class="idb-modal-backdrop" onclick="window.closeIdbModal()"></div>
3446
- <div class="idb-modal-content">
3447
- <button type="button" class="idb-modal-close" onclick="window.closeIdbModal()"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button>
3448
- <div class="idb-modal-img-wrap">
3449
- <img id="idb-modal-img" src="" alt="Enlarged view">
3450
- </div>
3451
- <div class="idb-modal-info">
3452
- <div id="idb-modal-meta" class="idb-modal-meta"></div>
3453
- <div class="idb-modal-actions">
3454
- <a id="idb-modal-dl" href="" download="qwen_generated.png" class="idb-btn-primary"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>Download High-Res</a>
3455
- <button type="button" id="idb-modal-use-prompt" class="idb-btn-secondary"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>Use Prompt</button>
3456
- <button type="button" id="idb-modal-delete" class="idb-btn-danger"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>Delete</button>
3457
- </div>
3458
- </div>
3459
- </div>
3460
- </div>
3461
- """)
3462
- gr.Markdown(
3463
- "<span style='font-size:0.8125rem; opacity:0.8;'>"
3464
- "All generated images are automatically saved directly into your <strong>Browser Storage (IndexedDB)</strong>. "
3465
- "This is 100% private to your browser (uses 0 KB of Space storage). Hover to view, zoom, or download:</span>"
3466
- )
3467
  idb_gallery_html = gr.HTML("""
3468
  <div id="idb-gallery-wrap">
3469
  <div class="idb-toolbar">
3470
- <span id="idb-count-label" class="idb-count"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:6px;"><rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></svg>Browser Storage: 0 image(s) (100% Private)</span>
3471
- <button type="button" id="idb-clear-btn" class="idb-btn-danger"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display:inline-block;vertical-align:middle;margin-right:5px;"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>Clear Browser Storage</button>
3472
  </div>
3473
  <div id="idb-gallery-grid" class="idb-grid">
3474
  <div class="idb-empty">No images saved in your browser yet. Generated images will be saved automatically here.</div>
@@ -3494,6 +3545,16 @@ with gr.Blocks(title="Qwen Image 2.1 Uncensored All-In-One LoRA Studio") as demo
3494
  </div>
3495
  """)
3496
 
 
 
 
 
 
 
 
 
 
 
3497
  # -------------------------------------------------------------
3498
  # Event Bindings: Prompt Presets & Templates
3499
  # -------------------------------------------------------------
 
620
  # Prompt Presets & Templates Manager
621
  # ============================================================
622
  PROMPT_PRESETS = [
623
+ ("Real Anatomy", "hyperrealistic 8k raw photograph, anatomically correct human body, perfect hands with 5 fingers, micro skin texture, cinematic lighting", True),
624
+ ("Body Swap", "seamless body swap composite, maintaining exact facial features and skin tone match, photo studio lighting, high resolution", True),
625
+ ("Face Swap", "high precision face identity transfer, identical eyes, nose, lips and facial structure, photorealistic blend", True),
626
+ ("Studio Light", "professional studio portrait, 3-point rim lighting, soft shadow falloff, Hasselblad medium format camera, 85mm lens f/1.4", False),
627
+ ("Phone Photo", "unfiltered candid smartphone photograph, natural daytime sunlight, subtle film grain, authentic real-life snapshot", False),
628
+ ("Restore Photo", "restored vintage photograph, ultra high definition remaster, noise removed, rich color grade, crystal sharp focus", False),
 
 
 
 
 
629
  ]
630
 
631
  MAX_PRESETS = 100
632
+ PRESET_STORAGE_KEY = "qwen_presets"
633
+ DEFAULT_PRESETS = [{"label": l, "text": t, "favorite": f} for l, t, f in PROMPT_PRESETS]
634
 
635
 
636
  def normalize_presets(raw) -> list:
 
647
  if not label or not text or label in seen:
648
  continue
649
  seen.add(label)
650
+ out.append({"label": label, "text": text, "favorite": bool(x.get("favorite", x.get("fav", False)))})
651
  if len(out) >= MAX_PRESETS:
652
  break
653
  return out
654
 
655
 
656
+ def _chip(p: dict) -> str:
657
  label = _html.escape(p["label"], quote=True)
658
  text = _html.escape(p["text"], quote=True)
659
  tip = _html.escape(p["text"][:200], quote=True)
660
+ fav = p.get("favorite", False)
661
+ fav_cls = "pp-fav is-on" if fav else "pp-fav"
662
  star_svg = (
663
+ '<svg class="pp-star-svg filled" width="12" height="12" viewBox="0 0 24 24" fill="#f59e0b" stroke="#f59e0b" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
664
+ if fav
665
+ else '<svg class="pp-star-svg outline" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
 
 
 
 
 
666
  )
667
  return (
668
+ f'<div class="pp-item" data-label="{label}" data-text="{text}">'
669
  f'<button type="button" class="pp-use" title="{tip}">{label}</button>'
670
  f'<button type="button" class="{fav_cls}" title="Toggle favorite">{star_svg}</button></div>'
671
  )
 
673
 
674
  def render_presets_html(presets) -> str:
675
  presets = normalize_presets(presets)
676
+ sorted_presets = sorted(presets, key=lambda x: not x.get("favorite", False))
677
+ chips_html = "".join(_chip(p) for p in sorted_presets)
678
+ return f'<div id="presets-list" class="pp-list">{chips_html}</div>'
 
 
 
 
 
 
 
 
 
 
 
 
679
 
680
 
681
  def apply_preset_cmd(cmd: str, presets) -> list:
 
968
  # UI Theme & Assets
969
  # ============================================================
970
  THEME = gr.themes.Monochrome(
971
+ radius_size="sm",
972
  text_size="sm",
973
  font=[gr.themes.GoogleFont("Plus Jakarta Sans"), "system-ui", "-apple-system", "sans-serif"],
974
  font_mono=[gr.themes.GoogleFont("JetBrains Mono"), "ui-monospace", "monospace"],
975
  ).set(
976
+ block_background_fill="transparent",
977
+ block_background_fill_dark="transparent",
978
+ block_border_width="0px",
979
+ block_border_width_dark="0px",
980
+ block_label_background_fill="transparent",
981
+ block_label_background_fill_dark="transparent",
982
+ panel_border_width="0px",
983
+ panel_border_width_dark="0px",
984
+ input_background_fill="*background_fill_primary",
985
  input_border_color="*neutral_200",
986
  input_border_color_dark="*neutral_800",
987
  button_primary_background_fill="*neutral_950",
 
1530
  'Custom Repo ID': 'wrench',
1531
 
1532
  // Accordions
1533
+ 'Generation Mode': 'layers',
1534
+ 'Reference Images & Media Inputs': 'image',
1535
+ 'Prompt Description': 'wand-2',
1536
  'Prompt History': 'history',
1537
  'Prompt Templates & Presets': 'bookmark',
1538
+ 'LoRA Adapters & Acceleration': 'zap',
1539
+ 'Generation Settings': 'sliders',
1540
+ 'Generated Result & Canvas Viewport': 'sparkles',
1541
+ 'Generated Result & Canvas': 'sparkles',
1542
+ 'Output Download & Model Prompt': 'download',
1543
+ 'Private Browser Gallery (IndexedDB)': 'hard-drive',
1544
+ 'Private Browser Gallery': 'hard-drive',
1545
  'Media Library': 'image',
1546
+ 'Import / Export / Reset (JSON)': 'sliders'
 
1547
  };
1548
 
1549
  var MODE_ICON_MAP = {
 
1656
  """
1657
 
1658
  CONTAINER_HEAD_CSS = """
1659
+ <script>
1660
+ (function() {
1661
+ var saved = localStorage.getItem('qwen_theme');
1662
+ var isDark = saved ? saved === 'dark' : true;
1663
+ if (isDark) {
1664
+ document.documentElement.classList.add('dark');
1665
+ if (document.body) { document.body.classList.add('dark'); }
1666
+ } else {
1667
+ document.documentElement.classList.remove('dark');
1668
+ if (document.body) { document.body.classList.remove('dark'); }
1669
+ }
1670
+ })();
1671
+ </script>
1672
  <style>
1673
  /* Outer Canvas Layout: Center Gradio app on wide displays */
1674
  body, html {
 
1977
  #left-controls, #right-preview {
1978
  display: flex !important;
1979
  flex-direction: column !important;
1980
+ gap: 0 !important;
1981
+ background: var(--card) !important;
 
 
 
 
 
 
 
 
 
 
1982
  background-color: var(--card) !important;
1983
+ border: 1px solid var(--border) !important;
1984
+ border-radius: var(--radius-lg, 8px) !important;
1985
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05) !important;
1986
+ padding: 24px !important;
1987
  box-sizing: border-box !important;
1988
+ transition: border-color 0.15s ease !important;
1989
  }
1990
+ #left-controls:hover, #right-preview:hover {
1991
  border-color: var(--border-hover) !important;
1992
  }
1993
+
1994
+ /* Strip generic Gradio block wrappers from having gray backgrounds/borders */
1995
+ .block,
1996
+ .prose,
1997
+ .html-container,
1998
+ div[data-testid="block"] {
1999
  background: transparent !important;
2000
+ background-color: transparent !important;
2001
+ border: none !important;
2002
  box-shadow: none !important;
2003
  padding: 0 !important;
 
2004
  }
2005
 
2006
+ /* SECTION ACCORDIONS (Inside the 2 master cards) */
2007
+ .studio-section,
2008
+ .accordion,
2009
+ [data-testid="accordion"] {
2010
+ border: none !important;
2011
+ border-bottom: 1px solid var(--border) !important;
2012
+ border-radius: 0 !important;
2013
+ background: transparent !important;
2014
+ background-color: transparent !important;
2015
+ padding: 0 0 16px 0 !important;
2016
+ margin: 0 0 16px 0 !important;
2017
+ box-shadow: none !important;
2018
+ width: 100% !important;
2019
+ box-sizing: border-box !important;
2020
+ }
2021
+ .studio-section.no-border,
2022
+ .accordion.no-border,
2023
+ .no-border {
2024
+ border-bottom: none !important;
2025
+ padding-bottom: 0 !important;
2026
+ margin-bottom: 0 !important;
2027
+ }
2028
+
2029
  .studio-section-header {
2030
+ display: flex !important;
2031
+ align-items: center !important;
2032
+ justify-content: space-between !important;
2033
+ width: 100% !important;
2034
+ margin-bottom: 10px !important;
2035
+ padding: 0 !important;
2036
+ background: transparent !important;
2037
+ border: none !important;
2038
  }
2039
  .studio-section-title {
2040
+ font-size: 0.75rem !important;
2041
+ font-weight: 600 !important;
2042
+ text-transform: uppercase !important;
2043
+ letter-spacing: 0.05em !important;
2044
+ color: var(--foreground) !important;
2045
+ display: inline-flex !important;
2046
+ align-items: center !important;
2047
+ gap: 8px !important;
2048
  }
2049
  .studio-section-desc {
2050
+ display: none !important;
 
 
 
 
 
 
 
 
2051
  }
2052
+
2053
  .tab-helper {
2054
  font-size: 0.8125rem;
2055
  color: var(--muted-foreground);
 
2058
  }
2059
 
2060
  /* Radio Group: Clean Segmented Controls with 8px radius */
2061
+ .gr-radio,
2062
+ [data-testid="radio-group"],
2063
+ .gradio-radio {
2064
  display: grid !important;
2065
+ grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
2066
  gap: 8px !important;
2067
  width: 100% !important;
2068
+ margin-top: 4px !important;
2069
+ margin-bottom: 4px !important;
2070
+ border: none !important;
2071
+ background: transparent !important;
2072
+ padding: 0 !important;
2073
+ box-shadow: none !important;
2074
+ }
2075
+ @media (max-width: 640px) {
2076
+ .gr-radio,
2077
+ [data-testid="radio-group"],
2078
+ .gradio-radio {
2079
+ grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
2080
+ }
2081
+ }
2082
+ .gr-radio .wrap,
2083
+ [data-testid="radio-group"] .wrap {
2084
+ display: contents !important;
2085
+ border: none !important;
2086
+ background: transparent !important;
2087
  }
2088
+ .gr-radio label,
2089
+ [data-testid="radio-group"] label {
2090
+ height: 38px !important;
2091
+ min-height: 38px !important;
2092
+ max-height: 38px !important;
2093
+ padding: 0 10px !important;
2094
  border: 1px solid var(--border) !important;
2095
  border-radius: var(--radius) !important;
 
2096
  background-color: var(--background) !important;
2097
  color: var(--foreground) !important;
2098
+ font-size: 0.75rem !important;
2099
  font-weight: 500 !important;
2100
  cursor: pointer !important;
2101
  transition: all 0.15s ease !important;
 
2105
  gap: 6px !important;
2106
  text-align: center !important;
2107
  box-sizing: border-box !important;
2108
+ margin: 0 !important;
2109
  }
2110
+ .gr-radio label:hover,
2111
+ [data-testid="radio-group"] label:hover {
2112
  background-color: var(--secondary) !important;
2113
  border-color: var(--border-hover) !important;
2114
  }
2115
+ .gr-radio label.selected,
2116
+ .gr-radio label:has(input:checked),
2117
+ [data-testid="radio-group"] label.selected,
2118
+ [data-testid="radio-group"] label:has(input:checked) {
2119
  background-color: var(--primary) !important;
2120
  color: var(--primary-foreground) !important;
2121
  border-color: var(--primary) !important;
2122
  font-weight: 600 !important;
2123
  }
2124
+ .gr-radio label.selected svg,
2125
+ .gr-radio label:has(input:checked) svg,
2126
+ [data-testid="radio-group"] label.selected svg,
2127
+ [data-testid="radio-group"] label:has(input:checked) svg {
2128
+ stroke: var(--primary-foreground) !important;
2129
+ }
2130
+ /* Completely remove the radio circle in all Gradio versions */
2131
+ .gr-radio input,
2132
+ .gr-radio input[type="radio"],
2133
+ .gr-radio .circle,
2134
+ .gr-radio svg.circle,
2135
+ .gr-radio span:has(input),
2136
+ .gr-radio span:first-child:not(.lucide-injected-wrap),
2137
+ [data-testid="radio-group"] input,
2138
+ [data-testid="radio-group"] .circle,
2139
+ [data-testid="radio-group"] span:has(input) {
2140
  display: none !important;
2141
+ visibility: hidden !important;
2142
+ width: 0 !important;
2143
+ height: 0 !important;
2144
+ margin: 0 !important;
2145
+ padding: 0 !important;
2146
+ position: absolute !important;
2147
+ opacity: 0 !important;
2148
+ pointer-events: none !important;
2149
  }
2150
 
2151
  /* Inputs & Form Controls: 8px Radius, standard padding */
 
2563
  }
2564
  }
2565
 
2566
+ /* Accordions: Card Accordion with clean divider */
2567
  .accordion, [data-testid="accordion"] {
2568
+ border: none !important;
2569
+ border-bottom: 1px solid var(--border) !important;
2570
+ border-radius: 0 !important;
2571
+ background-color: transparent !important;
2572
+ padding: 0 0 16px 0 !important;
2573
+ margin: 0 0 16px 0 !important;
2574
  box-sizing: border-box !important;
2575
+ box-shadow: none !important;
 
 
2576
  width: 100% !important;
2577
  }
2578
+ .accordion.no-border, [data-testid="accordion"].no-border, .no-border {
2579
+ border-bottom: none !important;
2580
+ padding-bottom: 0 !important;
2581
+ margin-bottom: 0 !important;
2582
  }
2583
  .accordion > .label-wrap,
2584
  .label-wrap,
2585
  summary,
2586
  .accordion-header {
2587
+ padding: 0 0 8px 0 !important;
2588
  cursor: pointer !important;
2589
  background: transparent !important;
2590
  background-color: transparent !important;
2591
+ font-size: 0.75rem !important;
2592
  font-weight: 600 !important;
2593
+ text-transform: uppercase !important;
2594
+ letter-spacing: 0.05em !important;
2595
  color: var(--foreground) !important;
2596
  display: flex !important;
2597
  align-items: center !important;
 
2603
  }
2604
  .accordion > .label-wrap:hover,
2605
  .label-wrap:hover {
2606
+ opacity: 0.8 !important;
2607
  background: transparent !important;
2608
  }
2609
  .accordion > .label-wrap *,
 
2871
  .pp-section { font-weight: 600; font-size: 0.8125rem; color: var(--foreground); display: flex; align-items: center; gap: 6px; }
2872
  .pp-hint { font-weight: 400; color: var(--muted-foreground); font-size: 0.75rem; }
2873
  .pp-empty { color: var(--muted-foreground); font-size: 0.8125rem; padding: 4px 0; font-style: italic; }
2874
+ .pp-list {
2875
+ display: flex !important;
2876
+ flex-wrap: wrap !important;
2877
+ gap: 6px !important;
2878
+ margin: 4px 0 12px 0 !important;
2879
+ }
2880
+ .pp-item {
2881
+ display: inline-flex !important;
2882
+ align-items: center !important;
2883
+ border: 1px solid var(--border) !important;
2884
+ border-radius: var(--radius) !important;
2885
+ background-color: var(--secondary) !important;
2886
+ color: var(--foreground) !important;
2887
+ overflow: hidden !important;
2888
+ transition: all 0.15s ease !important;
2889
+ font-size: 0.75rem !important;
2890
+ }
2891
+ .pp-item:hover {
2892
+ border-color: var(--foreground) !important;
2893
+ }
2894
+ .pp-use {
2895
+ border: none !important;
2896
+ background: transparent !important;
2897
+ cursor: pointer !important;
2898
+ padding: 5px 9px !important;
2899
+ font-size: 0.75rem !important;
2900
+ color: inherit !important;
2901
+ font-weight: 500 !important;
2902
+ font-family: var(--font-sans) !important;
2903
+ }
2904
+ .pp-use:hover {
2905
+ background-color: var(--accent) !important;
2906
+ }
2907
+ .pp-fav {
2908
+ border: none !important;
2909
+ background: transparent !important;
2910
+ cursor: pointer !important;
2911
+ padding: 5px 7px !important;
2912
+ font-size: 0.75rem !important;
2913
+ color: var(--muted-foreground) !important;
2914
+ transition: all 0.15s ease !important;
2915
+ display: inline-flex !important;
2916
+ align-items: center !important;
2917
+ justify-content: center !important;
2918
+ }
2919
+ .pp-fav:hover {
2920
+ color: #f59e0b !important;
2921
+ background-color: var(--accent) !important;
2922
+ }
2923
+ .pp-fav.is-on {
2924
+ color: #f59e0b !important;
2925
+ }
2926
+ .pp-star-svg {
2927
+ display: block !important;
2928
+ }
2929
+ .pp-fav.is-on .pp-star-svg {
2930
+ fill: #f59e0b !important;
2931
+ stroke: #f59e0b !important;
2932
+ }
2933
+ .pp-fav:not(.is-on) .pp-star-svg {
2934
+ stroke: currentColor !important;
2935
+ fill: none !important;
2936
+ }
2937
  .pp-ghost { opacity: 0.35; }
2938
 
2939
  /* Private Browser Gallery (IndexedDB) */
 
2947
  display: flex;
2948
  justify-content: space-between;
2949
  align-items: center;
2950
+ padding: 10px 12px;
2951
  background: var(--secondary);
2952
  border: 1px solid var(--border);
2953
+ border-radius: var(--radius);
2954
+ font-size: 0.75rem;
2955
  }
2956
  .idb-count {
2957
  font-weight: 500;
 
2959
  display: flex;
2960
  align-items: center;
2961
  gap: 6px;
2962
+ font-size: 0.75rem;
2963
  }
2964
  .idb-btn-danger, #idb-clear-btn {
2965
+ background: rgba(239, 68, 68, 0.1) !important;
2966
+ color: #ef4444 !important;
2967
+ border: 1px solid rgba(239, 68, 68, 0.3) !important;
2968
+ border-radius: var(--radius) !important;
2969
+ padding: 5px 12px !important;
2970
  font-size: 0.75rem !important;
2971
+ font-weight: 500 !important;
2972
  cursor: pointer !important;
2973
  display: inline-flex !important;
2974
  align-items: center !important;
2975
  gap: 6px !important;
2976
+ transition: all 0.15s ease !important;
2977
  }
2978
  .idb-btn-danger:hover, #idb-clear-btn:hover {
2979
+ background: #ef4444 !important;
2980
  color: #ffffff !important;
2981
+ border-color: #ef4444 !important;
2982
  }
2983
  .idb-grid {
2984
  display: grid;
 
2990
  }
2991
  .idb-empty {
2992
  grid-column: 1 / -1;
2993
+ text-align: center;
2994
+ font-style: italic;
2995
+ color: var(--muted-foreground);
2996
+ font-size: 0.75rem;
2997
+ padding: 24px 0;
2998
+ }
2999
+
3000
+ /* Studio Footer */
3001
+ .studio-footer {
3002
+ width: 100% !important;
3003
+ max-width: 1440px !important;
3004
+ margin: 32px auto 16px auto !important;
3005
+ padding: 16px 0 !important;
3006
+ text-align: center !important;
3007
+ font-size: 0.75rem !important;
3008
+ color: var(--muted-foreground) !important;
3009
+ border-top: 1px solid var(--border) !important;
3010
+ display: flex !important;
3011
+ align-items: center !important;
3012
+ justify-content: center !important;
3013
+ gap: 16px !important;
3014
+ flex-wrap: wrap !important;
3015
+ }
3016
  text-align: center;
3017
  padding: 24px 12px;
3018
  color: var(--muted-foreground);
 
3273
  # LEFT COLUMN
3274
  with gr.Column(scale=6, elem_id="left-controls"):
3275
  # Section 1: Generation Mode
3276
+ with gr.Accordion("Generation Mode", open=True, elem_id="acc-mode", elem_classes=["studio-section"]):
 
 
 
 
 
 
 
 
 
 
3277
  mode_selector = gr.Radio(
3278
  choices=MODES,
3279
  value=MODES[0],
 
3282
  )
3283
 
3284
  # Section 2: Reference Images & Media Library (Hidden on Text to Image & Transparent PNG)
3285
+ with gr.Accordion("Reference Images & Media Inputs", open=True, visible=False, elem_id="reference-section", elem_classes=["studio-section"]) as ref_section:
 
 
 
 
 
 
 
 
 
 
3286
  with gr.Row():
3287
  ref_img_1 = gr.Image(
3288
  label="Reference Image 1 (Base / Target)",
 
3326
  clear_library_btn = gr.Button("Clear Library", size="sm", elem_classes=["action-btn", "btn-delete-template"])
3327
 
3328
  # Section 3: Prompt Description
3329
+ with gr.Accordion("Prompt Description", open=True, elem_id="acc-prompt", elem_classes=["studio-section"]):
 
 
 
 
 
 
 
 
 
 
3330
  prompt = gr.Textbox(
3331
  elem_id="prompt-box",
3332
  label="Prompt",
 
3337
  )
3338
 
3339
  # Section 4: Prompt History
3340
+ with gr.Accordion("Prompt History", open=False, elem_id="prompt-history-accordion", elem_classes=["studio-section"]):
3341
  prompt_history_state = gr.BrowserState([], storage_key="qwen_studio_prompt_history_v1")
3342
  history_html = gr.HTML(
3343
  '<div id="history-list-box" style="font-size: 12px; color: var(--muted-foreground); font-style: italic;">No prompt history yet. Prompts you generate will be saved here automatically.</div>',
 
3347
  clear_history_btn = gr.Button("Clear History", size="sm", elem_classes=["action-btn", "btn-delete-template"])
3348
 
3349
  # Section 5: Prompt Templates & Presets
3350
+ with gr.Accordion("Prompt Templates & Presets", open=True, elem_id="acc-presets", elem_classes=["studio-section"]):
3351
  presets_state = gr.BrowserState(DEFAULT_PRESETS, storage_key=PRESET_STORAGE_KEY)
3352
  presets_html = gr.HTML(render_presets_html(DEFAULT_PRESETS), elem_id="pp-html")
3353
  pp_cmd = gr.Textbox(elem_id="pp-cmd", show_label=False, container=False, lines=1)
 
3387
  reset_btn = gr.Button("Reset to Default Templates", size="sm")
3388
 
3389
  # Section 6: LoRA Adapters & Acceleration
3390
+ with gr.Accordion("LoRA Adapters & Acceleration", open=True, elem_id="acc-lora", elem_classes=["studio-section"]):
 
 
 
 
 
 
 
 
 
 
3391
  with gr.Row():
3392
  lora_dropdown = gr.Dropdown(
3393
  label="LoRA Adapter",
 
3461
  with gr.Row():
3462
  custom_apply_btn = gr.Button("Apply Custom LoRA", variant="secondary")
3463
 
3464
+ # Section 7: Generation Settings
3465
+ with gr.Accordion("Generation Settings (Resolution, Steps, Seed)", open=True, elem_id="acc-settings", elem_classes=["studio-section", "no-border"]):
 
 
 
 
 
 
 
 
 
 
3466
  with gr.Row():
3467
  aspect_ratio_dropdown = gr.Dropdown(
3468
  label="Aspect Ratio & Resolution",
 
3485
  seed_number = gr.Number(label="Seed", value=42, precision=0, scale=3)
3486
  randomize_seed_cb = gr.Checkbox(label="Randomize Seed", value=True, scale=1)
3487
 
3488
+ # Section 8: Generate Button (Full Width of left master card)
3489
  run = gr.Button("Generate Image", variant="primary", size="lg", elem_id="generate-btn")
3490
 
3491
  # RIGHT COLUMN
3492
  with gr.Column(scale=6, elem_id="right-preview"):
3493
  # Section R1: Canvas & Result Viewport
3494
+ with gr.Accordion("Generated Result & Canvas Viewport", open=True, elem_id="acc-canvas", elem_classes=["studio-section"]):
 
 
 
 
 
 
 
 
 
 
3495
  output_image = gr.Image(
3496
  label="Generated Result",
3497
  show_label=False,
 
3503
  )
3504
 
3505
  # Section R2: Download & Model Prompt
3506
+ with gr.Accordion("Output Download & Model Prompt", open=True, elem_id="acc-details", elem_classes=["studio-section"]):
3507
  download_file = gr.File(
3508
  label="Download High-Res Output",
3509
  interactive=False,
 
3513
  used_prompt = gr.Textbox(label="Prompt sent to the model", lines=2, interactive=False, elem_id="used-prompt")
3514
  idb_trigger = gr.Textbox(elem_id="idb-trigger", visible=False, container=False)
3515
 
3516
+ # Section R3: Private Browser Gallery (IndexedDB)
3517
+ with gr.Accordion("Private Browser Gallery (IndexedDB)", open=True, elem_id="acc-gallery", elem_classes=["studio-section", "no-border"]):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3518
  idb_gallery_html = gr.HTML("""
3519
  <div id="idb-gallery-wrap">
3520
  <div class="idb-toolbar">
3521
+ <span id="idb-count-label" class="idb-count"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5V19A9 3 0 0 0 21 19V5"/><path d="M3 12A9 3 0 0 0 21 12"/></svg>Browser Storage: 0 image(s) (100% Private, 0 KB on Space)</span>
3522
+ <button type="button" id="idb-clear-btn" class="idb-btn-danger"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>Clear Storage</button>
3523
  </div>
3524
  <div id="idb-gallery-grid" class="idb-grid">
3525
  <div class="idb-empty">No images saved in your browser yet. Generated images will be saved automatically here.</div>
 
3545
  </div>
3546
  """)
3547
 
3548
+ gr.HTML("""
3549
+ <footer class="studio-footer">
3550
+ <span>Qwen Studio 2.1 Viggle Turbo</span>
3551
+ <span>•</span>
3552
+ <span>100% Client-Side Storage</span>
3553
+ <span>•</span>
3554
+ <span>Shadcn Monochromatic UI</span>
3555
+ </footer>
3556
+ """)
3557
+
3558
  # -------------------------------------------------------------
3559
  # Event Bindings: Prompt Presets & Templates
3560
  # -------------------------------------------------------------