/* ========================================
   AQUADEVS STUDIO — STYLES v4 (Queue Support)
   ======================================== */

/* ---- Theme Variables ---- */
:root, [data-theme="orange"] {
  --accent: #f5a623;
  --accent-hover: #ffba3d;
  --accent-dim: rgba(245, 166, 35, 0.12);
  --accent-glow: rgba(245, 166, 35, 0.3);
  --accent-secondary: #ff6b35;
  --accent-text: #1a0e00;
}

[data-theme="blue"] {
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-dim: rgba(56, 189, 248, 0.12);
  --accent-glow: rgba(56, 189, 248, 0.3);
  --accent-secondary: #818cf8;
  --accent-text: #011425;
}

:root {
  --bg-deep: #08080a;
  --bg-primary: #0e0e12;
  --bg-secondary: #16161c;
  --bg-tertiary: #1e1e26;
  --bg-hover: #28283a;
  --bg-active: #32324a;
  --text-primary: #eeeef0;
  --text-secondary: #9898a8;
  --text-tertiary: #5c5c70;
  --border: #222230;
  --border-hover: #363650;
  --success: #22c55e;
  --error: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Sora', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --panel-w: 380px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; font-family: var(--font); background: var(--bg-deep); color: var(--text-primary); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; border: none; outline: none; background: none; color: inherit; }
select { cursor: pointer; }
kbd { display: inline-block; padding: 2px 6px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px; font-family: var(--mono); font-size: 11px; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

.noise { position: fixed; inset: 0; pointer-events: none; z-index: 99999; opacity: 0.025; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* ---- Modals ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(16px); display: flex; align-items: center; justify-content: center; z-index: 10000; opacity: 0; visibility: hidden; transition: all 0.4s var(--ease); }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-xl); position: relative; transform: translateY(24px) scale(0.96); transition: transform 0.5s var(--spring); overflow: hidden; }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--bg-tertiary); z-index: 10; transition: all 0.2s var(--ease); }
.modal-close:hover { background: var(--bg-hover); }
.modal-close svg { width: 18px; height: 18px; }

/* ---- Setup Modal ---- */
.modal-setup { width: 92%; max-width: 420px; padding: 40px 32px 32px; text-align: center; }
.setup-glow { position: absolute; top: -60px; left: 50%; transform: translateX(-50%); width: 300px; height: 200px; background: radial-gradient(ellipse, var(--accent-glow), transparent 70%); pointer-events: none; }
.setup-icon { width: 64px; height: 64px; margin: 0 auto 20px; position: relative; }
.setup-icon svg { width: 100%; height: 100%; }
.setup-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; position: relative; }
.setup-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; position: relative; }
.setup-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; position: relative; }
.setup-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-tertiary); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; transition: all 0.3s var(--ease); flex-shrink: 0; }
.setup-avatar:hover { border-color: var(--accent); background: var(--accent-dim); }
.setup-avatar-placeholder { width: 24px; height: 24px; color: var(--text-tertiary); }
.setup-avatar img { width: 100%; height: 100%; object-fit: cover; }
.setup-avatar-label { font-size: 13px; color: var(--text-secondary); text-align: left; }
.setup-avatar-label small { display: block; color: var(--text-tertiary); font-size: 11px; margin-top: 2px; }
.setup-btn { width: 100%; margin-top: 8px; }

/* ---- Inputs ---- */
.input-group { margin-bottom: 18px; text-align: left; position: relative; }
.input-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.required-dot::after { content: ''; display: inline-block; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; margin-left: 4px; vertical-align: middle; }
.input-wrap { display: flex; align-items: center; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0 14px; transition: all 0.3s var(--ease); position: relative; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input-wrap input { flex: 1; height: 46px; font-size: 14px; font-family: var(--mono); }
.input-wrap input::placeholder { color: var(--text-tertiary); font-family: var(--font); }
.input-wrap-sm { height: 40px; }
.input-wrap-sm input { height: 40px; font-family: var(--font); font-size: 13px; }
.input-eye { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: background 0.2s; flex-shrink: 0; }
.input-eye:hover { background: var(--bg-hover); }
.input-eye svg { width: 16px; height: 16px; }
.input-hint { display: block; margin-top: 8px; font-size: 12px; color: var(--text-tertiary); }

/* ---- Settings Modal ---- */
.modal-settings { width: 94%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; }
.settings-header { display: flex; align-items: center; gap: 10px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.settings-header h2 { font-size: 18px; font-weight: 700; }
.settings-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.settings-section { margin-bottom: 24px; }
.settings-section-title { font-size: 12px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 12px; }
.settings-desc { font-size: 12px; color: var(--text-tertiary); margin-bottom: 10px; line-height: 1.5; }
.settings-row { margin-bottom: 12px; }
.settings-row-avatar { display: flex; align-items: center; gap: 14px; }
.settings-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-tertiary); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; flex-shrink: 0; transition: all 0.3s var(--ease); }
.settings-avatar:hover { border-color: var(--accent); }
.settings-avatar-ph { width: 22px; height: 22px; color: var(--text-tertiary); }
.settings-avatar img { width: 100%; height: 100%; object-fit: cover; }
.settings-select { width: 100%; height: 44px; padding: 0 14px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; color: var(--text-primary); appearance: none; cursor: pointer; transition: all 0.3s var(--ease); background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239898a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.settings-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 13px; color: var(--text-secondary); }
.settings-divider { height: 1px; background: var(--border); margin: 8px 0 4px; }
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-tertiary); border-radius: 12px; transition: all 0.3s var(--ease); }
.toggle-slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--text-tertiary); border-radius: 50%; transition: all 0.3s var(--spring); }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); background: var(--accent-text); }
.theme-options { display: flex; gap: 10px; }
.theme-opt { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--bg-primary); border: 2px solid var(--border); border-radius: var(--radius-md); transition: all 0.3s var(--ease); cursor: pointer; }
.theme-opt:hover { border-color: var(--border-hover); }
.theme-opt.active { border-color: var(--accent); background: var(--accent-dim); }
.theme-swatch { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.theme-label { font-size: 13px; font-weight: 500; }
.settings-footer { padding: 16px 24px; border-top: 1px solid var(--border); }
.settings-footer .btn-primary { width: 100%; }

/* ---- Buttons ---- */
.btn-primary { height: 48px; padding: 0 28px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); color: var(--accent-text); font-weight: 700; font-size: 14px; border-radius: var(--radius-md); transition: all 0.3s var(--ease); position: relative; overflow: hidden; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary { height: 40px; padding: 0 16px; display: inline-flex; align-items: center; gap: 6px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; transition: all 0.2s var(--ease); white-space: nowrap; }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.btn-danger:hover { background: rgba(239,68,68,0.15); border-color: var(--error); color: var(--error); }
.btn-fav-toggle.active svg { fill: var(--accent); stroke: var(--accent); }

.btn-x { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); transition: background 0.2s; }
.btn-x:hover { background: var(--bg-hover); }
.btn-x svg { width: 18px; height: 18px; }
.btn-sm { height: 36px; padding: 0 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 12px; border-radius: var(--radius-sm); transition: all 0.2s var(--ease); white-space: nowrap; }
.btn-sm:hover { background: var(--accent-hover); }
.btn-shuffle { margin-left: auto; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: all 0.2s var(--ease); }
.btn-shuffle:hover { background: var(--bg-hover); color: var(--accent); }
.btn-foot { width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; font-weight: 500; transition: all 0.2s var(--ease); }
.btn-foot:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.btn-add-style { display: flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 12px; color: var(--text-tertiary); border-radius: var(--radius-sm); transition: all 0.2s var(--ease); margin-top: 8px; }
.btn-add-style:hover { color: var(--accent); background: var(--accent-dim); }

/* ---- Enhance Button ---- */
.btn-enhance { width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg-tertiary); border: 1px dashed var(--accent); border-radius: var(--radius-md); font-size: 13px; font-weight: 600; color: var(--accent); transition: all 0.3s var(--ease); }
.btn-enhance:hover { background: var(--accent-dim); border-style: solid; }
.btn-enhance.enhancing { opacity: 0.6; pointer-events: none; }
.btn-enhance.enhancing span::after { content: ''; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; margin-left: 8px; vertical-align: middle; animation: spinFast 0.8s linear infinite; }

/* ---- Generation Overlay (Updated for Queue) ---- */
.gen-overlay { position: fixed; inset: 0; background: var(--bg-deep); z-index: 9500; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.5s var(--ease); }
.gen-overlay.active { opacity: 1; visibility: visible; }
.gen-bg { position: absolute; inset: 0; overflow: hidden; }
.gen-particle { position: absolute; left: var(--x); bottom: -10px; width: 3px; height: 3px; background: var(--accent); border-radius: 50%; opacity: 0; animation: floatUp var(--dur) var(--delay) ease-in-out infinite; }
@keyframes floatUp { 0% { transform: translateY(0) scale(1); opacity: 0; } 8% { opacity: 0.6; } 85% { opacity: 0.6; } 100% { transform: translateY(-100vh) scale(0.3); opacity: 0; } }
.gen-center { position: relative; display: flex; flex-direction: column; align-items: center; gap: 20px; z-index: 2; padding: 20px; width: 100%; max-width: 600px; }
.gen-orbs { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.gen-orb { width: 60px; height: 60px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 50%; animation: morph 6s ease-in-out infinite, orbPulse 2s ease-in-out infinite; filter: blur(1px); box-shadow: 0 0 60px var(--accent-glow), 0 0 120px var(--accent-dim); }
@keyframes morph { 0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; } 25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; } 50% { border-radius: 50% 40% 50% 60% / 40% 60% 50% 50%; } 75% { border-radius: 40% 60% 40% 70% / 60% 30% 60% 40%; } }
@keyframes orbPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.gen-ring { position: absolute; border: 2px solid transparent; border-radius: 50%; }
.gen-ring-1 { width: 100px; height: 100px; border-top-color: var(--accent); border-right-color: var(--accent); opacity: 0.4; animation: spin 4s linear infinite; }
.gen-ring-2 { width: 120px; height: 120px; border-bottom-color: var(--accent-secondary); border-left-color: var(--accent-secondary); opacity: 0.25; animation: spin 7s linear infinite reverse; }
.gen-ring-3 { width: 140px; height: 140px; border-top-color: var(--accent); opacity: 0.15; animation: spin 10s linear infinite; border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinFast { to { transform: rotate(360deg); } }

/* Queue List Styles */
.gen-queue-list { width: 100%; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 0 10px; }
.gen-queue-item { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; display: flex; align-items: center; gap: 12px; transition: all 0.3s var(--ease); }
.gen-queue-item.active { border-color: var(--accent); box-shadow: 0 0 15px var(--accent-dim); }
.gen-queue-item.done { border-color: var(--success); opacity: 0.7; }
.gen-queue-item.fail { border-color: var(--error); opacity: 0.7; }
.gq-status { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.gq-status.waiting { background: var(--bg-tertiary); border: 2px solid var(--border); }
.gq-status.active { background: var(--accent); animation: orbPulse 1.5s infinite; }
.gq-status.done { background: var(--success); color: #fff; }
.gq-status.fail { background: var(--error); color: #fff; }
.gq-info { flex: 1; min-width: 0; }
.gq-prompt { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.gq-meta { font-size: 10px; color: var(--text-tertiary); font-family: var(--mono); }
.gq-progress { height: 3px; background: var(--bg-tertiary); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.gq-progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s linear; }

.gen-prompt-text { max-width: 380px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--text-secondary); opacity: 0; animation: fadeUp 0.6s 0.3s var(--ease) forwards; word-break: break-word; display: none; /* Hidden in queue mode, shown in single mode if needed */ }
.gen-bar-track { width: 240px; height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; display: none; /* Replaced by queue items */ }
.gen-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-secondary)); border-radius: 2px; transition: width 0.5s var(--ease); box-shadow: 0 0 12px var(--accent-glow); }
.gen-status { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-top: 10px; }
.gen-count { font-family: var(--mono); font-size: 12px; color: var(--accent); background: var(--accent-dim); padding: 4px 12px; border-radius: 20px; }

/* ---- Gen Minimize Button ---- */
.gen-minimize { position: absolute; top: 20px; right: 20px; display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 12px; font-weight: 600; color: var(--text-secondary); z-index: 10; transition: all 0.3s var(--ease); }
.gen-minimize:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-hover); }

/* ---- Minimized Indicator ---- */
.gen-mini { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 28px; padding: 10px 10px 10px 18px; display: flex; align-items: center; gap: 12px; z-index: 9400; box-shadow: 0 8px 32px rgba(0,0,0,0.5); opacity: 0; transition: all 0.4s var(--spring); pointer-events: none; }
.gen-mini.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.gen-mini-orb { width: 10px; height: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); border-radius: 50%; animation: orbPulse 2s ease-in-out infinite; flex-shrink: 0; }
.gen-mini-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gen-mini-info span:first-child { font-size: 12px; font-weight: 600; white-space: nowrap; }
.gen-mini-time { font-size: 10px; font-family: var(--mono); color: var(--text-tertiary); }
.gen-mini-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); border-radius: 50%; transition: all 0.2s var(--ease); flex-shrink: 0; }
.gen-mini-btn:hover { background: var(--accent-dim); color: var(--accent); }

/* ---- App Layout ---- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 499; opacity: 0; visibility: hidden; transition: all 0.3s var(--ease); }
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ---- Sidebar ---- */
.sidebar { width: var(--sidebar-w); background: var(--bg-primary); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; z-index: 500; transition: transform 0.4s var(--ease); }
.sidebar-head { padding: 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.sidebar-logo { width: 36px; height: 36px; flex-shrink: 0; }
.sidebar-logo svg { width: 100%; height: 100%; }
.sidebar-brand { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-group { margin-bottom: 20px; }
.nav-label { font-size: 10px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 1.2px; padding: 0 12px; margin-bottom: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s var(--ease); margin-bottom: 2px; }
.nav-item:hover { background: var(--bg-secondary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--bg-tertiary); padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; font-family: var(--mono); }
.nav-item.active .nav-badge { background: var(--accent); color: var(--accent-text); }
.sidebar-foot { padding: 16px; border-top: 1px solid var(--border); }

/* ---- Main ---- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar { height: var(--topbar-h); padding: 0 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.menu-btn { display: none; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: var(--radius-sm); transition: background 0.2s; }
.menu-btn:hover { background: var(--bg-secondary); }
.menu-btn svg { width: 22px; height: 22px; }
.search-box { flex: 1; max-width: 460px; position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary); pointer-events: none; }
.search-box input { width: 100%; height: 42px; padding: 0 14px 0 42px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; transition: all 0.3s var(--ease); }
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-avatar { width: 36px; height: 36px; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--accent-text); transition: all 0.2s var(--ease); overflow: hidden; }
.topbar-avatar:hover { transform: scale(1.05); }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Content ---- */
.content-wrap { flex: 1; display: flex; overflow: hidden; }
.gallery-area { flex: 1; overflow-y: auto; padding: 20px; min-width: 0; }
.gallery-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg-secondary); padding: 4px; border-radius: var(--radius-md); width: fit-content; }
.g-tab { padding: 9px 18px; font-size: 13px; font-weight: 500; border-radius: var(--radius-sm); transition: all 0.3s var(--ease); color: var(--text-secondary); white-space: nowrap; }
.g-tab:hover { color: var(--text-primary); }
.g-tab.active { background: var(--bg-tertiary); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.g-tab span { font-size: 11px; color: var(--text-tertiary); margin-left: 4px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 40px; text-align: center; animation: fadeUp 0.5s var(--ease); }
.empty-icon { width: 72px; height: 72px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-xl); display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
.empty-icon svg { width: 32px; height: 32px; color: var(--text-tertiary); }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); max-width: 300px; line-height: 1.6; }

/* ---- Gallery Grid ---- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.gallery-grid:empty { display: none; }
.gcard { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-secondary); border: 1px solid var(--border); aspect-ratio: 1; cursor: pointer; transition: all 0.4s var(--ease); animation: fadeUp 0.5s var(--ease) both; }
.gcard:nth-child(1) { animation-delay: 0ms; }
.gcard:nth-child(2) { animation-delay: 40ms; }
.gcard:nth-child(3) { animation-delay: 80ms; }
.gcard:nth-child(4) { animation-delay: 120ms; }
.gcard:nth-child(5) { animation-delay: 160ms; }
.gcard:nth-child(6) { animation-delay: 200ms; }
.gcard:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
.gcard img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.gcard:hover img { transform: scale(1.04); }
.gcard-badge { position: absolute; top: 10px; right: 10px; background: var(--accent); color: var(--accent-text); padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0; transform: translateY(-6px); transition: all 0.3s var(--spring); }
.gcard:hover .gcard-badge { opacity: 1; transform: translateY(0); }
.gcard-actions { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; opacity: 0; transform: translateY(-6px); transition: all 0.3s var(--spring); }
.gcard:hover .gcard-actions { opacity: 1; transform: translateY(0); }
.gcard-actions button { width: 30px; height: 30px; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.gcard-actions button:hover { background: var(--accent); color: var(--accent-text); }
.gcard-actions button svg { width: 14px; height: 14px; }
.gcard-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 40%, transparent 100%); opacity: 0; transition: opacity 0.3s var(--ease); display: flex; flex-direction: column; justify-content: flex-end; padding: 14px; }
.gcard:hover .gcard-overlay { opacity: 1; }
.gcard-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard-meta { font-size: 11px; color: var(--text-secondary); display: flex; gap: 8px; }

/* ---- Panel ---- */
.panel { width: var(--panel-w); background: var(--bg-primary); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: transform 0.4s var(--ease); }
.panel-top { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.panel-top h3 { font-size: 15px; font-weight: 700; }
.panel-scroll { flex: 1; overflow-y: auto; padding: 18px 20px; }
.p-section { margin-bottom: 22px; }
.p-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.prompt-box { position: relative; }
.prompt-box textarea { width: 100%; min-height: 110px; max-height: 280px; padding: 14px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; line-height: 1.6; resize: vertical; transition: all 0.3s var(--ease); overflow-y: auto; }
.prompt-box textarea::placeholder { color: var(--text-tertiary); }
.prompt-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.char-count { position: absolute; bottom: 10px; right: 12px; font-size: 10px; font-family: var(--mono); color: var(--text-tertiary); }

/* ---- Reference ---- */
.ref-drop { position: relative; border: 2px dashed var(--border); border-radius: var(--radius-md); overflow: hidden; transition: all 0.3s var(--ease); cursor: pointer; }
.ref-drop:hover, .ref-drop.dragover { border-color: var(--accent); background: var(--accent-dim); }
.ref-drop-inner { padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.ref-drop-inner svg { color: var(--text-tertiary); }
.ref-drop-inner span { font-size: 12px; color: var(--text-secondary); }
.ref-drop.has-image .ref-drop-inner { display: none; }
.ref-drop img { width: 100%; max-height: 200px; object-fit: contain; display: none; padding: 8px; }
.ref-drop.has-image img { display: block; }
.ref-url-row { display: flex; gap: 8px; margin-top: 10px; }
.ref-url-row input { flex: 1; height: 36px; padding: 0 12px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; transition: all 0.3s var(--ease); }
.ref-url-row input::placeholder { color: var(--text-tertiary); }
.ref-url-row input:focus { border-color: var(--accent); }

/* ---- Panel Select ---- */
.p-select { width: 100%; height: 44px; padding: 0 14px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px; color: var(--text-primary); appearance: none; transition: all 0.3s var(--ease); background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239898a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.p-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---- Ratio ---- */
.ratio-row { display: flex; gap: 8px; }
.ratio-btn { flex: 1; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.2s var(--ease); }
.ratio-btn:hover { border-color: var(--border-hover); background: var(--bg-tertiary); }
.ratio-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.ratio-btn svg { width: 18px; height: 18px; color: var(--text-secondary); }
.ratio-btn.active svg { color: var(--accent); }
.ratio-btn span { font-size: 10px; font-weight: 600; color: var(--text-secondary); }
.ratio-btn.active span { color: var(--accent); }

/* ---- Custom Ratio ---- */
.custom-ratio-wrap { display: none; margin-top: 10px; }
.custom-ratio-wrap.show { display: block; }
.custom-ratio-row { display: flex; gap: 8px; }
.custom-ratio-row input { flex: 1; height: 36px; padding: 0 12px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; font-family: var(--mono); transition: all 0.3s var(--ease); }
.custom-ratio-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.custom-ratio-row input::placeholder { color: var(--text-tertiary); font-family: var(--font); }

/* ---- Style Chips ---- */
.style-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.schip { height: 32px; padding: 0 12px; display: flex; align-items: center; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; transition: all 0.2s var(--ease); }
.schip:hover { border-color: var(--border-hover); background: var(--bg-tertiary); }
.schip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.add-style-row { display: flex; gap: 8px; margin-top: 8px; }
.add-style-row input { flex: 1; height: 36px; padding: 0 12px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; transition: all 0.3s var(--ease); }
.add-style-row input:focus { border-color: var(--accent); }

/* ---- Count ---- */
.count-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cbtn { height: 42px; display: flex; align-items: center; justify-content: center; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; transition: all 0.2s var(--ease); }
.cbtn:hover { border-color: var(--border-hover); background: var(--bg-tertiary); }
.cbtn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 16px var(--accent-glow); }

/* ---- Generate Button ---- */
.btn-generate { width: 100%; height: 54px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); color: var(--accent-text); font-weight: 800; font-size: 15px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; gap: 10px; transition: all 0.3s var(--ease); position: relative; overflow: hidden; }
.btn-generate::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, transparent, rgba(255,255,255,0.15), transparent); transform: translateX(-100%); transition: transform 0.6s var(--ease); }
.btn-generate:hover::before { transform: translateX(100%); }
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-generate:disabled::before { display: none; }
.btn-generate svg { width: 18px; height: 18px; }

/* ---- Viewer ---- */
.modal-viewer { width: 94%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column; padding: 0; }
.viewer-img-wrap { position: relative; background: var(--bg-deep); display: flex; align-items: center; justify-content: center; min-height: 200px; max-height: 60vh; overflow: hidden; }
.viewer-img-wrap img { max-width: 100%; max-height: 60vh; object-fit: contain; }
.viewer-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.viewer-close:hover { background: rgba(0,0,0,0.9); }
.viewer-close svg { width: 18px; height: 18px; }
.viewer-info { padding: 16px 20px; background: var(--bg-secondary); border-top: 1px solid var(--border); }
.viewer-info p { font-size: 13px; line-height: 1.6; margin-bottom: 8px; color: var(--text-secondary); }
.viewer-meta { font-size: 11px; color: var(--text-tertiary); margin-bottom: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.viewer-meta span { display: flex; align-items: center; gap: 4px; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.viewer-actions .btn-secondary { flex: 1; min-width: 0; justify-content: center; }
.viewer-actions .btn-fav-toggle,
.viewer-actions .btn-danger { flex: 0 0 44px; min-width: 44px; max-width: 44px; padding: 0; justify-content: center; }

/* ---- Toast ---- */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 20000; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 18px; display: flex; align-items: flex-start; gap: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); min-width: 260px; max-width: 360px; pointer-events: auto; transform: translateX(120%); transition: transform 0.4s var(--spring); }
.toast.show { transform: translateX(0); }
.toast-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-icon.success { background: rgba(34,197,94,0.15); color: var(--success); }
.toast-icon.error { background: rgba(239,68,68,0.15); color: var(--error); }
.toast-icon.info { background: var(--accent-dim); color: var(--accent); }
.toast-icon svg { width: 16px; height: 16px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-msg { font-size: 12px; color: var(--text-secondary); margin-top: 2px; word-break: break-word; }

/* ---- Mobile Bottom Nav ---- */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-primary); border-top: 1px solid var(--border); z-index: 800; padding-bottom: env(safe-area-inset-bottom, 0); }
.mobile-nav-inner { display: flex; height: 60px; }
.mnav { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--text-tertiary); cursor: pointer; transition: all 0.2s; }
.mnav svg { width: 20px; height: 20px; }
.mnav.active { color: var(--accent); }

/* ---- FAB ---- */
.fab { display: none; position: fixed; bottom: 80px; right: 16px; width: 52px; height: 52px; background: linear-gradient(135deg, var(--accent), var(--accent-secondary)); color: var(--accent-text); border-radius: 50%; align-items: center; justify-content: center; z-index: 750; box-shadow: 0 6px 24px var(--accent-glow); transition: all 0.3s var(--spring); }
.fab:hover { transform: scale(1.1); box-shadow: 0 8px 32px var(--accent-glow); }
.fab svg { width: 22px; height: 22px; }

/* ---- Animations ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   RESPONSIVE — TABLET (≤1024px)
   ======================================== */
@media (max-width: 1024px) {
  .panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 850; transform: translateX(100%);
    background: var(--bg-primary);
  }
  .panel.open { transform: translateX(0); }
  .sidebar-overlay.active { z-index: 800; }
}

/* ========================================
   RESPONSIVE — MOBILE (≤768px)
   ======================================== */
@media (max-width: 768px) {
  /* Sidebar overlay */
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); z-index: 500; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { z-index: 850; }

  /* Topbar */
  .menu-btn { display: flex; }
  .topbar { height: 52px; padding: 0 14px; gap: 10px; }
  .search-box input { height: 38px; font-size: 13px; }
  .topbar-avatar { width: 34px; height: 34px; font-size: 13px; }

  /* Mobile nav */
  .mobile-nav { display: block; }
  .main { padding-bottom: 0; }

  /* FAB */
  .fab { display: flex; bottom: 76px; right: 14px; width: 50px; height: 50px; }
  .fab svg { width: 20px; height: 20px; }

  /* Gallery */
  .gallery-area { padding: 14px; padding-bottom: 76px; }
  .gallery-tabs { margin-bottom: 14px; }
  .g-tab { padding: 8px 14px; font-size: 12px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .gcard { border-radius: var(--radius-md); }
  .gcard-badge { top: 6px; right: 6px; padding: 2px 7px; font-size: 9px; }
  .gcard-actions { top: 6px; left: 6px; gap: 4px; }
  .gcard-actions button { width: 28px; height: 28px; }
  .gcard-actions button svg { width: 12px; height: 12px; }
  .gcard-overlay { padding: 10px; }
  .gcard-name { font-size: 12px; }
  .gcard-meta { font-size: 10px; }

  /* Panel — covers mobile nav */
  .panel {
    width: 100%; left: 0; border-left: none;
    border-top: 1px solid var(--border);
    z-index: 900; bottom: 0;
  }
  .panel-top { padding: 12px 16px; }
  .panel-top h3 { font-size: 14px; }
  .panel-scroll { padding: 14px 16px; padding-bottom: 28px; }

  /* Panel sections — compact */
  .p-section { margin-bottom: 16px; }
  .p-label { font-size: 11px; margin-bottom: 8px; }
  .prompt-box textarea { min-height: 80px; padding: 12px; font-size: 13px; }
  .p-select { height: 40px; font-size: 12px; }
  .ratio-btn { height: 44px; }
  .ratio-btn svg { width: 16px; height: 16px; }
  .ratio-btn span { font-size: 9px; }
  .schip { height: 28px; padding: 0 10px; font-size: 11px; }
  .cbtn { height: 38px; font-size: 13px; }
  .btn-enhance { height: 40px; font-size: 12px; }
  .btn-generate { height: 48px; font-size: 14px; }
  .btn-sm { height: 34px; font-size: 11px; padding: 0 12px; }
  .ref-drop-inner { padding: 20px 12px; }
  .ref-url-row input { height: 34px; font-size: 11px; }

  /* Content wrap */
  .content-wrap { flex-direction: column; }

  /* Viewer */
  .modal-viewer { width: 100%; max-width: 100%; border-radius: 0; max-height: 100vh; }
  .viewer-img-wrap { max-height: 55vh; }
  .viewer-info { padding: 14px 16px; }
  .viewer-info p { font-size: 12px; }
  .viewer-actions { gap: 6px; }
  .viewer-actions .btn-secondary { height: 36px; font-size: 12px; gap: 4px; }
  .viewer-actions .btn-secondary svg { width: 14px; height: 14px; }
  .viewer-actions .btn-fav-toggle,
  .viewer-actions .btn-danger { flex: 0 0 38px; min-width: 38px; max-width: 38px; height: 36px; }

  /* Toast */
  .toast-wrap { bottom: 76px; right: 12px; left: 12px; }
  .toast { min-width: 0; max-width: 100%; }

  /* Gen overlay — mobile */
  .gen-orbs { width: 100px; height: 100px; }
  .gen-orb { width: 50px; height: 50px; }
  .gen-ring-1 { width: 80px; height: 80px; }
  .gen-ring-2 { width: 100px; height: 100px; }
  .gen-ring-3 { width: 120px; height: 120px; }
  .gen-center { gap: 16px; padding: 16px; }
  .gen-prompt-text { max-width: 300px; font-size: 12px; }
  .gen-bar-track { width: 200px; }
  .gen-status { font-size: 12px; gap: 10px; }
  .gen-minimize { top: 14px; right: 14px; padding: 8px 14px; font-size: 11px; }

  /* Mini indicator */
  .gen-mini { bottom: 76px; left: 12px; right: 12px; transform: translateX(0) translateY(100px); border-radius: var(--radius-lg); }
  .gen-mini.visible { transform: translateX(0) translateY(0); }

  /* Settings */
  .modal-settings { width: 100%; max-width: 100%; border-radius: 0; max-height: 100vh; }
  .settings-header { padding: 16px 18px; }
  .settings-body { padding: 16px 18px; }
  .settings-select { height: 40px; font-size: 12px; }
  .settings-toggle-row { font-size: 12px; }
  .theme-opt { padding: 10px 12px; }
  .theme-swatch { width: 24px; height: 24px; }
  .theme-label { font-size: 12px; }
}

/* ========================================
   RESPONSIVE — SMALL MOBILE (≤420px)
   ======================================== */
@media (max-width: 420px) {
  .gallery-area { padding: 10px; padding-bottom: 76px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .gallery-tabs { gap: 2px; padding: 3px; }
  .g-tab { padding: 7px 10px; font-size: 11px; }

  /* Panel */
  .panel-scroll { padding: 12px 12px 28px; }
  .p-section { margin-bottom: 14px; }
  .prompt-box textarea { min-height: 70px; padding: 10px; font-size: 12px; }
  .ratio-row { gap: 6px; }
  .ratio-btn { height: 40px; }
  .style-chips { gap: 4px; }
  .schip { height: 26px; padding: 0 8px; font-size: 10px; border-radius: 13px; }
  .count-grid { gap: 6px; }
  .cbtn { height: 36px; font-size: 12px; }
  .btn-enhance { height: 38px; font-size: 11px; }
  .btn-generate { height: 44px; font-size: 13px; border-radius: var(--radius-sm); }

  /* Viewer */
  .viewer-info { padding: 12px 14px; }
  .viewer-actions .btn-secondary:not(.btn-fav-toggle):not(.btn-danger) {
    padding: 0 10px; font-size: 11px;
  }

  /* Setup */
  .modal-setup { padding: 28px 18px 24px; }
  .setup-title { font-size: 18px; }
  .setup-sub { font-size: 13px; margin-bottom: 22px; }
  .setup-avatar { width: 48px; height: 48px; }

  /* FAB */
  .fab { bottom: 72px; right: 12px; width: 48px; height: 48px; }

  /* Mini indicator */
  .gen-mini { bottom: 72px; left: 10px; right: 10px; padding: 8px 8px 8px 14px; }
}